Merge libc++ r291274, and update the library Makefile.

This commit is contained in:
Dimitry Andric 2017-01-08 19:39:03 +00:00
commit aed8d94e97
122 changed files with 12133 additions and 5432 deletions

View File

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

View File

@ -163,7 +163,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
{
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
static const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@ -199,7 +199,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
{
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@ -251,7 +251,7 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
difference_type __r = 0;
// do first partial word
if (__first.__ctz_ != 0)
@ -282,7 +282,7 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
difference_type __r = 0;
// do first partial word
if (__first.__ctz_ != 0)
@ -324,7 +324,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@ -354,7 +354,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@ -412,7 +412,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word;
const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -461,7 +461,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word;
static const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -551,7 +551,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word;
const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -600,7 +600,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word;
const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -718,7 +718,7 @@ __swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1,
typedef __bit_iterator<__C1, false> _I1;
typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type;
static const unsigned __bits_per_word = _I1::__bits_per_word;
const int __bits_per_word = _I1::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -768,7 +768,7 @@ __swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1
typedef __bit_iterator<__C1, false> _I1;
typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type;
static const unsigned __bits_per_word = _I1::__bits_per_word;
const int __bits_per_word = _I1::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -959,7 +959,7 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
static const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@ -1041,7 +1041,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
static const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{

View File

@ -27,14 +27,14 @@
#define _GNUC_VER 0
#endif
#define _LIBCPP_VERSION 3900
#define _LIBCPP_VERSION 4000
#ifndef _LIBCPP_ABI_VERSION
#define _LIBCPP_ABI_VERSION 1
#endif
#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
// Change short string represention so that string data starts at offset 0,
// Change short string representation so that string data starts at offset 0,
// improving its alignment in some cases.
#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
// Fix deque iterator type in order to support incomplete types.
@ -43,10 +43,25 @@
#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
// Fix undefined behavior in how __tree stores its end and parent nodes.
#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
// Fix undefined behavior in how __hash_table stores it's pointer types
#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
// provided under the alternate keyword __nullptr, which changes the mangling
// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
// instead of as a class simulating an enum. If this option is enabled
// `pointer_safety` and `get_pointer_safety()` will no longer be available
// in C++03.
#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
#elif _LIBCPP_ABI_VERSION == 1
#if !defined(_WIN32)
// Enable compiling a definition of error_category() into the libc++ dylib.
#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
#endif
// Feature macros for disabling pre ABI v1 features. All of these options
// are deprecated.
#if defined(__FreeBSD__)
@ -64,6 +79,9 @@
#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
#if __cplusplus < 201103L
#define _LIBCPP_CXX03_LANG
#endif
#ifndef __has_attribute
#define __has_attribute(__x) 0
@ -83,6 +101,13 @@
#define __is_identifier(__x) 1
#endif
// Need to detect which libc we're using if we're on Linux.
#if defined(__linux__)
#include <features.h>
#if !defined(__GLIBC_PREREQ)
#define __GLIBC_PREREQ(a, b) 0
#endif // !defined(__GLIBC_PREREQ)
#endif // defined(__linux__)
#ifdef __LITTLE_ENDIAN__
#if __LITTLE_ENDIAN__
@ -134,11 +159,13 @@
# define _LIBCPP_HAS_QUICK_EXIT
#endif // __NetBSD__
#ifdef _WIN32
#if defined(_WIN32)
# define _LIBCPP_WIN32API 1
# define _LIBCPP_LITTLE_ENDIAN 1
# define _LIBCPP_BIG_ENDIAN 0
# define _LIBCPP_SHORT_WCHAR 1
// Compiler intrinsics (MSVC)
#if defined(_MSC_VER) && _MSC_VER >= 1400
# if defined(_MSC_VER) && _MSC_VER >= 1400
# define _LIBCPP_HAS_IS_BASE_OF
# endif
# if defined(_MSC_VER) && !defined(__clang__)
@ -147,11 +174,14 @@
# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
# endif
# // If mingw not explicitly detected, assume using MS C runtime only.
// If mingw not explicitly detected, assume using MS C runtime only.
# ifndef __MINGW32__
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
# endif
#endif // _WIN32
# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
# define _LIBCPP_HAS_BITSCAN64
# endif
#endif // defined(_WIN32)
#ifdef __sun__
# include <sys/isa_defs.h>
@ -175,7 +205,7 @@
// including accesses to the special files under /dev. C++11's
// std::random_device is instead exposed through a NaCl syscall.
# define _LIBCPP_USING_NACL_RANDOM
#elif defined(_WIN32)
#elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_USING_WIN32_RANDOM
#else
# define _LIBCPP_USING_DEV_RANDOM
@ -200,90 +230,6 @@
#define _LIBCPP_NO_CFI
#endif
#ifdef _WIN32
// only really useful for a DLL
#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
# ifdef cxx_EXPORTS
# define _LIBCPP_HIDDEN
# define _LIBCPP_FUNC_VIS __declspec(dllexport)
# define _LIBCPP_TYPE_VIS __declspec(dllexport)
# else
# define _LIBCPP_HIDDEN
# define _LIBCPP_FUNC_VIS __declspec(dllimport)
# define _LIBCPP_TYPE_VIS __declspec(dllimport)
# endif
#else
# define _LIBCPP_HIDDEN
# define _LIBCPP_FUNC_VIS
# define _LIBCPP_TYPE_VIS
#endif
#define _LIBCPP_TYPE_VIS_ONLY
#define _LIBCPP_FUNC_VIS_ONLY
#ifndef _LIBCPP_INLINE_VISIBILITY
# ifdef _LIBCPP_MSVC
# define _LIBCPP_INLINE_VISIBILITY __forceinline
# else // MinGW GCC and Clang
# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
# endif
#endif
#ifndef _LIBCPP_EXCEPTION_ABI
#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
#endif
#ifndef _LIBCPP_ALWAYS_INLINE
# ifdef _LIBCPP_MSVC
# define _LIBCPP_ALWAYS_INLINE __forceinline
# endif
#endif
#endif // _WIN32
#ifndef _LIBCPP_HIDDEN
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
#endif
#ifndef _LIBCPP_FUNC_VIS
#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
#endif
#ifndef _LIBCPP_TYPE_VIS
# if __has_attribute(__type_visibility__)
# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
# else
# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
# endif
#endif
#ifndef _LIBCPP_PREFERRED_OVERLOAD
# if __has_attribute(__enable_if__)
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
# endif
#endif
#ifndef _LIBCPP_TYPE_VIS_ONLY
# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
#endif
#ifndef _LIBCPP_FUNC_VIS_ONLY
# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
#endif
#ifndef _LIBCPP_INLINE_VISIBILITY
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
#endif
#ifndef _LIBCPP_EXCEPTION_ABI
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
#endif
#ifndef _LIBCPP_ALWAYS_INLINE
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
#endif
#if defined(__clang__)
// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
@ -302,10 +248,6 @@
# define _ALIGNAS(x) __attribute__((__aligned__(x)))
#endif
#if !__has_feature(cxx_alias_templates)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif
#if __cplusplus < 201103L
typedef __char16_t char16_t;
typedef __char32_t char32_t;
@ -333,14 +275,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_NORETURN __attribute__ ((noreturn))
#endif
#if !(__has_feature(cxx_default_function_template_args))
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#endif
#if !(__has_feature(cxx_defaulted_functions))
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // !(__has_feature(cxx_defaulted_functions))
#if !(__has_feature(cxx_deleted_functions))
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#endif // !(__has_feature(cxx_deleted_functions))
@ -350,33 +284,25 @@ typedef __char32_t char32_t;
#endif
#if !(__has_feature(cxx_nullptr))
#define _LIBCPP_HAS_NO_NULLPTR
# if __has_extension(cxx_nullptr) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
# define nullptr __nullptr
# else
# define _LIBCPP_HAS_NO_NULLPTR
# endif
#endif
#if !(__has_feature(cxx_rvalue_references))
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif
#if !(__has_feature(cxx_static_assert))
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif
#if !(__has_feature(cxx_auto_type))
#define _LIBCPP_HAS_NO_AUTO_TYPE
#endif
#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#endif
#if !(__has_feature(cxx_variadic_templates))
#define _LIBCPP_HAS_NO_VARIADICS
#endif
#if !(__has_feature(cxx_trailing_return))
#define _LIBCPP_HAS_NO_TRAILING_RETURN
#endif
#if !(__has_feature(cxx_generalized_initializers))
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif
@ -415,12 +341,12 @@ typedef __char32_t char32_t;
#if defined(__FreeBSD__)
#define _LIBCPP_HAS_QUICK_EXIT
#define _LIBCPP_HAS_C11_FEATURES
#elif defined(__ANDROID__)
#elif defined(__Fuchsia__)
#define _LIBCPP_HAS_QUICK_EXIT
#define _LIBCPP_HAS_C11_FEATURES
#elif defined(__linux__)
#if !defined(_LIBCPP_HAS_MUSL_LIBC)
# include <features.h>
#if __GLIBC_PREREQ(2, 15)
#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
#define _LIBCPP_HAS_QUICK_EXIT
#endif
#if __GLIBC_PREREQ(2, 17)
@ -504,34 +430,25 @@ namespace std {
#endif
#ifndef __GXX_EXPERIMENTAL_CXX0X__
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DECLTYPE
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_NOEXCEPT
#else // __GXX_EXPERIMENTAL_CXX0X__
#if _GNUC_VER < 403
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif
#if _GNUC_VER < 404
#define _LIBCPP_HAS_NO_DECLTYPE
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_TRAILING_RETURN
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@ -540,12 +457,6 @@ namespace std {
#if _GNUC_VER < 406
#define _LIBCPP_HAS_NO_NOEXCEPT
#define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif
#if _GNUC_VER < 407
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif
#endif // __GXX_EXPERIMENTAL_CXX0X__
@ -566,21 +477,19 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
#elif defined(_LIBCPP_MSVC)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#if _MSC_VER <= 1800
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#endif
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#define _LIBCPP_HAS_NO_NOEXCEPT
#define __alignof__ __alignof
#define _LIBCPP_NORETURN __declspec(noreturn)
#define _ALIGNAS(x) __declspec(align(x))
#define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
#define _LIBCPP_END_NAMESPACE_STD }
#define _VSTD std
@ -598,9 +507,6 @@ namespace std {
#define _ATTRIBUTE(x) __attribute__((x))
#define _LIBCPP_NORETURN __attribute__((noreturn))
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#define _LIBCPP_HAS_NO_NOEXCEPT
#define _LIBCPP_HAS_NO_NULLPTR
@ -626,6 +532,149 @@ namespace std {
#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
#if defined(__ELF__)
#define _LIBCPP_OBJECT_FORMAT_ELF 1
#elif defined(__MACH__)
#define _LIBCPP_OBJECT_FORMAT_MACHO 1
#else
#define _LIBCPP_OBJECT_FORMAT_COFF 1
#endif
#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_DLL_VIS
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
# define _LIBCPP_OVERRIDABLE_FUNC_VIS
#elif defined(_LIBCPP_BUILDING_LIBRARY)
# define _LIBCPP_DLL_VIS __declspec(dllexport)
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
#else
# define _LIBCPP_DLL_VIS __declspec(dllimport)
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
# define _LIBCPP_OVERRIDABLE_FUNC_VIS
#endif
#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
#define _LIBCPP_HIDDEN
#define _LIBCPP_TEMPLATE_VIS
#define _LIBCPP_FUNC_VIS_ONLY
#define _LIBCPP_ENUM_VIS
#if defined(_LIBCPP_MSVC)
# define _LIBCPP_INLINE_VISIBILITY __forceinline
# define _LIBCPP_ALWAYS_INLINE __forceinline
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
#else
# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
#endif
#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
#ifndef _LIBCPP_HIDDEN
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
#else
#define _LIBCPP_HIDDEN
#endif
#endif
#ifndef _LIBCPP_FUNC_VIS
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
#else
#define _LIBCPP_FUNC_VIS
#endif
#endif
#ifndef _LIBCPP_TYPE_VIS
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# if __has_attribute(__type_visibility__)
# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
# else
# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
# endif
# else
# define _LIBCPP_TYPE_VIS
# endif
#endif
#ifndef _LIBCPP_TEMPLATE_VIS
# define _LIBCPP_TEMPLATE_VIS _LIBCPP_TYPE_VIS
#endif
#ifndef _LIBCPP_FUNC_VIS_ONLY
# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
#endif
#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
#endif
#ifndef _LIBCPP_EXCEPTION_ABI
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
#else
#define _LIBCPP_EXCEPTION_ABI
#endif
#endif
#ifndef _LIBCPP_ENUM_VIS
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
# else
# define _LIBCPP_ENUM_VIS
# endif
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
# else
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
# endif
#endif
#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
#endif
#ifndef _LIBCPP_INLINE_VISIBILITY
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
#else
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
#endif
#endif
#ifndef _LIBCPP_ALWAYS_INLINE
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
#else
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
#endif
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
# else
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
# endif
#endif
#ifndef _LIBCPP_PREFERRED_OVERLOAD
# if __has_attribute(__enable_if__)
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
# endif
#endif
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
# define _NOEXCEPT noexcept
# define _NOEXCEPT_(x) noexcept(x)
@ -634,6 +683,17 @@ namespace std {
# define _NOEXCEPT_(x)
#endif
#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
# if !defined(_LIBCPP_DEBUG)
# error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
# endif
# define _NOEXCEPT_DEBUG noexcept(false)
# define _NOEXCEPT_DEBUG_(x) noexcept(false)
#else
# define _NOEXCEPT_DEBUG _NOEXCEPT
# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
#endif
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef unsigned short char16_t;
typedef unsigned int char32_t;
@ -643,8 +703,10 @@ typedef unsigned int char32_t;
#define _LIBCPP_HAS_NO_INT128
#endif
#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
#ifdef _LIBCPP_CXX03_LANG
# if __has_extension(c_static_assert)
# define static_assert(__b, __m) _Static_assert(__b, __m)
# else
extern "C++" {
template <bool> struct __static_assert_test;
template <> struct __static_assert_test<true> {};
@ -653,8 +715,8 @@ template <unsigned> struct __static_assert_check {};
#define static_assert(__b, __m) \
typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
_LIBCPP_CONCAT(__t, __LINE__)
#endif // _LIBCPP_HAS_NO_STATIC_ASSERT
# endif // __has_extension(c_static_assert)
#endif // _LIBCPP_CXX03_LANG
#ifdef _LIBCPP_HAS_NO_DECLTYPE
// GCC 4.6 provides __decltype in all standard modes.
@ -671,7 +733,7 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_CONSTEXPR constexpr
#endif
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#ifdef _LIBCPP_CXX03_LANG
#define _LIBCPP_DEFAULT {}
#else
#define _LIBCPP_DEFAULT = default;
@ -689,7 +751,8 @@ template <unsigned> struct __static_assert_check {};
#define _NOALIAS
#endif
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
(!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
# define _LIBCPP_EXPLICIT explicit
#else
# define _LIBCPP_EXPLICIT
@ -708,7 +771,7 @@ template <unsigned> struct __static_assert_check {};
_LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
};
#else // _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
@ -735,14 +798,14 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
// Most unix variants have catopen. These are the specific ones that don't.
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_CATOPEN 1
#endif
#endif
@ -795,6 +858,11 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_CONSTEXPR_AFTER_CXX14
#endif
// FIXME: Remove all usages of this macro once compilers catch up.
#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L)
# define _LIBCPP_HAS_NO_INLINE_VARIABLES
#endif
#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
#else
@ -802,7 +870,7 @@ template <unsigned> struct __static_assert_check {};
#endif
#ifndef _LIBCPP_HAS_NO_ASAN
extern "C" void __sanitizer_annotate_contiguous_container(
_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
const void *, const void *, const void *, const void *);
#endif
@ -823,8 +891,11 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#endif
// Thread API
#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# if defined(__FreeBSD__) || \
defined(__Fuchsia__) || \
defined(__NetBSD__) || \
defined(__linux__) || \
defined(__APPLE__) || \
@ -841,6 +912,11 @@ extern "C" void __sanitizer_annotate_contiguous_container(
_LIBCPP_HAS_NO_THREADS is not defined.
#endif
#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \
_LIBCPP_HAS_NO_THREADS is defined.
#endif
#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
_LIBCPP_HAS_NO_THREADS is defined.
@ -861,11 +937,12 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_STDOUT
#endif
#if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC)
#if defined(__BIONIC__) || defined(__CloudABI__) || \
defined(_LIBCPP_HAS_MUSL_LIBC)
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
#endif
// Thread-unsafe functions such as strtok(), mbtowc() and localtime()
// Thread-unsafe functions such as strtok() and localtime()
// are not available.
#ifdef __CloudABI__
#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
@ -886,19 +963,27 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
#endif
#if __cplusplus < 201103L
#define _LIBCPP_CXX03_LANG
#else
#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
#endif
#endif
#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
&& __has_attribute(acquire_capability))
#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
#endif
#if __has_attribute(require_constant_initialization)
#define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
#else
#define _LIBCPP_SAFE_STATIC
#endif
#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
#endif
#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
#endif
#endif
#endif // __cplusplus
#endif // _LIBCPP_CONFIG

View File

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

View File

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

View File

@ -24,14 +24,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Arg, class _Result>
struct _LIBCPP_TYPE_VIS_ONLY unary_function
struct _LIBCPP_TEMPLATE_VIS unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
template <class _Arg1, class _Arg2, class _Result>
struct _LIBCPP_TYPE_VIS_ONLY binary_function
struct _LIBCPP_TEMPLATE_VIS binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
@ -54,7 +54,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -63,7 +63,7 @@ struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY less<void>
struct _LIBCPP_TEMPLATE_VIS less<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -382,7 +382,7 @@ struct __invoke_void_return_wrapper<void>
};
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY reference_wrapper
class _LIBCPP_TEMPLATE_VIS reference_wrapper
: public __weak_result_type<_Tp>
{
public:
@ -585,7 +585,7 @@ public:
// allocator_arg_t
struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { };
struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY)
extern const allocator_arg_t allocator_arg;
@ -620,11 +620,16 @@ struct __uses_allocator<_Tp, _Alloc, false>
};
template <class _Tp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator
struct _LIBCPP_TEMPLATE_VIS uses_allocator
: public __uses_allocator<_Tp, _Alloc>
{
};
#if _LIBCPP_STD_VER > 14
template <class _Tp, class _Alloc>
constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
#endif
#ifndef _LIBCPP_HAS_NO_VARIADICS
// allocator construction
@ -632,7 +637,8 @@ struct _LIBCPP_TYPE_VIS_ONLY uses_allocator
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp
{
static const bool __ua = uses_allocator<_Tp, _Alloc>::value;
typedef typename __uncvref<_Alloc>::type _RawAlloc;
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
static const bool __ic =
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
static const int value = __ua ? 2 - __ic : 0;
@ -650,6 +656,7 @@ void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, con
new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
@ -657,6 +664,7 @@ void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, con
new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
@ -664,6 +672,7 @@ void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, con
new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
}
// FIXME: Theis should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY
void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
4000

View File

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

View File

@ -43,7 +43,7 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mut
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
constexpr mutex() _NOEXCEPT _LIBCPP_DEFAULT
constexpr mutex() _NOEXCEPT = default;
#else
mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
#endif
@ -85,11 +85,11 @@ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
// the mangling consistent between dialects.
#if defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
template <class ..._Mutexes>
class _LIBCPP_TYPE_VIS_ONLY lock_guard;
class _LIBCPP_TEMPLATE_VIS lock_guard;
#endif
template <class _Mutex>
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
#if !defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
lock_guard
#else
@ -118,7 +118,7 @@ private:
};
template <class _Mutex>
class _LIBCPP_TYPE_VIS_ONLY unique_lock
class _LIBCPP_TEMPLATE_VIS unique_lock
{
public:
typedef _Mutex mutex_type;
@ -300,7 +300,7 @@ class _LIBCPP_TYPE_VIS condition_variable
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
constexpr condition_variable() _NOEXCEPT _LIBCPP_DEFAULT
constexpr condition_variable() _NOEXCEPT = default;
#else
condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
#endif

View File

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

View File

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

View File

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

View File

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

View File

@ -19,187 +19,335 @@
#ifndef _LIBCPP_HAS_NO_THREADS
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
#ifndef __libcpp_has_include
#ifndef __has_include
#define __libcpp_has_include(x) 0
#else
#define __libcpp_has_include(x) __has_include(x)
#endif
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
!__libcpp_has_include(<__external_threading>)
// If the <__external_threading> header is absent, build libc++ against a
// pthread-oriented thread api but leave out its implementation. This setup
// allows building+testing of an externally-threaded library variant (on any
// platform that supports pthreads). Here, an 'externally-threaded' library
// variant is one where the implementation of the libc++ thread api is provided
// as a separate library.
#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
__libcpp_has_include(<__external_threading>)
#include <__external_threading>
#else
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
#include <pthread.h>
#include <sched.h>
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
#else
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
// Mutex
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
typedef pthread_mutex_t __libcpp_mutex_t;
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
{
pthread_mutexattr_t attr;
int __ec = pthread_mutexattr_init(&attr);
if (__ec) return __ec;
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (__ec)
{
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutex_init(__m, &attr);
if (__ec)
{
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutexattr_destroy(&attr);
if (__ec)
{
pthread_mutex_destroy(__m);
return __ec;
}
return 0;
}
typedef pthread_mutex_t __libcpp_recursive_mutex_t;
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
{
return pthread_mutex_lock(__m);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
{
return pthread_mutex_trylock(__m);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
{
return pthread_mutex_unlock(__m);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mutex_destroy(__libcpp_mutex_t* __m)
{
return pthread_mutex_destroy(__m);
}
// Condition variable
#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
// Condition Variable
typedef pthread_cond_t __libcpp_condvar_t;
#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
{
return pthread_cond_signal(__cv);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
{
return pthread_cond_broadcast(__cv);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
{
return pthread_cond_wait(__cv, __m);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts)
{
return pthread_cond_timedwait(__cv, __m, __ts);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
{
return pthread_cond_destroy(__cv);
}
// Execute once
typedef pthread_once_t __libcpp_exec_once_flag;
#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
// Thread id
typedef pthread_t __libcpp_thread_id;
// Returns non-zero if the thread ids are equal, otherwise 0
inline _LIBCPP_ALWAYS_INLINE
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
return pthread_equal(t1, t2) != 0;
}
// Returns non-zero if t1 < t2, otherwise 0
inline _LIBCPP_ALWAYS_INLINE
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
return t1 < t2;
}
// Thread
typedef pthread_t __libcpp_thread_t;
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg)
// Thrad Local Storage
typedef pthread_key_t __libcpp_tls_key;
#endif
// Mutex
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
// Condition variable
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
// Execute once
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
void (*init_routine)(void));
// Thread id
#if defined(__APPLE__) && !defined(__arm__)
_LIBCPP_THREAD_ABI_VISIBILITY
mach_port_t __libcpp_thread_get_port();
#endif
_LIBCPP_THREAD_ABI_VISIBILITY
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
_LIBCPP_THREAD_ABI_VISIBILITY
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
// Thread
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg);
_LIBCPP_THREAD_ABI_VISIBILITY
__libcpp_thread_id __libcpp_thread_get_current_id();
_LIBCPP_THREAD_ABI_VISIBILITY
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_thread_join(__libcpp_thread_t *__t);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_thread_detach(__libcpp_thread_t *__t);
_LIBCPP_THREAD_ABI_VISIBILITY
void __libcpp_thread_yield();
// Thread local storage
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *));
_LIBCPP_THREAD_ABI_VISIBILITY
void *__libcpp_tls_get(__libcpp_tls_key __key);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
{
return pthread_create(__t, 0, __func, __arg);
pthread_mutexattr_t attr;
int __ec = pthread_mutexattr_init(&attr);
if (__ec)
return __ec;
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (__ec) {
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutex_init(__m, &attr);
if (__ec) {
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutexattr_destroy(&attr);
if (__ec) {
pthread_mutex_destroy(__m);
return __ec;
}
return 0;
}
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_lock(__m);
}
int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_trylock(__m);
}
int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
{
return pthread_mutex_unlock(__m);
}
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_destroy(__m);
}
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
{
return pthread_mutex_lock(__m);
}
int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
{
return pthread_mutex_trylock(__m);
}
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
{
return pthread_mutex_unlock(__m);
}
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
{
return pthread_mutex_destroy(__m);
}
// Condition Variable
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
{
return pthread_cond_signal(__cv);
}
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
{
return pthread_cond_broadcast(__cv);
}
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
{
return pthread_cond_wait(__cv, __m);
}
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts)
{
return pthread_cond_timedwait(__cv, __m, __ts);
}
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
{
return pthread_cond_destroy(__cv);
}
// Execute once
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
void (*init_routine)(void)) {
return pthread_once(flag, init_routine);
}
// Thread id
#if defined(__APPLE__) && !defined(__arm__)
mach_port_t __libcpp_thread_get_port() {
return pthread_mach_thread_np(pthread_self());
}
#endif
// Returns non-zero if the thread ids are equal, otherwise 0
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
return pthread_equal(t1, t2) != 0;
}
// Returns non-zero if t1 < t2, otherwise 0
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
return t1 < t2;
}
// Thread
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
{
return pthread_create(__t, 0, __func, __arg);
}
inline _LIBCPP_ALWAYS_INLINE
__libcpp_thread_id __libcpp_thread_get_current_id()
{
return pthread_self();
return pthread_self();
}
inline _LIBCPP_ALWAYS_INLINE
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
{
return *__t;
return *__t;
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_thread_join(__libcpp_thread_t* __t)
int __libcpp_thread_join(__libcpp_thread_t *__t)
{
return pthread_join(*__t, 0);
return pthread_join(*__t, 0);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_thread_detach(__libcpp_thread_t* __t)
int __libcpp_thread_detach(__libcpp_thread_t *__t)
{
return pthread_detach(*__t);
return pthread_detach(*__t);
}
inline _LIBCPP_ALWAYS_INLINE
void __libcpp_thread_yield()
{
sched_yield();
sched_yield();
}
// Thread local storage
typedef pthread_key_t __libcpp_tl_key;
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit)(void*))
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
{
return pthread_key_create(__key, __at_exit);
return pthread_key_create(__key, __at_exit);
}
inline _LIBCPP_ALWAYS_INLINE
void* __libcpp_tl_get(__libcpp_tl_key __key)
void *__libcpp_tls_get(__libcpp_tls_key __key)
{
return pthread_getspecific(__key);
return pthread_getspecific(__key);
}
inline _LIBCPP_ALWAYS_INLINE
void __libcpp_tl_set(__libcpp_tl_key __key, void* __p)
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
{
pthread_setspecific(__key, __p);
return pthread_setspecific(__key, __p);
}
#else // !_LIBCPP_HAS_THREAD_API_PTHREAD
#error "No thread API selected."
#endif
#endif // _LIBCPP_HAS_THREAD_API_PTHREAD
_LIBCPP_END_NAMESPACE_STD
#endif // !_LIBCPP_HAS_THREAD_API_EXTERNAL || !__libcpp_has_include(<__external_threading>)
#endif // _LIBCPP_HAS_NO_THREADS
#endif // _LIBCPP_THREADING_SUPPORT

View File

@ -25,9 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Compare, class _Allocator> class __tree;
template <class _Tp, class _NodePtr, class _DiffType>
class _LIBCPP_TYPE_VIS_ONLY __tree_iterator;
class _LIBCPP_TEMPLATE_VIS __tree_iterator;
template <class _Tp, class _ConstNodePtr, class _DiffType>
class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
template <class _Pointer> class __tree_end_node;
template <class _VoidPtr> class __tree_node_base;
@ -42,8 +42,8 @@ struct __value_type;
#endif
template <class _Allocator> class __map_node_destructor;
template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_iterator;
template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_iterator;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
/*
@ -797,7 +797,7 @@ public:
template <class _Tp, class _NodePtr, class _DiffType>
class _LIBCPP_TYPE_VIS_ONLY __tree_iterator
class _LIBCPP_TEMPLATE_VIS __tree_iterator
{
typedef __tree_node_types<_NodePtr> _NodeTypes;
typedef _NodePtr __node_pointer;
@ -861,16 +861,16 @@ private:
_LIBCPP_INLINE_VISIBILITY
__node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
template <class, class, class> friend class __tree;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_iterator;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY set;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
template <class> friend class _LIBCPP_TEMPLATE_VIS __map_iterator;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS set;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS multiset;
};
template <class _Tp, class _NodePtr, class _DiffType>
class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator
class _LIBCPP_TEMPLATE_VIS __tree_const_iterator
{
typedef __tree_node_types<_NodePtr> _NodeTypes;
typedef typename _NodeTypes::__node_pointer __node_pointer;
@ -947,11 +947,11 @@ private:
__node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
template <class, class, class> friend class __tree;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY set;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS set;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS multiset;
template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
};
@ -1106,19 +1106,22 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
{return __node_traits::max_size(__node_alloc());}
{return std::min<size_type>(
__node_traits::max_size(__node_alloc()),
numeric_limits<difference_type >::max());}
void clear() _NOEXCEPT;
void swap(__tree& __t)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(
__is_nothrow_swappable<value_compare>::value
#if _LIBCPP_STD_VER <= 11
&& (!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
);
#else
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
#endif
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class ..._Args>
@ -1394,10 +1397,17 @@ private:
__node_base_pointer&
__find_leaf(const_iterator __hint,
__parent_pointer& __parent, const key_type& __v);
// FIXME: Make this function const qualified. Unfortunetly doing so
// breaks existing code which uses non-const callable comparators.
template <class _Key>
__node_base_pointer&
__find_equal(__parent_pointer& __parent, const _Key& __v);
template <class _Key>
_LIBCPP_INLINE_VISIBILITY __node_base_pointer&
__find_equal(__parent_pointer& __parent, const _Key& __v) const {
return const_cast<__tree*>(this)->__find_equal(__parent, __v);
}
template <class _Key>
__node_base_pointer&
__find_equal(const_iterator __hint, __parent_pointer& __parent,
__node_base_pointer& __dummy,
@ -1425,7 +1435,7 @@ private:
__node_alloc() = __t.__node_alloc();
}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __tree& __t, false_type) {}
void __copy_assign_alloc(const __tree&, false_type) {}
void __move_assign(__tree& __t, false_type);
void __move_assign(__tree& __t, true_type)
@ -1445,13 +1455,13 @@ private:
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
{__node_alloc() = _VSTD::move(__t.__node_alloc());}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__tree& __t, false_type) _NOEXCEPT {}
void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
__node_pointer __detach();
static __node_pointer __detach(__node_pointer);
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
};
template <class _Tp, class _Compare, class _Allocator>
@ -1797,13 +1807,15 @@ __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
template <class _Tp, class _Compare, class _Allocator>
void
__tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(
__is_nothrow_swappable<value_compare>::value
#if _LIBCPP_STD_VER <= 11
&& (!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
)
#else
_NOEXCEPT_(__is_nothrow_swappable<value_compare>::value)
#endif
{
using _VSTD::swap;
swap(__begin_node_, __t.__begin_node_);

View File

@ -22,38 +22,56 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size;
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Tp, class...>
using __enable_if_tuple_size_imp = _Tp;
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const _Tp>
: public tuple_size<_Tp> {};
class _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_TYPE_VIS_ONLY tuple_size<volatile _Tp>
: public tuple_size<_Tp> {};
class _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_TYPE_VIS_ONLY tuple_size<const volatile _Tp>
: public tuple_size<_Tp> {};
class _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> {};
template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element;
#else
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
#endif
template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
template <size_t _Ip, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const _Tp>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
{
public:
typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, volatile _Tp>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
{
public:
typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const volatile _Tp>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
{
public:
typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
@ -142,10 +160,16 @@ struct __make_tuple_indices
};
template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
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...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
template <size_t _Ip, class ..._Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type&
@ -195,7 +219,7 @@ get(const pair<_T1, _T2>&&) _NOEXCEPT;
// array specializations
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
@ -258,7 +282,7 @@ using __type_pack_element = typename decltype(
#endif
template <size_t _Ip, class ..._Types>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Types...>>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
{
public:
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
@ -267,7 +291,7 @@ public:
template <class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> >
class _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
@ -368,7 +392,7 @@ template <bool ..._Preds>
struct __all_dummy;
template <bool ..._Pred>
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<(_Pred, true)...>>;
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
struct __tuple_sfinae_base {
template <template <class, class...> class _Trait,
@ -431,8 +455,105 @@ struct __tuple_assignable<_Tp, _Up, true, true>
>
{};
template <size_t _Ip, class ..._Tp>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
{
public:
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
};
#if _LIBCPP_STD_VER > 11
template <size_t _Ip, class ..._Tp>
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
#endif
#endif // _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_CXX03_LANG
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp : false_type {};
template <class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
: integral_constant<bool, _SizeTrait::value == _Expected> {};
template <class _Tuple, size_t _ExpectedSize,
class _RawTuple = typename __uncvref<_Tuple>::type>
using __tuple_like_with_size = __tuple_like_with_size_imp<
__tuple_like<_RawTuple>::value,
tuple_size<_RawTuple>, _ExpectedSize
>;
struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
template <class ...>
static constexpr bool __enable_default() { return false; }
template <class ...>
static constexpr bool __enable_explicit() { return false; }
template <class ...>
static constexpr bool __enable_implicit() { return false; }
template <class ...>
static constexpr bool __enable_assign() { return false; }
};
#endif
#if _LIBCPP_STD_VER > 14
template <bool _CanCopy, bool _CanMove>
struct __sfinae_ctor_base {};
template <>
struct __sfinae_ctor_base<false, false> {
__sfinae_ctor_base() = default;
__sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
__sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
};
template <>
struct __sfinae_ctor_base<true, false> {
__sfinae_ctor_base() = default;
__sfinae_ctor_base(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
};
template <>
struct __sfinae_ctor_base<false, true> {
__sfinae_ctor_base() = default;
__sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
__sfinae_ctor_base(__sfinae_ctor_base &&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
};
template <bool _CanCopy, bool _CanMove>
struct __sfinae_assign_base {};
template <>
struct __sfinae_assign_base<false, false> {
__sfinae_assign_base() = default;
__sfinae_assign_base(__sfinae_assign_base const&) = default;
__sfinae_assign_base(__sfinae_assign_base &&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
};
template <>
struct __sfinae_assign_base<true, false> {
__sfinae_assign_base() = default;
__sfinae_assign_base(__sfinae_assign_base const&) = default;
__sfinae_assign_base(__sfinae_assign_base &&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
};
template <>
struct __sfinae_assign_base<false, true> {
__sfinae_assign_base() = default;
__sfinae_assign_base(__sfinae_assign_base const&) = default;
__sfinae_assign_base(__sfinae_assign_base &&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
};
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TUPLE

View File

@ -89,7 +89,7 @@ template <class InputIterator1, class InputIterator2>
template <class InputIterator1, class InputIterator2>
pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2); // **C++14**
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
@ -109,7 +109,7 @@ template <class InputIterator1, class InputIterator2>
template <class InputIterator1, class InputIterator2>
bool
equal(InputIterator1 first1, InputIterator1 last1,
equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2); // **C++14**
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
@ -288,6 +288,12 @@ template <class RandomAccessIterator, class RandomNumberGenerator>
random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
RandomNumberGenerator& rand); // deprecated in C++14
template<class PopulationIterator, class SampleIterator,
class Distance, class UniformRandomBitGenerator>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n,
UniformRandomBitGenerator&& g); // C++17
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
void shuffle(RandomAccessIterator first, RandomAccessIterator last,
UniformRandomNumberGenerator&& g);
@ -688,7 +694,7 @@ struct __equal_to<_T1, const _T1>
template <class _T1, class _T2 = _T1>
struct __less
{
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@ -749,14 +755,28 @@ struct __debug_less
{
_Compare __comp_;
__debug_less(_Compare& __c) : __comp_(__c) {}
template <class _Tp, class _Up>
bool operator()(const _Tp& __x, const _Up& __y)
{
bool __r = __comp_(__x, __y);
if (__r)
_LIBCPP_ASSERT(!__comp_(__y, __x), "Comparator does not induce a strict weak ordering");
__do_compare_assert(0, __y, __x);
return __r;
}
template <class _LHS, class _RHS>
inline _LIBCPP_INLINE_VISIBILITY
decltype((void)_VSTD::declval<_Compare&>()(
_VSTD::declval<_LHS const&>(), _VSTD::declval<_RHS const&>()))
__do_compare_assert(int, _LHS const& __l, _RHS const& __r) {
_LIBCPP_ASSERT(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
}
template <class _LHS, class _RHS>
inline _LIBCPP_INLINE_VISIBILITY
void __do_compare_assert(long, _LHS const&, _RHS const&) {}
};
#endif // _LIBCPP_DEBUG
@ -857,7 +877,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
{
for (; __first != __last; ++__first)
__f(*__first);
return _LIBCPP_EXPLICIT_MOVE(__f); // explicitly moved for (emulated) C++03
return __f;
}
// find
@ -1215,7 +1235,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
inline _LIBCPP_INLINE_VISIBILITY
bool
__equal(_InputIterator1 __first1, _InputIterator1 __last1,
__equal(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
input_iterator_tag, input_iterator_tag )
{
@ -1228,8 +1248,8 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1,
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
inline _LIBCPP_INLINE_VISIBILITY
bool
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
random_access_iterator_tag, random_access_iterator_tag )
{
if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
@ -1242,11 +1262,11 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
inline _LIBCPP_INLINE_VISIBILITY
bool
equal(_InputIterator1 __first1, _InputIterator1 __last1,
equal(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
{
return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>
(__first1, __last1, __first2, __last2, __pred,
(__first1, __last1, __first2, __last2, __pred,
typename iterator_traits<_InputIterator1>::iterator_category(),
typename iterator_traits<_InputIterator2>::iterator_category());
}
@ -1254,7 +1274,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1,
template <class _InputIterator1, class _InputIterator2>
inline _LIBCPP_INLINE_VISIBILITY
bool
equal(_InputIterator1 __first1, _InputIterator1 __last1,
equal(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
{
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
@ -1328,7 +1348,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
template<class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
bool
__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __pred,
forward_iterator_tag, forward_iterator_tag )
{
@ -1379,7 +1399,7 @@ __next_iter:;
template<class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
bool
__is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
_RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
_RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
_BinaryPredicate __pred,
random_access_iterator_tag, random_access_iterator_tag )
{
@ -1458,7 +1478,7 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
_LIBCPP_CONSTEXPR_AFTER_CXX11
_LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_RandomAccessIterator1, _RandomAccessIterator1>
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
@ -1474,9 +1494,9 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
if (__len1 < __len2)
return make_pair(__last1, __last1);
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
while (true)
{
#if !_LIBCPP_UNROLL_LOOPS
while (true)
{
if (__first1 == __s)
@ -1485,40 +1505,9 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
break;
++__first1;
}
#else // !_LIBCPP_UNROLL_LOOPS
for (_D1 __loop_unroll = (__s - __first1) / 4; __loop_unroll > 0; --__loop_unroll)
{
if (__pred(*__first1, *__first2))
goto __phase2;
if (__pred(*++__first1, *__first2))
goto __phase2;
if (__pred(*++__first1, *__first2))
goto __phase2;
if (__pred(*++__first1, *__first2))
goto __phase2;
++__first1;
}
switch (__s - __first1)
{
case 3:
if (__pred(*__first1, *__first2))
break;
++__first1;
case 2:
if (__pred(*__first1, *__first2))
break;
++__first1;
case 1:
if (__pred(*__first1, *__first2))
break;
case 0:
return make_pair(__last1, __last1);
}
__phase2:
#endif // !_LIBCPP_UNROLL_LOOPS
_RandomAccessIterator1 __m1 = __first1;
_RandomAccessIterator2 __m2 = __first2;
#if !_LIBCPP_UNROLL_LOOPS
while (true)
{
if (++__m2 == __last2)
@ -1530,43 +1519,6 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
break;
}
}
#else // !_LIBCPP_UNROLL_LOOPS
++__m2;
++__m1;
for (_D2 __loop_unroll = (__last2 - __m2) / 4; __loop_unroll > 0; --__loop_unroll)
{
if (!__pred(*__m1, *__m2))
goto __continue;
if (!__pred(*++__m1, *++__m2))
goto __continue;
if (!__pred(*++__m1, *++__m2))
goto __continue;
if (!__pred(*++__m1, *++__m2))
goto __continue;
++__m1;
++__m2;
}
switch (__last2 - __m2)
{
case 3:
if (!__pred(*__m1, *__m2))
break;
++__m1;
++__m2;
case 2:
if (!__pred(*__m1, *__m2))
break;
++__m1;
++__m2;
case 1:
if (!__pred(*__m1, *__m2))
break;
case 0:
return make_pair(__first1, __first1 + __len2);
}
__continue:
++__first1;
#endif // !_LIBCPP_UNROLL_LOOPS
}
}
@ -1729,6 +1681,20 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
return __i.base();
}
#else
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
__wrap_iter<_Tp*>
>::type
__unwrap_iter(__wrap_iter<_Tp*> __i)
{
return __i;
}
#endif // _LIBCPP_DEBUG_LEVEL < 2
template <class _InputIterator, class _OutputIterator>
@ -1802,7 +1768,9 @@ _BidirectionalIterator2
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result)
{
return _VSTD::__copy_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
return _VSTD::__copy_backward(__unwrap_iter(__first),
__unwrap_iter(__last),
__unwrap_iter(__result));
}
// copy_if
@ -2417,7 +2385,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
template<typename _Integral>
inline _LIBCPP_INLINE_VISIBILITY
_Integral
__gcd(_Integral __x, _Integral __y)
__algo_gcd(_Integral __x, _Integral __y)
{
do
{
@ -2442,7 +2410,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
_VSTD::swap_ranges(__first, __middle, __middle);
return __middle;
}
const difference_type __g = _VSTD::__gcd(__m1, __m2);
const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{
value_type __t(_VSTD::move(*--__p));
@ -2785,7 +2753,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
__result.second = *__first;
++__first;
}
while (__first != __last)
{
_Tp __prev = *__first++;
@ -2797,7 +2765,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
if ( __comp(__prev, __result.first)) __result.first = __prev;
if (!__comp(*__first, __result.second)) __result.second = *__first;
}
__first++;
}
return __result;
@ -3128,6 +3096,78 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
}
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n,
_UniformRandomNumberGenerator & __g,
input_iterator_tag) {
_Distance __k = 0;
for (; __first != __last && __k < __n; ++__first, (void)++__k)
__out[__k] = *__first;
_Distance __sz = __k;
for (; __first != __last; ++__first, (void)++__k) {
_Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
if (__r < __sz)
__out[__r] = *__first;
}
return __out + _VSTD::min(__n, __k);
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n,
_UniformRandomNumberGenerator& __g,
forward_iterator_tag) {
_Distance __unsampled_sz = _VSTD::distance(__first, __last);
for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
_Distance __r =
_VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
if (__r < __n) {
*__out++ = *__first;
--__n;
}
}
return __out;
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n, _UniformRandomNumberGenerator& __g) {
typedef typename iterator_traits<_PopulationIterator>::iterator_category
_PopCategory;
typedef typename iterator_traits<_PopulationIterator>::difference_type
_Difference;
static_assert(__is_forward_iterator<_PopulationIterator>::value ||
__is_random_access_iterator<_SampleIterator>::value,
"SampleIterator must meet the requirements of RandomAccessIterator");
typedef typename common_type<_Distance, _Difference>::type _CommonType;
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
return _VSTD::__sample(
__first, __last, __out, _CommonType(__n),
__g, _PopCategory());
}
#if _LIBCPP_STD_VER > 14
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
inline _LIBCPP_INLINE_VISIBILITY
_SampleIterator sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n, _UniformRandomNumberGenerator&& __g) {
return _VSTD::__sample(__first, __last, __out, __n, __g);
}
#endif // _LIBCPP_STD_VER > 14
template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@ -4423,7 +4463,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
::new(__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
__half_inplace_merge(_Rv(__p), _Rv(__buff),
__half_inplace_merge(_Rv(__p), _Rv(__buff),
_RBi(__middle), _RBi(__first),
_RBi(__last), __negate<_Compare>(__comp));
}
@ -4871,7 +4911,8 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
template <class _Compare, class _RandomAccessIterator>
void
__sift_down(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
_Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start)
{

663
contrib/libc++/include/any Normal file
View File

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

View File

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

View File

@ -557,7 +557,6 @@ void atomic_signal_fence(memory_order m) noexcept;
#endif
#if _LIBCPP_STD_VER > 14
// FIXME: use the right feature test macro value as chose by SG10.
# define __cpp_lib_atomic_is_always_lock_free 201603L
#endif
@ -580,11 +579,11 @@ struct __gcc_atomic_t {
#endif
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#ifndef _LIBCPP_CXX03_LANG
__gcc_atomic_t() _NOEXCEPT = default;
#else
__gcc_atomic_t() _NOEXCEPT : __a_value() {}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
: __a_value(value) {}
_Tp __a_value;
@ -936,11 +935,11 @@ struct __atomic_base // false
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#ifndef _LIBCPP_CXX03_LANG
__atomic_base() _NOEXCEPT = default;
#else
__atomic_base() _NOEXCEPT : __a_() {}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
@ -1691,11 +1690,11 @@ typedef struct atomic_flag
{__c11_atomic_store(&__a_, false, __m);}
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#ifndef _LIBCPP_CXX03_LANG
atomic_flag() _NOEXCEPT = default;
#else
atomic_flag() _NOEXCEPT : __a_() {}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -106,10 +106,6 @@ public:
#include <__undef___deallocate>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@ -117,7 +113,7 @@ public:
namespace std { namespace experimental { inline namespace __array_extensions_v1 {
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY dynarray
struct _LIBCPP_TEMPLATE_VIS dynarray
{
public:
// types:
@ -142,13 +138,8 @@ private:
static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
{
if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_array_length();
#else
assert(!"dynarray::allocation");
#endif
}
__throw_bad_array_length();
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
}
@ -283,13 +274,8 @@ typename dynarray<_Tp>::reference
dynarray<_Tp>::at(size_type __n)
{
if (__n >= __size_)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("dynarray::at");
#else
assert(!"dynarray::at out_of_range");
#endif
}
__throw_out_of_range("dynarray::at");
return data()[__n];
}
@ -299,13 +285,8 @@ typename dynarray<_Tp>::const_reference
dynarray<_Tp>::at(size_type __n) const
{
if (__n >= __size_)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("dynarray::at");
#else
assert(!"dynarray::at out_of_range");
#endif
}
__throw_out_of_range("dynarray::at");
return data()[__n];
}
@ -314,7 +295,7 @@ dynarray<_Tp>::at(size_type __n) const
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
struct _LIBCPP_TEMPLATE_VIS uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
_LIBCPP_END_NAMESPACE_STD
#endif // if _LIBCPP_STD_VER > 11

View File

@ -228,7 +228,7 @@
#include <system_error>
#include <utility>
#include <iomanip> // for quoted
#include <experimental/string_view>
#include <string_view>
#include <__debug>
@ -249,7 +249,7 @@ struct _LIBCPP_TYPE_VIS space_info
uintmax_t available;
};
enum class _LIBCPP_TYPE_VIS file_type : signed char
enum class _LIBCPP_ENUM_VIS file_type : signed char
{
none = 0,
not_found = -1,
@ -263,7 +263,7 @@ enum class _LIBCPP_TYPE_VIS file_type : signed char
unknown = 8
};
enum class _LIBCPP_TYPE_VIS perms : unsigned
enum class _LIBCPP_ENUM_VIS perms : unsigned
{
none = 0,
@ -323,7 +323,7 @@ _LIBCPP_INLINE_VISIBILITY
inline perms& operator^=(perms& _LHS, perms _RHS)
{ return _LHS = _LHS ^ _RHS; }
enum class _LIBCPP_TYPE_VIS copy_options : unsigned short
enum class _LIBCPP_ENUM_VIS copy_options : unsigned short
{
none = 0,
skip_existing = 1,
@ -367,7 +367,7 @@ inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS)
{ return _LHS = _LHS ^ _RHS; }
enum class directory_options : unsigned char
enum class _LIBCPP_ENUM_VIS directory_options : unsigned char
{
none = 0,
follow_directory_symlink = 1,
@ -453,6 +453,9 @@ class _LIBCPP_TYPE_VIS directory_entry;
template <class _Tp> struct __can_convert_char {
static const bool value = false;
};
template <class _Tp> struct __can_convert_char<const _Tp>
: public __can_convert_char<_Tp> {
};
template <> struct __can_convert_char<char> {
static const bool value = true;
using __char_type = char;
@ -498,6 +501,21 @@ struct __is_pathable_string<basic_string<_ECharT, _Traits, _Alloc>,
}
};
template <class _ECharT, class _Traits>
struct __is_pathable_string<basic_string_view<_ECharT, _Traits>,
_Void<typename __can_convert_char<_ECharT>::__char_type>>
: public __can_convert_char<_ECharT>
{
using _Str = basic_string_view<_ECharT, _Traits>;
using _Base = __can_convert_char<_ECharT>;
static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); }
static _ECharT __first_or_null(_Str const& __s) {
return __s.empty() ? _ECharT{} : __s[0];
}
};
template <class _Source,
class _DS = typename decay<_Source>::type,
class _UnqualPtrType = typename remove_const<
@ -605,12 +623,22 @@ struct _PathCVT {
template <>
struct _PathCVT<char> {
template <class _Iter>
static void __append_range(string& __dest, _Iter __b, _Iter __e) {
static typename enable_if<
__is_exactly_input_iterator<_Iter>::value
>::type __append_range(string& __dest, _Iter __b, _Iter __e) {
for (; __b != __e; ++__b)
__dest.push_back(*__b);
}
template <class _Iter>
static typename enable_if<
__is_forward_iterator<_Iter>::value
>::type __append_range(string& __dest, _Iter __b, _Iter __e) {
__dest.__append_forward_unsafe(__b, __e);
}
template <class _Iter>
static void __append_range(string& __dest, _Iter __b, _NullSentinal) {
const char __sentinal = char{};
@ -622,7 +650,8 @@ struct _PathCVT<char> {
static void __append_source(string& __dest, _Source const& __s)
{
using _Traits = __is_pathable<_Source>;
__append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));
__append_range(__dest, _Traits::__range_begin(__s),
_Traits::__range_end(__s));
}
};
@ -642,6 +671,7 @@ class _LIBCPP_TYPE_VIS path
public:
typedef char value_type;
typedef basic_string<value_type> string_type;
typedef _VSTD::string_view __string_view;
static _LIBCPP_CONSTEXPR value_type preferred_separator = '/';
// constructors and destructor
@ -740,6 +770,8 @@ private:
public:
// appends
path& operator/=(const path& __p) {
_LIBCPP_ASSERT(!__p.has_root_name(),
"cannot append to a path with a root name");
__append_sep_if_needed(__p.empty() ? char{} : __p.__pn_[0]);
__pn_ += __p.native();
return *this;
@ -787,6 +819,12 @@ public:
return *this;
}
_LIBCPP_INLINE_VISIBILITY
path& operator+=(__string_view __x) {
__pn_ += __x;
return *this;
}
_LIBCPP_INLINE_VISIBILITY
path& operator+=(const value_type* __x) {
__pn_ += __x;
@ -799,7 +837,6 @@ public:
return *this;
}
template <class _ECharT>
typename enable_if<__can_convert_char<_ECharT>::value, path&>::type
operator+=(_ECharT __x)
@ -837,7 +874,15 @@ public:
}
path& make_preferred() { return *this; }
path& remove_filename() { return *this = parent_path(); }
_LIBCPP_INLINE_VISIBILITY
path& remove_filename() {
if (__pn_.size() == __root_path_raw().size())
clear();
else
__pn_ = __parent_path();
return *this;
}
path& replace_filename(const path& __replacement) {
remove_filename();
@ -896,37 +941,39 @@ public:
std::u32string generic_u32string() const { return string<char32_t>(); }
private:
_LIBCPP_FUNC_VIS int __compare(const value_type*) const;
_LIBCPP_FUNC_VIS string_view __root_name() const;
_LIBCPP_FUNC_VIS string_view __root_directory() const;
_LIBCPP_FUNC_VIS string_view __relative_path() const;
_LIBCPP_FUNC_VIS string_view __parent_path() const;
_LIBCPP_FUNC_VIS string_view __filename() const;
_LIBCPP_FUNC_VIS string_view __stem() const;
_LIBCPP_FUNC_VIS string_view __extension() const;
_LIBCPP_FUNC_VIS int __compare(__string_view) const;
_LIBCPP_FUNC_VIS __string_view __root_name() const;
_LIBCPP_FUNC_VIS __string_view __root_directory() const;
_LIBCPP_FUNC_VIS __string_view __root_path_raw() const;
_LIBCPP_FUNC_VIS __string_view __relative_path() const;
_LIBCPP_FUNC_VIS __string_view __parent_path() const;
_LIBCPP_FUNC_VIS __string_view __filename() const;
_LIBCPP_FUNC_VIS __string_view __stem() const;
_LIBCPP_FUNC_VIS __string_view __extension() const;
public:
// compare
_LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const _NOEXCEPT { return __compare(__p.c_str());}
_LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s.c_str()); }
_LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const _NOEXCEPT { return __compare(__p.__pn_);}
_LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s); }
_LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { return __compare(__s); }
_LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { return __compare(__s); }
// decomposition
_LIBCPP_INLINE_VISIBILITY path root_name() const { return __root_name().to_string(); }
_LIBCPP_INLINE_VISIBILITY path root_directory() const { return __root_directory().to_string(); }
_LIBCPP_INLINE_VISIBILITY path root_path() const { return root_name().append(__root_directory().to_string()); }
_LIBCPP_INLINE_VISIBILITY path relative_path() const { return __relative_path().to_string(); }
_LIBCPP_INLINE_VISIBILITY path parent_path() const { return __parent_path().to_string(); }
_LIBCPP_INLINE_VISIBILITY path filename() const { return __filename().to_string(); }
_LIBCPP_INLINE_VISIBILITY path stem() const { return __stem().to_string();}
_LIBCPP_INLINE_VISIBILITY path extension() const { return __extension().to_string(); }
_LIBCPP_INLINE_VISIBILITY path root_name() const { return string_type(__root_name()); }
_LIBCPP_INLINE_VISIBILITY path root_directory() const { return string_type(__root_directory()); }
_LIBCPP_INLINE_VISIBILITY path root_path() const { return root_name().append(string_type(__root_directory())); }
_LIBCPP_INLINE_VISIBILITY path relative_path() const { return string_type(__relative_path()); }
_LIBCPP_INLINE_VISIBILITY path parent_path() const { return string_type(__parent_path()); }
_LIBCPP_INLINE_VISIBILITY path filename() const { return string_type(__filename()); }
_LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem());}
_LIBCPP_INLINE_VISIBILITY path extension() const { return string_type(__extension()); }
// query
_LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT { return __pn_.empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_root_name() const { return !__root_name().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return !__root_directory().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_root_path() const { return !(__root_name().empty() && __root_directory().empty()); }
_LIBCPP_INLINE_VISIBILITY bool has_root_path() const { return !__root_path_raw().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { return !__relative_path().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { return !__parent_path().empty(); }
_LIBCPP_INLINE_VISIBILITY bool has_filename() const { return !__filename().empty(); }
@ -945,7 +992,7 @@ public:
private:
inline _LIBCPP_INLINE_VISIBILITY
path& __assign_view(string_view const& __s) noexcept { __pn_ = __s.to_string(); return *this; }
path& __assign_view(__string_view const& __s) noexcept { __pn_ = string_type(__s); return *this; }
string_type __pn_;
};
@ -1047,7 +1094,8 @@ public:
typedef const path& reference;
public:
_LIBCPP_INLINE_VISIBILITY
iterator() : __elem_(), __path_ptr_(nullptr), __pos_(0) {}
iterator() : __stashed_elem_(), __path_ptr_(nullptr),
__entry_(), __state_(__singular) {}
iterator(const iterator&) = default;
~iterator() = default;
@ -1056,16 +1104,20 @@ public:
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
return __elem_;
return __stashed_elem_;
}
_LIBCPP_INLINE_VISIBILITY
pointer operator->() const {
return &__elem_;
return &__stashed_elem_;
}
_LIBCPP_INLINE_VISIBILITY
iterator& operator++() {
_LIBCPP_ASSERT(__state_ != __singular,
"attempting to increment a singular iterator");
_LIBCPP_ASSERT(__state_ != __at_end,
"attempting to increment the end iterator");
return __increment();
}
@ -1078,6 +1130,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator& operator--() {
_LIBCPP_ASSERT(__state_ != __singular,
"attempting to decrement a singular iterator");
_LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
"attempting to decrement the begin iterator");
return __decrement();
}
@ -1090,20 +1146,26 @@ public:
private:
friend class path;
static constexpr unsigned char __singular = 0;
static constexpr unsigned char __at_end = 6;
inline _LIBCPP_INLINE_VISIBILITY
friend bool operator==(const iterator&, const iterator&);
_LIBCPP_FUNC_VIS iterator& __increment();
_LIBCPP_FUNC_VIS iterator& __decrement();
path __elem_;
path __stashed_elem_;
const path* __path_ptr_;
size_t __pos_;
path::__string_view __entry_;
unsigned char __state_;
};
inline _LIBCPP_INLINE_VISIBILITY
bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) {
return __lhs.__path_ptr_ == __rhs.__path_ptr_ &&
__lhs.__pos_ == __rhs.__pos_;
__lhs.__entry_.data() == __rhs.__entry_.data();
}
inline _LIBCPP_INLINE_VISIBILITY
@ -1154,6 +1216,21 @@ private:
shared_ptr<_Storage> __paths_;
};
template <class... _Args>
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
#ifndef _LIBCPP_NO_EXCEPTIONS
void __throw_filesystem_error(_Args && ...__args)
{
throw filesystem_error(std::forward<_Args>(__args)...);
}
#else
void __throw_filesystem_error(_Args&&...)
{
_VSTD::abort();
}
#endif
// operational functions
_LIBCPP_FUNC_VIS
@ -1865,6 +1942,7 @@ public:
{ return __increment(&__ec); }
private:
inline _LIBCPP_INLINE_VISIBILITY
friend bool operator==(const directory_iterator& __lhs,
const directory_iterator& __rhs) _NOEXCEPT;
@ -2014,6 +2092,7 @@ private:
_LIBCPP_FUNC_VIS
void __pop(error_code* __ec=nullptr);
inline _LIBCPP_INLINE_VISIBILITY
friend bool operator==(const recursive_directory_iterator&,
const recursive_directory_iterator&) _NOEXCEPT;
@ -2023,9 +2102,9 @@ private:
}; // class recursive_directory_iterator
_LIBCPP_INLINE_VISIBILITY
inline bool operator==(const recursive_directory_iterator& __lhs,
const recursive_directory_iterator& __rhs) _NOEXCEPT
inline _LIBCPP_INLINE_VISIBILITY
bool operator==(const recursive_directory_iterator& __lhs,
const recursive_directory_iterator& __rhs) _NOEXCEPT
{
return __lhs.__imp_ == __rhs.__imp_;
}

View File

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

View File

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

View File

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

View File

@ -123,8 +123,14 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS_V2
template <class _Tp>
class propagate_const;
template <class _Up> _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Up> _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Up>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Up>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Tp>
class propagate_const
@ -462,14 +468,12 @@ _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& _
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT
{
return __pt.__t_;
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT
{
return __pt.__t_;

View File

@ -192,7 +192,7 @@ namespace std {
_LIBCPP_BEGIN_NAMESPACE_LFTS
template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_string_view {
class _LIBCPP_TEMPLATE_VIS basic_string_view {
public:
// types
typedef _Traits traits_type;
@ -281,7 +281,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
const_reference at(size_type __pos) const
{
return __pos >= size()
? (__libcpp_throw(out_of_range("string_view::at")), __data[0])
? (__throw_out_of_range("string_view::at"), __data[0])
: __data[__pos];
}
@ -340,7 +340,12 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
// [string.view.ops], string operations:
template<class _Allocator>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
// Clang's extended C++11 explict conversions don't work with
// string_view in C++03.
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_EXPLICIT
#endif
operator basic_string<_CharT, _Traits, _Allocator>() const
{ return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
template<class _Allocator = allocator<_CharT> >
@ -352,7 +357,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{
if ( __pos > size())
__libcpp_throw(out_of_range("string_view::copy"));
__throw_out_of_range("string_view::copy");
size_type __rlen = _VSTD::min( __n, size() - __pos );
_VSTD::copy_n(begin() + __pos, __rlen, __s );
return __rlen;
@ -362,11 +367,11 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
{
// if (__pos > size())
// throw out_of_range("string_view::substr");
// __throw_out_of_range("string_view::substr");
// size_type __rlen = _VSTD::min( __n, size() - __pos );
// return basic_string_view(data() + __pos, __rlen);
return __pos > size()
? (__libcpp_throw((out_of_range("string_view::substr"))), basic_string_view())
? (__throw_out_of_range("string_view::substr"), basic_string_view())
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
}
@ -783,7 +788,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [string.view.hash]
// Shamelessly stolen from <string>
template<class _CharT, class _Traits>
struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> >
struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::basic_string_view<_CharT, _Traits> >
: public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
{
size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -212,6 +212,13 @@ template <class F> unspecified not_fn(F&& f); // C++17
template<class T> struct is_bind_expression;
template<class T> struct is_placeholder;
// See C++14 20.9.9, Function object binders
template <class T> constexpr bool is_bind_expression_v
= is_bind_expression<T>::value; // C++17
template <class T> constexpr int is_placeholder_v
= is_placeholder<T>::value; // C++17
template<class Fn, class... BoundArgs>
unspecified bind(Fn&&, BoundArgs&&...);
template<class R, class Fn, class... BoundArgs>
@ -386,15 +393,15 @@ public:
template<class F>
function(F);
template<Allocator Alloc>
function(allocator_arg_t, const Alloc&) noexcept;
function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17
template<Allocator Alloc>
function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17
template<Allocator Alloc>
function(allocator_arg_t, const Alloc&, const function&);
function(allocator_arg_t, const Alloc&, const function&); // removed in C++17
template<Allocator Alloc>
function(allocator_arg_t, const Alloc&, function&&);
function(allocator_arg_t, const Alloc&, function&&); // removed in C++17
template<class F, Allocator Alloc>
function(allocator_arg_t, const Alloc&, F);
function(allocator_arg_t, const Alloc&, F); // removed in C++17
function& operator=(const function&);
function& operator=(function&&) noexcept;
@ -492,7 +499,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -501,7 +508,7 @@ struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY plus<void>
struct _LIBCPP_TEMPLATE_VIS plus<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -519,7 +526,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -528,7 +535,7 @@ struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY minus<void>
struct _LIBCPP_TEMPLATE_VIS minus<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -546,7 +553,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -555,7 +562,7 @@ struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
struct _LIBCPP_TEMPLATE_VIS multiplies<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -573,7 +580,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -582,7 +589,7 @@ struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY divides<void>
struct _LIBCPP_TEMPLATE_VIS divides<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -600,7 +607,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -609,7 +616,7 @@ struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
struct _LIBCPP_TEMPLATE_VIS modulus<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -627,7 +634,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
@ -636,7 +643,7 @@ struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY negate<void>
struct _LIBCPP_TEMPLATE_VIS negate<void>
{
template <class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -654,7 +661,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -663,7 +670,7 @@ struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
struct _LIBCPP_TEMPLATE_VIS equal_to<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -681,7 +688,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -690,7 +697,7 @@ struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -708,7 +715,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -717,7 +724,7 @@ struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY greater<void>
struct _LIBCPP_TEMPLATE_VIS greater<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -737,7 +744,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -746,7 +753,7 @@ struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -764,7 +771,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -773,7 +780,7 @@ struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
struct _LIBCPP_TEMPLATE_VIS less_equal<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -791,7 +798,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -800,7 +807,7 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
struct _LIBCPP_TEMPLATE_VIS logical_and<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -818,7 +825,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
@ -827,7 +834,7 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
struct _LIBCPP_TEMPLATE_VIS logical_or<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -845,7 +852,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x) const
@ -854,7 +861,7 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
struct _LIBCPP_TEMPLATE_VIS logical_not<void>
{
template <class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -872,7 +879,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -881,7 +888,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
struct _LIBCPP_TEMPLATE_VIS bit_and<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -899,7 +906,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -908,7 +915,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
struct _LIBCPP_TEMPLATE_VIS bit_or<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -926,7 +933,7 @@ template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
@ -935,7 +942,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
#if _LIBCPP_STD_VER > 11
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -950,7 +957,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
#if _LIBCPP_STD_VER > 11
template <class _Tp = void>
struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp>
{
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
@ -958,7 +965,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
struct _LIBCPP_TEMPLATE_VIS bit_not<void>
{
template <class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@ -971,7 +978,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
#endif
template <class _Predicate>
class _LIBCPP_TYPE_VIS_ONLY unary_negate
class _LIBCPP_TEMPLATE_VIS unary_negate
: public unary_function<typename _Predicate::argument_type, bool>
{
_Predicate __pred_;
@ -990,7 +997,7 @@ unary_negate<_Predicate>
not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
template <class _Predicate>
class _LIBCPP_TYPE_VIS_ONLY binary_negate
class _LIBCPP_TEMPLATE_VIS binary_negate
: public binary_function<typename _Predicate::first_argument_type,
typename _Predicate::second_argument_type,
bool>
@ -1012,7 +1019,7 @@ binary_negate<_Predicate>
not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
template <class __Operation>
class _LIBCPP_TYPE_VIS_ONLY binder1st
class _LIBCPP_TEMPLATE_VIS binder1st
: public unary_function<typename __Operation::second_argument_type,
typename __Operation::result_type>
{
@ -1038,7 +1045,7 @@ bind1st(const __Operation& __op, const _Tp& __x)
{return binder1st<__Operation>(__op, __x);}
template <class __Operation>
class _LIBCPP_TYPE_VIS_ONLY binder2nd
class _LIBCPP_TEMPLATE_VIS binder2nd
: public unary_function<typename __Operation::first_argument_type,
typename __Operation::result_type>
{
@ -1064,7 +1071,7 @@ bind2nd(const __Operation& __op, const _Tp& __x)
{return binder2nd<__Operation>(__op, __x);}
template <class _Arg, class _Result>
class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function
: public unary_function<_Arg, _Result>
{
_Result (*__f_)(_Arg);
@ -1082,7 +1089,7 @@ ptr_fun(_Result (*__f)(_Arg))
{return pointer_to_unary_function<_Arg,_Result>(__f);}
template <class _Arg1, class _Arg2, class _Result>
class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function
: public binary_function<_Arg1, _Arg2, _Result>
{
_Result (*__f_)(_Arg1, _Arg2);
@ -1100,7 +1107,7 @@ ptr_fun(_Result (*__f)(_Arg1,_Arg2))
{return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
template<class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp>
{
_Sp (_Tp::*__p_)();
public:
@ -1111,7 +1118,7 @@ public:
};
template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap);
public:
@ -1134,7 +1141,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap))
{return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
template<class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp>
{
_Sp (_Tp::*__p_)();
public:
@ -1145,7 +1152,7 @@ public:
};
template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap);
public:
@ -1168,7 +1175,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
{return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
template <class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp>
{
_Sp (_Tp::*__p_)() const;
public:
@ -1179,7 +1186,7 @@ public:
};
template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap) const;
public:
@ -1202,7 +1209,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const)
{return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
template <class _Sp, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
{
_Sp (_Tp::*__p_)() const;
public:
@ -1213,7 +1220,7 @@ public:
};
template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t
: public binary_function<_Tp, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap) const;
@ -1382,7 +1389,17 @@ class _LIBCPP_EXCEPTION_ABI bad_function_call
{
};
template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_function_call()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_function_call();
#else
_VSTD::abort();
#endif
}
template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
namespace __function
{
@ -1558,7 +1575,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
} // __function
template<class _Rp, class ..._ArgTypes>
class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
: public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
{
@ -1595,13 +1612,12 @@ public:
function(nullptr_t) _NOEXCEPT : __f_(0) {}
function(const function&);
function(function&&) _NOEXCEPT;
template<class _Fp>
function(_Fp, typename enable_if
<
__callable<_Fp>::value &&
!is_same<_Fp, function>::value
>::type* = 0);
template<class _Fp, class = typename enable_if<
__callable<_Fp>::value && !is_same<_Fp, function>::value
>::type>
function(_Fp);
#if _LIBCPP_STD_VER <= 14
template<class _Alloc>
_LIBCPP_INLINE_VISIBILITY
function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
@ -1612,9 +1628,9 @@ public:
function(allocator_arg_t, const _Alloc&, const function&);
template<class _Alloc>
function(allocator_arg_t, const _Alloc&, function&&);
template<class _Fp, class _Alloc>
function(allocator_arg_t, const _Alloc& __a, _Fp __f,
typename enable_if<__callable<_Fp>::value>::type* = 0);
template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
function(allocator_arg_t, const _Alloc& __a, _Fp __f);
#endif
function& operator=(const function&);
function& operator=(function&&) _NOEXCEPT;
@ -1675,6 +1691,7 @@ function<_Rp(_ArgTypes...)>::function(const function& __f)
__f_ = __f.__f_->__clone();
}
#if _LIBCPP_STD_VER <= 14
template<class _Rp, class ..._ArgTypes>
template <class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
@ -1690,6 +1707,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
else
__f_ = __f.__f_->__clone();
}
#endif
template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
@ -1708,6 +1726,7 @@ function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
}
}
#if _LIBCPP_STD_VER <= 14
template<class _Rp, class ..._ArgTypes>
template <class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
@ -1726,15 +1745,11 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
__f.__f_ = 0;
}
}
#endif
template<class _Rp, class ..._ArgTypes>
template <class _Fp>
function<_Rp(_ArgTypes...)>::function(_Fp __f,
typename enable_if
<
__callable<_Fp>::value &&
!is_same<_Fp, function>::value
>::type*)
template <class _Fp, class>
function<_Rp(_ArgTypes...)>::function(_Fp __f)
: __f_(0)
{
if (__function::__not_null(__f))
@ -1756,10 +1771,10 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f,
}
}
#if _LIBCPP_STD_VER <= 14
template<class _Rp, class ..._ArgTypes>
template <class _Fp, class _Alloc>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
typename enable_if<__callable<_Fp>::value>::type*)
template <class _Fp, class _Alloc, class>
function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f)
: __f_(0)
{
typedef allocator_traits<_Alloc> __alloc_traits;
@ -1782,6 +1797,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
}
}
}
#endif
template<class _Rp, class ..._ArgTypes>
function<_Rp(_ArgTypes...)>&
@ -1854,6 +1870,8 @@ template<class _Rp, class ..._ArgTypes>
void
function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
{
if (_VSTD::addressof(__f) == this)
return;
if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
{
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@ -1891,10 +1909,8 @@ template<class _Rp, class ..._ArgTypes>
_Rp
function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0)
throw bad_function_call();
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_bad_function_call();
return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
}
@ -1968,13 +1984,23 @@ swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCE
//==============================================================================
template<class _Tp> struct __is_bind_expression : public false_type {};
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
: public __is_bind_expression<typename remove_cv<_Tp>::type> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
#endif
template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
: public __is_placeholder<typename remove_cv<_Tp>::type> {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
#endif
namespace placeholders
{
@ -2204,36 +2230,6 @@ private:
typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
public:
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
_LIBCPP_INLINE_VISIBILITY
__bind(const __bind& __b)
: __f_(__b.__f_),
__bound_args_(__b.__bound_args_) {}
_LIBCPP_INLINE_VISIBILITY
__bind& operator=(const __bind& __b)
{
__f_ = __b.__f_;
__bound_args_ = __b.__bound_args_;
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__bind(__bind&& __b)
: __f_(_VSTD::move(__b.__f_)),
__bound_args_(_VSTD::move(__b.__bound_args_)) {}
_LIBCPP_INLINE_VISIBILITY
__bind& operator=(__bind&& __b)
{
__f_ = _VSTD::move(__b.__f_);
__bound_args_ = _VSTD::move(__b.__bound_args_);
return *this;
}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
template <class _Gp, class ..._BA,
class = typename enable_if
<
@ -2278,31 +2274,6 @@ class __bind_r
public:
typedef _Rp result_type;
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
_LIBCPP_INLINE_VISIBILITY
__bind_r(const __bind_r& __b)
: base(_VSTD::forward<const base&>(__b)) {}
_LIBCPP_INLINE_VISIBILITY
__bind_r& operator=(const __bind_r& __b)
{
base::operator=(_VSTD::forward<const base&>(__b));
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__bind_r(__bind_r&& __b)
: base(_VSTD::forward<base>(__b)) {}
_LIBCPP_INLINE_VISIBILITY
__bind_r& operator=(__bind_r&& __b)
{
base::operator=(_VSTD::forward<base>(__b));
return *this;
}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
template <class _Gp, class ..._BA,
class = typename enable_if
@ -2369,7 +2340,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
#endif // _LIBCPP_HAS_NO_VARIADICS
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<bool>
struct _LIBCPP_TEMPLATE_VIS hash<bool>
: public unary_function<bool, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2377,7 +2348,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<bool>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<char>
struct _LIBCPP_TEMPLATE_VIS hash<char>
: public unary_function<char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2385,7 +2356,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<char>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
struct _LIBCPP_TEMPLATE_VIS hash<signed char>
: public unary_function<signed char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2393,7 +2364,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
: public unary_function<unsigned char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2403,7 +2374,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
: public unary_function<char16_t, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2411,7 +2382,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
: public unary_function<char32_t, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2421,7 +2392,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
: public unary_function<wchar_t, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2429,7 +2400,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<short>
struct _LIBCPP_TEMPLATE_VIS hash<short>
: public unary_function<short, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2437,7 +2408,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<short>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
: public unary_function<unsigned short, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2445,7 +2416,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<int>
struct _LIBCPP_TEMPLATE_VIS hash<int>
: public unary_function<int, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2453,7 +2424,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<int>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
: public unary_function<unsigned int, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2461,7 +2432,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<long>
struct _LIBCPP_TEMPLATE_VIS hash<long>
: public unary_function<long, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2469,7 +2440,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
: public unary_function<unsigned long, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -2477,13 +2448,13 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<long long>
struct _LIBCPP_TEMPLATE_VIS hash<long long>
: public __scalar_hash<long long>
{
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long>
: public __scalar_hash<unsigned long long>
{
};
@ -2491,13 +2462,13 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
#ifndef _LIBCPP_HAS_NO_INT128
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<__int128_t>
struct _LIBCPP_TEMPLATE_VIS hash<__int128_t>
: public __scalar_hash<__int128_t>
{
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<__uint128_t>
struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t>
: public __scalar_hash<__uint128_t>
{
};
@ -2505,7 +2476,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<__uint128_t>
#endif
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<float>
struct _LIBCPP_TEMPLATE_VIS hash<float>
: public __scalar_hash<float>
{
_LIBCPP_INLINE_VISIBILITY
@ -2519,7 +2490,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<float>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<double>
struct _LIBCPP_TEMPLATE_VIS hash<double>
: public __scalar_hash<double>
{
_LIBCPP_INLINE_VISIBILITY
@ -2533,7 +2504,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<double>
};
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
struct _LIBCPP_TEMPLATE_VIS hash<long double>
: public __scalar_hash<long double>
{
_LIBCPP_INLINE_VISIBILITY
@ -2583,12 +2554,11 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
};
#if _LIBCPP_STD_VER > 11
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY hash
template <class _Tp, bool = is_enum<_Tp>::value>
struct _LIBCPP_TEMPLATE_VIS __enum_hash
: public unary_function<_Tp, size_t>
{
static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");
_LIBCPP_INLINE_VISIBILITY
size_t operator()(_Tp __v) const _NOEXCEPT
{
@ -2596,11 +2566,24 @@ struct _LIBCPP_TYPE_VIS_ONLY hash
return hash<type>{}(static_cast<type>(__v));
}
};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
__enum_hash() = delete;
__enum_hash(__enum_hash const&) = delete;
__enum_hash& operator=(__enum_hash const&) = delete;
};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
{
};
#endif
#if _LIBCPP_STD_VER > 14
#define __cpp_lib_invoke 201411
template <class _Fn, class ..._Args>
result_of_t<_Fn&&(_Args&&...)>
invoke(_Fn&& __f, _Args&&... __args)
@ -2610,7 +2593,7 @@ invoke(_Fn&& __f, _Args&&... __args)
}
template <class _DecayFunc>
class _LIBCPP_TYPE_VIS_ONLY __not_fn_imp {
class _LIBCPP_TEMPLATE_VIS __not_fn_imp {
_DecayFunc __fd;
public:
@ -2620,30 +2603,30 @@ public:
_LIBCPP_INLINE_VISIBILITY
auto operator()(_Args&& ...__args) &
noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
-> decltype(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
-> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
auto operator()(_Args&& ...__args) &&
noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
-> decltype(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
-> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
auto operator()(_Args&& ...__args) const&
noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
-> decltype(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
-> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
auto operator()(_Args&& ...__args) const&&
noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
-> decltype(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
-> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
private:
template <class _RawFunc,

View File

@ -50,7 +50,7 @@ class future_error
{
public:
future_error(error_code ec); // exposition only
explicit future_error(future_errc); // C++17
const error_code& code() const noexcept;
const char* what() const noexcept;
};
@ -391,11 +391,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(future_errc)
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc> : public true_type {};
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc::__lx> : public true_type { };
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { };
#endif
//enum class launch
@ -505,20 +505,23 @@ class _LIBCPP_EXCEPTION_ABI future_error
error_code __ec_;
public:
future_error(error_code __ec);
#if _LIBCPP_STD_VERS > 14
explicit future_error(future_errc _Ev) : logic_error(), __ec_(make_error_code(_Ev)) {}
#endif
_LIBCPP_INLINE_VISIBILITY
const error_code& code() const _NOEXCEPT {return __ec_;}
virtual ~future_error() _NOEXCEPT;
};
inline _LIBCPP_ALWAYS_INLINE
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_future_error(future_errc _Ev)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw future_error(make_error_code(_Ev));
#else
assert(!"future_error");
((void)_Ev);
_VSTD::abort();
#endif
}
@ -1048,12 +1051,12 @@ __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT
base::__on_zero_shared();
}
template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY promise;
template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY shared_future;
template <class _Rp> class _LIBCPP_TEMPLATE_VIS promise;
template <class _Rp> class _LIBCPP_TEMPLATE_VIS shared_future;
// future
template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY future;
template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;
template <class _Rp, class _Fp>
future<_Rp>
@ -1072,7 +1075,7 @@ __make_async_assoc_state(_Fp __f);
#endif
template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY future
class _LIBCPP_TEMPLATE_VIS future
{
__assoc_state<_Rp>* __state_;
@ -1175,7 +1178,7 @@ future<_Rp>::get()
}
template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY future<_Rp&>
class _LIBCPP_TEMPLATE_VIS future<_Rp&>
{
__assoc_state<_Rp&>* __state_;
@ -1356,7 +1359,7 @@ swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT
template <class _Callable> class packaged_task;
template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY promise
class _LIBCPP_TEMPLATE_VIS promise
{
__assoc_state<_Rp>* __state_;
@ -1523,7 +1526,7 @@ promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
// promise<R&>
template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY promise<_Rp&>
class _LIBCPP_TEMPLATE_VIS promise<_Rp&>
{
__assoc_state<_Rp&>* __state_;
@ -1734,7 +1737,7 @@ swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT
}
template <class _Rp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<promise<_Rp>, _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc>
: public true_type {};
#ifndef _LIBCPP_HAS_NO_VARIADICS
@ -1995,7 +1998,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) cons
}
template<class _Rp, class ..._ArgTypes>
class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)>
class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)>
{
public:
typedef _Rp result_type; // extension
@ -2124,7 +2127,7 @@ packaged_task<_Rp(_ArgTypes...)>::reset()
}
template<class ..._ArgTypes>
class _LIBCPP_TYPE_VIS_ONLY packaged_task<void(_ArgTypes...)>
class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)>
{
public:
typedef void result_type; // extension
@ -2263,7 +2266,7 @@ swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT
}
template <class _Callable, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<packaged_task<_Callable>, _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>
: public true_type {};
template <class _Rp, class _Fp>
@ -2364,7 +2367,7 @@ async(_Fp&& __f, _Args&&... __args)
// shared_future
template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY shared_future
class _LIBCPP_TEMPLATE_VIS shared_future
{
__assoc_state<_Rp>* __state_;
@ -2372,7 +2375,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
shared_future() _NOEXCEPT : __state_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY
shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{if (__state_) __state_->__add_shared();}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
@ -2383,7 +2386,7 @@ public:
{__rhs.__state_ = nullptr;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_future();
shared_future& operator=(const shared_future& __rhs);
shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
@ -2427,7 +2430,7 @@ shared_future<_Rp>::~shared_future()
template <class _Rp>
shared_future<_Rp>&
shared_future<_Rp>::operator=(const shared_future& __rhs)
shared_future<_Rp>::operator=(const shared_future& __rhs) _NOEXCEPT
{
if (__rhs.__state_)
__rhs.__state_->__add_shared();
@ -2438,7 +2441,7 @@ shared_future<_Rp>::operator=(const shared_future& __rhs)
}
template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY shared_future<_Rp&>
class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&>
{
__assoc_state<_Rp&>* __state_;

View File

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

View File

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

View File

@ -44,6 +44,7 @@ template <class charT, class traits, class Allocator>
*/
#include <__config>
#include <__string>
#include <istream>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -567,19 +568,6 @@ __quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _Char
}
template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
struct __quoted_output_proxy
{
_Iter __first;
_Iter __last;
_CharT __delim;
_CharT __escape;
__quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
: __first(__f), __last(__l), __delim(__d), __escape(__e) {}
// This would be a nice place for a string_ref
};
template <class _CharT, class _Traits, class _Iter>
basic_ostream<_CharT, _Traits>& operator<<(
basic_ostream<_CharT, _Traits>& __os,
@ -666,6 +654,15 @@ quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _Char
{
return __quoted(__s, __delim, __escape);
}
template <class _CharT, class _Traits>
__quoted_output_proxy<_CharT, const _CharT *, _Traits>
quoted (basic_string_view <_CharT, _Traits> __sv,
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{
return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
}
#endif
_LIBCPP_END_NAMESPACE_STD

View File

@ -393,11 +393,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc)
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc> : public true_type { };
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_type { };
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
#endif
_LIBCPP_FUNC_VIS
@ -573,7 +573,7 @@ ios_base::exceptions(iostate __iostate)
}
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ios
class _LIBCPP_TEMPLATE_VIS basic_ios
: public ios_base
{
public:
@ -586,8 +586,8 @@ public:
typedef typename traits_type::off_type off_type;
_LIBCPP_ALWAYS_INLINE
_LIBCPP_EXPLICIT
operator bool() const {return !fail();}
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}

View File

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

View File

@ -171,7 +171,7 @@ template <class charT, class traits, class T>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_istream
class _LIBCPP_TEMPLATE_VIS basic_istream
: virtual public basic_ios<_CharT, _Traits>
{
streamsize __gc_;
@ -184,19 +184,26 @@ public:
typedef typename traits_type::off_type off_type;
// 27.7.1.1.1 Constructor/destructor:
explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
{ this->init(__sb); }
virtual ~basic_istream();
protected:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY
basic_istream(basic_istream&& __rhs);
#endif
// 27.7.1.1.2 Assign/swap:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY
basic_istream& operator=(basic_istream&& __rhs);
#endif
void swap(basic_istream& __rhs);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void swap(basic_istream& __rhs) {
_VSTD::swap(__gc_, __rhs.__gc_);
basic_ios<char_type, traits_type>::swap(__rhs);
}
#if _LIBCPP_STD_VER > 11
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
@ -210,13 +217,22 @@ protected:
public:
// 27.7.1.1.3 Prefix/suffix:
class _LIBCPP_TYPE_VIS_ONLY sentry;
class _LIBCPP_TEMPLATE_VIS sentry;
// 27.7.1.2 Formatted input:
basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&));
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&))
{ return __pf(*this); }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& operator>>(basic_ios<char_type, traits_type>&
(*__pf)(basic_ios<char_type, traits_type>&));
basic_istream& operator>>(ios_base& (*__pf)(ios_base&));
(*__pf)(basic_ios<char_type, traits_type>&))
{ __pf(*this); return *this; }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& operator>>(ios_base& (*__pf)(ios_base&))
{ __pf(*this); return *this; }
basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
basic_istream& operator>>(bool& __n);
basic_istream& operator>>(short& __n);
@ -236,13 +252,31 @@ public:
_LIBCPP_INLINE_VISIBILITY
streamsize gcount() const {return __gc_;}
int_type get();
basic_istream& get(char_type& __c);
basic_istream& get(char_type* __s, streamsize __n);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& get(char_type& __c) {
int_type __ch = get();
if (__ch != traits_type::eof())
__c = traits_type::to_char_type(__ch);
return *this;
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& get(char_type* __s, streamsize __n)
{ return get(__s, __n, this->widen('\n')); }
basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& get(basic_streambuf<char_type, traits_type>& __sb);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& get(basic_streambuf<char_type, traits_type>& __sb)
{ return get(__sb, this->widen('\n')); }
basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
basic_istream& getline(char_type* __s, streamsize __n);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& getline(char_type* __s, streamsize __n)
{ return getline(__s, __n, this->widen('\n')); }
basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
@ -260,7 +294,7 @@ public:
};
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry
class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry
{
bool __ok_;
@ -303,18 +337,9 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
__is.setstate(ios_base::failbit);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb)
: __gc_(0)
{
this->init(__sb);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
: __gc_(__rhs.__gc_)
{
@ -323,7 +348,6 @@ basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
{
@ -338,15 +362,6 @@ basic_istream<_CharT, _Traits>::~basic_istream()
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
{
_VSTD::swap(__gc_, __rhs.__gc_);
basic_ios<char_type, traits_type>::swap(__rhs);
}
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
@ -724,33 +739,6 @@ basic_istream<_CharT, _Traits>::operator>>(int& __n)
return *this;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&))
{
return __pf(*this);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>&
(*__pf)(basic_ios<char_type, traits_type>&))
{
__pf(*this);
return *this;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
{
__pf(*this);
return *this;
}
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
@ -946,17 +934,6 @@ basic_istream<_CharT, _Traits>::get()
return __r;
}
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type& __c)
{
int_type __ch = get();
if (__ch != traits_type::eof())
__c = traits_type::to_char_type(__ch);
return *this;
}
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
@ -1005,14 +982,6 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
return *this;
}
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
{
return get(__s, __n, this->widen('\n'));
}
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
@ -1067,14 +1036,6 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
return *this;
}
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb)
{
return get(__sb, this->widen('\n'));
}
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
@ -1128,14 +1089,6 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
return *this;
}
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n)
{
return getline(__s, __n, this->widen('\n'));
}
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
@ -1481,16 +1434,16 @@ ws(basic_istream<_CharT, _Traits>& __is)
template <class _CharT, class _Traits, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x)
{
__is >> __x;
__is >> _VSTD::forward<_Tp>(__x);
return __is;
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_iostream
class _LIBCPP_TEMPLATE_VIS basic_iostream
: public basic_istream<_CharT, _Traits>,
public basic_ostream<_CharT, _Traits>
{
@ -1503,41 +1456,38 @@ public:
typedef typename traits_type::off_type off_type;
// constructor/destructor
explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
: basic_istream<_CharT, _Traits>(__sb)
{}
virtual ~basic_iostream();
protected:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream(basic_iostream&& __rhs);
#endif
// assign/swap
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream& operator=(basic_iostream&& __rhs);
#endif
void swap(basic_iostream& __rhs);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void swap(basic_iostream& __rhs)
{ basic_istream<char_type, traits_type>::swap(__rhs); }
public:
};
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
: basic_istream<_CharT, _Traits>(__sb)
{
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream<_CharT, _Traits>&
basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
{
@ -1552,14 +1502,6 @@ basic_iostream<_CharT, _Traits>::~basic_iostream()
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs)
{
basic_istream<char_type, traits_type>::swap(__rhs);
}
template<class _CharT, class _Traits, class _Allocator>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
@ -1705,7 +1647,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{
basic_string<_CharT, _Traits> __str;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
streamsize __c = 0;
size_t __c = 0;
ios_base::iostate __err = ios_base::goodbit;
_CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1');
@ -1741,9 +1683,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
return __is;
}
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_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>)
_LIBCPP_END_NAMESPACE_STD

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,65 @@
// -*- C++ -*-
//===--------------------------- limits.h ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_LIMITS_H
#define _LIBCPP_LIMITS_H
/*
limits.h synopsis
Macros:
CHAR_BIT
SCHAR_MIN
SCHAR_MAX
UCHAR_MAX
CHAR_MIN
CHAR_MAX
MB_LEN_MAX
SHRT_MIN
SHRT_MAX
USHRT_MAX
INT_MIN
INT_MAX
UINT_MAX
LONG_MIN
LONG_MAX
ULONG_MAX
LLONG_MIN // C99
LLONG_MAX // C99
ULLONG_MAX // C99
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#ifndef __GNUC__
#include_next <limits.h>
#else
// GCC header limits.h recursively includes itself through another header called
// syslimits.h for some reason. This setup breaks down if we directly
// #include_next GCC's limits.h (reasons not entirely clear to me). Therefore,
// we manually re-create the necessary include sequence below:
// Get the system limits.h defines (force recurse into the next level)
#define _GCC_LIMITS_H_
#define _GCC_NEXT_LIMITS_H
#include_next <limits.h>
// Get the ISO C defines
#undef _GCC_LIMITS_H_
#include_next <limits.h>
#endif // __GNUC__
#endif // _LIBCPP_LIMITS_H

View File

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

View File

@ -523,11 +523,11 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
return 0;
}
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY num_get
class _LIBCPP_TEMPLATE_VIS num_get
: public locale::facet,
private __num_get<_CharT>
{
@ -779,6 +779,7 @@ long double __do_strtod<long double>(const char* __a, char** __p2) {
}
template <class _Tp>
_LIBCPP_HIDDEN
_Tp
__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
{
@ -1042,8 +1043,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
struct _LIBCPP_TYPE_VIS __num_put_base
{
@ -1192,11 +1193,11 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
__op = __ob + (__np - __nb);
}
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY num_put
class _LIBCPP_TEMPLATE_VIS num_put
: public locale::facet,
private __num_put<_CharT>
{
@ -1621,8 +1622,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
template <class _CharT, class _InputIterator>
_LIBCPP_HIDDEN
@ -1664,7 +1665,7 @@ public:
};
template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage
class _LIBCPP_TEMPLATE_VIS __time_get_c_storage
{
protected:
typedef basic_string<_CharT> string_type;
@ -1682,7 +1683,7 @@ protected:
};
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_get
class _LIBCPP_TEMPLATE_VIS time_get
: public locale::facet,
public time_base,
private __time_get_c_storage<_CharT>
@ -2291,8 +2292,8 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
class _LIBCPP_TYPE_VIS __time_get
{
@ -2305,7 +2306,7 @@ protected:
};
template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY __time_get_storage
class _LIBCPP_TEMPLATE_VIS __time_get_storage
: public __time_get
{
protected:
@ -2332,7 +2333,7 @@ private:
};
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_get_byname
class _LIBCPP_TEMPLATE_VIS time_get_byname
: public time_get<_CharT, _InputIterator>,
private __time_get_storage<_CharT>
{
@ -2374,8 +2375,8 @@ private:
virtual const string_type& __X() const {return this->__X_;}
};
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
class _LIBCPP_TYPE_VIS __time_put
{
@ -2392,7 +2393,7 @@ protected:
};
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_put
class _LIBCPP_TEMPLATE_VIS time_put
: public locale::facet,
private __time_put
{
@ -2487,11 +2488,11 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
return _VSTD::copy(__nb, __ne, __s);
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_put_byname
class _LIBCPP_TEMPLATE_VIS time_put_byname
: public time_put<_CharT, _OutputIterator>
{
public:
@ -2508,8 +2509,8 @@ protected:
~time_put_byname() {}
};
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
// money_base
@ -2525,7 +2526,7 @@ public:
// moneypunct
template <class _CharT, bool _International = false>
class _LIBCPP_TYPE_VIS_ONLY moneypunct
class _LIBCPP_TEMPLATE_VIS moneypunct
: public locale::facet,
public money_base
{
@ -2575,15 +2576,15 @@ template <class _CharT, bool _International>
const bool
moneypunct<_CharT, _International>::intl;
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
// moneypunct_byname
template <class _CharT, bool _International = false>
class _LIBCPP_TYPE_VIS_ONLY moneypunct_byname
class _LIBCPP_TEMPLATE_VIS moneypunct_byname
: public moneypunct<_CharT, _International>
{
public:
@ -2632,10 +2633,10 @@ template<> void moneypunct_byname<char, true>::init(const char*);
template<> void moneypunct_byname<wchar_t, false>::init(const char*);
template<> void moneypunct_byname<wchar_t, true>::init(const char*);
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
// money_get
@ -2691,11 +2692,11 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
}
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY money_get
class _LIBCPP_TEMPLATE_VIS money_get
: public locale::facet,
private __money_get<_CharT>
{
@ -3074,8 +3075,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b;
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
// money_put
@ -3249,11 +3250,11 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
__mi = __mb;
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY money_put
class _LIBCPP_TEMPLATE_VIS money_put
: public locale::facet,
private __money_put<_CharT>
{
@ -3402,8 +3403,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
// messages
@ -3416,7 +3417,7 @@ public:
};
template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY messages
class _LIBCPP_TEMPLATE_VIS messages
: public locale::facet,
public messages_base
{
@ -3512,11 +3513,11 @@ messages<_CharT>::do_close(catalog __c) const
#endif // _LIBCPP_HAS_CATOPEN
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY messages_byname
class _LIBCPP_TEMPLATE_VIS messages_byname
: public messages<_CharT>
{
public:
@ -3536,13 +3537,13 @@ protected:
~messages_byname() {}
};
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
template<class _Codecvt, class _Elem = wchar_t,
class _Wide_alloc = allocator<_Elem>,
class _Byte_alloc = allocator<char> >
class _LIBCPP_TYPE_VIS_ONLY wstring_convert
class _LIBCPP_TEMPLATE_VIS wstring_convert
{
public:
typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
@ -3701,10 +3702,10 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
if (__r == codecvt_base::ok)
return __ws;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__wide_err_string_.empty())
throw range_error("wstring_convert: from_bytes error");
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_range_error("wstring_convert: from_bytes error");
return __wide_err_string_;
}
@ -3790,15 +3791,15 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
return __bs;
}
}
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__byte_err_string_.empty())
throw range_error("wstring_convert: to_bytes error");
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_range_error("wstring_convert: to_bytes error");
return __byte_err_string_;
}
template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
class _LIBCPP_TYPE_VIS_ONLY wbuffer_convert
class _LIBCPP_TEMPLATE_VIS wbuffer_convert
: public basic_streambuf<_Elem, _Tr>
{
public:
@ -3932,7 +3933,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
static_cast<streamsize>(__extbufend_ - __extbufnext_));
codecvt_base::result __r;
state_type __svs = __st_;
// FIXME: Do we ever need to restore the state here?
//state_type __svs = __st_;
streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb);
if (__nr != 0)
{

View File

@ -0,0 +1,45 @@
// -*- C++ -*-
//===---------------------------- locale.h --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_LOCALE_H
#define _LIBCPP_LOCALE_H
/*
locale.h synopsis
Macros:
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
Types:
lconv
Functions:
setlocale
localeconv
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#include_next <locale.h>
#endif // _LIBCPP_LOCALE_H

View File

@ -533,7 +533,7 @@ public:
using _VSTD::swap;
swap(comp, __y.comp);
}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
@ -682,7 +682,7 @@ struct __extract_key_value_types<__value_type<_Key, _Tp> >
};
template <class _TreeIterator>
class _LIBCPP_TYPE_VIS_ONLY __map_iterator
class _LIBCPP_TEMPLATE_VIS __map_iterator
{
typedef typename _TreeIterator::_NodeTypes _NodeTypes;
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
@ -730,18 +730,18 @@ public:
friend _LIBCPP_INLINE_VISIBILITY
bool operator==(const __map_iterator& __x, const __map_iterator& __y)
{return __x.__i_ == __y.__i_;}
friend
friend
_LIBCPP_INLINE_VISIBILITY
bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
{return __x.__i_ != __y.__i_;}
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
};
template <class _TreeIterator>
class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator
class _LIBCPP_TEMPLATE_VIS __map_const_iterator
{
typedef typename _TreeIterator::_NodeTypes _NodeTypes;
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
@ -797,14 +797,14 @@ public:
bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
{return __x.__i_ != __y.__i_;}
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
};
template <class _Key, class _Tp, class _Compare = less<_Key>,
class _Allocator = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY map
class _LIBCPP_TEMPLATE_VIS map
{
public:
// types:
@ -820,7 +820,7 @@ public:
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
class _LIBCPP_TYPE_VIS_ONLY value_compare
class _LIBCPP_TEMPLATE_VIS value_compare
: public binary_function<value_type, value_type, bool>
{
friend class map;
@ -895,7 +895,7 @@ public:
#if _LIBCPP_STD_VER > 11
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: map(__f, __l, key_compare(), __a) {}
#endif
@ -961,7 +961,7 @@ public:
}
#if _LIBCPP_STD_VER > 11
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
map(initializer_list<value_type> __il, const allocator_type& __a)
: map(__il, key_compare(), __a) {}
#endif
@ -1297,6 +1297,7 @@ private:
typedef typename __base::__node_allocator __node_allocator;
typedef typename __base::__node_pointer __node_pointer;
typedef typename __base::__node_base_pointer __node_base_pointer;
typedef typename __base::__parent_pointer __parent_pointer;
typedef __map_node_destructor<__node_allocator> _Dp;
typedef unique_ptr<__node, _Dp> __node_holder;
@ -1304,65 +1305,9 @@ private:
#ifdef _LIBCPP_CXX03_LANG
__node_holder __construct_node_with_key(const key_type& __k);
#endif
__node_base_pointer const&
__find_equal_key(__node_base_pointer& __parent, const key_type& __k) const;
_LIBCPP_INLINE_VISIBILITY
__node_base_pointer&
__find_equal_key(__node_base_pointer& __parent, const key_type& __k) {
map const* __const_this = this;
return const_cast<__node_base_pointer&>(
__const_this->__find_equal_key(__parent, __k));
}
};
// Find __k
// Set __parent to parent of null leaf and
// return reference to null leaf iv __k does not exist.
// If __k exists, set parent to node of __k and return reference to node of __k
template <class _Key, class _Tp, class _Compare, class _Allocator>
typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer const&
map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
const key_type& __k) const
{
__node_pointer __nd = __tree_.__root();
if (__nd != nullptr)
{
while (true)
{
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
{
if (__nd->__left_ != nullptr)
__nd = static_cast<__node_pointer>(__nd->__left_);
else
{
__parent = static_cast<__node_base_pointer>(__nd);
return __parent->__left_;
}
}
else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
{
if (__nd->__right_ != nullptr)
__nd = static_cast<__node_pointer>(__nd->__right_);
else
{
__parent = static_cast<__node_base_pointer>(__nd);
return __parent->__right_;
}
}
else
{
__parent = static_cast<__node_base_pointer>(__nd);
return __parent;
}
}
}
__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
return __parent->__left_;
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator>
@ -1400,8 +1345,8 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp&
map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
{
__node_base_pointer __parent;
__node_base_pointer& __child = __find_equal_key(__parent, __k);
__parent_pointer __parent;
__node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
__node_pointer __r = static_cast<__node_pointer>(__child);
if (__child == nullptr)
{
@ -1440,8 +1385,8 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp&
map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
{
__node_base_pointer __parent;
__node_base_pointer& __child = __find_equal_key(__parent, __k);
__parent_pointer __parent;
__node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
throw out_of_range("map::at: key not found");
@ -1453,8 +1398,8 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
const _Tp&
map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
{
__node_base_pointer __parent;
__node_base_pointer __child = __find_equal_key(__parent, __k);
__parent_pointer __parent;
__node_base_pointer __child = __tree_.__find_equal(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
throw out_of_range("map::at: key not found");
@ -1529,7 +1474,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
template <class _Key, class _Tp, class _Compare = less<_Key>,
class _Allocator = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY multimap
class _LIBCPP_TEMPLATE_VIS multimap
{
public:
// types:
@ -1545,7 +1490,7 @@ public:
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
class _LIBCPP_TYPE_VIS_ONLY value_compare
class _LIBCPP_TEMPLATE_VIS value_compare
: public binary_function<value_type, value_type, bool>
{
friend class multimap;
@ -1621,7 +1566,7 @@ public:
#if _LIBCPP_STD_VER > 11
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: multimap(__f, __l, key_compare(), __a) {}
#endif
@ -1688,7 +1633,7 @@ public:
}
#if _LIBCPP_STD_VER > 11
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
multimap(initializer_list<value_type> __il, const allocator_type& __a)
: multimap(__il, key_compare(), __a) {}
#endif

View File

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

View File

@ -164,6 +164,7 @@ template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept
template <class T> void return_temporary_buffer(T* p) noexcept;
template <class T> T* addressof(T& r) noexcept;
template <class T> T* addressof(const T&& r) noexcept = delete;
template <class InputIterator, class ForwardIterator>
ForwardIterator
@ -180,6 +181,33 @@ template <class ForwardIterator, class Size, class T>
ForwardIterator
uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
template <class T>
void destroy_at(T* location);
template <class ForwardIterator>
void destroy(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator destroy_n(ForwardIterator first, Size n);
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
template <class InputIterator, class Size, class ForwardIterator>
pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
template <class ForwardIterator>
void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
template <class ForwardIterator>
void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
template <class Y> struct auto_ptr_ref {};
template<class X>
@ -610,9 +638,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
#include <tuple>
#include <stdexcept>
#include <cstring>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <atomic>
@ -639,12 +664,24 @@ _ValueType __libcpp_relaxed_load(_ValueType const* __value) {
#endif
}
// addressof moved to <__functional_base>
template <class _ValueType>
inline _LIBCPP_ALWAYS_INLINE
_ValueType __libcpp_acquire_load(_ValueType const* __value) {
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
defined(__ATOMIC_ACQUIRE) && \
(__has_builtin(__atomic_load_n) || _GNUC_VER >= 407)
return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
#else
return *__value;
#endif
}
// addressof moved to <type_traits>
template <class _Tp> class allocator;
template <>
class _LIBCPP_TYPE_VIS_ONLY allocator<void>
class _LIBCPP_TEMPLATE_VIS allocator<void>
{
public:
typedef void* pointer;
@ -655,7 +692,7 @@ public:
};
template <>
class _LIBCPP_TYPE_VIS_ONLY allocator<const void>
class _LIBCPP_TEMPLATE_VIS allocator<const void>
{
public:
typedef const void* pointer;
@ -792,7 +829,7 @@ public:
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __pointer_traits_rebind
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Tp::template rebind<_Up> type;
#else
typedef typename _Tp::template rebind<_Up>::other type;
@ -804,7 +841,7 @@ struct __pointer_traits_rebind
template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
#else
typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
@ -822,7 +859,7 @@ struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
template <template <class> class _Sp, class _Tp, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp>::template rebind<_Up> type;
#else
typedef typename _Sp<_Tp>::template rebind<_Up>::other type;
@ -838,7 +875,7 @@ struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false>
template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type;
#else
typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type;
@ -855,7 +892,7 @@ template <template <class, class, class> class _Sp, class _Tp, class _A0,
class _A1, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type;
#else
typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type;
@ -873,7 +910,7 @@ template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
class _A1, class _A2, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type;
#else
typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
@ -890,18 +927,18 @@ struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false>
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Ptr>
struct _LIBCPP_TYPE_VIS_ONLY pointer_traits
struct _LIBCPP_TEMPLATE_VIS pointer_traits
{
typedef _Ptr pointer;
typedef typename __pointer_traits_element_type<pointer>::type element_type;
typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
#else
template <class _Up> struct rebind
{typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif // _LIBCPP_CXX03_LANG
private:
struct __nat {};
@ -913,13 +950,13 @@ public:
};
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*>
struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
{
typedef _Tp* pointer;
typedef _Tp element_type;
typedef ptrdiff_t difference_type;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _Up> using rebind = _Up*;
#else
template <class _Up> struct rebind {typedef _Up* other;};
@ -936,7 +973,7 @@ public:
template <class _From, class _To>
struct __rebind_pointer {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_From>::template rebind<_To> type;
#else
typedef typename pointer_traits<_From>::template rebind<_To>::other type;
@ -1000,7 +1037,7 @@ struct __const_pointer
template <class _Tp, class _Ptr, class _Alloc>
struct __const_pointer<_Tp, _Ptr, _Alloc, false>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
#else
typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
@ -1027,7 +1064,7 @@ struct __void_pointer
template <class _Ptr, class _Alloc>
struct __void_pointer<_Ptr, _Alloc, false>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_Ptr>::template rebind<void> type;
#else
typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
@ -1054,7 +1091,7 @@ struct __const_void_pointer
template <class _Ptr, class _Alloc>
struct __const_void_pointer<_Ptr, _Alloc, false>
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
#else
typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type;
@ -1285,7 +1322,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false>
#endif // _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
#ifndef _LIBCPP_CXX03_LANG
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
auto
@ -1308,7 +1345,7 @@ struct __has_allocate_hint
{
};
#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#else // _LIBCPP_CXX03_LANG
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
struct __has_allocate_hint
@ -1316,9 +1353,9 @@ struct __has_allocate_hint
{
};
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#endif // _LIBCPP_CXX03_LANG
#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS)
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Alloc, class _Tp, class ..._Args>
decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),
@ -1399,7 +1436,7 @@ struct __has_select_on_container_copy_construction
{
};
#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#else // _LIBCPP_CXX03_LANG
#ifndef _LIBCPP_HAS_NO_VARIADICS
@ -1437,7 +1474,7 @@ struct __has_select_on_container_copy_construction
{
};
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#endif // _LIBCPP_CXX03_LANG
template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
struct __alloc_traits_difference_type
@ -1452,7 +1489,7 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
};
template <class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
struct _LIBCPP_TEMPLATE_VIS allocator_traits
{
typedef _Alloc allocator_type;
typedef typename allocator_type::value_type value_type;
@ -1474,16 +1511,16 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
typedef typename __is_always_equal<allocator_type>::type
is_always_equal;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp> using rebind_alloc =
typename __allocator_traits_rebind<allocator_type, _Tp>::type;
template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#else // _LIBCPP_CXX03_LANG
template <class _Tp> struct rebind_alloc
{typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
template <class _Tp> struct rebind_traits
{typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
static pointer allocate(allocator_type& __a, size_type __n)
@ -1568,7 +1605,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
__construct_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
ptrdiff_t _Np = __end1 - __begin1;
if (_Np > 0)
@ -1598,7 +1635,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
__construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
typedef typename remove_const<_Tp>::type _Vp;
ptrdiff_t _Np = __end1 - __begin1;
@ -1632,7 +1669,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
__construct_backward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
{
ptrdiff_t _Np = __end1 - __begin1;
__end2 -= _Np;
@ -1695,7 +1732,7 @@ private:
template <class _Traits, class _Tp>
struct __rebind_alloc_helper
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
typedef typename _Traits::template rebind_alloc<_Tp> type;
#else
typedef typename _Traits::template rebind_alloc<_Tp>::other type;
@ -1705,7 +1742,7 @@ struct __rebind_alloc_helper
// allocator
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY allocator
class _LIBCPP_TEMPLATE_VIS allocator
{
public:
typedef size_t size_type;
@ -1730,8 +1767,8 @@ public:
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{
if (__n > max_size())
__libcpp_throw(length_error("allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size"));
__throw_length_error("allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
@ -1803,7 +1840,7 @@ public:
};
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp>
class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
{
public:
typedef size_t size_type;
@ -1826,8 +1863,8 @@ public:
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{
if (__n > max_size())
__libcpp_throw(length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size"));
__throw_length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
@ -1907,7 +1944,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
template <class _OutputIterator, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator
class _LIBCPP_TEMPLATE_VIS raw_storage_iterator
: public iterator<output_iterator_tag,
_Tp, // purposefully not C++03
ptrdiff_t, // purposefully not C++03
@ -1967,7 +2004,7 @@ struct auto_ptr_ref
};
template<class _Tp>
class _LIBCPP_TYPE_VIS_ONLY auto_ptr
class _LIBCPP_TEMPLATE_VIS auto_ptr
{
private:
_Tp* __ptr_;
@ -2011,7 +2048,7 @@ public:
};
template <>
class _LIBCPP_TYPE_VIS_ONLY auto_ptr<void>
class _LIBCPP_TEMPLATE_VIS auto_ptr<void>
{
public:
typedef void element_type;
@ -2068,49 +2105,11 @@ public:
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
: __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
is_nothrow_copy_constructible<_T2>::value)
: __first_(__p.first()),
__second_(__p.second()) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
is_nothrow_copy_assignable<_T2>::value)
{
__first_ = __p.first();
__second_ = __p.second();
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
is_nothrow_move_constructible<_T2>::value)
: __first_(_VSTD::forward<_T1>(__p.first())),
__second_(_VSTD::forward<_T2>(__p.second())) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
is_nothrow_move_assignable<_T2>::value)
{
__first_ = _VSTD::forward<_T1>(__p.first());
__second_ = _VSTD::forward<_T2>(__p.second());
return *this;
}
#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(piecewise_construct_t __pc,
__libcpp_compressed_pair_imp(piecewise_construct_t,
tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
@ -2161,47 +2160,11 @@ public:
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
: _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
is_nothrow_copy_constructible<_T2>::value)
: _T1(__p.first()), __second_(__p.second()) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
is_nothrow_copy_assignable<_T2>::value)
{
_T1::operator=(__p.first());
__second_ = __p.second();
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
is_nothrow_move_constructible<_T2>::value)
: _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
is_nothrow_move_assignable<_T2>::value)
{
_T1::operator=(_VSTD::move(__p.first()));
__second_ = _VSTD::forward<_T2>(__p.second());
return *this;
}
#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(piecewise_construct_t __pc,
__libcpp_compressed_pair_imp(piecewise_construct_t,
tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
@ -2253,47 +2216,11 @@ public:
is_nothrow_move_constructible<_T2>::value)
: _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {}
#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
is_nothrow_copy_constructible<_T2>::value)
: _T2(__p.second()), __first_(__p.first()) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
is_nothrow_copy_assignable<_T2>::value)
{
_T2::operator=(__p.second());
__first_ = __p.first();
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
is_nothrow_move_constructible<_T2>::value)
: _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
is_nothrow_move_assignable<_T2>::value)
{
_T2::operator=(_VSTD::forward<_T2>(__p.second()));
__first_ = _VSTD::move(__p.first());
return *this;
}
#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(piecewise_construct_t __pc,
__libcpp_compressed_pair_imp(piecewise_construct_t,
tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
@ -2343,47 +2270,11 @@ public:
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
: _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {}
#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
is_nothrow_copy_constructible<_T2>::value)
: _T1(__p.first()), _T2(__p.second()) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
is_nothrow_copy_assignable<_T2>::value)
{
_T1::operator=(__p.first());
_T2::operator=(__p.second());
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
is_nothrow_move_constructible<_T2>::value)
: _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {}
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
is_nothrow_move_assignable<_T2>::value)
{
_T1::operator=(_VSTD::move(__p.first()));
_T2::operator=(_VSTD::move(__p.second()));
return *this;
}
#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
__libcpp_compressed_pair_imp(piecewise_construct_t __pc,
__libcpp_compressed_pair_imp(piecewise_construct_t,
tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
@ -2430,40 +2321,6 @@ public:
_LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2)
: base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {}
#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY
__compressed_pair(const __compressed_pair& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
is_nothrow_copy_constructible<_T2>::value)
: base(__p) {}
_LIBCPP_INLINE_VISIBILITY
__compressed_pair& operator=(const __compressed_pair& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
is_nothrow_copy_assignable<_T2>::value)
{
base::operator=(__p);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
__compressed_pair(__compressed_pair&& __p)
_NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
is_nothrow_move_constructible<_T2>::value)
: base(_VSTD::move(__p)) {}
_LIBCPP_INLINE_VISIBILITY
__compressed_pair& operator=(__compressed_pair&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
is_nothrow_move_assignable<_T2>::value)
{
base::operator=(_VSTD::move(__p));
return *this;
}
#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2>
@ -2524,9 +2381,9 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false>
// default_delete
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY default_delete
struct _LIBCPP_TEMPLATE_VIS default_delete
{
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
#else
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {}
@ -2543,10 +2400,10 @@ struct _LIBCPP_TYPE_VIS_ONLY default_delete
};
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]>
struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]>
{
public:
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
#else
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {}
@ -2566,7 +2423,7 @@ public:
};
template <class _Tp, class _Dp = default_delete<_Tp> >
class _LIBCPP_TYPE_VIS_ONLY unique_ptr
class _LIBCPP_TEMPLATE_VIS unique_ptr
{
public:
typedef _Tp element_type;
@ -2752,7 +2609,7 @@ public:
};
template <class _Tp, class _Dp>
class _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp>
class _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp>
{
public:
typedef _Tp element_type;
@ -3488,8 +3345,19 @@ struct __scalar_hash<_Tp, 4>
}
};
_LIBCPP_INLINE_VISIBILITY
inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
struct _PairT {
size_t first;
size_t second;
};
typedef __scalar_hash<_PairT> _HashT;
const _PairT __p = {__lhs, __rhs};
return _HashT()(__p);
}
template<class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*>
struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>
: public unary_function<_Tp*, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -3506,7 +3374,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*>
};
template <class _Tp, class _Dp>
struct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> >
struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
{
typedef unique_ptr<_Tp, _Dp> argument_type;
typedef size_t result_type;
@ -3671,6 +3539,148 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
return __f;
}
#if _LIBCPP_STD_VER > 14
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void destroy_at(_Tp* __loc) {
_LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
__loc->~_Tp();
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
void destroy(_ForwardIterator __first, _ForwardIterator __last) {
for (; __first != __last; ++__first)
_VSTD::destroy_at(_VSTD::addressof(*__first));
}
template <class _ForwardIterator, class _Size>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
for (; __n > 0; (void)++__first, --__n)
_VSTD::destroy_at(_VSTD::addressof(*__first));
return __first;
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
auto __idx = __first;
#ifndef _LIBCPP_NO_EXCEPTIONS
try {
#endif
for (; __idx != __last; ++__idx)
::new((void*)_VSTD::addressof(*__idx)) _Vt;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
throw;
}
#endif
}
template <class _ForwardIterator, class _Size>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
auto __idx = __first;
#ifndef _LIBCPP_NO_EXCEPTIONS
try {
#endif
for (; __n > 0; (void)++__idx, --__n)
::new((void*)_VSTD::addressof(*__idx)) _Vt;
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
throw;
}
#endif
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
auto __idx = __first;
#ifndef _LIBCPP_NO_EXCEPTIONS
try {
#endif
for (; __idx != __last; ++__idx)
::new((void*)_VSTD::addressof(*__idx)) _Vt();
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
throw;
}
#endif
}
template <class _ForwardIterator, class _Size>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
auto __idx = __first;
#ifndef _LIBCPP_NO_EXCEPTIONS
try {
#endif
for (; __n > 0; (void)++__idx, --__n)
::new((void*)_VSTD::addressof(*__idx)) _Vt();
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
throw;
}
#endif
}
template <class _InputIt, class _ForwardIt>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __first_res) {
using _Vt = typename iterator_traits<_ForwardIt>::value_type;
auto __idx = __first_res;
#ifndef _LIBCPP_NO_EXCEPTIONS
try {
#endif
for (; __first != __last; (void)++__idx, ++__first)
::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first));
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first_res, __idx);
throw;
}
#endif
}
template <class _InputIt, class _Size, class _ForwardIt>
inline _LIBCPP_INLINE_VISIBILITY
pair<_InputIt, _ForwardIt>
uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
using _Vt = typename iterator_traits<_ForwardIt>::value_type;
auto __idx = __first_res;
#ifndef _LIBCPP_NO_EXCEPTIONS
try {
#endif
for (; __n > 0; ++__idx, (void)++__first, --__n)
::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first));
return {__first, __idx};
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first_res, __idx);
throw;
}
#endif
}
#endif // _LIBCPP_STD_VER > 14
class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
: public std::exception
{
@ -3679,7 +3689,17 @@ public:
virtual const char* what() const _NOEXCEPT;
};
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_weak_ptr()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_weak_ptr();
#else
_VSTD::abort();
#endif
}
template<class _Tp> class _LIBCPP_TEMPLATE_VIS weak_ptr;
class _LIBCPP_TYPE_VIS __shared_count
{
@ -3857,10 +3877,10 @@ __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
__a.deallocate(_PTraits::pointer_to(*this), 1);
}
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this;
template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
template<class _Tp>
class _LIBCPP_TYPE_VIS_ONLY shared_ptr
class _LIBCPP_TEMPLATE_VIS shared_ptr
{
public:
typedef _Tp element_type;
@ -4136,8 +4156,8 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {}
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
};
template<class _Tp>
@ -5070,7 +5090,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
#endif // _LIBCPP_NO_RTTI
template<class _Tp>
class _LIBCPP_TYPE_VIS_ONLY weak_ptr
class _LIBCPP_TEMPLATE_VIS weak_ptr
{
public:
typedef _Tp element_type;
@ -5155,8 +5175,8 @@ public:
bool owner_before(const weak_ptr<_Up>& __r) const
{return __cntrl_ < __r.__cntrl_;}
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
};
template<class _Tp>
@ -5335,11 +5355,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
__cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
{
if (__cntrl_ == 0)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_weak_ptr();
#else
assert(!"bad_weak_ptr");
#endif
__throw_bad_weak_ptr();
}
template<class _Tp>
@ -5360,7 +5376,7 @@ template <class _Tp> struct owner_less;
#endif
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> >
struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> >
: binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
{
typedef bool result_type;
@ -5376,7 +5392,7 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> >
};
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> >
struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> >
: binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
{
typedef bool result_type;
@ -5393,7 +5409,7 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> >
#if _LIBCPP_STD_VER > 14
template <>
struct _LIBCPP_TYPE_VIS_ONLY owner_less<void>
struct _LIBCPP_TEMPLATE_VIS owner_less<void>
{
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
@ -5416,7 +5432,7 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less<void>
#endif
template<class _Tp>
class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this
class _LIBCPP_TEMPLATE_VIS enable_shared_from_this
{
mutable weak_ptr<_Tp> __weak_this_;
protected:
@ -5451,7 +5467,7 @@ public:
};
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> >
struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> >
{
typedef shared_ptr<_Tp> argument_type;
typedef size_t result_type;
@ -5600,6 +5616,15 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v
#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
//enum class
#if defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE)
# ifndef _LIBCPP_CXX03_LANG
enum class pointer_safety : unsigned char {
relaxed,
preferred,
strict
};
# endif
#else
struct _LIBCPP_TYPE_VIS pointer_safety
{
enum __lx
@ -5611,16 +5636,33 @@ struct _LIBCPP_TYPE_VIS pointer_safety
__lx __v_;
_LIBCPP_INLINE_VISIBILITY
pointer_safety() : __v_() {}
_LIBCPP_INLINE_VISIBILITY
pointer_safety(__lx __v) : __v_(__v) {}
_LIBCPP_INLINE_VISIBILITY
operator int() const {return __v_;}
};
#endif
#if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) && \
defined(_LIBCPP_BUILDING_MEMORY)
_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
#else
// This function is only offered in C++03 under ABI v1.
# if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) || !defined(_LIBCPP_CXX03_LANG)
inline _LIBCPP_INLINE_VISIBILITY
pointer_safety get_pointer_safety() _NOEXCEPT {
return pointer_safety::relaxed;
}
# endif
#endif
_LIBCPP_FUNC_VIS void declare_reachable(void* __p);
_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n);
_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n);
_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p);
template <class _Tp>

View File

@ -1,13 +1,224 @@
// define the module for __config outside of the top level 'std' module
// since __config may be included from C headers which may create an
// include cycle.
module std_config [system] [extern_c] {
header "__config"
}
module std [system] {
export std_config
// FIXME: The standard does not require that each of these submodules
// re-exports its imported modules. We should provide an alternative form of
// export that issues a warning if a name from the submodule is used, and
// use that to provide a 'strict mode' for libc++.
// Deprecated C-compatibility headers. These can all be included from within
// an 'extern "C"' context.
module depr [extern_c] {
// <assert.h> provided by C library.
module ctype_h {
header "ctype.h"
export *
}
module errno_h {
header "errno.h"
export *
}
// <fenv.h> provided by C library.
// <float.h> provided by compiler or C library.
module inttypes_h {
header "inttypes.h"
export stdint_h
export *
}
// <iso646.h> provided by compiler.
// <limits.h> provided by compiler or C library.
module locale_h {
header "locale.h"
export *
}
module math_h {
header "math.h"
export *
}
module setjmp_h {
header "setjmp.h"
export *
}
// FIXME: <stdalign.h> is missing.
// <signal.h> provided by C library.
// <stdarg.h> provided by compiler.
// <stdbool.h> provided by compiler.
module stddef_h {
// <stddef.h>'s __need_* macros require textual inclusion.
textual header "stddef.h"
}
module stdint_h {
header "stdint.h"
export *
// FIXME: This module only exists on OS X and for some reason the
// wildcard above doesn't export it.
export Darwin.C.stdint
}
module stdio_h {
// <stdio.h>'s __need_* macros require textual inclusion.
textual header "stdio.h"
export *
export Darwin.C.stdio
}
module stdlib_h {
// <stdlib.h>'s __need_* macros require textual inclusion.
textual header "stdlib.h"
export *
}
module string_h {
header "string.h"
export *
}
// FIXME: <uchar.h> is missing.
// <time.h> provided by C library.
module wchar_h {
// <wchar.h>'s __need_* macros require textual inclusion.
textual header "wchar.h"
export *
}
module wctype_h {
header "wctype.h"
export *
}
}
// <complex.h> and <tgmath.h> are not C headers in any real sense, do not
// allow their use in extern "C" contexts.
module complex_h {
header "complex.h"
export ccomplex
export *
}
module tgmath_h {
header "tgmath.h"
export ccomplex
export cmath
export *
}
// C compatibility headers.
module compat {
module cassert {
// <cassert>'s use of NDEBUG requires textual inclusion.
textual header "cassert"
}
module ccomplex {
header "ccomplex"
export complex
export *
}
module cctype {
header "cctype"
export *
}
module cerrno {
header "cerrno"
export *
}
module cfenv {
header "cfenv"
export *
}
module cfloat {
header "cfloat"
export *
}
module cinttypes {
header "cinttypes"
export cstdint
export *
}
module ciso646 {
header "ciso646"
export *
}
module climits {
header "climits"
export *
}
module clocale {
header "clocale"
export *
}
module cmath {
header "cmath"
export *
}
module csetjmp {
header "csetjmp"
export *
}
module csignal {
header "csignal"
export *
}
// FIXME: <cstdalign> is missing.
module cstdarg {
header "cstdarg"
export *
}
module cstdbool {
header "cstdbool"
export *
}
module cstddef {
header "cstddef"
export *
}
module cstdint {
header "cstdint"
export depr.stdint_h
export *
}
module cstdio {
header "cstdio"
export *
}
module cstdlib {
header "cstdlib"
export *
}
module cstring {
header "cstring"
export *
}
module ctgmath {
header "ctgmath"
export ccomplex
export cmath
export *
}
module ctime {
header "ctime"
export *
}
// FIXME: <cuchar> is missing.
module cwchar {
header "cwchar"
export depr.stdio_h
export *
}
module cwctype {
header "cwctype"
export *
}
}
module algorithm {
header "algorithm"
export initializer_list
export *
}
module any {
header "any"
export *
}
module array {
header "array"
export initializer_list
@ -16,7 +227,6 @@ module std [system] {
module atomic {
header "atomic"
export *
requires cplusplus11
}
module bitset {
header "bitset"
@ -25,118 +235,10 @@ module std [system] {
export *
}
// No submodule for cassert. It fundamentally needs repeated, textual inclusion.
module ccomplex {
header "ccomplex"
export complex
export *
}
module cctype {
header "cctype"
export *
}
module cerrno {
header "cerrno"
/*
export_macros ECONNREFUSED, EIO, ENODEV, ENOTEMPTY, ERANGE,
E2BIG, ECONNRESET, EISCONN, ENOENT, ENOTRECOVERABLE, EROFS,
EACCES, EDEADLK, EISDIR, ENOEXEC, ENOTSOCK, ESPIPE,
EADDRINUSE, EDESTADDRREQ, ELOOP, ENOLCK, ENOTSUP, ESRCH,
EADDRNOTAVAIL, EDOM, EMFILE, ENOLINK, ENOTTY, ETIME,
EAFNOSUPPORT, EEXIST, EMLINK, ENOMEM, ENXIO, ETIMEDOUT,
EAGAIN, EFAULT, EMSGSIZE, ENOMSG, EOPNOTSUPP, ETXTBSY,
EALREADY, EFBIG, ENAMETOOLONG, ENOPROTOOPT, EOVERFLOW, EWOULDBLOCK,
EBADF, EHOSTUNREACH, ENETDOWN, ENOSPC, EOWNERDEAD, EXDEV,
EBADMSG, EIDRM, ENETRESET, ENOSR, EPERM, errno,
EBUSY, EILSEQ, ENETUNREACH, ENOSTR, EPIPE,
ECANCELED, EINPROGRESS, ENFILE, ENOSYS, EPROTO,
ECHILD, EINTR, ENOBUFS, ENOTCONN, EPROTONOSUPPORT,
ECONNABORTED, EINVAL, ENODATA, ENOTDIR, EPROTOTYPE
*/
export *
}
module cfenv {
header "cfenv"
/*
export_macros FE_ALL_EXCEPT, FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW,
FE_UNDERFLOW, FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD,
FE_DFL_ENV
*/
export *
}
module cfloat {
header "cfloat"
/*
export_macros FLT_EVAL_METHOD, FLT_RADIX, FLT_ROUNDS,
FLT_DIG, FLT_EPSILON, FLT_MANT_DIG,
FLT_MAX, FLT_MAX_10_EXP, FLT_MAX_EXP,
FLT_MIN, FLT_MIN_10_EXP, FLT_MIN_EXP,
DBL_DIG, DBL_EPSILON, DBL_MANT_DIG,
DBL_MAX, DBL_MAX_10_EXP, DBL_MAX_EXP,
DBL_MIN, DBL_MIN_10_EXP, DBL_MIN_EXP,
LDBL_DIG, LDBL_EPSILON, LDBL_MANT_DIG,
LDBL_MAX, LDBL_MAX_10_EXP, LDBL_MAX_EXP,
LDBL_MIN, LDBL_MIN_10_EXP, LDBL_MIN_EXP
*/
export *
}
module chrono {
header "chrono"
export *
}
module cinttypes {
header "cinttypes"
export cstdint
/*
export_macros
PRId8, PRId16, PRId32, PRId64, PRIdFAST8, PRIdFAST16, PRIdFAST32, PRIdFAST64, PRIdLEAST8, PRIdLEAST16, PRIdLEAST32, PRIdLEAST64, PRIdMAX, PRIdPTR,
PRIi8, PRIi16, PRIi32, PRIi64, PRIiFAST8, PRIiFAST16, PRIiFAST32, PRIiFAST64, PRIiLEAST8, PRIiLEAST16, PRIiLEAST32, PRIiLEAST64, PRIiMAX, PRIiPTR,
PRIo8, PRIo16, PRIo32, PRIo64, PRIoFAST8, PRIoFAST16, PRIoFAST32, PRIoFAST64, PRIoLEAST8, PRIoLEAST16, PRIoLEAST32, PRIoLEAST64, PRIoMAX, PRIoPTR,
PRIu8, PRIu16, PRIu32, PRIu64, PRIuFAST8, PRIuFAST16, PRIuFAST32, PRIuFAST64, PRIuLEAST8, PRIuLEAST16, PRIuLEAST32, PRIuLEAST64, PRIuMAX, PRIuPTR,
PRIx8, PRIx16, PRIx32, PRIx64, PRIxFAST8, PRIxFAST16, PRIxFAST32, PRIxFAST64, PRIxLEAST8, PRIxLEAST16, PRIxLEAST32, PRIxLEAST64, PRIxMAX, PRIxPTR,
PRIX8, PRIX16, PRIX32, PRIX64, PRIXFAST8, PRIXFAST16, PRIXFAST32, PRIXFAST64, PRIXLEAST8, PRIXLEAST16, PRIXLEAST32, PRIXLEAST64, PRIXMAX, PRIXPTR,
SCNd8, SCNd16, SCNd32, SCNd64, SCNdFAST8, SCNdFAST16, SCNdFAST32, SCNdFAST64, SCNdLEAST8, SCNdLEAST16, SCNdLEAST32, SCNdLEAST64, SCNdMAX, SCNdPTR,
SCNi8, SCNi16, SCNi32, SCNi64, SCNiFAST8, SCNiFAST16, SCNiFAST32, SCNiFAST64, SCNiLEAST8, SCNiLEAST16, SCNiLEAST32, SCNiLEAST64, SCNiMAX, SCNiPTR,
SCNo8, SCNo16, SCNo32, SCNo64, SCNoFAST8, SCNoFAST16, SCNoFAST32, SCNoFAST64, SCNoLEAST8, SCNoLEAST16, SCNoLEAST32, SCNoLEAST64, SCNoMAX, SCNoPTR,
SCNu8, SCNu16, SCNu32, SCNu64, SCNuFAST8, SCNuFAST16, SCNuFAST32, SCNuFAST64, SCNuLEAST8, SCNuLEAST16, SCNuLEAST32, SCNuLEAST64, SCNuMAX, SCNuPTR,
SCNx8, SCNx16, SCNx32, SCNx64, SCNxFAST8, SCNxFAST16, SCNxFAST32, SCNxFAST64, SCNxLEAST8, SCNxLEAST16, SCNxLEAST32, SCNxLEAST64, SCNxMAX, SCNxPTR,
SCNX8, SCNX16, SCNX32, SCNX64, SCNXFAST8, SCNXFAST16, SCNXFAST32, SCNXFAST64, SCNXLEAST8, SCNXLEAST16, SCNXLEAST32, SCNXLEAST64, SCNXMAX, SCNXPTR
*/
export *
}
module ciso646 {
header "ciso646"
export *
}
module climits {
header "climits"
/*
export_macros CHAR_BIT, CHAR_MIN, CHAR_MAX,
SCHAR_MIN, SCHAR_MAX, UCHAR_MAX,
SHRT_MIN, SHRT_MAX, USHRT_MAX,
INT_MIN, INT_MAX, UINT_MAX,
LONG_MIN, LONG_MAX, ULONG_MAX,
LLONG_MIN, LLONG_MAX, ULLONG_MAX,
MB_LEN_MAX
*/
export *
}
module clocale {
header "clocale"
/*
export_macros LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, NULL
*/
export *
}
module cmath {
header "cmath"
/*
export_macros FP_FAST_FMA, FP_FAST_FMAF, FP_FAST_FMAL, FP_ILOGBO, FP_ILOGBNAN,
FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, FP_ZERO,
HUGE_VAL, HUGE_VALF, HUGE_VALL, INFINITY, NAN,
MATH_ERRNO, MATH_ERREXCEPT, math_errhandling
*/
export *
}
module codecvt {
header "codecvt"
export *
@ -149,108 +251,6 @@ module std [system] {
header "condition_variable"
export *
}
module csetjmp {
header "csetjmp"
/*
export_macros setjmp
*/
export *
}
module csignal {
header "csignal"
/*
export_macros SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM,
SIG_DFL, SIG_IGN, SIG_ERR
*/
export *
}
module cstdarg {
header "cstdarg"
/*
export_macros va_arg, va_start, va_end, va_copy
*/
export *
}
module cstdbool {
header "cstdbool"
/*
export_macros __bool_true_false_are_defined
*/
export *
}
module cstddef {
header "cstddef"
/*
export_macros NULL, offsetof
*/
export *
}
module cstdint {
header "cstdint"
/*
export_macros
INT_8_MIN, INT_8_MAX, UINT_8_MAX, INT_16_MIN, INT_16_MAX, UINT_16_MAX,
INT_32_MIN, INT_32_MAX, UINT_32_MAX, INT_64_MIN, INT_64_MAX, UINT_64_MAX,
INT_FAST8_MIN, INT_FAST8_MAX, UINT_FAST8_MAX, INT_FAST16_MIN, INT_FAST16_MAX, UINT_FAST16_MAX,
INT_FAST32_MIN, INT_FAST32_MAX, UINT_FAST32_MAX, INT_FAST64_MIN, INT_FAST64_MAX, UINT_FAST64_MAX,
INT_LEAST8_MIN, INT_LEAST8_MAX, UINT_LEAST8_MAX, INT_LEAST16_MIN, INT_LEAST16_MAX, UINT_LEAST16_MAX,
INT_LEAST32_MIN, INT_LEAST32_MAX, UINT_LEAST32_MAX, INT_LEAST64_MIN, INT_LEAST64_MAX, UINT_LEAST64_MAX,
INT_MAX_MIN, INT_MAX_MAX, UINT_MAX_MAX, INT_PTR_MIN, INT_PTR_MAX, UINT_PTR_MAX,
PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN, WINT_MAX,
SIZE_MAX
*/
export *
}
module cstdio {
header "cstdio"
/*
export_macros BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_tmpnam, NULL,
SEEK_CUR, SEEK_END, SEEK_SET, TMP_MAX, _IOFBF, _IOLBF,
stdin, stdout, stderr
*/
export *
}
module cstdlib {
header "cstdlib"
/*
export_macros RAND_MAX
*/
export *
}
module cstring {
header "cstring"
/*
export_macros NULL
*/
export *
}
module ctgmath {
header "ctgmath"
export ccomplex
export cmath
export *
}
module ctime {
header "ctime"
/*
export_macros NULL, CLOCKS_PER_SEC
*/
export *
}
module cwchar {
header "cwchar"
/*
export_macros NULL, WCHAR_MAX, WCHAR_MIN, WEOF
*/
export *
}
module cwctype {
header "cwctype"
/*
export_macros WEOF
*/
export *
}
module deque {
header "deque"
export initializer_list
@ -345,6 +345,10 @@ module std [system] {
header "numeric"
export *
}
module optional {
header "optional"
export *
}
module ostream {
header "ostream"
// FIXME: should re-export ios, streambuf?
@ -399,11 +403,19 @@ module std [system] {
module string {
header "string"
export initializer_list
export string_view
export __string
export *
}
module string_view {
header "string_view"
export initializer_list
export __string
export *
}
module strstream {
header "strstream"
requires !cplusplus11
export *
}
module system_error {
header "system_error"
@ -449,17 +461,16 @@ module std [system] {
export initializer_list
export *
}
module variant {
header "variant"
export *
}
module vector {
header "vector"
export initializer_list
export *
}
// FIXME: We don't have modules for the <foo.h> headers, because they might
// be included from the C library's headers, and that would create a #include
// cycle. For the same reason, we don't have a module for __config.
//module __config { header "__config" export * }
// FIXME: These should be private.
module __bit_reference { header "__bit_reference" export * }
module __debug { header "__debug" export * }
@ -470,8 +481,127 @@ module std [system] {
module __split_buffer { header "__split_buffer" export * }
module __sso_allocator { header "__sso_allocator" export * }
module __std_stream { header "__std_stream" export * }
module __string { header "__string" export * }
module __tree { header "__tree" export * }
module __tuple { header "__tuple" export * }
module __undef_min_max { header "__undef_min_max" export * }
module __undef___deallocate { header "__undef___deallocate" export * }
module experimental {
requires cplusplus11
module algorithm {
header "experimental/algorithm"
export *
}
module any {
header "experimental/any"
export *
}
module chrono {
header "experimental/chrono"
export *
}
module deque {
header "experimental/deque"
export *
}
module dynarray {
header "experimental/dynarray"
export *
}
module filesystem {
header "experimental/filesystem"
export *
}
module forward_list {
header "experimental/forward_list"
export *
}
module functional {
header "experimental/functional"
export *
}
module iterator {
header "experimental/iterator"
export *
}
module list {
header "experimental/list"
export *
}
module map {
header "experimental/map"
export *
}
module memory_resource {
header "experimental/memory_resource"
export *
}
module numeric {
header "experimental/numeric"
export *
}
module optional {
header "experimental/optional"
export *
}
module propagate_const {
header "experimental/propagate_const"
export *
}
module ratio {
header "experimental/ratio"
export *
}
module regex {
header "experimental/regex"
export *
}
module set {
header "experimental/set"
export *
}
module string {
header "experimental/string"
export *
}
module string_view {
header "experimental/string_view"
export *
}
module system_error {
header "experimental/system_error"
export *
}
module tuple {
header "experimental/tuple"
export *
}
module type_traits {
header "experimental/type_traits"
export *
}
module unordered_map {
header "experimental/unordered_map"
export *
}
module unordered_set {
header "experimental/unordered_set"
export *
}
module utility {
header "experimental/utility"
export *
}
module vector {
header "experimental/vector"
export *
}
// FIXME these should be private
module __memory {
header "experimental/__memory"
export *
}
} // end experimental
}

View File

@ -206,7 +206,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS recursive_mutex
{
__libcpp_mutex_t __m_;
__libcpp_recursive_mutex_t __m_;
public:
recursive_mutex();
@ -221,7 +221,8 @@ public:
bool try_lock() _NOEXCEPT;
void unlock() _NOEXCEPT;
typedef __libcpp_mutex_t* native_handle_type;
typedef __libcpp_recursive_mutex_t* native_handle_type;
_LIBCPP_INLINE_VISIBILITY
native_handle_type native_handle() {return &__m_;}
};
@ -465,7 +466,7 @@ void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
#endif // !_LIBCPP_HAS_NO_THREADS
struct _LIBCPP_TYPE_VIS_ONLY once_flag;
struct _LIBCPP_TEMPLATE_VIS once_flag;
#ifndef _LIBCPP_HAS_NO_VARIADICS
@ -485,7 +486,7 @@ void call_once(once_flag&, const _Callable&);
#endif // _LIBCPP_HAS_NO_VARIADICS
struct _LIBCPP_TYPE_VIS_ONLY once_flag
struct _LIBCPP_TEMPLATE_VIS once_flag
{
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
@ -574,7 +575,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
{
if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
{
typedef tuple<_Callable&&, _Args&&...> _Gp;
_Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
@ -590,7 +591,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable& __func)
{
if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
{
__call_once_param<_Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
@ -615,7 +616,7 @@ call_once(once_flag& __flag, const _Callable& __func)
#if defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD) \
&& !defined(_LIBCPP_CXX03_LANG)
template <>
class _LIBCPP_TYPE_VIS_ONLY lock_guard<> {
class _LIBCPP_TEMPLATE_VIS lock_guard<> {
public:
explicit lock_guard() {}
~lock_guard() = default;
@ -628,7 +629,7 @@ public:
};
template <class ..._MArgs>
class _LIBCPP_TYPE_VIS_ONLY lock_guard
class _LIBCPP_TEMPLATE_VIS lock_guard
{
static_assert(sizeof...(_MArgs) >= 2, "At least 2 lock types required");
typedef tuple<_MArgs&...> _MutexTuple;

View File

@ -27,18 +27,19 @@ public:
virtual const char* what() const noexcept;
};
class bad_array_length : public bad_alloc // C++14
class bad_array_length : public bad_alloc // FIXME: Not part of C++
{
public:
bad_array_length() noexcept;
};
class bad_array_new_length : public bad_alloc
class bad_array_new_length : public bad_alloc // C++14
{
public:
bad_array_new_length() noexcept;
};
enum class align_val_t : size_t {}; // C++17
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
@ -48,16 +49,34 @@ new_handler get_new_handler() noexcept;
} // std
void* operator new(std::size_t size); // replaceable
void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17
void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable
void* operator new(std::size_t size, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void operator delete(void* ptr) noexcept; // replaceable
void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete(void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete(void* ptr, std::size_t size,
std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable
void operator delete(void* ptr, std:align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void* operator new[](std::size_t size); // replaceable
void* operator new[](std::size_t size,
std::align_val_t alignment) noexcept; // replaceable, C++17
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
void* operator new[](std::size_t size, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void operator delete[](void* ptr) noexcept; // replaceable
void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete[](void* ptr,
std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete[](void* ptr, std::size_t size,
std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable
void operator delete[](void* ptr, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void* operator new (std::size_t size, void* ptr) noexcept;
void* operator new[](std::size_t size, void* ptr) noexcept;
@ -69,6 +88,9 @@ void operator delete[](void* ptr, void*) noexcept;
#include <__config>
#include <exception>
#include <cstddef>
#ifdef _LIBCPP_NO_EXCEPTIONS
#include <cstdlib>
#endif
#include <__undef___deallocate>
@ -76,6 +98,16 @@ void operator delete[](void* ptr, void*) noexcept;
#pragma GCC system_header
#endif
#if !(defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
(defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309))
# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
#endif
#if !(defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER > 14 || \
(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606))
# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#endif
namespace std // purposefully not using versioning namespace
{
@ -97,6 +129,8 @@ public:
virtual const char* what() const _NOEXCEPT;
};
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
#if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
class _LIBCPP_EXCEPTION_ABI bad_array_length
@ -112,7 +146,13 @@ public:
#endif // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
_LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#ifndef _LIBCPP_CXX03_LANG
enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
#else
enum align_val_t { __zero = 0, __max = (size_t)-1 };
#endif
#endif
struct _LIBCPP_TYPE_VIS nothrow_t {};
extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
@ -122,36 +162,44 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
} // std
#if defined(_WIN32) && !defined(cxx_EXPORTS)
# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS_ONLY
#if defined(_LIBCPP_CXX03_LANG)
#define _THROW_BAD_ALLOC throw(std::bad_alloc)
#else
# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS
#define _THROW_BAD_ALLOC
#endif
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz)
#if !__has_feature(cxx_noexcept)
throw(std::bad_alloc)
#endif
;
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p) _NOEXCEPT;
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
(defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
#endif
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
#if !__has_feature(cxx_noexcept)
throw(std::bad_alloc)
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
#endif
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
#endif
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
#endif
;
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT;
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
(defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
#endif
inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
@ -177,6 +225,18 @@ inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
#endif
}
#ifdef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_array_length()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_array_length();
#else
_VSTD::abort();
#endif
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_NEW

View File

@ -53,6 +53,12 @@ template <class InputIterator, class OutputIterator, class BinaryOperation>
template <class ForwardIterator, class T>
void iota(ForwardIterator first, ForwardIterator last, T value);
template <class M, class N>
constexpr common_type_t<M,N> gcd(M m, N n); // C++17
template <class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n); // C++17
} // std
*/
@ -192,6 +198,66 @@ iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
*__first = __value_;
}
#if _LIBCPP_STD_VER > 14
template <typename _Tp, bool _IsSigned = is_signed<_Tp>::value> struct __abs;
template <typename _Tp>
struct __abs<_Tp, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Tp operator()(_Tp __t) const noexcept { return __t >= 0 ? __t : -__t; }
};
template <typename _Tp>
struct __abs<_Tp, false> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Tp operator()(_Tp __t) const noexcept { return __t; }
};
template<class _Tp>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Tp __gcd(_Tp __m, _Tp __n)
{
static_assert((!is_signed<_Tp>::value), "" );
return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
}
template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
common_type_t<_Tp,_Up>
gcd(_Tp __m, _Up __n)
{
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
using _Rp = common_type_t<_Tp,_Up>;
using _Wp = make_unsigned_t<_Rp>;
return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)),
static_cast<_Wp>(__abs<_Up>()(__n))));
}
template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
common_type_t<_Tp,_Up>
lcm(_Tp __m, _Up __n)
{
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
if (__m == 0 || __n == 0)
return 0;
using _Rp = common_type_t<_Tp,_Up>;
_Rp __val1 = __abs<_Tp>()(__m) / gcd(__m,__n);
_Up __val2 = __abs<_Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
}
#endif /* _LIBCPP_STD_VER > 14 */
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_NUMERIC

File diff suppressed because it is too large Load Diff

View File

@ -148,7 +148,7 @@ template <class charT, class traits, class T>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ostream
class _LIBCPP_TEMPLATE_VIS basic_ostream
: virtual public basic_ios<_CharT, _Traits>
{
public:
@ -160,20 +160,24 @@ public:
typedef typename traits_type::off_type off_type;
// 27.7.2.2 Constructor/destructor:
explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
{ this->init(__sb); }
virtual ~basic_ostream();
protected:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream(basic_ostream&& __rhs);
#endif
// 27.7.2.3 Assign/swap
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream& operator=(basic_ostream&& __rhs);
#endif
void swap(basic_ostream& __rhs);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void swap(basic_ostream& __rhs)
{ basic_ios<char_type, traits_type>::swap(__rhs); }
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
basic_ostream (const basic_ostream& __rhs) = delete;
@ -185,13 +189,22 @@ protected:
public:
// 27.7.2.4 Prefix/suffix:
class _LIBCPP_TYPE_VIS_ONLY sentry;
class _LIBCPP_TEMPLATE_VIS sentry;
// 27.7.2.6 Formatted output:
basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&));
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
{ return __pf(*this); }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_ostream& operator<<(basic_ios<char_type, traits_type>&
(*__pf)(basic_ios<char_type,traits_type>&));
basic_ostream& operator<<(ios_base& (*__pf)(ios_base&));
(*__pf)(basic_ios<char_type,traits_type>&))
{ __pf(*this); return *this; }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
{ __pf(*this); return *this; }
basic_ostream& operator<<(bool __n);
basic_ostream& operator<<(short __n);
basic_ostream& operator<<(unsigned short __n);
@ -213,8 +226,11 @@ public:
basic_ostream& flush();
// 27.7.2.5 seeks:
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
pos_type tellp();
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_ostream& seekp(pos_type __pos);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
protected:
@ -223,7 +239,7 @@ protected:
};
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ostream<_CharT, _Traits>::sentry
class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry
{
bool __ok_;
basic_ostream<_CharT, _Traits>& __os_;
@ -274,24 +290,15 @@ basic_ostream<_CharT, _Traits>::sentry::~sentry()
}
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
{
this->init(__sb);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
{
this->move(__rhs);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
{
@ -306,41 +313,6 @@ basic_ostream<_CharT, _Traits>::~basic_ostream()
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs)
{
basic_ios<char_type, traits_type>::swap(__rhs);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream&))
{
return __pf(*this);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(basic_ios<char_type, traits_type>&
(*__pf)(basic_ios<char_type,traits_type>&))
{
__pf(*this);
return *this;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(ios_base& (*__pf)(ios_base&))
{
__pf(*this);
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb)
@ -989,7 +961,6 @@ basic_ostream<_CharT, _Traits>::flush()
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_ostream<_CharT, _Traits>::pos_type
basic_ostream<_CharT, _Traits>::tellp()
{
@ -999,7 +970,6 @@ basic_ostream<_CharT, _Traits>::tellp()
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
{
@ -1013,7 +983,6 @@ basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
{
@ -1080,6 +1049,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
}
template<class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const basic_string_view<_CharT, _Traits> __sv)
{
return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
@ -1105,8 +1082,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<wchar_t>)
_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>)
_LIBCPP_END_NAMESPACE_STD

View File

@ -63,7 +63,7 @@ public:
void push(const value_type& v);
void push(value_type&& v);
template <class... Args> void emplace(Args&&... args);
template <class... Args> reference emplace(Args&&... args);
void pop();
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
@ -178,7 +178,7 @@ template <class T, class Container, class Compare>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TYPE_VIS_ONLY queue;
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
template <class _Tp, class _Container>
_LIBCPP_INLINE_VISIBILITY
@ -191,7 +191,7 @@ bool
operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
template <class _Tp, class _Container /*= deque<_Tp>*/>
class _LIBCPP_TYPE_VIS_ONLY queue
class _LIBCPP_TEMPLATE_VIS queue
{
public:
typedef _Container container_type;
@ -292,8 +292,8 @@ public:
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
void emplace(_Args&&... __args)
{c.emplace_back(_VSTD::forward<_Args>(__args)...);}
reference emplace(_Args&&... __args)
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
@ -381,14 +381,14 @@ swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
}
template <class _Tp, class _Container, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<queue<_Tp, _Container>, _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
: public uses_allocator<_Container, _Alloc>
{
};
template <class _Tp, class _Container = vector<_Tp>,
class _Compare = less<typename _Container::value_type> >
class _LIBCPP_TYPE_VIS_ONLY priority_queue
class _LIBCPP_TEMPLATE_VIS priority_queue
{
public:
typedef _Container container_type;
@ -732,7 +732,7 @@ swap(priority_queue<_Tp, _Container, _Compare>& __x,
}
template <class _Tp, class _Container, class _Compare, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
: public uses_allocator<_Container, _Alloc>
{
};

View File

@ -1813,7 +1813,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b>
};
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine;
class _LIBCPP_TEMPLATE_VIS linear_congruential_engine;
template <class _CharT, class _Traits,
class _Up, _Up _Ap, _Up _Cp, _Up _Np>
@ -1829,7 +1829,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine
class _LIBCPP_TEMPLATE_VIS linear_congruential_engine
{
public:
// types
@ -2011,7 +2011,7 @@ typedef minstd_rand default_random_engine;
template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine;
class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine;
template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
_UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
@ -2053,7 +2053,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s,
_UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine
class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine
{
public:
// types
@ -2499,7 +2499,7 @@ typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
// subtract_with_carry_engine
template<class _UIntType, size_t __w, size_t __s, size_t __r>
class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine;
class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine;
template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
bool
@ -2527,7 +2527,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x);
template<class _UIntType, size_t __w, size_t __s, size_t __r>
class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine
class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine
{
public:
// types
@ -2810,13 +2810,14 @@ typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base;
// discard_block_engine
template<class _Engine, size_t __p, size_t __r>
class _LIBCPP_TYPE_VIS_ONLY discard_block_engine
class _LIBCPP_TEMPLATE_VIS discard_block_engine
{
_Engine __e_;
int __n_;
static_assert( 0 < __r, "discard_block_engine invalid parameters");
static_assert(__r <= __p, "discard_block_engine invalid parameters");
static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters");
public:
// types
typedef typename _Engine::result_type result_type;
@ -2918,7 +2919,7 @@ template<class _Engine, size_t __p, size_t __r>
typename discard_block_engine<_Engine, __p, __r>::result_type
discard_block_engine<_Engine, __p, __r>::operator()()
{
if (__n_ >= __r)
if (__n_ >= static_cast<int>(__r))
{
__e_.discard(__p - __r);
__n_ = 0;
@ -2983,7 +2984,7 @@ typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
// independent_bits_engine
template<class _Engine, size_t __w, class _UIntType>
class _LIBCPP_TYPE_VIS_ONLY independent_bits_engine
class _LIBCPP_TEMPLATE_VIS independent_bits_engine
{
template <class _UI, _UI _R0, size_t _Wp, size_t _Mp>
class __get_n
@ -3247,7 +3248,7 @@ public:
};
template<class _Engine, size_t __k>
class _LIBCPP_TYPE_VIS_ONLY shuffle_order_engine
class _LIBCPP_TEMPLATE_VIS shuffle_order_engine
{
static_assert(0 < __k, "shuffle_order_engine invalid parameters");
public:
@ -3510,7 +3511,7 @@ private:
// seed_seq
class _LIBCPP_TYPE_VIS_ONLY seed_seq
class _LIBCPP_TEMPLATE_VIS seed_seq
{
public:
// types
@ -3687,13 +3688,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// uniform_real_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY uniform_real_distribution
class _LIBCPP_TEMPLATE_VIS uniform_real_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __a_;
result_type __b_;
@ -3808,13 +3809,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// bernoulli_distribution
class _LIBCPP_TYPE_VIS_ONLY bernoulli_distribution
class _LIBCPP_TEMPLATE_VIS bernoulli_distribution
{
public:
// types
typedef bool result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
double __p_;
public:
@ -3917,13 +3918,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
// binomial_distribution
template<class _IntType = int>
class _LIBCPP_TYPE_VIS_ONLY binomial_distribution
class _LIBCPP_TEMPLATE_VIS binomial_distribution
{
public:
// types
typedef _IntType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __t_;
double __p_;
@ -4085,13 +4086,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// exponential_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY exponential_distribution
class _LIBCPP_TEMPLATE_VIS exponential_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __lambda_;
public:
@ -4200,13 +4201,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// normal_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY normal_distribution
class _LIBCPP_TEMPLATE_VIS normal_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __mean_;
result_type __stddev_;
@ -4368,13 +4369,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// lognormal_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY lognormal_distribution
class _LIBCPP_TEMPLATE_VIS lognormal_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
normal_distribution<result_type> __nd_;
public:
@ -4493,13 +4494,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// poisson_distribution
template<class _IntType = int>
class _LIBCPP_TYPE_VIS_ONLY poisson_distribution
class _LIBCPP_TEMPLATE_VIS poisson_distribution
{
public:
// types
typedef _IntType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
double __mean_;
double __s_;
@ -4724,13 +4725,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// weibull_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY weibull_distribution
class _LIBCPP_TEMPLATE_VIS weibull_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __a_;
result_type __b_;
@ -4838,13 +4839,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
}
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY extreme_value_distribution
class _LIBCPP_TEMPLATE_VIS extreme_value_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __a_;
result_type __b_;
@ -4959,13 +4960,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// gamma_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY gamma_distribution
class _LIBCPP_TEMPLATE_VIS gamma_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __alpha_;
result_type __beta_;
@ -5131,13 +5132,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// negative_binomial_distribution
template<class _IntType = int>
class _LIBCPP_TYPE_VIS_ONLY negative_binomial_distribution
class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution
{
public:
// types
typedef _IntType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __k_;
double __p_;
@ -5266,13 +5267,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// geometric_distribution
template<class _IntType = int>
class _LIBCPP_TYPE_VIS_ONLY geometric_distribution
class _LIBCPP_TEMPLATE_VIS geometric_distribution
{
public:
// types
typedef _IntType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
double __p_;
public:
@ -5368,13 +5369,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// chi_squared_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY chi_squared_distribution
class _LIBCPP_TEMPLATE_VIS chi_squared_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __n_;
public:
@ -5474,13 +5475,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// cauchy_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY cauchy_distribution
class _LIBCPP_TEMPLATE_VIS cauchy_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __a_;
result_type __b_;
@ -5597,13 +5598,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// fisher_f_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY fisher_f_distribution
class _LIBCPP_TEMPLATE_VIS fisher_f_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __m_;
result_type __n_;
@ -5719,13 +5720,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// student_t_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY student_t_distribution
class _LIBCPP_TEMPLATE_VIS student_t_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __n_;
public:
@ -5832,13 +5833,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// discrete_distribution
template<class _IntType = int>
class _LIBCPP_TYPE_VIS_ONLY discrete_distribution
class _LIBCPP_TEMPLATE_VIS discrete_distribution
{
public:
// types
typedef _IntType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
vector<double> __p_;
public:
@ -6060,13 +6061,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// piecewise_constant_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY piecewise_constant_distribution
class _LIBCPP_TEMPLATE_VIS piecewise_constant_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
vector<result_type> __b_;
vector<result_type> __densities_;
@ -6383,13 +6384,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
// piecewise_linear_distribution
template<class _RealType = double>
class _LIBCPP_TYPE_VIS_ONLY piecewise_linear_distribution
class _LIBCPP_TEMPLATE_VIS piecewise_linear_distribution
{
public:
// types
typedef _RealType result_type;
class _LIBCPP_TYPE_VIS_ONLY param_type
class _LIBCPP_TEMPLATE_VIS param_type
{
vector<result_type> __b_;
vector<result_type> __densities_;

View File

@ -244,7 +244,7 @@ public:
};
template <intmax_t _Num, intmax_t _Den = 1>
class _LIBCPP_TYPE_VIS_ONLY ratio
class _LIBCPP_TEMPLATE_VIS ratio
{
static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
static_assert(_Den != 0, "ratio divide by 0");
@ -300,18 +300,18 @@ public:
>::type type;
};
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_multiply
= typename __ratio_multiply<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_multiply
struct _LIBCPP_TEMPLATE_VIS ratio_multiply
: public __ratio_multiply<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct __ratio_divide
@ -327,18 +327,18 @@ public:
>::type type;
};
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_divide
= typename __ratio_divide<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_divide
struct _LIBCPP_TEMPLATE_VIS ratio_divide
: public __ratio_divide<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct __ratio_add
@ -362,18 +362,18 @@ public:
>::type type;
};
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_add
= typename __ratio_add<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_add
struct _LIBCPP_TEMPLATE_VIS ratio_add
: public __ratio_add<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct __ratio_subtract
@ -397,27 +397,27 @@ public:
>::type type;
};
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_subtract
= typename __ratio_subtract<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract
struct _LIBCPP_TEMPLATE_VIS ratio_subtract
: public __ratio_subtract<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif // _LIBCPP_CXX03_LANG
// ratio_equal
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_equal
struct _LIBCPP_TEMPLATE_VIS ratio_equal
: public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_not_equal
struct _LIBCPP_TEMPLATE_VIS ratio_not_equal
: public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};
// ratio_less
@ -476,19 +476,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>
};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_less
struct _LIBCPP_TEMPLATE_VIS ratio_less
: public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_less_equal
struct _LIBCPP_TEMPLATE_VIS ratio_less_equal
: public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_greater
struct _LIBCPP_TEMPLATE_VIS ratio_greater
: public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_greater_equal
struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal
: public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};
template <class _R1, class _R2>

View File

@ -127,6 +127,8 @@ class basic_regex
public:
// types:
typedef charT value_type;
typedef traits traits_type;
typedef typename traits::string_type string_type;
typedef regex_constants::syntax_option_type flag_type;
typedef typename traits::locale_type locale_type;
@ -145,7 +147,7 @@ public:
// construct/copy/destroy:
basic_regex();
explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
basic_regex(const charT* p, size_t len, flag_type f);
basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
basic_regex(const basic_regex&);
basic_regex(basic_regex&&) noexcept;
template <class ST, class SA>
@ -762,7 +764,6 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#include <memory>
#include <vector>
#include <deque>
#include <cassert>
#include <__undef_min_max>
@ -864,7 +865,8 @@ enum match_flag_type
format_sed = 1 << 8,
format_no_copy = 1 << 9,
format_first_only = 1 << 10,
__no_update_pos = 1 << 11
__no_update_pos = 1 << 11,
__full_match = 1 << 12
};
inline _LIBCPP_INLINE_VISIBILITY
@ -957,18 +959,18 @@ public:
};
template <regex_constants::error_type _Ev>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_regex_error()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(_Ev);
#else
assert(!"regex_error");
_VSTD::abort();
#endif
}
template <class _CharT>
struct _LIBCPP_TYPE_VIS_ONLY regex_traits
struct _LIBCPP_TEMPLATE_VIS regex_traits
{
public:
typedef _CharT char_type;
@ -1285,11 +1287,11 @@ regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
template <class _CharT> class __node;
template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match;
template <class _BidirectionalIterator> class _LIBCPP_TEMPLATE_VIS sub_match;
template <class _BidirectionalIterator,
class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
class _LIBCPP_TYPE_VIS_ONLY match_results;
class _LIBCPP_TEMPLATE_VIS match_results;
template <class _CharT>
struct __state
@ -2470,11 +2472,13 @@ __exit:
template <class _CharT, class _Traits> class __lookahead;
template <class _CharT, class _Traits = regex_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_regex
class _LIBCPP_TEMPLATE_VIS basic_regex
{
public:
// types:
typedef _CharT value_type;
typedef _Traits traits_type;
typedef typename _Traits::string_type string_type;
typedef regex_constants::syntax_option_type flag_type;
typedef typename _Traits::locale_type locale_type;
@ -2515,7 +2519,7 @@ public:
__end_(0)
{__parse(__p, __p + __traits_.length(__p));}
_LIBCPP_INLINE_VISIBILITY
basic_regex(const value_type* __p, size_t __len, flag_type __f)
basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{__parse(__p, __p + __len);}
@ -2981,10 +2985,12 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const
{
match_results<const _CharT*> __m;
__m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
__m,
__s.__flags_ | regex_constants::match_continuous,
__s.__at_first_ && __s.__current_ == __s.__first_);
bool __matched = __exp_.__match_at_start_ecma(
__s.__current_, __s.__last_,
__m,
(__s.__flags_ | regex_constants::match_continuous) &
~regex_constants::__full_match,
__s.__at_first_ && __s.__current_ == __s.__first_);
if (__matched != __invert_)
{
__s.__do_ = __state::__accept_but_not_consume;
@ -4308,7 +4314,8 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
else if ('1' <= *__first && *__first <= '9')
{
unsigned __v = *__first - '0';
for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
for (++__first;
__first != __last && '0' <= *__first && *__first <= '9'; ++__first)
__v = 10 * __v + *__first - '0';
if (__v > mark_count())
__throw_regex_error<regex_constants::error_backref>();
@ -4758,7 +4765,7 @@ typedef basic_regex<wchar_t> wregex;
// sub_match
template <class _BidirectionalIterator>
class _LIBCPP_TYPE_VIS_ONLY sub_match
class _LIBCPP_TEMPLATE_VIS sub_match
: public pair<_BidirectionalIterator, _BidirectionalIterator>
{
public:
@ -5181,7 +5188,7 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
}
template <class _BidirectionalIterator, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY match_results
class _LIBCPP_TEMPLATE_VIS match_results
{
public:
typedef _Allocator allocator_type;
@ -5552,6 +5559,18 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
switch (__s.__do_)
{
case __state::__end_state:
if ((__flags & regex_constants::match_not_null) &&
__s.__current_ == __first)
{
__states.pop_back();
break;
}
if ((__flags & regex_constants::__full_match) &&
__s.__current_ != __last)
{
__states.pop_back();
break;
}
__m.__matches_[0].first = __first;
__m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
__m.__matches_[0].matched = true;
@ -5615,6 +5634,18 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
switch (__s.__do_)
{
case __state::__end_state:
if ((__flags & regex_constants::match_not_null) &&
__s.__current_ == __first)
{
__states.pop_back();
break;
}
if ((__flags & regex_constants::__full_match) &&
__s.__current_ != __last)
{
__states.pop_back();
break;
}
if (!__matched || __highest_j < __s.__current_ - __s.__first_)
__highest_j = __s.__current_ - __s.__first_;
__matched = true;
@ -5700,6 +5731,18 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
switch (__s.__do_)
{
case __state::__end_state:
if ((__flags & regex_constants::match_not_null) &&
__s.__current_ == __first)
{
__states.pop_back();
break;
}
if ((__flags & regex_constants::__full_match) &&
__s.__current_ != __last)
{
__states.pop_back();
break;
}
if (!__matched || __highest_j < __s.__current_ - __s.__first_)
{
__highest_j = __s.__current_ - __s.__first_;
@ -5930,8 +5973,10 @@ regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
const basic_regex<_CharT, _Traits>& __e,
regex_constants::match_flag_type __flags = regex_constants::match_default)
{
bool __r = _VSTD::regex_search(__first, __last, __m, __e,
__flags | regex_constants::match_continuous);
bool __r = _VSTD::regex_search(
__first, __last, __m, __e,
__flags | regex_constants::match_continuous |
regex_constants::__full_match);
if (__r)
{
__r = !__m.suffix().matched;
@ -6007,7 +6052,7 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
template <class _BidirectionalIterator,
class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
class _Traits = regex_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY regex_iterator
class _LIBCPP_TEMPLATE_VIS regex_iterator
{
public:
typedef basic_regex<_CharT, _Traits> regex_type;
@ -6126,7 +6171,7 @@ typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
template <class _BidirectionalIterator,
class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
class _Traits = regex_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator
class _LIBCPP_TEMPLATE_VIS regex_token_iterator
{
public:
typedef basic_regex<_CharT, _Traits> regex_type;
@ -6142,7 +6187,7 @@ private:
_Position __position_;
const value_type* __result_;
value_type __suffix_;
ptrdiff_t _N_;
ptrdiff_t __n_;
vector<int> __subs_;
public:
@ -6225,10 +6270,10 @@ public:
private:
void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
void __establish_result () {
if (__subs_[_N_] == -1)
if (__subs_[__n_] == -1)
__result_ = &__position_->prefix();
else
__result_ = &(*__position_)[__subs_[_N_]];
__result_ = &(*__position_)[__subs_[__n_]];
}
};
@ -6237,7 +6282,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
regex_token_iterator()
: __result_(nullptr),
__suffix_(),
_N_(0)
__n_(0)
{
}
@ -6248,7 +6293,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
{
if (__position_ != _Position())
__establish_result ();
else if (__subs_[_N_] == -1)
else if (__subs_[__n_] == -1)
{
__suffix_.matched = true;
__suffix_.first = __a;
@ -6265,7 +6310,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
const regex_type& __re, int __submatch,
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
_N_(0),
__n_(0),
__subs_(1, __submatch)
{
__init(__a, __b);
@ -6277,7 +6322,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
const regex_type& __re, const vector<int>& __submatches,
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
_N_(0),
__n_(0),
__subs_(__submatches)
{
__init(__a, __b);
@ -6292,7 +6337,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
initializer_list<int> __submatches,
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
_N_(0),
__n_(0),
__subs_(__submatches)
{
__init(__a, __b);
@ -6308,7 +6353,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
const int (&__submatches)[_Np],
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
_N_(0),
__n_(0),
__subs_(__submatches, __submatches + _Np)
{
__init(__a, __b);
@ -6320,7 +6365,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
: __position_(__x.__position_),
__result_(__x.__result_),
__suffix_(__x.__suffix_),
_N_(__x._N_),
__n_(__x.__n_),
__subs_(__x.__subs_)
{
if (__x.__result_ == &__x.__suffix_)
@ -6342,7 +6387,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
else
__result_ = __x.__result_;
__suffix_ = __x.__suffix_;
_N_ = __x._N_;
__n_ = __x.__n_;
__subs_ = __x.__subs_;
if ( __result_ != nullptr && __result_ != &__suffix_ )
@ -6365,7 +6410,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
return false;
if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
return false;
return __position_ == __x.__position_ && _N_ == __x._N_ &&
return __position_ == __x.__position_ && __n_ == __x.__n_ &&
__subs_ == __x.__subs_;
}
@ -6376,14 +6421,14 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
_Position __prev = __position_;
if (__result_ == &__suffix_)
__result_ = nullptr;
else if (_N_ + 1 < __subs_.size())
else if (static_cast<size_t>(__n_ + 1) < __subs_.size())
{
++_N_;
++__n_;
__establish_result();
}
else
{
_N_ = 0;
__n_ = 0;
++__position_;
if (__position_ != _Position())
__establish_result();

View File

@ -115,7 +115,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
_LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE)
#if !defined(_LIBCPP_CXX03_LANG)
// scoped_allocator_adaptor
@ -384,7 +384,7 @@ struct __outermost<_Alloc, true>
};
template <class _OuterAlloc, class... _InnerAllocs>
class _LIBCPP_TYPE_VIS_ONLY scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
: public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
{
typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
@ -498,8 +498,58 @@ public:
template <class _Tp, class... _Args>
_LIBCPP_INLINE_VISIBILITY
void construct(_Tp* __p, _Args&& ...__args)
{__construct(__uses_alloc_ctor<_Tp, inner_allocator_type, _Args...>(),
{__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(),
__p, _VSTD::forward<_Args>(__args)...);}
template <class _T1, class _T2, class... _Args1, class... _Args2>
void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
tuple<_Args1...> __x, tuple<_Args2...> __y)
{
typedef __outermost<outer_allocator_type> _OM;
allocator_traits<typename _OM::type>::construct(
_OM()(outer_allocator()), __p, piecewise_construct
, __transform_tuple(
typename __uses_alloc_ctor<
_T1, inner_allocator_type&, _Args1...
>::type()
, _VSTD::move(__x)
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
)
, __transform_tuple(
typename __uses_alloc_ctor<
_T2, inner_allocator_type&, _Args2...
>::type()
, _VSTD::move(__y)
, typename __make_tuple_indices<sizeof...(_Args2)>::type{}
)
);
}
template <class _T1, class _T2>
void construct(pair<_T1, _T2>* __p)
{ construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }
template <class _T1, class _T2, class _Up, class _Vp>
void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
construct(__p, piecewise_construct,
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)),
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y)));
}
template <class _T1, class _T2, class _Up, class _Vp>
void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
construct(__p, piecewise_construct,
_VSTD::forward_as_tuple(__x.first),
_VSTD::forward_as_tuple(__x.second));
}
template <class _T1, class _T2, class _Up, class _Vp>
void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
construct(__p, piecewise_construct,
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void destroy(_Tp* __p)
@ -515,6 +565,7 @@ public:
private:
template <class _OuterA2,
class = typename enable_if<
is_constructible<outer_allocator_type, _OuterA2>::value
@ -545,9 +596,7 @@ private:
allocator_traits<typename _OM::type>::construct
(
_OM()(outer_allocator()),
__p,
allocator_arg,
inner_allocator(),
__p, allocator_arg, inner_allocator(),
_VSTD::forward<_Args>(__args)...
);
}
@ -566,6 +615,36 @@ private:
);
}
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<_Args&&...>
__transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,
__tuple_indices<_Idx...>)
{
return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);
}
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
__tuple_indices<_Idx...>)
{
using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;
return _Tup(allocator_arg, inner_allocator(),
_VSTD::get<_Idx>(_VSTD::move(__t))...);
}
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<_Args&&..., inner_allocator_type&>
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
__tuple_indices<_Idx...>)
{
using _Tup = tuple<_Args&&..., inner_allocator_type&>;
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator());
}
template <class...> friend class __scoped_allocator_storage;
};
@ -597,7 +676,7 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
return !(__a == __b);
}
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE)
#endif // !defined(_LIBCPP_CXX03_LANG)
_LIBCPP_END_NAMESPACE_STD

View File

@ -397,7 +397,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key> >
class _LIBCPP_TYPE_VIS_ONLY set
class _LIBCPP_TEMPLATE_VIS set
{
public:
// types:
@ -672,7 +672,7 @@ public:
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_unique(__k);}
count(const _K2& __k) const {return __tree_.__count_unique(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
@ -810,7 +810,7 @@ swap(set<_Key, _Compare, _Allocator>& __x,
template <class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key> >
class _LIBCPP_TYPE_VIS_ONLY multiset
class _LIBCPP_TEMPLATE_VIS multiset
{
public:
// types:
@ -1023,7 +1023,7 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, value_type&& __v)
{return __tree_.__insert_multi(_VSTD::move(__v));}
{return __tree_.__insert_multi(__p, _VSTD::move(__v));}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY

View File

@ -186,7 +186,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// basic_stringbuf
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf
class _LIBCPP_TEMPLATE_VIS basic_stringbuf
: public basic_streambuf<_CharT, _Traits>
{
public:
@ -207,7 +207,9 @@ private:
public:
// 27.8.1.1 Constructors:
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_stringbuf(const string_type& __s,
ios_base::openmode __wch = ios_base::in | ios_base::out);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@ -231,12 +233,12 @@ protected:
virtual int_type overflow (int_type __c = traits_type::eof());
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __wch = ios_base::in | ios_base::out);
inline _LIBCPP_INLINE_VISIBILITY
virtual pos_type seekpos(pos_type __sp,
ios_base::openmode __wch = ios_base::in | ios_base::out);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
: __hm_(0),
__mode_(__wch)
@ -245,7 +247,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
ios_base::openmode __wch)
: __hm_(0),
@ -607,7 +608,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
ios_base::openmode __wch)
@ -618,7 +618,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
// basic_istringstream
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY basic_istringstream
class _LIBCPP_TEMPLATE_VIS basic_istringstream
: public basic_istream<_CharT, _Traits>
{
public:
@ -636,25 +636,31 @@ private:
public:
// 27.8.2.1 Constructors:
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_istringstream(const string_type& __s,
ios_base::openmode __wch = ios_base::in);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream(basic_istringstream&& __rhs);
// 27.8.2.2 Assign and swap:
basic_istringstream& operator=(basic_istringstream&& __rhs);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
inline _LIBCPP_INLINE_VISIBILITY
void swap(basic_istringstream& __rhs);
// 27.8.2.3 Members:
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
inline _LIBCPP_INLINE_VISIBILITY
string_type str() const;
inline _LIBCPP_INLINE_VISIBILITY
void str(const string_type& __s);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
: basic_istream<_CharT, _Traits>(&__sb_),
__sb_(__wch | ios_base::in)
@ -662,7 +668,6 @@ basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
ios_base::openmode __wch)
: basic_istream<_CharT, _Traits>(&__sb_),
@ -673,7 +678,6 @@ basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const stri
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
__sb_(_VSTD::move(__rhs.__sb_))
@ -693,9 +697,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
{
basic_istream<char_type, traits_type>::swap(__rhs);
__sb_.swap(__rhs.__sb_);
@ -711,7 +713,6 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>*
basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
{
@ -719,7 +720,6 @@ basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>
basic_istringstream<_CharT, _Traits, _Allocator>::str() const
{
@ -727,9 +727,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str() const
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
__sb_.str(__s);
}
@ -737,7 +735,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
// basic_ostringstream
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream
class _LIBCPP_TEMPLATE_VIS basic_ostringstream
: public basic_ostream<_CharT, _Traits>
{
public:
@ -755,25 +753,31 @@ private:
public:
// 27.8.2.1 Constructors:
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_ostringstream(const string_type& __s,
ios_base::openmode __wch = ios_base::out);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream(basic_ostringstream&& __rhs);
// 27.8.2.2 Assign and swap:
basic_ostringstream& operator=(basic_ostringstream&& __rhs);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
inline _LIBCPP_INLINE_VISIBILITY
void swap(basic_ostringstream& __rhs);
// 27.8.2.3 Members:
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
inline _LIBCPP_INLINE_VISIBILITY
string_type str() const;
inline _LIBCPP_INLINE_VISIBILITY
void str(const string_type& __s);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
: basic_ostream<_CharT, _Traits>(&__sb_),
__sb_(__wch | ios_base::out)
@ -781,7 +785,6 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
ios_base::openmode __wch)
: basic_ostream<_CharT, _Traits>(&__sb_),
@ -792,7 +795,6 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const stri
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
: basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
__sb_(_VSTD::move(__rhs.__sb_))
@ -812,7 +814,6 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
{
@ -830,7 +831,6 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>*
basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
{
@ -838,7 +838,6 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>
basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
{
@ -846,7 +845,6 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
@ -856,7 +854,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
// basic_stringstream
template <class _CharT, class _Traits, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY basic_stringstream
class _LIBCPP_TEMPLATE_VIS basic_stringstream
: public basic_iostream<_CharT, _Traits>
{
public:
@ -874,25 +872,31 @@ private:
public:
// 27.8.2.1 Constructors:
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
inline _LIBCPP_INLINE_VISIBILITY
explicit basic_stringstream(const string_type& __s,
ios_base::openmode __wch = ios_base::in | ios_base::out);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream(basic_stringstream&& __rhs);
// 27.8.2.2 Assign and swap:
basic_stringstream& operator=(basic_stringstream&& __rhs);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
inline _LIBCPP_INLINE_VISIBILITY
void swap(basic_stringstream& __rhs);
// 27.8.2.3 Members:
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
inline _LIBCPP_INLINE_VISIBILITY
string_type str() const;
inline _LIBCPP_INLINE_VISIBILITY
void str(const string_type& __s);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
: basic_iostream<_CharT, _Traits>(&__sb_),
__sb_(__wch)
@ -900,7 +904,6 @@ basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::op
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
ios_base::openmode __wch)
: basic_iostream<_CharT, _Traits>(&__sb_),
@ -911,7 +914,6 @@ basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
: basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
__sb_(_VSTD::move(__rhs.__sb_))
@ -931,7 +933,6 @@ basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&&
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
{
@ -949,7 +950,6 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>*
basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
{
@ -957,7 +957,6 @@ basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>
basic_stringstream<_CharT, _Traits, _Allocator>::str() const
{
@ -965,7 +964,6 @@ basic_stringstream<_CharT, _Traits, _Allocator>::str() const
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{

View File

@ -55,7 +55,7 @@ public:
void push(const value_type& x);
void push(value_type&& x);
template <class... Args> void emplace(Args&&... args);
template <class... Args> reference emplace(Args&&... args);
void pop();
void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
@ -91,7 +91,7 @@ template <class T, class Container>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TYPE_VIS_ONLY stack;
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack;
template <class _Tp, class _Container>
_LIBCPP_INLINE_VISIBILITY
@ -104,7 +104,7 @@ bool
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
template <class _Tp, class _Container /*= deque<_Tp>*/>
class _LIBCPP_TYPE_VIS_ONLY stack
class _LIBCPP_TEMPLATE_VIS stack
{
public:
typedef _Container container_type;
@ -199,8 +199,8 @@ public:
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
void emplace(_Args&&... __args)
{c.emplace_back(_VSTD::forward<_Args>(__args)...);}
reference emplace(_Args&&... __args)
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
@ -286,7 +286,7 @@ swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
}
template <class _Tp, class _Container, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<stack<_Tp, _Container>, _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
: public uses_allocator<_Container, _Alloc>
{
};

View File

@ -45,22 +45,31 @@ public:
#include <__config>
#include <exception>
#include <iosfwd> // for string forward decl
#ifdef _LIBCPP_NO_EXCEPTIONS
#include <cstdlib>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#ifndef _LIBCPP___REFSTRING
_LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_HIDDEN __libcpp_refstring {
#ifdef __clang__
const char *__imp_ __attribute__((__unused__)); // only clang emits a warning
#else
const char *__imp_;
#endif
class _LIBCPP_HIDDEN __libcpp_refstring
{
const char* __imp_;
bool __uses_refcount() const;
public:
explicit __libcpp_refstring(const char* msg);
__libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT;
__libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT;
~__libcpp_refstring();
const char* c_str() const _NOEXCEPT {return __imp_;}
};
_LIBCPP_END_NAMESPACE_STD
#endif
namespace std // purposefully not using versioning namespace
{
@ -171,4 +180,99 @@ public:
} // std
_LIBCPP_BEGIN_NAMESPACE_STD
// in the dylib
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_logic_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw logic_error(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_domain_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw domain_error(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_invalid_argument(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw invalid_argument(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_length_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw length_error(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_out_of_range(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_range_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw range_error(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_overflow_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw overflow_error(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_underflow_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw underflow_error(__msg);
#else
((void)__msg);
_VSTD::abort();
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STDEXCEPT

View File

@ -0,0 +1,121 @@
// -*- C++ -*-
//===---------------------------- stdint.h --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STDINT_H
#define _LIBCPP_STDINT_H
/*
stdint.h synopsis
Macros:
INT8_MIN
INT16_MIN
INT32_MIN
INT64_MIN
INT8_MAX
INT16_MAX
INT32_MAX
INT64_MAX
UINT8_MAX
UINT16_MAX
UINT32_MAX
UINT64_MAX
INT_LEAST8_MIN
INT_LEAST16_MIN
INT_LEAST32_MIN
INT_LEAST64_MIN
INT_LEAST8_MAX
INT_LEAST16_MAX
INT_LEAST32_MAX
INT_LEAST64_MAX
UINT_LEAST8_MAX
UINT_LEAST16_MAX
UINT_LEAST32_MAX
UINT_LEAST64_MAX
INT_FAST8_MIN
INT_FAST16_MIN
INT_FAST32_MIN
INT_FAST64_MIN
INT_FAST8_MAX
INT_FAST16_MAX
INT_FAST32_MAX
INT_FAST64_MAX
UINT_FAST8_MAX
UINT_FAST16_MAX
UINT_FAST32_MAX
UINT_FAST64_MAX
INTPTR_MIN
INTPTR_MAX
UINTPTR_MAX
INTMAX_MIN
INTMAX_MAX
UINTMAX_MAX
PTRDIFF_MIN
PTRDIFF_MAX
SIG_ATOMIC_MIN
SIG_ATOMIC_MAX
SIZE_MAX
WCHAR_MIN
WCHAR_MAX
WINT_MIN
WINT_MAX
INT8_C(value)
INT16_C(value)
INT32_C(value)
INT64_C(value)
UINT8_C(value)
UINT16_C(value)
UINT32_C(value)
UINT64_C(value)
INTMAX_C(value)
UINTMAX_C(value)
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
are defined
*/
#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
# define __STDC_LIMIT_MACROS
#endif
#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
# define __STDC_CONSTANT_MACROS
#endif
#include_next <stdint.h>
#endif // _LIBCPP_STDINT_H

View File

@ -119,7 +119,7 @@ protected:
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_streambuf
class _LIBCPP_TEMPLATE_VIS basic_streambuf
{
public:
// types:
@ -132,32 +132,96 @@ public:
virtual ~basic_streambuf();
// 27.6.2.2.1 locales:
locale pubimbue(const locale& __loc);
locale getloc() const;
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
locale pubimbue(const locale& __loc) {
imbue(__loc);
locale __r = __loc_;
__loc_ = __loc;
return __r;
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
locale getloc() const { return __loc_; }
// 27.6.2.2.2 buffer and positioning:
basic_streambuf* pubsetbuf(char_type* __s, streamsize __n);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_streambuf* pubsetbuf(char_type* __s, streamsize __n)
{ return setbuf(__s, __n); }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
pos_type pubseekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __which = ios_base::in | ios_base::out);
ios_base::openmode __which = ios_base::in | ios_base::out)
{ return seekoff(__off, __way, __which); }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
pos_type pubseekpos(pos_type __sp,
ios_base::openmode __which = ios_base::in | ios_base::out);
int pubsync();
ios_base::openmode __which = ios_base::in | ios_base::out)
{ return seekpos(__sp, __which); }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int pubsync() { return sync(); }
// Get and put areas:
// 27.6.2.2.3 Get area:
streamsize in_avail();
int_type snextc();
int_type sbumpc();
int_type sgetc();
streamsize sgetn(char_type* __s, streamsize __n);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
streamsize in_avail() {
if (__ninp_ < __einp_)
return static_cast<streamsize>(__einp_ - __ninp_);
return showmanyc();
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int_type snextc() {
if (sbumpc() == traits_type::eof())
return traits_type::eof();
return sgetc();
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int_type sbumpc() {
if (__ninp_ == __einp_)
return uflow();
return traits_type::to_int_type(*__ninp_++);
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int_type sgetc() {
if (__ninp_ == __einp_)
return underflow();
return traits_type::to_int_type(*__ninp_);
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
streamsize sgetn(char_type* __s, streamsize __n)
{ return xsgetn(__s, __n); }
// 27.6.2.2.4 Putback:
int_type sputbackc(char_type __c);
int_type sungetc();
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int_type sputbackc(char_type __c) {
if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))
return pbackfail(traits_type::to_int_type(__c));
return traits_type::to_int_type(*--__ninp_);
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int_type sungetc() {
if (__binp_ == __ninp_)
return pbackfail();
return traits_type::to_int_type(*--__ninp_);
}
// 27.6.2.2.5 Put area:
int_type sputc(char_type __c);
streamsize sputn(const char_type* __s, streamsize __n);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
int_type sputc(char_type __c) {
if (__nout_ == __eout_)
return overflow(traits_type::to_int_type(__c));
*__nout_++ = __c;
return traits_type::to_int_type(__c);
}
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
streamsize sputn(const char_type* __s, streamsize __n)
{ return xsputn(__s, __n); }
protected:
basic_streambuf();
@ -169,15 +233,30 @@ protected:
_LIBCPP_ALWAYS_INLINE char_type* eback() const {return __binp_;}
_LIBCPP_ALWAYS_INLINE char_type* gptr() const {return __ninp_;}
_LIBCPP_ALWAYS_INLINE char_type* egptr() const {return __einp_;}
void gbump(int __n);
void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void gbump(int __n) { __ninp_ += __n; }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) {
__binp_ = __gbeg;
__ninp_ = __gnext;
__einp_ = __gend;
}
// 27.6.2.3.3 Put area:
_LIBCPP_ALWAYS_INLINE char_type* pbase() const {return __bout_;}
_LIBCPP_ALWAYS_INLINE char_type* pptr() const {return __nout_;}
_LIBCPP_ALWAYS_INLINE char_type* epptr() const {return __eout_;}
void pbump(int __n);
void setp(char_type* __pbeg, char_type* __pend);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void pbump(int __n) { __nout_ += __n; }
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void setp(char_type* __pbeg, char_type* __pend) {
__bout_ = __nout_ = __pbeg;
__eout_ = __pend;
}
// 27.6.2.4 virtual functions:
// 27.6.2.4.1 Locales:
@ -219,147 +298,6 @@ basic_streambuf<_CharT, _Traits>::~basic_streambuf()
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
locale
basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc)
{
imbue(__loc);
locale __r = __loc_;
__loc_ = __loc;
return __r;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
locale
basic_streambuf<_CharT, _Traits>::getloc() const
{
return __loc_;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_streambuf<_CharT, _Traits>*
basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n)
{
return setbuf(__s, __n);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off,
ios_base::seekdir __way,
ios_base::openmode __which)
{
return seekoff(__off, __way, __which);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp,
ios_base::openmode __which)
{
return seekpos(__sp, __which);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
int
basic_streambuf<_CharT, _Traits>::pubsync()
{
return sync();
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
streamsize
basic_streambuf<_CharT, _Traits>::in_avail()
{
if (__ninp_ < __einp_)
return static_cast<streamsize>(__einp_ - __ninp_);
return showmanyc();
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::snextc()
{
if (sbumpc() == traits_type::eof())
return traits_type::eof();
return sgetc();
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sbumpc()
{
if (__ninp_ == __einp_)
return uflow();
return traits_type::to_int_type(*__ninp_++);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sgetc()
{
if (__ninp_ == __einp_)
return underflow();
return traits_type::to_int_type(*__ninp_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
streamsize
basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n)
{
return xsgetn(__s, __n);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c)
{
if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))
return pbackfail(traits_type::to_int_type(__c));
return traits_type::to_int_type(*--__ninp_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sungetc()
{
if (__binp_ == __ninp_)
return pbackfail();
return traits_type::to_int_type(*--__ninp_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sputc(char_type __c)
{
if (__nout_ == __eout_)
return overflow(traits_type::to_int_type(__c));
*__nout_++ = __c;
return traits_type::to_int_type(__c);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
streamsize
basic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n)
{
return xsputn(__s, __n);
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::basic_streambuf()
: __binp_(0),
@ -410,42 +348,6 @@ basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb)
_VSTD::swap(__eout_, __sb.__eout_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::gbump(int __n)
{
__ninp_ += __n;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext,
char_type* __gend)
{
__binp_ = __gbeg;
__ninp_ = __gnext;
__einp_ = __gend;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::pbump(int __n)
{
__nout_ += __n;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend)
{
__bout_ = __nout_ = __pbeg;
__eout_ = __pend;
}
template <class _CharT, class _Traits>
void
basic_streambuf<_CharT, _Traits>::imbue(const locale&)
@ -574,11 +476,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
return traits_type::eof();
}
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<wchar_t>)
_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>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>)
_LIBCPP_END_NAMESPACE_STD

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,754 @@
// -*- C++ -*-
//===------------------------ string_view ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STRING_VIEW
#define _LIBCPP_STRING_VIEW
/*
string_view synopsis
namespace std {
// 7.2, Class template basic_string_view
template<class charT, class traits = char_traits<charT>>
class basic_string_view;
// 7.9, basic_string_view non-member comparison functions
template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator!=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator< (basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator> (basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator<=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator>=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
// see below, sufficient additional overloads of comparison functions
// 7.10, Inserters and extractors
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os,
basic_string_view<charT, traits> str);
// basic_string_view typedef names
typedef basic_string_view<char> string_view;
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
template<class charT, class traits = char_traits<charT>>
class basic_string_view {
public:
// types
typedef traits traits_type;
typedef charT value_type;
typedef charT* pointer;
typedef const charT* const_pointer;
typedef charT& reference;
typedef const charT& const_reference;
typedef implementation-defined const_iterator;
typedef const_iterator iterator;
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
static constexpr size_type npos = size_type(-1);
// 7.3, basic_string_view constructors and assignment operators
constexpr basic_string_view() noexcept;
constexpr basic_string_view(const basic_string_view&) noexcept = default;
basic_string_view& operator=(const basic_string_view&) noexcept = default;
template<class Allocator>
constexpr basic_string_view(const charT* str);
constexpr basic_string_view(const charT* str, size_type len);
// 7.4, basic_string_view iterator support
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// 7.5, basic_string_view capacity
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
constexpr size_type max_size() const noexcept;
constexpr bool empty() const noexcept;
// 7.6, basic_string_view element access
constexpr const_reference operator[](size_type pos) const;
constexpr const_reference at(size_type pos) const;
constexpr const_reference front() const;
constexpr const_reference back() const;
constexpr const_pointer data() const noexcept;
// 7.7, basic_string_view modifiers
constexpr void clear() noexcept;
constexpr void remove_prefix(size_type n);
constexpr void remove_suffix(size_type n);
constexpr void swap(basic_string_view& s) noexcept;
size_type copy(charT* s, size_type n, size_type pos = 0) const;
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
constexpr int compare(basic_string_view s) const noexcept;
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
constexpr int compare(size_type pos1, size_type n1,
basic_string_view s, size_type pos2, size_type n2) const;
constexpr int compare(const charT* s) const;
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
constexpr int compare(size_type pos1, size_type n1,
const charT* s, size_type n2) const;
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
constexpr size_type find(const charT* s, size_type pos = 0) const;
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
private:
const_pointer data_; // exposition only
size_type size_; // exposition only
};
// 7.11, Hash support
template <class T> struct hash;
template <> struct hash<string_view>;
template <> struct hash<u16string_view>;
template <> struct hash<u32string_view>;
template <> struct hash<wstring_view>;
} // namespace std
*/
#include <__config>
#include <__string>
#include <algorithm>
#include <iterator>
#include <limits>
#include <stdexcept>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS basic_string_view {
public:
// types
typedef _Traits traits_type;
typedef _CharT value_type;
typedef const _CharT* pointer;
typedef const _CharT* const_pointer;
typedef const _CharT& reference;
typedef const _CharT& const_reference;
typedef const_pointer const_iterator; // See [string.view.iterators]
typedef const_iterator iterator;
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
// [string.view.cons], construct/copy
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
_LIBCPP_INLINE_VISIBILITY
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const _CharT* __s, size_type __len)
: __data(__s), __size(__len)
{
// #if _LIBCPP_STD_VER > 11
// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
// #endif
}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view(const _CharT* __s)
: __data(__s), __size(_Traits::length(__s)) {}
// [string.view.iterators], iterators
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT { return cbegin(); }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT { return cend(); }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const _NOEXCEPT { return __data; }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_iterator cend() const _NOEXCEPT { return __data + __size; }
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
// [string.view.capacity], capacity
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT { return __size; }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
size_type length() const _NOEXCEPT { return __size; }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); }
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
empty() const _NOEXCEPT { return __size == 0; }
// [string.view.access], element access
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; }
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference at(size_type __pos) const
{
return __pos >= size()
? (__throw_out_of_range("string_view::at"), __data[0])
: __data[__pos];
}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference front() const
{
return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference back() const
{
return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_pointer data() const _NOEXCEPT { return __data; }
// [string.view.modifiers], modifiers:
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{
__data = nullptr;
__size = 0;
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
void remove_prefix(size_type __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
__data += __n;
__size -= __n;
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
void remove_suffix(size_type __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
__size -= __n;
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
void swap(basic_string_view& __other) _NOEXCEPT
{
const value_type *__p = __data;
__data = __other.__data;
__other.__data = __p;
size_type __sz = __size;
__size = __other.__size;
__other.__size = __sz;
}
_LIBCPP_INLINE_VISIBILITY
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{
if (__pos > size())
__throw_out_of_range("string_view::copy");
size_type __rlen = _VSTD::min(__n, size() - __pos);
_Traits::copy(__s, data() + __pos, __rlen);
return __rlen;
}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
{
return __pos > size()
? (__throw_out_of_range("string_view::substr"), basic_string_view())
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
{
size_type __rlen = _VSTD::min( size(), __sv.size());
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
if ( __retval == 0 ) // first __rlen chars matched
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
return __retval;
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
{
return substr(__pos1, __n1).compare(__sv);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
int compare( size_type __pos1, size_type __n1,
basic_string_view _sv, size_type __pos2, size_type __n2) const
{
return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
int compare(const _CharT* __s) const _NOEXCEPT
{
return compare(basic_string_view(__s));
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
{
return substr(__pos1, __n1).compare(basic_string_view(__s));
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
{
return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
}
// find
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
return __str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
{
return __str_find<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find(const _CharT* __s, size_type __pos, size_type __n) const
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
return __str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find(const _CharT* __s, size_type __pos = 0) const
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
return __str_find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
// rfind
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
return __str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
{
return __str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
return __str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type rfind(const _CharT* __s, size_type __pos=npos) const
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
return __str_rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
// find_first_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
return __str_find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
{ return find(__c, __pos); }
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
return __str_find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_of(const _CharT* __s, size_type __pos=0) const
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
return __str_find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
// find_last_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
return __str_find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
{ return rfind(__c, __pos); }
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
return __str_find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
return __str_find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
// find_first_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
{
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
// find_last_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s.data(), __pos, __s.size());
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
{
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
private:
const value_type* __data;
size_type __size;
};
// [string.view.comparison]
// operator ==
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
if ( __lhs.size() != __rhs.size()) return false;
return __lhs.compare(__rhs) == 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
{
if ( __lhs.size() != __rhs.size()) return false;
return __lhs.compare(__rhs) == 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
if ( __lhs.size() != __rhs.size()) return false;
return __lhs.compare(__rhs) == 0;
}
// operator !=
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
if ( __lhs.size() != __rhs.size())
return true;
return __lhs.compare(__rhs) != 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
{
if ( __lhs.size() != __rhs.size())
return true;
return __lhs.compare(__rhs) != 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
if ( __lhs.size() != __rhs.size())
return true;
return __lhs.compare(__rhs) != 0;
}
// operator <
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) < 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator<(basic_string_view<_CharT, _Traits> __lhs,
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) < 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) < 0;
}
// operator >
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) > 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator>(basic_string_view<_CharT, _Traits> __lhs,
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) > 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) > 0;
}
// operator <=
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) <= 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) <= 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) <= 0;
}
// operator >=
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) >= 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) >= 0;
}
template<class _CharT, class _Traits>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
{
return __lhs.compare(__rhs) >= 0;
}
typedef basic_string_view<char> string_view;
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
// [string.view.hash]
template<class _CharT, class _Traits>
struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, _Traits> >
: public unary_function<basic_string_view<_CharT, _Traits>, size_t>
{
size_t operator()(const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT;
};
template<class _CharT, class _Traits>
size_t
hash<basic_string_view<_CharT, _Traits> >::operator()(
const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT
{
return __do_string_hash(__val.data(), __val.data() + __val.size());
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STRING_VIEW

View File

@ -46,6 +46,12 @@ template <class T> struct is_error_code_enum
template <class T> struct is_error_condition_enum
: public false_type {};
template <class _Tp>
constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17
template <class _Tp>
constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17
class error_code
{
public:
@ -213,6 +219,7 @@ bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;
bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;
template <> struct hash<std::error_code>;
template <> struct hash<std::error_condition>;
} // std
@ -233,15 +240,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// is_error_code_enum
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum
: public false_type {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value;
#endif
// is_error_condition_enum
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum
struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum
: public false_type {};
#if _LIBCPP_STD_VER > 14
template <class _Tp>
constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value;
#endif
// Some error codes are not present on all platforms, so we provide equivalents
// for them:
@ -346,12 +363,12 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc)
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc>
struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc>
: true_type { };
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc::__lx>
struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx>
: true_type { };
#endif
@ -367,7 +384,8 @@ class _LIBCPP_TYPE_VIS error_category
public:
virtual ~error_category() _NOEXCEPT;
#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \
defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
error_category() _NOEXCEPT;
#else
_LIBCPP_ALWAYS_INLINE
@ -603,7 +621,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
{return !(__x == __y);}
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<error_code>
struct _LIBCPP_TEMPLATE_VIS hash<error_code>
: public unary_function<error_code, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -613,6 +631,17 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<error_code>
}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<error_condition>
: public unary_function<error_condition, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const error_condition& __ec) const _NOEXCEPT
{
return static_cast<size_t>(__ec.value());
}
};
// system_error
class _LIBCPP_TYPE_VIS system_error
@ -635,7 +664,8 @@ private:
static string __init(const error_code&, string);
};
_LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg);
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
void __throw_system_error(int ev, const char* what_arg);
_LIBCPP_END_NAMESPACE_STD

View File

@ -99,6 +99,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#include <tuple>
#endif
#include <__threading_support>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@ -136,7 +137,7 @@ public:
template <class _Tp>
class __thread_specific_ptr
{
__libcpp_tl_key __key_;
__libcpp_tls_key __key_;
// Only __thread_local_data() may construct a __thread_specific_ptr
// and only with _Tp == __thread_struct.
@ -154,13 +155,12 @@ public:
~__thread_specific_ptr();
_LIBCPP_INLINE_VISIBILITY
pointer get() const {return static_cast<_Tp*>(__libcpp_tl_get(__key_));}
pointer get() const {return static_cast<_Tp*>(__libcpp_tls_get(__key_));}
_LIBCPP_INLINE_VISIBILITY
pointer operator*() const {return *get();}
_LIBCPP_INLINE_VISIBILITY
pointer operator->() const {return get();}
pointer release();
void reset(pointer __p = nullptr);
void set_pointer(pointer __p);
};
template <class _Tp>
@ -173,7 +173,7 @@ __thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
template <class _Tp>
__thread_specific_ptr<_Tp>::__thread_specific_ptr()
{
int __ec = __libcpp_tl_create(
int __ec = __libcpp_tls_create(
&__key_,
&__thread_specific_ptr::__at_thread_exit);
if (__ec)
@ -190,22 +190,13 @@ __thread_specific_ptr<_Tp>::~__thread_specific_ptr()
// thread local data. For this reason we leak the key.
}
template <class _Tp>
typename __thread_specific_ptr<_Tp>::pointer
__thread_specific_ptr<_Tp>::release()
{
pointer __p = get();
__libcpp_tl_set(__key_, nullptr);
return __p;
}
template <class _Tp>
void
__thread_specific_ptr<_Tp>::reset(pointer __p)
__thread_specific_ptr<_Tp>::set_pointer(pointer __p)
{
pointer __p_old = get();
__libcpp_tl_set(__key_, __p);
delete __p_old;
_LIBCPP_ASSERT(get() == nullptr,
"Attempting to overwrite thread local data");
__libcpp_tls_set(__key_, __p);
}
class _LIBCPP_TYPE_VIS thread;
@ -220,7 +211,7 @@ _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT;
template<> struct hash<__thread_id>;
class _LIBCPP_TYPE_VIS_ONLY __thread_id
class _LIBCPP_TEMPLATE_VIS __thread_id
{
// FIXME: pthread_t is a pointer on Darwin but a long on Linux.
// NULL is the no-thread value on Darwin. Someone needs to check
@ -263,11 +254,11 @@ private:
friend __thread_id this_thread::get_id() _NOEXCEPT;
friend class _LIBCPP_TYPE_VIS thread;
friend struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>;
friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;
};
template<>
struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>
struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>
: public unary_function<__thread_id, size_t>
{
_LIBCPP_INLINE_VISIBILITY
@ -351,7 +342,7 @@ void* __thread_proxy(void* __vp)
{
// _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
__thread_local_data().reset(_VSTD::get<0>(*__p).release());
__thread_local_data().set_pointer(_VSTD::get<0>(*__p).release());
typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
__thread_execute(*__p, _Index());
return nullptr;
@ -392,7 +383,7 @@ template <class _Fp>
void* __thread_proxy_cxx03(void* __vp)
{
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
__thread_local_data().reset(__p->__tsp_.release());
__thread_local_data().set_pointer(__p->__tsp_.release());
(__p->__fn_)();
return nullptr;
}

View File

@ -150,27 +150,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_VARIADICS
// tuple_size
template <class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
// tuple_element
template <size_t _Ip, class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
{
public:
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
};
#if _LIBCPP_STD_VER > 11
template <size_t _Ip, class ..._Tp>
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
#endif
// __tuple_leaf
@ -192,6 +171,20 @@ class __tuple_leaf
{
_Hp value;
template <class _Tp>
static constexpr bool __can_bind_reference() {
using _RawTp = typename remove_reference<_Tp>::type;
using _RawHp = typename remove_reference<_Hp>::type;
using _CheckLValueArg = integral_constant<bool,
is_lvalue_reference<_Tp>::value
|| is_same<_RawTp, reference_wrapper<_RawHp>>::value
|| is_same<_RawTp, reference_wrapper<typename remove_const<_RawHp>::type>>::value
>;
return !is_reference<_Hp>::value
|| (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
|| (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
}
__tuple_leaf& operator=(const __tuple_leaf&);
public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
@ -231,59 +224,29 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
: value(_VSTD::forward<_Tp>(__t))
{static_assert(!is_reference<_Hp>::value ||
(is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value)) ||
(is_rvalue_reference<_Hp>::value &&
!is_lvalue_reference<_Tp>::value),
{static_assert(__can_bind_reference<_Tp>(),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: value(_VSTD::forward<_Tp>(__t))
{static_assert(!is_lvalue_reference<_Hp>::value ||
(is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value)),
{static_assert(__can_bind_reference<_Tp>(),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
{static_assert(!is_lvalue_reference<_Hp>::value ||
(is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value)),
"Attempted to construct a reference element in a tuple with an rvalue");}
{static_assert(!is_reference<_Hp>::value,
"Attempted to uses-allocator construct a reference element in a tuple");}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: value(_VSTD::forward<_Tp>(__t), __a)
{static_assert(!is_lvalue_reference<_Hp>::value ||
(is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value)),
"Attempted to construct a reference element in a tuple with an rvalue");}
{static_assert(!is_reference<_Hp>::value,
"Attempted to uses-allocator construct a reference element in a tuple");}
__tuple_leaf(const __tuple_leaf& __t) = default;
__tuple_leaf(__tuple_leaf&& __t) = default;
@ -505,35 +468,21 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
}
};
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp : false_type {};
template <class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
: integral_constant<bool, _SizeTrait::value == _Expected> {};
template <class _Tuple, size_t _ExpectedSize,
class _RawTuple = typename __uncvref<_Tuple>::type>
using __tuple_like_with_size = __tuple_like_with_size_imp<
__tuple_like<_RawTuple>::value,
tuple_size<_RawTuple>, _ExpectedSize
>;
struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
template <class ...>
static constexpr bool __enable_explicit() { return false; }
template <class ...>
static constexpr bool __enable_implicit() { return false; }
};
template <class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple
class _LIBCPP_TEMPLATE_VIS tuple
{
typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
base base_;
#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
static constexpr bool _EnableImplicitReducedArityExtension = true;
#else
static constexpr bool _EnableImplicitReducedArityExtension = false;
#endif
template <class ..._Args>
struct _PackExpandsToThisTuple : false_type {};
@ -547,6 +496,11 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
template <class _Dummy>
struct _CheckArgsConstructor<true, _Dummy>
{
template <class ..._Args>
static constexpr bool __enable_default() {
return __all<is_default_constructible<_Args>::value...>::value;
}
template <class ..._Args>
static constexpr bool __enable_explicit() {
return
@ -657,12 +611,15 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
public:
template <bool _Dummy = true, class = typename enable_if<
__all<__dependent_type<is_default_constructible<_Tp>, _Dummy>::value...>::value
_CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
>::type>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR tuple()
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
tuple(tuple const&) = default;
tuple(tuple&&) = default;
template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
__lazy_and<
is_same<allocator_arg_t, _AllocArgT>,
@ -752,11 +709,17 @@ public:
) {}
template <class ..._Up,
bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
typename enable_if
<
_CheckArgsConstructor<
sizeof...(_Up) <= sizeof...(_Tp)
&& !_PackExpandsToThisTuple<_Up...>::value
sizeof...(_Up) == sizeof...(_Tp)
&& !_PackIsTuple
>::template __enable_implicit<_Up...>() ||
_CheckArgsConstructor<
_EnableImplicitReducedArityExtension
&& sizeof...(_Up) < sizeof...(_Tp)
&& !_PackIsTuple
>::template __enable_implicit<_Up...>(),
bool
>::type = false
@ -784,7 +747,12 @@ public:
_CheckArgsConstructor<
sizeof...(_Up) <= sizeof...(_Tp)
&& !_PackExpandsToThisTuple<_Up...>::value
>::template __enable_explicit<_Up...>(),
>::template __enable_explicit<_Up...>() ||
_CheckArgsConstructor<
!_EnableImplicitReducedArityExtension
&& sizeof...(_Up) < sizeof...(_Tp)
&& !_PackExpandsToThisTuple<_Up...>()
>::template __enable_implicit<_Up...>(),
bool
>::type = false
>
@ -901,6 +869,25 @@ public:
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
_LIBCPP_INLINE_VISIBILITY
tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
_NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
{
base_.operator=(__t.base_);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
_NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
{
base_.operator=(static_cast<base&&>(__t.base_));
return *this;
}
template <class _Tuple,
class = typename enable_if
<
@ -921,7 +908,7 @@ public:
};
template <>
class _LIBCPP_TYPE_VIS_ONLY tuple<>
class _LIBCPP_TEMPLATE_VIS tuple<>
{
public:
_LIBCPP_INLINE_VISIBILITY
@ -1353,9 +1340,12 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
}
template <class ..._Tp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
: true_type {};
#endif // _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_CXX03_LANG
template <class _T1, class _T2>
template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
inline _LIBCPP_INLINE_VISIBILITY
@ -1366,8 +1356,7 @@ pair<_T1, _T2>::pair(piecewise_construct_t,
second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
{
}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 14
template <class _Tp>

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ struct hash<type_index>
_LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS_ONLY type_index
class _LIBCPP_TEMPLATE_VIS type_index
{
const type_info* __t_;
public:
@ -87,10 +87,10 @@ public:
const char* name() const _NOEXCEPT {return __t_->name();}
};
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
template <>
struct _LIBCPP_TYPE_VIS_ONLY hash<type_index>
struct _LIBCPP_TEMPLATE_VIS hash<type_index>
: public unary_function<type_index, size_t>
{
_LIBCPP_INLINE_VISIBILITY

View File

@ -61,11 +61,20 @@ public:
#include <exception>
#include <cstddef>
#include <cstdint>
#ifdef _LIBCPP_NO_EXCEPTIONS
#include <cstdlib>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
#else
#define _LIBCPP_HAS_UNIQUE_TYPEINFO
#endif
namespace std // purposefully not using versioning namespace
{
@ -73,76 +82,90 @@ class _LIBCPP_EXCEPTION_ABI type_info
{
type_info& operator=(const type_info&);
type_info(const type_info&);
protected:
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
const char* __type_name;
#else
// A const char* with the non-unique RTTI bit possibly set.
uintptr_t __type_name;
#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
_LIBCPP_INLINE_VISIBILITY
int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
{ return __builtin_strcmp(name(), __arg.name()); }
#endif
protected:
#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
// A const char* with the non-unique RTTI bit possibly set.
uintptr_t __type_name;
_LIBCPP_INLINE_VISIBILITY
explicit type_info(const char* __n)
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
: __type_name(__n) {}
type_info(const char* __n) : __type_name(reinterpret_cast<uintptr_t>(__n)) {}
#else
: __type_name(reinterpret_cast<uintptr_t>(__n)) {}
const char *__type_name;
_LIBCPP_INLINE_VISIBILITY
type_info(const char* __n) : __type_name(__n) {}
#endif
public:
virtual ~type_info();
#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
_LIBCPP_INLINE_VISIBILITY
const char* name() const _NOEXCEPT
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
{return __type_name;}
#else
{return reinterpret_cast<const char*>(__type_name & ~_LIBCPP_NONUNIQUE_RTTI_BIT);}
#endif
{
return reinterpret_cast<const char*>(__type_name &
~_LIBCPP_NONUNIQUE_RTTI_BIT);
}
_LIBCPP_INLINE_VISIBILITY
bool before(const type_info& __arg) const _NOEXCEPT
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
{return __type_name < __arg.__type_name;}
#else
{if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
return __type_name < __arg.__type_name;
return __compare_nonunique_names(__arg) < 0;}
#endif
{
if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
return __type_name < __arg.__type_name;
return __compare_nonunique_names(__arg) < 0;
}
_LIBCPP_INLINE_VISIBILITY
size_t hash_code() const _NOEXCEPT
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
{return *reinterpret_cast<const size_t*>(&__type_name);}
#else
{if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
const char *__ptr = name();
size_t __hash = 5381;
while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
__hash = (__hash * 33) ^ __c;
return __hash;}
#endif
{
if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT))
return __type_name;
const char* __ptr = name();
size_t __hash = 5381;
while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
__hash = (__hash * 33) ^ __c;
return __hash;
}
_LIBCPP_INLINE_VISIBILITY
bool operator==(const type_info& __arg) const _NOEXCEPT
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
{return __type_name == __arg.__type_name;}
{
if (__type_name == __arg.__type_name)
return true;
if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
return false;
return __compare_nonunique_names(__arg) == 0;
}
#else
{if (__type_name == __arg.__type_name) return true;
if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
return false;
return __compare_nonunique_names(__arg) == 0;}
_LIBCPP_INLINE_VISIBILITY
const char* name() const _NOEXCEPT
{ return __type_name; }
_LIBCPP_INLINE_VISIBILITY
bool before(const type_info& __arg) const _NOEXCEPT
{ return __type_name < __arg.__type_name; }
_LIBCPP_INLINE_VISIBILITY
size_t hash_code() const _NOEXCEPT
{ return reinterpret_cast<size_t>(__type_name); }
_LIBCPP_INLINE_VISIBILITY
bool operator==(const type_info& __arg) const _NOEXCEPT
{ return __type_name == __arg.__type_name; }
#endif
_LIBCPP_INLINE_VISIBILITY
bool operator!=(const type_info& __arg) const _NOEXCEPT
{return !operator==(__arg);}
#ifdef _LIBCPP_NONUNIQUE_RTTI_BIT
private:
_LIBCPP_INLINE_VISIBILITY
int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
{return __builtin_strcmp(name(), __arg.name());}
#endif
{ return !operator==(__arg); }
};
class _LIBCPP_EXCEPTION_ABI bad_cast
@ -165,4 +188,16 @@ public:
} // std
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_cast()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_cast();
#else
_VSTD::abort();
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // __LIBCPP_TYPEINFO

View File

@ -641,7 +641,7 @@ private:
#endif
template <class _HashIterator>
class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator
class _LIBCPP_TEMPLATE_VIS __hash_map_iterator
{
_HashIterator __i_;
@ -682,15 +682,15 @@ public:
bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ != __y.__i_;}
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
};
template <class _HashIterator>
class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator
class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
{
_HashIterator __i_;
@ -736,15 +736,15 @@ public:
bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
{return __x.__i_ != __y.__i_;}
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
};
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
class _Alloc = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY unordered_map
class _LIBCPP_TEMPLATE_VIS unordered_map
{
public:
// types
@ -922,6 +922,8 @@ public:
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
" referring to this unordered_map");
#else
((void)__p);
#endif
return insert(__x).first;
}
@ -946,6 +948,8 @@ public:
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
" referring to this unordered_map");
#else
((void)__p);
#endif
return __table_.__insert_unique(_VSTD::move(__x)).first;
}
@ -965,6 +969,8 @@ public:
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
" referring to this unordered_map");
#else
((void)__p);
#endif
return insert(_VSTD::forward<_Pp>(__x)).first;
}
@ -982,6 +988,8 @@ public:
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
" referring to this unordered_map");
#else
((void)__p);
#endif
return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
}
@ -1012,11 +1020,13 @@ public:
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
" referring to this unordered_map");
#else
((void)__h);
#endif
return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
}
template <class... _Args>
@ -1024,9 +1034,11 @@ public:
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
" referring to this unordered_map");
#else
((void)__h);
#endif
return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
}
@ -1057,15 +1069,17 @@ public:
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v)
{
// FIXME: Add debug mode checking for the iterator input
return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v)
{
// FIXME: Add debug mode checking for the iterator input
return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
}
#endif
@ -1085,7 +1099,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void swap(unordered_map& __u)
_NOEXCEPT_(__is_nothrow_swappable<__table>::value)
{__table_.swap(__u.__table_);}
{ __table_.swap(__u.__table_);}
_LIBCPP_INLINE_VISIBILITY
hasher hash_function() const
@ -1499,7 +1513,7 @@ operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
class _Alloc = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY unordered_multimap
class _LIBCPP_TEMPLATE_VIS unordered_multimap
{
public:
// types

View File

@ -333,7 +333,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class _LIBCPP_TYPE_VIS_ONLY unordered_set
class _LIBCPP_TEMPLATE_VIS unordered_set
{
public:
// types
@ -873,7 +873,7 @@ operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class _LIBCPP_TYPE_VIS_ONLY unordered_multiset
class _LIBCPP_TEMPLATE_VIS unordered_multiset
{
public:
// types

View File

@ -171,6 +171,25 @@ template<class... T>
template<class T, class U=T>
T exchange(T& obj, U&& new_value);
// 20.2.7, in-place construction // C++17
struct in_place_t {
explicit in_place_t() = default;
};
inline constexpr in_place_t in_place{};
template <class T>
struct in_place_type_t {
explicit in_place_type_t() = default;
};
template <class T>
inline constexpr in_place_type_t<T> in_place_type{};
template <size_t I>
struct in_place_index_t {
explicit in_place_index_t() = default;
};
template <size_t I>
inline constexpr in_place_index_t<I> in_place_index{};
} // std
*/
@ -179,6 +198,7 @@ template<class T, class U=T>
#include <__tuple>
#include <type_traits>
#include <initializer_list>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@ -269,15 +289,27 @@ template <class _Tp> constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { r
template <class _Tp> void as_const(const _Tp&&) = delete;
#endif
struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { };
struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { };
#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY)
extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
#else
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
#endif
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
struct __non_trivially_copyable_base {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
__non_trivially_copyable_base() _NOEXCEPT {}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
};
#endif
template <class _T1, class _T2>
struct _LIBCPP_TYPE_VIS_ONLY pair
struct _LIBCPP_TEMPLATE_VIS pair
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
: private __non_trivially_copyable_base
#endif
{
typedef _T1 first_type;
typedef _T2 second_type;
@ -285,56 +317,179 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
_T1 first;
_T2 second;
#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
template <bool _Dummy = true, class = typename enable_if<
__dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
__dependent_type<is_default_constructible<_T2>, _Dummy>::value
>::type>
#endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(const _T1& __x, const _T2& __y)
: first(__x), second(__y) {}
template<class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(const pair<_U1, _U2>& __p
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
,typename enable_if<is_convertible<const _U1&, _T1>::value &&
is_convertible<const _U2&, _T2>::value>::type* = 0
#endif
)
: first(__p.first), second(__p.second) {}
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
_LIBCPP_INLINE_VISIBILITY
pair(const pair& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
is_nothrow_copy_constructible<second_type>::value)
: first(__p.first),
second(__p.second)
{
}
# ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
is_nothrow_move_constructible<second_type>::value)
: first(_VSTD::forward<first_type>(__p.first)),
second(_VSTD::forward<second_type>(__p.second))
{
}
# endif
#elif !defined(_LIBCPP_CXX03_LANG)
#if !defined(_LIBCPP_CXX03_LANG)
pair(pair const&) = default;
pair(pair&&) = default;
#else
// Use the implicitly declared copy constructor in C++03
#endif
#ifdef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
pair& operator=(const pair& __p)
pair() : first(), second() {}
_LIBCPP_INLINE_VISIBILITY
pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {}
template <class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY
pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
_LIBCPP_INLINE_VISIBILITY
pair& operator=(pair const& __p) {
first = __p.first;
second = __p.second;
return *this;
}
#else
template <bool _Val>
using _EnableB = typename enable_if<_Val, bool>::type;
struct _CheckArgs {
template <class _U1, class _U2>
static constexpr bool __enable_default() {
return is_default_constructible<_U1>::value
&& is_default_constructible<_U2>::value;
}
template <class _U1, class _U2>
static constexpr bool __enable_explicit() {
return is_constructible<first_type, _U1>::value
&& is_constructible<second_type, _U2>::value
&& (!is_convertible<_U1, first_type>::value
|| !is_convertible<_U2, second_type>::value);
}
template <class _U1, class _U2>
static constexpr bool __enable_implicit() {
return is_constructible<first_type, _U1>::value
&& is_constructible<second_type, _U2>::value
&& is_convertible<_U1, first_type>::value
&& is_convertible<_U2, second_type>::value;
}
};
template <bool _MaybeEnable>
using _CheckArgsDep = typename conditional<
_MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
struct _CheckTupleLikeConstructor {
template <class _Tuple>
static constexpr bool __enable_implicit() {
return __tuple_convertible<_Tuple, pair>::value;
}
template <class _Tuple>
static constexpr bool __enable_explicit() {
return __tuple_constructible<_Tuple, pair>::value
&& !__tuple_convertible<_Tuple, pair>::value;
}
template <class _Tuple>
static constexpr bool __enable_assign() {
return __tuple_assignable<_Tuple, pair>::value;
}
};
template <class _Tuple>
using _CheckTLC = typename conditional<
__tuple_like_with_size<_Tuple, 2>::value
&& !is_same<typename decay<_Tuple>::type, pair>::value,
_CheckTupleLikeConstructor,
__check_tuple_constructor_fail
>::type;
template<bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
pair() : 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)
: first(__t1), second(__t2) {}
template<bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_T1 const& __t1, _T2 const& __t2)
: first(__t1), second(__t2) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_U1&& __u1, _U2&& __u2)
: first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_U1&& __u1, _U2&& __u2)
: first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(pair<_U1, _U2> const& __p)
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2> const& __p)
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(pair<_U1, _U2>&&__p)
: first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1, _U2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2>&& __p)
: first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
template<class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_Tuple&& __p)
: first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
template<class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_Tuple&& __p)
: first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
template <class... _Args1, class... _Args2>
_LIBCPP_INLINE_VISIBILITY
pair(piecewise_construct_t __pc,
tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
: pair(__pc, __first_args, __second_args,
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
_LIBCPP_INLINE_VISIBILITY
pair& operator=(typename conditional<
is_copy_assignable<first_type>::value &&
is_copy_assignable<second_type>::value,
pair, __nat>::type const& __p)
_NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
is_nothrow_copy_assignable<second_type>::value)
{
@ -343,75 +498,30 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
return *this;
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _U1, class _U2,
class = typename enable_if<is_convertible<_U1, first_type>::value &&
is_convertible<_U2, second_type>::value>::type>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_U1&& __u1, _U2&& __u2)
: first(_VSTD::forward<_U1>(__u1)),
second(_VSTD::forward<_U2>(__u2))
{}
template<class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2>&& __p,
typename enable_if<is_convertible<_U1, _T1>::value &&
is_convertible<_U2, _T2>::value>::type* = 0)
: first(_VSTD::forward<_U1>(__p.first)),
second(_VSTD::forward<_U2>(__p.second)) {}
_LIBCPP_INLINE_VISIBILITY
pair&
operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value)
pair& operator=(typename conditional<
is_move_assignable<first_type>::value &&
is_move_assignable<second_type>::value,
pair, __nat>::type&& __p)
_NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value)
{
first = _VSTD::forward<first_type>(__p.first);
second = _VSTD::forward<second_type>(__p.second);
return *this;
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
> = false>
_LIBCPP_INLINE_VISIBILITY
pair& operator=(_Tuple&& __p) {
first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
return *this;
}
#endif
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_Tuple&& __p)
: first(_VSTD::forward<typename tuple_element<0,
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<0>(__p))),
second(_VSTD::forward<typename tuple_element<1,
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p)))
{}
template <class... _Args1, class... _Args2>
_LIBCPP_INLINE_VISIBILITY
pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args)
: pair(__pc, __first_args, __second_args,
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type())
{}
template <class _Tuple,
class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
pair&
operator=(_Tuple&& __p)
{
typedef typename __make_tuple_types<_Tuple>::type _TupleRef;
typedef typename tuple_element<0, _TupleRef>::type _U0;
typedef typename tuple_element<1, _TupleRef>::type _U1;
first = _VSTD::forward<_U0>(_VSTD::get<0>(__p));
second = _VSTD::forward<_U1>(_VSTD::get<1>(__p));
return *this;
}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
void
swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
@ -423,13 +533,13 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
}
private:
#ifndef _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>);
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif
};
template <class _T1, class _T2>
@ -538,18 +648,18 @@ make_pair(_T1 __x, _T2 __y)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> >
class _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> >
class _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
{
public:
typedef _T1 type;
};
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> >
class _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> >
{
public:
typedef _T2 type;
@ -719,7 +829,7 @@ constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
#if _LIBCPP_STD_VER > 11
template<class _Tp, _Tp... _Ip>
struct _LIBCPP_TYPE_VIS_ONLY integer_sequence
struct _LIBCPP_TEMPLATE_VIS integer_sequence
{
typedef _Tp value_type;
static_assert( is_integral<_Tp>::value,
@ -782,6 +892,44 @@ _T1 exchange(_T1& __obj, _T2 && __new_value)
}
#endif // _LIBCPP_STD_VER > 11
#if _LIBCPP_STD_VER > 14
struct _LIBCPP_TYPE_VIS in_place_t {
explicit in_place_t() = default;
};
#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES
inline
#endif
constexpr in_place_t in_place{};
template <class _Tp>
struct _LIBCPP_TYPE_VIS in_place_type_t {
explicit in_place_type_t() = default;
};
template <class _Tp>
#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES
inline
#endif
constexpr in_place_type_t<_Tp> in_place_type{};
template <size_t _Idx>
struct _LIBCPP_TYPE_VIS in_place_index_t {
explicit in_place_index_t() = default;
};
template <size_t _Idx>
#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES
inline
#endif
constexpr in_place_index_t<_Idx> in_place_index{};
template <class _Tp> struct __is_inplace_type_imp : false_type {};
template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
template <class _Tp>
using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>;
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_UTILITY

View File

@ -356,9 +356,9 @@ template <class T> unspecified2 end(const valarray<T>& v);
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY valarray;
template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
class _LIBCPP_TYPE_VIS_ONLY slice
class _LIBCPP_TEMPLATE_VIS slice
{
size_t __start_;
size_t __size_;
@ -383,11 +383,11 @@ public:
_LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
};
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY slice_array;
template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
class _LIBCPP_TYPE_VIS gslice;
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY gslice_array;
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY mask_array;
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY indirect_array;
template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
@ -673,7 +673,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __size_;}
template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
};
template <class _ValExpr>
@ -788,7 +788,7 @@ template<class _Tp>
struct __is_val_expr<valarray<_Tp> > : true_type {};
template<class _Tp>
class _LIBCPP_TYPE_VIS_ONLY valarray
class _LIBCPP_TEMPLATE_VIS valarray
{
public:
typedef _Tp value_type;
@ -802,8 +802,8 @@ public:
// construct/destroy:
_LIBCPP_INLINE_VISIBILITY
valarray() : __begin_(0), __end_(0) {}
_LIBCPP_INLINE_VISIBILITY
inline explicit valarray(size_t __n);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
explicit valarray(size_t __n);
_LIBCPP_INLINE_VISIBILITY
valarray(const value_type& __x, size_t __n);
valarray(const value_type* __p, size_t __n);
@ -819,7 +819,7 @@ public:
valarray(const gslice_array<value_type>& __ga);
valarray(const mask_array<value_type>& __ma);
valarray(const indirect_array<value_type>& __ia);
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
~valarray();
// assignment:
@ -1028,12 +1028,12 @@ public:
void resize(size_t __n, value_type __x = value_type());
private:
template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY slice_array;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY gslice_array;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY mask_array;
template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
template <class> friend class __mask_expr;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY indirect_array;
template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
template <class> friend class __indirect_expr;
template <class> friend class __val_expr;
@ -1147,7 +1147,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
// slice_array
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY slice_array
class _LIBCPP_TEMPLATE_VIS slice_array
{
public:
typedef _Tp value_type;
@ -1531,7 +1531,7 @@ private:
// gslice_array
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY gslice_array
class _LIBCPP_TEMPLATE_VIS gslice_array
{
public:
typedef _Tp value_type;
@ -1869,7 +1869,7 @@ gslice_array<_Tp>::operator=(const value_type& __x) const
// mask_array
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY mask_array
class _LIBCPP_TEMPLATE_VIS mask_array
{
public:
typedef _Tp value_type;
@ -2227,7 +2227,7 @@ public:
// indirect_array
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY indirect_array
class _LIBCPP_TEMPLATE_VIS indirect_array
{
public:
typedef _Tp value_type;
@ -2591,7 +2591,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __1d_.size();}
template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
};
template<class _ValExpr>

File diff suppressed because it is too large Load Diff

View File

@ -99,7 +99,7 @@ public:
void push_back(const value_type& x);
void push_back(value_type&& x);
template <class... Args>
void emplace_back(Args&&... args);
reference emplace_back(Args&&... args);
void pop_back();
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
@ -218,7 +218,7 @@ public:
const_reference back() const;
void push_back(const value_type& x);
template <class... Args> void emplace_back(Args&&... args); // C++14
template <class... Args> reference emplace_back(Args&&... args); // C++14
void pop_back();
template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14
@ -290,37 +290,29 @@ class __vector_base_common
{
protected:
_LIBCPP_ALWAYS_INLINE __vector_base_common() {}
void __throw_length_error() const;
void __throw_out_of_range() const;
_LIBCPP_NORETURN void __throw_length_error() const;
_LIBCPP_NORETURN void __throw_out_of_range() const;
};
template <bool __b>
void
__vector_base_common<__b>::__throw_length_error() const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw length_error("vector");
#else
assert(!"vector length_error");
#endif
_VSTD::__throw_length_error("vector");
}
template <bool __b>
void
__vector_base_common<__b>::__throw_out_of_range() const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("vector");
#else
assert(!"vector out_of_range");
#endif
_VSTD::__throw_out_of_range("vector");
}
#ifdef _LIBCPP_MSVC
#pragma warning( push )
#pragma warning( disable: 4231 )
#endif // _LIBCPP_MSVC
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __vector_base_common<true>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>)
#ifdef _LIBCPP_MSVC
#pragma warning( pop )
#endif // _LIBCPP_MSVC
@ -455,7 +447,7 @@ __vector_base<_Tp, _Allocator>::~__vector_base()
}
template <class _Tp, class _Allocator /* = allocator<_Tp> */>
class _LIBCPP_TYPE_VIS_ONLY vector
class _LIBCPP_TEMPLATE_VIS vector
: private __vector_base<_Tp, _Allocator>
{
private:
@ -687,7 +679,7 @@ public:
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
void emplace_back(_Args&&... __args);
reference emplace_back(_Args&&... __args);
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
@ -746,9 +738,9 @@ public:
void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
_NOEXCEPT_DEBUG;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
@ -765,6 +757,7 @@ public:
private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
void allocate(size_type __n);
void deallocate() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
@ -794,21 +787,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
--__p;
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
if (__i->base() > __new_last)
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
#endif
__invalidate_iterators_past(__new_last);
size_type __old_size = size();
__base::__destruct_at_end(__new_last);
__annotate_shrink(__old_size);
@ -829,30 +808,40 @@ private:
// We call annotatations only for the default Allocator because other allocators
// may not meet the AddressSanitizer alignment constraints.
// See the documentation for __sanitizer_annotate_contiguous_container for more details.
void __annotate_contiguous_container
(const void *__beg, const void *__end, const void *__old_mid, const void *__new_mid) const
{
#ifndef _LIBCPP_HAS_NO_ASAN
void __annotate_contiguous_container(const void *__beg, const void *__end,
const void *__old_mid,
const void *__new_mid) const
{
if (__beg && is_same<allocator_type, __default_allocator_type>::value)
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
#endif
}
void __annotate_new(size_type __current_size) const
{
#else
_LIBCPP_INLINE_VISIBILITY
void __annotate_contiguous_container(const void*, const void*, const void*,
const void*) const {}
#endif
_LIBCPP_INLINE_VISIBILITY
void __annotate_new(size_type __current_size) const {
__annotate_contiguous_container(data(), data() + capacity(),
data() + capacity(), data() + __current_size);
}
void __annotate_delete() const
{
_LIBCPP_INLINE_VISIBILITY
void __annotate_delete() const {
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + capacity());
}
_LIBCPP_INLINE_VISIBILITY
void __annotate_increase(size_type __n) const
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + size() + __n);
}
_LIBCPP_INLINE_VISIBILITY
void __annotate_shrink(size_type __old_size) const
{
__annotate_contiguous_container(data(), data() + capacity(),
@ -877,8 +866,9 @@ private:
};
#else
struct __RAII_IncreaseAnnotator {
inline __RAII_IncreaseAnnotator(const vector &, size_type __n = 1) {}
inline void __done() {}
_LIBCPP_INLINE_VISIBILITY
__RAII_IncreaseAnnotator(const vector &, size_type = 1) {}
_LIBCPP_INLINE_VISIBILITY void __done() {}
};
#endif
@ -949,7 +939,8 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
{
return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2); // end() >= begin(), always
return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()),
numeric_limits<difference_type>::max());
}
// Precondition: __new_size > capacity()
@ -1411,6 +1402,7 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
allocate(__recommend(__new_size));
__construct_at_end(__first, __last, __new_size);
}
__invalidate_all_iterators();
}
template <class _Tp, class _Allocator>
@ -1432,6 +1424,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
allocate(__recommend(static_cast<size_type>(__n)));
__construct_at_end(__n, __u);
}
__invalidate_all_iterators();
}
template <class _Tp, class _Allocator>
@ -1632,7 +1625,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
template <class _Tp, class _Allocator>
template <class... _Args>
inline
void
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
if (this->__end_ < this->__end_cap())
@ -1646,6 +1639,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
else
__emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
return this->back();
}
#endif // _LIBCPP_HAS_NO_VARIADICS
@ -1674,8 +1668,9 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
"vector::erase(iterator) called with a non-dereferenceable iterator");
difference_type __ps = __position - cbegin();
pointer __p = this->__begin_ + __ps;
iterator __r = __make_iter(__p);
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
this->__invalidate_iterators_past(__p-1);
iterator __r = __make_iter(__p);
return __r;
}
@ -1687,12 +1682,17 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
"vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
"vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
#endif
_LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
pointer __p = this->__begin_ + (__first - begin());
iterator __r = __make_iter(__p);
if (__first != __last)
if (__first != __last) {
this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
this->__invalidate_iterators_past(__p - 1);
}
iterator __r = __make_iter(__p);
return __r;
}
@ -2013,9 +2013,9 @@ template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
_NOEXCEPT_DEBUG
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
@ -2098,6 +2098,28 @@ vector<_Tp, _Allocator>::__invalidate_all_iterators()
#endif // _LIBCPP_DEBUG_LEVEL >= 2
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
#if _LIBCPP_DEBUG_LEVEL >= 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
--__p;
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
if (__i->base() > __new_last) {
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
#else
((void)__new_last);
#endif
}
// vector<bool>
template <class _Allocator> class vector<bool, _Allocator>;
@ -2111,7 +2133,7 @@ struct __has_storage_type<vector<bool, _Allocator> >
};
template <class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY vector<bool, _Allocator>
class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator>
: private __vector_base_common<true>
{
public:
@ -2314,8 +2336,10 @@ public:
void push_back(const value_type& __x);
#if _LIBCPP_STD_VER > 11
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
{ push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); }
_LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) {
push_back ( value_type ( _VSTD::forward<_Args>(__args)... ));
return this->back();
}
#endif
_LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
@ -2360,7 +2384,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
static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
@ -2448,7 +2472,7 @@ private:
friend class __bit_iterator<vector, false>;
friend class __bit_iterator<vector, true>;
friend struct __bit_array<vector>;
friend struct _LIBCPP_TYPE_VIS_ONLY hash<vector>;
friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;
};
template <class _Allocator>
@ -2891,6 +2915,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
}
_VSTD::fill_n(begin(), __n, __x);
}
__invalidate_all_iterators();
}
template <class _Allocator>
@ -2918,7 +2943,9 @@ typename enable_if
vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
clear();
difference_type __n = _VSTD::distance(__first, __last);
difference_type __ns = _VSTD::distance(__first, __last);
_LIBCPP_ASSERT(__ns >= 0, "invalid range specified");
const size_t __n = static_cast<size_type>(__ns);
if (__n)
{
if (__n > capacity())
@ -3097,7 +3124,9 @@ typename enable_if
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
{
difference_type __n = _VSTD::distance(__first, __last);
const difference_type __n_signed = _VSTD::distance(__first, __last);
_LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");
const size_type __n = static_cast<size_type>(__n_signed);
iterator __r;
size_type __c = capacity();
if (__n <= __c && size() <= __c - __n)
@ -3148,7 +3177,7 @@ vector<bool, _Allocator>::swap(vector& __x)
#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
{
@ -3246,7 +3275,7 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
}
template <class _Allocator>
struct _LIBCPP_TYPE_VIS_ONLY hash<vector<bool, _Allocator> >
struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
: public unary_function<vector<bool, _Allocator>, size_t>
{
_LIBCPP_INLINE_VISIBILITY

View File

@ -48,7 +48,7 @@ template bool __insertion_sort_incomplete<__less<long double>&, long double*>(lo
template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
#ifndef _LIBCPP_HAS_NO_THREADS
static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
#endif
unsigned __rs_default::__c_ = 0;

View File

@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
#include "any"
#include "experimental/any"
_LIBCPP_BEGIN_NAMESPACE_LFTS
namespace std {
const char* bad_any_cast::what() const _NOEXCEPT {
return "bad any cast";
}
}
_LIBCPP_BEGIN_NAMESPACE_LFTS
const char* bad_any_cast::what() const _NOEXCEPT {
return "bad any cast";
}
_LIBCPP_END_NAMESPACE_LFTS

View File

@ -12,14 +12,23 @@
#include "system_error" // __throw_system_error
#include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
#if defined(_LIBCPP_WIN32API)
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRA_LEAN
#include <Windows.h>
#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
#include <winapifamily.h>
#endif
#else
#if !defined(CLOCK_REALTIME)
#include <sys/time.h> // for gettimeofday and timeval
#endif
#endif // !defined(CLOCK_REALTIME)
#endif // defined(_LIBCPP_WIN32API)
#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(CLOCK_MONOTONIC)
#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
#if __APPLE__
#include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
#else
#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
#error "Monotonic clock not implemented"
#endif
#endif
@ -36,6 +45,31 @@ const bool system_clock::is_steady;
system_clock::time_point
system_clock::now() _NOEXCEPT
{
#if defined(_LIBCPP_WIN32API)
// FILETIME is in 100ns units
using filetime_duration =
_VSTD::chrono::duration<__int64,
_VSTD::ratio_multiply<_VSTD::ratio<100, 1>,
nanoseconds::period>>;
// The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
FILETIME ft;
#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
GetSystemTimePreciseAsFileTime(&ft);
#else
GetSystemTimeAsFileTime(&ft);
#endif
#else
GetSystemTimeAsFileTime(&ft);
#endif
filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
return time_point(duration_cast<duration>(d - nt_to_unix_epoch));
#else
#ifdef CLOCK_REALTIME
struct timespec tp;
if (0 != clock_gettime(CLOCK_REALTIME, &tp))
@ -46,6 +80,7 @@ system_clock::now() _NOEXCEPT
gettimeofday(&tv, 0);
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
#endif // CLOCK_REALTIME
#endif
}
time_t
@ -69,18 +104,7 @@ system_clock::from_time_t(time_t t) _NOEXCEPT
const bool steady_clock::is_steady;
#ifdef CLOCK_MONOTONIC
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
struct timespec tp;
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
}
#elif defined(__APPLE__)
#if defined(__APPLE__)
// mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
// nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom
@ -90,8 +114,6 @@ steady_clock::now() _NOEXCEPT
// MachInfo.numer / MachInfo.denom is often 1 on the latest equipment. Specialize
// for that case as an optimization.
#pragma GCC visibility push(hidden)
static
steady_clock::rep
steady_simplified()
@ -129,8 +151,6 @@ init_steady_clock()
return &steady_full;
}
#pragma GCC visibility pop
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
@ -138,6 +158,32 @@ steady_clock::now() _NOEXCEPT
return time_point(duration(fp()));
}
#elif defined(_LIBCPP_WIN32API)
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
static LARGE_INTEGER freq;
static BOOL initialized = FALSE;
if (!initialized)
initialized = QueryPerformanceFrequency(&freq); // always succceeds
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
return time_point(duration(counter.QuadPart * nano::den / freq.QuadPart));
}
#elif defined(CLOCK_MONOTONIC)
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
struct timespec tp;
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
}
#else
#error "Monotonic clock not implemented"
#endif

View File

@ -79,6 +79,12 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
void
notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
{
auto& tl_ptr = __thread_local_data();
// If this thread was not created using std::thread then it will not have
// previously allocated.
if (tl_ptr.get() == nullptr) {
tl_ptr.set_pointer(new __thread_struct);
}
__thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
}

View File

@ -7,16 +7,79 @@
//
//===----------------------------------------------------------------------===//
#define _LIBCPP_DEBUG 1
#include "__config"
#include "__debug"
#include "functional"
#include "algorithm"
#include "string"
#include "cstdio"
#include "__hash_table"
#include "mutex"
_LIBCPP_BEGIN_NAMESPACE_STD
static std::string make_what_str(__libcpp_debug_info const& info) {
string msg = info.__file_;
msg += ":" + to_string(info.__line_) + ": _LIBCPP_ASSERT '";
msg += info.__pred_;
msg += "' failed. ";
msg += info.__msg_;
return msg;
}
_LIBCPP_SAFE_STATIC __libcpp_debug_function_type
__libcpp_debug_function = __libcpp_abort_debug_function;
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
__libcpp_debug_function = __func;
return true;
}
_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
std::fprintf(stderr, "%s\n", make_what_str(info).c_str());
std::abort();
}
_LIBCPP_NORETURN void __libcpp_throw_debug_function(__libcpp_debug_info const& info) {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw __libcpp_debug_exception(info);
#else
__libcpp_abort_debug_function(info);
#endif
}
struct __libcpp_debug_exception::__libcpp_debug_exception_imp {
__libcpp_debug_info __info_;
std::string __what_str_;
};
__libcpp_debug_exception::__libcpp_debug_exception() _NOEXCEPT
: __imp_(nullptr) {
}
__libcpp_debug_exception::__libcpp_debug_exception(
__libcpp_debug_info const& info) : __imp_(new __libcpp_debug_exception_imp)
{
__imp_->__info_ = info;
__imp_->__what_str_ = make_what_str(info);
}
__libcpp_debug_exception::__libcpp_debug_exception(
__libcpp_debug_exception const& other) : __imp_(nullptr) {
if (other.__imp_)
__imp_ = new __libcpp_debug_exception_imp(*other.__imp_);
}
__libcpp_debug_exception::~__libcpp_debug_exception() _NOEXCEPT {
if (__imp_)
delete __imp_;
}
const char* __libcpp_debug_exception::what() const _NOEXCEPT {
if (__imp_)
return __imp_->__what_str_.c_str();
return "__libcpp_debug_exception";
}
_LIBCPP_FUNC_VIS
__libcpp_db*
__get_db()
@ -152,11 +215,8 @@ __libcpp_db::__insert_c(void* __c)
size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
__c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(void*)));
if (cbeg == nullptr)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_alloc();
#else
abort();
#endif
__throw_bad_alloc();
for (__c_node** p = __cbeg_; p != __cend_; ++p)
{
__c_node* q = *p;
@ -178,11 +238,8 @@ __libcpp_db::__insert_c(void* __c)
__c_node* r = __cbeg_[hc] =
static_cast<__c_node*>(malloc(sizeof(__c_node)));
if (__cbeg_[hc] == nullptr)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_alloc();
#else
abort();
#endif
__throw_bad_alloc();
r->__c_ = __c;
r->__next_ = p;
++__csz_;
@ -475,11 +532,8 @@ __c_node::__add(__i_node* i)
__i_node** beg =
static_cast<__i_node**>(malloc(nc * sizeof(__i_node*)));
if (beg == nullptr)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_alloc();
#else
abort();
#endif
__throw_bad_alloc();
if (nc > 1)
memcpy(beg, beg_, nc/2*sizeof(__i_node*));
free(beg_);
@ -501,11 +555,8 @@ __libcpp_db::__insert_iterator(void* __i)
size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1);
__i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(void*)));
if (ibeg == nullptr)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_alloc();
#else
abort();
#endif
__throw_bad_alloc();
for (__i_node** p = __ibeg_; p != __iend_; ++p)
{
__i_node* q = *p;
@ -527,11 +578,8 @@ __libcpp_db::__insert_iterator(void* __i)
__i_node* r = __ibeg_[hi] =
static_cast<__i_node*>(malloc(sizeof(__i_node)));
if (r == nullptr)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_alloc();
#else
abort();
#endif
__throw_bad_alloc();
::new(r) __i_node(__i, p, nullptr);
++__isz_;
return r;

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