Import libc++ trunk r224926. This fixes a number of bugs, completes
C++14 support[1], adds more C++1z features[2], and fixes the following LWG issues[3]: 1450: Contradiction in regex_constants 2003: String exception inconsistency in erase. 2075: Progress guarantees, lock-free property, and scheduling assumptions 2104: unique_lock move-assignment should not be noexcept 2112: User-defined classes that cannot be derived from 2132: std::function ambiguity 2135: Unclear requirement for exceptions thrown in condition_variable::wait() 2142: packaged_task::operator() synchronization too broad? 2182: Container::[const_]reference types are misleadingly specified 2186: Incomplete action on async/launch::deferred 2188: Reverse iterator does not fully support targets that overload operator& 2193: Default constructors for standard library containers are explicit 2205: Problematic postconditions of regex_match and regex_search 2213: Return value of std::regex_replace 2240: Probable misuse of term "function scope" in [thread.condition] 2252: Strong guarantee on vector::push_back() still broken with C++11? 2257: Simplify container requirements with the new algorithms 2258: a.erase(q1, q2) unable to directly return q2 2263: Comparing iterators and allocator pointers with different const-character 2268: Setting a default argument in the declaration of a member function assign of std::basic_string 2271: regex_traits::lookup_classname specification unclear 2272: quoted should use char_traits::eq for character comparison 2278: User-defined literals for Standard Library types 2280: begin / end for arrays should be constexpr and noexcept 2285: make_reverse_iterator 2288: Inconsistent requirements for shared mutexes 2291: std::hash is vulnerable to collision DoS attack 2293: Wrong facet used by num_put::do_put 2299: Effects of inaccessible key_compare::is_transparent type are not clear 2301: Why is std::tie not constexpr? 2304: Complexity of count in unordered associative containers 2306: match_results::reference should be value_type&, not const value_type& 2308: Clarify container destructor requirements w.r.t. std::array 2313: tuple_size should always derive from integral_constant<size_t, N> 2314: apply() should return decltype(auto) and use decay_t before tuple_size 2315: weak_ptr should be movable 2316: weak_ptr::lock() should be atomic 2317: The type property queries should be UnaryTypeTraits returning size_t 2320: select_on_container_copy_construction() takes allocators, not containers 2322: Associative(initializer_list, stuff) constructors are underspecified 2323: vector::resize(n, t)'s specification should be simplified 2324: Insert iterator constructors should use addressof() 2329: regex_match()/regex_search() with match_results should forbid temporary strings 2330: regex("meow", regex::icase) is technically forbidden but should be permitted 2332: regex_iterator/regex_token_iterator should forbid temporary regexes 2339: Wording issue in nth_element 2341: Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir) 2344: quoted()'s interaction with padding is unclear 2346: integral_constant's member functions should be marked noexcept 2350: min, max, and minmax should be constexpr 2356: Stability of erasure in unordered associative containers 2357: Remaining "Assignable" requirement 2359: How does regex_constants::nosubs affect basic_regex::mark_count()? 2360: reverse_iterator::operator*() is unimplementable [1] http://libcxx.llvm.org/cxx1y_status.html [2] http://libcxx.llvm.org/cxx1z_status.html [3] http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html Exp-run: antoine MFC after: 1 month
This commit is contained in:
commit
d72607e9e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277217
@ -33,6 +33,10 @@ E: mclow.lists@gmail.com
|
||||
E: marshall@idio.com
|
||||
D: C++14 support, patches and bug fixes.
|
||||
|
||||
N: Eric Fiselier
|
||||
E: eric@efcs.ca
|
||||
D: LFTS support, patches and bug fixes.
|
||||
|
||||
N: Bill Fisher
|
||||
E: william.w.fisher@gmail.com
|
||||
D: Regex bug fixes.
|
||||
|
@ -14,7 +14,7 @@ Full text of the relevant licenses is included below.
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@ -55,7 +55,7 @@ SOFTWARE.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -174,7 +174,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
|
||||
if (__b)
|
||||
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
|
||||
if (__n == __dn)
|
||||
return _It(__first.__seg_, __first.__ctz_ + __n);
|
||||
return __first + __n;
|
||||
__n -= __dn;
|
||||
++__first.__seg_;
|
||||
}
|
||||
@ -210,7 +210,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
|
||||
if (__b)
|
||||
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
|
||||
if (__n == __dn)
|
||||
return _It(__first.__seg_, __first.__ctz_ + __n);
|
||||
return __first + __n;
|
||||
__n -= __dn;
|
||||
++__first.__seg_;
|
||||
}
|
||||
@ -705,7 +705,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
__bit_iterator<_Cp, false>
|
||||
move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
|
||||
{
|
||||
return _VSTD::copy(__first, __last, __result);
|
||||
return _VSTD::copy_backward(__first, __last, __result);
|
||||
}
|
||||
|
||||
// swap_ranges
|
||||
|
@ -19,6 +19,11 @@
|
||||
#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||
#endif
|
||||
|
||||
#if !_WIN32
|
||||
#include <unistd.h>
|
||||
#include <errno.h> // for ELAST on FreeBSD
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_VERSION 1101
|
||||
|
||||
#define _LIBCPP_ABI_VERSION 1
|
||||
@ -106,6 +111,13 @@
|
||||
# endif
|
||||
#endif // __sun__
|
||||
|
||||
#if defined(__native_client__)
|
||||
// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
|
||||
// including accesses to the special files under /dev. C++11's
|
||||
// std::random_device is instead exposed through a NaCl syscall.
|
||||
# define _LIBCPP_USING_NACL_RANDOM
|
||||
#endif // defined(__native_client__)
|
||||
|
||||
#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
|
||||
# include <endian.h>
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
@ -194,7 +206,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXCEPTION_ABI
|
||||
#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
|
||||
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_ALWAYS_INLINE
|
||||
@ -203,6 +215,11 @@
|
||||
|
||||
#if defined(__clang__)
|
||||
|
||||
#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
|
||||
!defined(__arm__)
|
||||
#define _LIBCPP_ALTERNATE_STRING_LAYOUT
|
||||
#endif
|
||||
|
||||
#if __has_feature(cxx_alignas)
|
||||
# define _ALIGNAS_TYPE(x) alignas(x)
|
||||
# define _ALIGNAS(x) alignas(x)
|
||||
@ -215,14 +232,10 @@
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
#endif
|
||||
|
||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||
#ifdef __linux__
|
||||
#define _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
#else
|
||||
#if __cplusplus < 201103L
|
||||
typedef __char16_t char16_t;
|
||||
typedef __char32_t char32_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !(__has_feature(cxx_exceptions))
|
||||
#define _LIBCPP_NO_EXCEPTIONS
|
||||
@ -246,6 +259,8 @@ typedef __char32_t char32_t;
|
||||
# define _LIBCPP_NORETURN __attribute__ ((noreturn))
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_UNUSED __attribute__((__unused__))
|
||||
|
||||
#if !(__has_feature(cxx_defaulted_functions))
|
||||
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
#endif // !(__has_feature(cxx_defaulted_functions))
|
||||
@ -308,10 +323,16 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if !(__has_feature(cxx_relaxed_constexpr))
|
||||
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
|
||||
#if defined(__FreeBSD__)
|
||||
#define _LIBCPP_HAS_QUICK_EXIT
|
||||
#define _LIBCPP_HAS_C11_FEATURES
|
||||
#elif defined(__ANDROID__)
|
||||
#define _LIBCPP_HAS_QUICK_EXIT
|
||||
#elif defined(__linux__)
|
||||
#include <features.h>
|
||||
#if __GLIBC_PREREQ(2, 15)
|
||||
@ -326,13 +347,19 @@ typedef __char32_t char32_t;
|
||||
#if (__has_feature(cxx_noexcept))
|
||||
# define _NOEXCEPT noexcept
|
||||
# define _NOEXCEPT_(x) noexcept(x)
|
||||
# define _NOEXCEPT_OR_FALSE(x) noexcept(x)
|
||||
#else
|
||||
# define _NOEXCEPT throw()
|
||||
# define _NOEXCEPT_(x)
|
||||
# define _NOEXCEPT_OR_FALSE(x) false
|
||||
#endif
|
||||
|
||||
#if __has_feature(underlying_type)
|
||||
# define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
|
||||
# define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
|
||||
#endif
|
||||
|
||||
#if __has_feature(is_literal)
|
||||
# define _LIBCPP_IS_LITERAL(T) __is_literal(T)
|
||||
#endif
|
||||
|
||||
// Inline namespaces are available in Clang regardless of C++ dialect.
|
||||
@ -345,6 +372,10 @@ namespace std {
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
#endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
|
||||
@ -352,15 +383,33 @@ namespace std {
|
||||
|
||||
#define _LIBCPP_NORETURN __attribute__((noreturn))
|
||||
|
||||
#define _LIBCPP_UNUSED __attribute__((__unused__))
|
||||
|
||||
#if _GNUC_VER >= 407
|
||||
#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
|
||||
#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
|
||||
#endif
|
||||
|
||||
#if !__EXCEPTIONS
|
||||
#define _LIBCPP_NO_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
|
||||
// constexpr was added to GCC in 4.6.
|
||||
#if _GNUC_VER < 406
|
||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||
// Can only use constexpr in c++11 mode.
|
||||
#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
|
||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||
#endif
|
||||
|
||||
// No version of GCC supports relaxed constexpr rules
|
||||
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
|
||||
|
||||
#define _NOEXCEPT throw()
|
||||
#define _NOEXCEPT_(x)
|
||||
#define _NOEXCEPT_OR_FALSE(x) false
|
||||
|
||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||
|
||||
@ -390,9 +439,7 @@ namespace std {
|
||||
#endif
|
||||
|
||||
#if _GNUC_VER < 404
|
||||
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
#define _LIBCPP_HAS_NO_DECLTYPE
|
||||
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
#define _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
#define _LIBCPP_HAS_NO_VARIADICS
|
||||
@ -403,6 +450,11 @@ namespace std {
|
||||
#define _LIBCPP_HAS_NO_NULLPTR
|
||||
#endif
|
||||
|
||||
#if _GNUC_VER < 407
|
||||
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
|
||||
@ -415,21 +467,28 @@ namespace _LIBCPP_NAMESPACE {
|
||||
using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
#endif
|
||||
|
||||
#elif defined(_LIBCPP_MSVC)
|
||||
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
|
||||
#define _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
#define __alignof__ __alignof
|
||||
#define _LIBCPP_NORETURN __declspec(noreturn)
|
||||
#define _LIBCPP_UNUSED
|
||||
#define _ALIGNAS(x) __declspec(align(x))
|
||||
#define _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#define _NOEXCEPT throw()
|
||||
#define _NOEXCEPT throw ()
|
||||
#define _NOEXCEPT_(x)
|
||||
#define _NOEXCEPT_OR_FALSE(x) false
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
|
||||
#define _LIBCPP_END_NAMESPACE_STD }
|
||||
@ -439,15 +498,19 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
|
||||
namespace std {
|
||||
}
|
||||
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
|
||||
#elif defined(__IBMCPP__)
|
||||
|
||||
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
|
||||
#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
|
||||
#define _ATTRIBUTE(x) __attribute__((x))
|
||||
#define _LIBCPP_NORETURN __attribute__((noreturn))
|
||||
#define _LIBCPP_UNUSED
|
||||
|
||||
#define _NOEXCEPT throw()
|
||||
#define _NOEXCEPT_(x)
|
||||
#define _NOEXCEPT_OR_FALSE(x) false
|
||||
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
@ -455,7 +518,6 @@ namespace std {
|
||||
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
#define _LIBCPP_HAS_NO_NULLPTR
|
||||
#define _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
#define _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
#define _LIBCPP_HAS_IS_BASE_OF
|
||||
|
||||
#if defined(_AIX)
|
||||
@ -471,13 +533,19 @@ namespace std {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __clang__ || __GNUC___ || _MSC_VER || __IBMCPP__
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
|
||||
#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
typedef unsigned short char16_t;
|
||||
typedef unsigned int char32_t;
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
|
||||
#ifndef __SIZEOF_INT128__
|
||||
#define _LIBCPP_HAS_NO_INT128
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
|
||||
|
||||
template <bool> struct __static_assert_test;
|
||||
@ -515,12 +583,20 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define __has_feature(__x) 0
|
||||
#endif
|
||||
|
||||
#if __has_feature(cxx_explicit_conversions)
|
||||
#ifndef __has_builtin
|
||||
#define __has_builtin(__x) 0
|
||||
#endif
|
||||
|
||||
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
|
||||
# define _LIBCPP_EXPLICIT explicit
|
||||
#else
|
||||
# define _LIBCPP_EXPLICIT
|
||||
#endif
|
||||
|
||||
#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
|
||||
# define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
|
||||
#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
|
||||
@ -546,16 +622,21 @@ template <unsigned> struct __static_assert_check {};
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXTERN_TEMPLATE
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...)
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXTERN_TEMPLATE2
|
||||
#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
|
||||
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__)
|
||||
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define _DECLARE_C99_LDBL_MATH 1
|
||||
#endif
|
||||
@ -568,21 +649,39 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_WCTYPE_IS_MASK
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0
|
||||
#endif
|
||||
#if defined(ELAST)
|
||||
#define _LIBCPP_ELAST ELAST
|
||||
#elif defined(__linux__)
|
||||
#define _LIBCPP_ELAST 4095
|
||||
#elif defined(_NEWLIB_VERSION)
|
||||
#define _LIBCPP_ELAST __ELASTERROR
|
||||
#elif defined(__APPLE__)
|
||||
// Not _LIBCPP_ELAST needed on Apple
|
||||
#elif defined(__sun__)
|
||||
#define _LIBCPP_ELAST ESTALE
|
||||
#else
|
||||
// Warn here so that the person doing the libcxx port has an easier time:
|
||||
#warning This platform's ELAST hasn't been ported yet
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
|
||||
# if defined(__FreeBSD__)
|
||||
// Making the std::pair copy constructor trivial breaks ABI compatibility with
|
||||
// earlier versions of libc++ shipped by FreeBSD, so turn it off by default.
|
||||
// See also http://svnweb.freebsd.org/changeset/base/261801
|
||||
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0
|
||||
# else
|
||||
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_STD_VER
|
||||
# if __cplusplus <= 201103L
|
||||
# define _LIBCPP_STD_VER 11
|
||||
# elif __cplusplus <= 201402L
|
||||
# define _LIBCPP_STD_VER 14
|
||||
# else
|
||||
# define _LIBCPP_STD_VER 13 // current year, or date of c++14 ratification
|
||||
# define _LIBCPP_STD_VER 15 // current year, or date of c++17 ratification
|
||||
# endif
|
||||
#endif // _LIBCPP_STD_VER
|
||||
|
||||
@ -593,21 +692,30 @@ template <unsigned> struct __static_assert_check {};
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
#define _LIBCPP_EXPLICIT_AFTER_CXX11
|
||||
#define _LIBCPP_DEPRECATED_AFTER_CXX11
|
||||
#else
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
|
||||
#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
|
||||
#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
|
||||
#else
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_ASAN
|
||||
extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
const void *, const void *, const void *, const void *);
|
||||
#endif
|
||||
|
||||
// Try to find out if RTTI is disabled.
|
||||
// g++ and cl.exe have RTTI on by default and define a macro when it is.
|
||||
// g++ only defines the macro in 4.3.2 and onwards.
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
# if defined(__GNUG__) && (__GNUC__ >= 4 && \
|
||||
(__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2)) && !defined(__GXX_RTTI)
|
||||
# if defined(__GNUG__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
|
||||
(__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
|
||||
# define _LIBCPP_NO_RTTI
|
||||
# elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
|
||||
# define _LIBCPP_NO_RTTI
|
||||
@ -618,4 +726,9 @@ template <unsigned> struct __static_assert_check {};
|
||||
# define _LIBCPP_WEAK __attribute__((__weak__))
|
||||
#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.
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CONFIG
|
||||
|
@ -11,19 +11,23 @@
|
||||
#ifndef _LIBCPP_DEBUG_H
|
||||
#define _LIBCPP_DEBUG_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 1
|
||||
|
||||
# include <cstdlib>
|
||||
# include <cstdio>
|
||||
# include <cstddef>
|
||||
# ifndef _LIBCPP_ASSERT
|
||||
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_ASSERT
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
@ -651,9 +651,14 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp()>
|
||||
__base* __f_;
|
||||
|
||||
template <class _Fp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(const _Fp&) {return true;}
|
||||
template <class _R2>
|
||||
static bool __not_null(const function<_Rp()>& __p) {return __p;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(_R2 (*__p)()) {return __p;}
|
||||
template <class _R2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(const function<_R2()>& __p) {return __p;}
|
||||
public:
|
||||
typedef _Rp result_type;
|
||||
|
||||
@ -955,7 +960,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)>
|
||||
static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;}
|
||||
template <class _R2, class _B0>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(const function<_Rp(_B0)>& __p) {return __p;}
|
||||
static bool __not_null(const function<_R2(_B0)>& __p) {return __p;}
|
||||
public:
|
||||
typedef _Rp result_type;
|
||||
|
||||
@ -1257,7 +1262,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)>
|
||||
static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return __p;}
|
||||
template <class _R2, class _B0, class _B1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(const function<_Rp(_B0, _B1)>& __p) {return __p;}
|
||||
static bool __not_null(const function<_R2(_B0, _B1)>& __p) {return __p;}
|
||||
public:
|
||||
typedef _Rp result_type;
|
||||
|
||||
@ -1558,7 +1563,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)>
|
||||
static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const volatile) {return __p;}
|
||||
template <class _R2, class _B0, class _B1, class _B2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(const function<_Rp(_B0, _B1, _B2)>& __p) {return __p;}
|
||||
static bool __not_null(const function<_R2(_B0, _B1, _B2)>& __p) {return __p;}
|
||||
public:
|
||||
typedef _Rp result_type;
|
||||
|
||||
@ -1911,7 +1916,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __mu_return1<true, _Ti, _Uj...>::type
|
||||
__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>)
|
||||
{
|
||||
__ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj))...);
|
||||
__ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj))...);
|
||||
}
|
||||
|
||||
template <class _Ti, class ..._Uj>
|
||||
@ -1947,9 +1952,9 @@ __mu(_Ti&, _Uj& __uj)
|
||||
{
|
||||
const size_t _Indx = is_placeholder<_Ti>::value - 1;
|
||||
// compiler bug workaround
|
||||
typename tuple_element<_Indx, _Uj>::type __t = get<_Indx>(__uj);
|
||||
typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj);
|
||||
return __t;
|
||||
// return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj));
|
||||
// return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
|
||||
}
|
||||
|
||||
template <class _Ti, class _Uj>
|
||||
@ -2040,7 +2045,7 @@ typename __bind_return<_Fp, _BoundArgs, _Args>::type
|
||||
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
|
||||
_Args&& __args)
|
||||
{
|
||||
return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...);
|
||||
return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
|
||||
}
|
||||
|
||||
template<class _Fp, class ..._BoundArgs>
|
||||
|
@ -451,10 +451,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp> struct ____is_reference_wrapper : public false_type {};
|
||||
template <class _Tp> struct ____is_reference_wrapper<reference_wrapper<_Tp> > : public true_type {};
|
||||
template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
|
||||
template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
|
||||
template <class _Tp> struct __is_reference_wrapper
|
||||
: public ____is_reference_wrapper<typename remove_cv<_Tp>::type> {};
|
||||
: public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -1027,7 +1027,7 @@ public:
|
||||
typename __invoke_return0<type&, _A0>::type
|
||||
operator() (_A0& __a0) const
|
||||
{
|
||||
return __invoke(get(), __a0);
|
||||
return __invoke<type&, _A0>(get(), __a0);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
@ -1035,7 +1035,7 @@ public:
|
||||
typename __invoke_return1<type&, _A0, _A1>::type
|
||||
operator() (_A0& __a0, _A1& __a1) const
|
||||
{
|
||||
return __invoke(get(), __a0, __a1);
|
||||
return __invoke<type&, _A0, _A1>(get(), __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
@ -1043,14 +1043,14 @@ public:
|
||||
typename __invoke_return2<type&, _A0, _A1, _A2>::type
|
||||
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
|
||||
{
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
return __invoke<type&, _A0, _A1, _A2>(get(), __a0, __a1, __a2);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp> struct ____is_reference_wrapper : public false_type {};
|
||||
template <class _Tp> struct ____is_reference_wrapper<reference_wrapper<_Tp> > : public true_type {};
|
||||
template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
|
||||
template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
|
||||
template <class _Tp> struct __is_reference_wrapper
|
||||
: public ____is_reference_wrapper<typename remove_cv<_Tp>::type> {};
|
||||
: public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -20,11 +20,7 @@
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
# include <__debug>
|
||||
#else
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
|
@ -21,11 +21,22 @@
|
||||
#include <locale.h>
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
# include <support/win32/locale_win32.h>
|
||||
#elif _AIX
|
||||
#elif defined(_AIX)
|
||||
# include <support/ibm/xlocale.h>
|
||||
#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)
|
||||
#elif defined(__ANDROID__)
|
||||
// Android gained the locale aware functions in L (API level 21)
|
||||
# include <android/api-level.h>
|
||||
# if __ANDROID_API__ <= 20
|
||||
# include <support/android/locale_bionic.h>
|
||||
# endif
|
||||
#elif defined(__sun__)
|
||||
# include <support/solaris/xlocale.h>
|
||||
#elif defined(_NEWLIB_VERSION)
|
||||
# include <support/newlib/xlocale.h>
|
||||
#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
|
||||
# include <xlocale.h>
|
||||
#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
|
||||
#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -341,13 +352,15 @@ public:
|
||||
static const mask punct = _PUNCT;
|
||||
static const mask xdigit = _HEX;
|
||||
static const mask blank = _BLANK;
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__ANDROID__)
|
||||
#ifdef __APPLE__
|
||||
typedef __uint32_t mask;
|
||||
#elif defined(__FreeBSD__)
|
||||
typedef unsigned long mask;
|
||||
#elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
||||
typedef unsigned short mask;
|
||||
#elif defined(__ANDROID__)
|
||||
typedef unsigned char mask;
|
||||
#endif
|
||||
static const mask space = _CTYPE_S;
|
||||
static const mask print = _CTYPE_R;
|
||||
@ -357,7 +370,12 @@ public:
|
||||
static const mask alpha = _CTYPE_A;
|
||||
static const mask digit = _CTYPE_D;
|
||||
static const mask punct = _CTYPE_P;
|
||||
# if defined(__ANDROID__)
|
||||
static const mask xdigit = _CTYPE_X | _CTYPE_D;
|
||||
# else
|
||||
static const mask xdigit = _CTYPE_X;
|
||||
# endif
|
||||
|
||||
# if defined(__NetBSD__)
|
||||
static const mask blank = _CTYPE_BL;
|
||||
# else
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
class _LIBCPP_TYPE_VIS mutex
|
||||
{
|
||||
pthread_mutex_t __m_;
|
||||
@ -254,19 +256,13 @@ void
|
||||
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT
|
||||
{__x.swap(__y);}
|
||||
|
||||
struct _LIBCPP_TYPE_VIS cv_status
|
||||
//enum class cv_status
|
||||
_LIBCPP_DECLARE_STRONG_ENUM(cv_status)
|
||||
{
|
||||
enum __lx {
|
||||
no_timeout,
|
||||
timeout
|
||||
};
|
||||
|
||||
__lx __v_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY cv_status(__lx __v) : __v_(__v) {}
|
||||
_LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;}
|
||||
|
||||
no_timeout,
|
||||
timeout
|
||||
};
|
||||
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable
|
||||
{
|
||||
@ -288,7 +284,7 @@ public:
|
||||
void notify_one() _NOEXCEPT;
|
||||
void notify_all() _NOEXCEPT;
|
||||
|
||||
void wait(unique_lock<mutex>& __lk);
|
||||
void wait(unique_lock<mutex>& __lk) _NOEXCEPT;
|
||||
template <class _Predicate>
|
||||
void wait(unique_lock<mutex>& __lk, _Predicate __pred);
|
||||
|
||||
@ -319,8 +315,9 @@ public:
|
||||
|
||||
private:
|
||||
void __do_timed_wait(unique_lock<mutex>& __lk,
|
||||
chrono::time_point<chrono::system_clock, chrono::nanoseconds>);
|
||||
chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
|
||||
};
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
template <class _To, class _Rep, class _Period>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -338,6 +335,7 @@ __ceil(chrono::duration<_Rep, _Period> __d)
|
||||
return __r;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
template <class _Predicate>
|
||||
void
|
||||
condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred)
|
||||
@ -402,6 +400,8 @@ condition_variable::wait_for(unique_lock<mutex>& __lk,
|
||||
_VSTD::move(__pred));
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___MUTEX_BASE
|
||||
|
139
contrib/libc++/include/__refstring
Normal file
139
contrib/libc++/include/__refstring
Normal file
@ -0,0 +1,139 @@
|
||||
//===------------------------ __refstring ---------------------------------===//
|
||||
//
|
||||
// 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___REFSTRING
|
||||
#define _LIBCPP___REFSTRING
|
||||
|
||||
#include <__config>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#if __APPLE__
|
||||
#include <dlfcn.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_HIDDEN __libcpp_refstring
|
||||
{
|
||||
private:
|
||||
const char* str_;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#if __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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
__libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_)
|
||||
{
|
||||
if (uses_refcount())
|
||||
__sync_add_and_fetch(&rep_from_data(str_)->count, 1);
|
||||
}
|
||||
|
||||
__libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT
|
||||
{
|
||||
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)
|
||||
{
|
||||
::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* c_str() const _NOEXCEPT {return str_;}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif //_LIBCPP___REFSTRING
|
@ -55,14 +55,14 @@ public:
|
||||
__allocated_ = true;
|
||||
return (pointer)&buf_;
|
||||
}
|
||||
return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type)
|
||||
{
|
||||
if (__p == (pointer)&buf_)
|
||||
__allocated_ = false;
|
||||
else
|
||||
::operator delete(__p);
|
||||
_VSTD::__deallocate(__p);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
|
||||
|
||||
|
@ -1980,9 +1980,9 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
|
||||
__begin_node() = __r.__ptr_;
|
||||
--size();
|
||||
__node_allocator& __na = __node_alloc();
|
||||
__node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
|
||||
__tree_remove(__end_node()->__left_,
|
||||
static_cast<__node_base_pointer>(__np));
|
||||
__node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
|
||||
__node_traits::deallocate(__na, __np, 1);
|
||||
return __r;
|
||||
}
|
||||
|
@ -27,6 +27,32 @@
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// __lazy_and
|
||||
|
||||
template <bool _Last, class ..._Preds>
|
||||
struct __lazy_and_impl;
|
||||
|
||||
template <class ..._Preds>
|
||||
struct __lazy_and_impl<false, _Preds...> : false_type {};
|
||||
|
||||
template <>
|
||||
struct __lazy_and_impl<true> : true_type {};
|
||||
|
||||
template <class _Pred>
|
||||
struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
|
||||
|
||||
template <class _Hp, class ..._Tp>
|
||||
struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
|
||||
|
||||
template <class _P1, class ..._Pr>
|
||||
struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
|
||||
|
||||
// __lazy_not
|
||||
|
||||
template <class _Pred>
|
||||
struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
|
||||
|
||||
|
||||
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
|
||||
|
||||
template <class _Tp>
|
||||
@ -219,19 +245,30 @@ struct __make_tuple_types
|
||||
|
||||
// __tuple_convertible
|
||||
|
||||
template <bool, class _Tp, class _Up>
|
||||
template <class, class>
|
||||
struct __tuple_convertible_imp : public false_type {};
|
||||
|
||||
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
|
||||
struct __tuple_convertible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
|
||||
struct __tuple_convertible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
|
||||
: public integral_constant<bool,
|
||||
is_convertible<_Tp0, _Up0>::value &&
|
||||
__tuple_convertible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
__tuple_convertible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
|
||||
template <>
|
||||
struct __tuple_convertible_imp<true, __tuple_types<>, __tuple_types<> >
|
||||
struct __tuple_convertible_imp<__tuple_types<>, __tuple_types<> >
|
||||
: public true_type {};
|
||||
|
||||
template <bool, class, class>
|
||||
struct __tuple_convertible_apply : public false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_convertible_apply<true, _Tp, _Up>
|
||||
: public __tuple_convertible_imp<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_convertible
|
||||
@ -239,26 +276,36 @@ struct __tuple_convertible
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_convertible<_Tp, _Up, true, true>
|
||||
: public __tuple_convertible_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value,
|
||||
typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
|
||||
: public __tuple_convertible_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value, _Tp, _Up>
|
||||
{};
|
||||
|
||||
// __tuple_constructible
|
||||
|
||||
template <bool, class _Tp, class _Up>
|
||||
template <class, class>
|
||||
struct __tuple_constructible_imp : public false_type {};
|
||||
|
||||
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
|
||||
struct __tuple_constructible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
|
||||
struct __tuple_constructible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
|
||||
: public integral_constant<bool,
|
||||
is_constructible<_Up0, _Tp0>::value &&
|
||||
__tuple_constructible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
__tuple_constructible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
|
||||
template <>
|
||||
struct __tuple_constructible_imp<true, __tuple_types<>, __tuple_types<> >
|
||||
struct __tuple_constructible_imp<__tuple_types<>, __tuple_types<> >
|
||||
: public true_type {};
|
||||
|
||||
template <bool _SameSize, class, class>
|
||||
struct __tuple_constructible_apply : public false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_constructible_apply<true, _Tp, _Up>
|
||||
: public __tuple_constructible_imp<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_constructible
|
||||
@ -266,26 +313,36 @@ struct __tuple_constructible
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_constructible<_Tp, _Up, true, true>
|
||||
: public __tuple_constructible_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value,
|
||||
typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
|
||||
: public __tuple_constructible_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value, _Tp, _Up>
|
||||
{};
|
||||
|
||||
// __tuple_assignable
|
||||
|
||||
template <bool, class _Tp, class _Up>
|
||||
template <class, class>
|
||||
struct __tuple_assignable_imp : public false_type {};
|
||||
|
||||
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
|
||||
struct __tuple_assignable_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
|
||||
struct __tuple_assignable_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
|
||||
: public integral_constant<bool,
|
||||
is_assignable<_Up0&, _Tp0>::value &&
|
||||
__tuple_assignable_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
__tuple_assignable_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
|
||||
template <>
|
||||
struct __tuple_assignable_imp<true, __tuple_types<>, __tuple_types<> >
|
||||
struct __tuple_assignable_imp<__tuple_types<>, __tuple_types<> >
|
||||
: public true_type {};
|
||||
|
||||
template <bool, class, class>
|
||||
struct __tuple_assignable_apply : public false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_assignable_apply<true, _Tp, _Up>
|
||||
: __tuple_assignable_imp<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_assignable
|
||||
@ -293,9 +350,8 @@ struct __tuple_assignable
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_assignable<_Tp, _Up, true, true>
|
||||
: public __tuple_assignable_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value,
|
||||
typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
|
||||
: public __tuple_assignable_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value, _Tp, _Up>
|
||||
{};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -281,11 +281,12 @@ template <class ForwardIterator, class OutputIterator>
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14
|
||||
|
||||
template <class RandomAccessIterator, class RandomNumberGenerator>
|
||||
void
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator& rand);
|
||||
random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
|
||||
RandomNumberGenerator& rand); // deprecated in C++14
|
||||
|
||||
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
||||
void shuffle(RandomAccessIterator first, RandomAccessIterator last,
|
||||
@ -528,19 +529,19 @@ template <class ForwardIterator, class Compare>
|
||||
|
||||
template <class T>
|
||||
const T&
|
||||
min(const T& a, const T& b);
|
||||
min(const T& a, const T& b); // constexpr in C++14
|
||||
|
||||
template <class T, class Compare>
|
||||
const T&
|
||||
min(const T& a, const T& b, Compare comp);
|
||||
min(const T& a, const T& b, Compare comp); // constexpr in C++14
|
||||
|
||||
template<class T>
|
||||
T
|
||||
min(initializer_list<T> t);
|
||||
min(initializer_list<T> t); // constexpr in C++14
|
||||
|
||||
template<class T, class Compare>
|
||||
T
|
||||
min(initializer_list<T> t, Compare comp);
|
||||
min(initializer_list<T> t, Compare comp); // constexpr in C++14
|
||||
|
||||
template <class ForwardIterator>
|
||||
ForwardIterator
|
||||
@ -552,19 +553,19 @@ template <class ForwardIterator, class Compare>
|
||||
|
||||
template <class T>
|
||||
const T&
|
||||
max(const T& a, const T& b);
|
||||
max(const T& a, const T& b); // constexpr in C++14
|
||||
|
||||
template <class T, class Compare>
|
||||
const T&
|
||||
max(const T& a, const T& b, Compare comp);
|
||||
max(const T& a, const T& b, Compare comp); // constexpr in C++14
|
||||
|
||||
template<class T>
|
||||
T
|
||||
max(initializer_list<T> t);
|
||||
max(initializer_list<T> t); // constexpr in C++14
|
||||
|
||||
template<class T, class Compare>
|
||||
T
|
||||
max(initializer_list<T> t, Compare comp);
|
||||
max(initializer_list<T> t, Compare comp); // constexpr in C++14
|
||||
|
||||
template<class ForwardIterator>
|
||||
pair<ForwardIterator, ForwardIterator>
|
||||
@ -576,19 +577,19 @@ template<class ForwardIterator, class Compare>
|
||||
|
||||
template<class T>
|
||||
pair<const T&, const T&>
|
||||
minmax(const T& a, const T& b);
|
||||
minmax(const T& a, const T& b); // constexpr in C++14
|
||||
|
||||
template<class T, class Compare>
|
||||
pair<const T&, const T&>
|
||||
minmax(const T& a, const T& b, Compare comp);
|
||||
minmax(const T& a, const T& b, Compare comp); // constexpr in C++14
|
||||
|
||||
template<class T>
|
||||
pair<T, T>
|
||||
minmax(initializer_list<T> t);
|
||||
minmax(initializer_list<T> t); // constexpr in C++14
|
||||
|
||||
template<class T, class Compare>
|
||||
pair<T, T>
|
||||
minmax(initializer_list<T> t, Compare comp);
|
||||
minmax(initializer_list<T> t, Compare comp); // constexpr in C++14
|
||||
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
bool
|
||||
@ -637,12 +638,17 @@ template <class BidirectionalIterator, class Compare>
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
|
||||
// * That only works with C++14 and later, and
|
||||
// * We haven't included <functional> here.
|
||||
template <class _T1, class _T2 = _T1>
|
||||
struct __equal_to
|
||||
{
|
||||
@ -655,46 +661,59 @@ struct __equal_to
|
||||
template <class _T1>
|
||||
struct __equal_to<_T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __equal_to<const _T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __equal_to<_T1, const _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
|
||||
};
|
||||
|
||||
template <class _T1, class _T2 = _T1>
|
||||
struct __less
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
|
||||
_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
|
||||
bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __less<_T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __less<const _T1, _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __less<_T1, const _T1>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
|
||||
};
|
||||
|
||||
template <class _Predicate>
|
||||
@ -958,7 +977,7 @@ __find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1,
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_RandomAccessIterator1
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
|
||||
__find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag)
|
||||
@ -1024,8 +1043,8 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
// find_first_of
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
_ForwardIterator1
|
||||
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1
|
||||
__find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1)
|
||||
@ -1035,6 +1054,16 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
return __last1;
|
||||
}
|
||||
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator1
|
||||
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
|
||||
{
|
||||
return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator1
|
||||
@ -1043,7 +1072,7 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::find_first_of(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
// adjacent_find
|
||||
@ -1111,7 +1140,7 @@ pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _BinaryPredicate __pred)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
||||
@ -1135,7 +1164,7 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_BinaryPredicate __pred)
|
||||
{
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
||||
@ -1160,7 +1189,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
return false;
|
||||
return true;
|
||||
@ -1184,7 +1213,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
|
||||
input_iterator_tag, input_iterator_tag )
|
||||
{
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
return false;
|
||||
return __first1 == __last1 && __first2 == __last2;
|
||||
@ -1238,7 +1267,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _BinaryPredicate __pred)
|
||||
{
|
||||
// shorten sequences as much as possible by lopping of any equal parts
|
||||
for (; __first1 != __last1; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
goto __not_done;
|
||||
return true;
|
||||
@ -1298,7 +1327,7 @@ __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
forward_iterator_tag, forward_iterator_tag )
|
||||
{
|
||||
// shorten sequences as much as possible by lopping of any equal parts
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
goto __not_done;
|
||||
return __first1 == __last1 && __first2 == __last2;
|
||||
@ -1423,7 +1452,7 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_RandomAccessIterator1
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
|
||||
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag)
|
||||
@ -1716,7 +1745,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
@ -1845,7 +1874,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
*__result = _VSTD::move(*__first);
|
||||
return __result;
|
||||
}
|
||||
@ -1921,7 +1950,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
*__result = __op(*__first);
|
||||
return __result;
|
||||
}
|
||||
@ -1932,7 +1961,7 @@ _OutputIterator
|
||||
transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2, ++__result)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result)
|
||||
*__result = __binary_op(*__first1, *__first2);
|
||||
return __result;
|
||||
}
|
||||
@ -1969,7 +1998,7 @@ _OutputIterator
|
||||
replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
|
||||
const _Tp& __old_value, const _Tp& __new_value)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
if (*__first == __old_value)
|
||||
*__result = __new_value;
|
||||
else
|
||||
@ -1985,7 +2014,7 @@ _OutputIterator
|
||||
replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
|
||||
_Predicate __pred, const _Tp& __new_value)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
if (__pred(*__first))
|
||||
*__result = __new_value;
|
||||
else
|
||||
@ -2000,7 +2029,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
|
||||
{
|
||||
for (; __n > 0; ++__first, --__n)
|
||||
for (; __n > 0; ++__first, (void) --__n)
|
||||
*__first = __value_;
|
||||
return __first;
|
||||
}
|
||||
@ -2074,7 +2103,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
|
||||
{
|
||||
for (; __n > 0; ++__first, --__n)
|
||||
for (; __n > 0; ++__first, (void) --__n)
|
||||
*__first = __gen();
|
||||
return __first;
|
||||
}
|
||||
@ -2505,9 +2534,9 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato
|
||||
// min_element
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_ForwardIterator
|
||||
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
@ -2519,19 +2548,27 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator
|
||||
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
return __min_element(__first, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator
|
||||
min_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::min_element(__first, __last,
|
||||
return __min_element(__first, __last,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
// min
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
@ -2539,7 +2576,7 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
min(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
@ -2549,19 +2586,19 @@ min(const _Tp& __a, const _Tp& __b)
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
min(initializer_list<_Tp> __t, _Compare __comp)
|
||||
{
|
||||
return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
|
||||
return *__min_element(__t.begin(), __t.end(), __comp);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
min(initializer_list<_Tp> __t)
|
||||
{
|
||||
return *_VSTD::min_element(__t.begin(), __t.end());
|
||||
return *__min_element(__t.begin(), __t.end(), __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
@ -2569,9 +2606,9 @@ min(initializer_list<_Tp> __t)
|
||||
// max_element
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_ForwardIterator
|
||||
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
@ -2583,19 +2620,28 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
return __first;
|
||||
}
|
||||
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator
|
||||
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
|
||||
{
|
||||
return __max_element(__first, __last, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator
|
||||
max_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::max_element(__first, __last,
|
||||
return __max_element(__first, __last,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
// max
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
@ -2603,7 +2649,7 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
max(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
@ -2613,19 +2659,19 @@ max(const _Tp& __a, const _Tp& __b)
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
max(initializer_list<_Tp> __t, _Compare __comp)
|
||||
{
|
||||
return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
|
||||
return *__max_element(__t.begin(), __t.end(), __comp);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp
|
||||
max(initializer_list<_Tp> __t)
|
||||
{
|
||||
return *_VSTD::max_element(__t.begin(), __t.end());
|
||||
return *__max_element(__t.begin(), __t.end(), __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
@ -2684,13 +2730,14 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
std::pair<_ForwardIterator, _ForwardIterator>
|
||||
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
return _VSTD::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
return _VSTD::minmax_element(__first, __last,
|
||||
__less<typename iterator_traits<_ForwardIterator>::value_type>());
|
||||
}
|
||||
|
||||
// minmax
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
@ -2699,7 +2746,7 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<const _Tp&, const _Tp&>
|
||||
minmax(const _Tp& __a, const _Tp& __b)
|
||||
{
|
||||
@ -2708,24 +2755,49 @@ minmax(const _Tp& __a, const _Tp& __b)
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
pair<_Tp, _Tp>
|
||||
minmax(initializer_list<_Tp> __t)
|
||||
{
|
||||
pair<const _Tp*, const _Tp*> __p =
|
||||
_VSTD::minmax_element(__t.begin(), __t.end());
|
||||
return pair<_Tp, _Tp>(*__p.first, *__p.second);
|
||||
}
|
||||
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_Tp, _Tp>
|
||||
minmax(initializer_list<_Tp> __t, _Compare __comp)
|
||||
{
|
||||
pair<const _Tp*, const _Tp*> __p =
|
||||
_VSTD::minmax_element(__t.begin(), __t.end(), __comp);
|
||||
return pair<_Tp, _Tp>(*__p.first, *__p.second);
|
||||
typedef typename initializer_list<_Tp>::const_iterator _Iter;
|
||||
_Iter __first = __t.begin();
|
||||
_Iter __last = __t.end();
|
||||
std::pair<_Tp, _Tp> __result ( *__first, *__first );
|
||||
|
||||
++__first;
|
||||
if (__t.size() % 2 == 0)
|
||||
{
|
||||
if (__comp(*__first, __result.first))
|
||||
__result.first = *__first;
|
||||
else
|
||||
__result.second = *__first;
|
||||
++__first;
|
||||
}
|
||||
|
||||
while (__first != __last)
|
||||
{
|
||||
_Tp __prev = *__first++;
|
||||
if (__comp(__prev, *__first)) {
|
||||
if (__comp(__prev, __result.first)) __result.first = __prev;
|
||||
if (__comp(__result.second, *__first)) __result.second = *__first;
|
||||
}
|
||||
else {
|
||||
if (__comp(*__first, __result.first)) __result.first = *__first;
|
||||
if (__comp(__result.second, __prev)) __result.second = __prev;
|
||||
}
|
||||
|
||||
__first++;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_Tp, _Tp>
|
||||
minmax(initializer_list<_Tp> __t)
|
||||
{
|
||||
return _VSTD::minmax(__t, __less<_Tp>());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
@ -4300,7 +4372,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
|
||||
if (__len1 <= __len2)
|
||||
{
|
||||
value_type* __p = __buff;
|
||||
for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), ++__i, ++__p)
|
||||
for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, ++__p)
|
||||
::new(__p) value_type(_VSTD::move(*__i));
|
||||
__merge<_Compare>(move_iterator<value_type*>(__buff),
|
||||
move_iterator<value_type*>(__p),
|
||||
@ -4311,7 +4383,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
|
||||
else
|
||||
{
|
||||
value_type* __p = __buff;
|
||||
for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), ++__i, ++__p)
|
||||
for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), (void) ++__i, ++__p)
|
||||
::new(__p) value_type(_VSTD::move(*__i));
|
||||
typedef reverse_iterator<_BidirectionalIterator> _RBi;
|
||||
typedef reverse_iterator<value_type*> _Rv;
|
||||
@ -4336,7 +4408,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
|
||||
if (__len2 == 0)
|
||||
return;
|
||||
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
|
||||
for (; true; ++__first, --__len1)
|
||||
for (; true; ++__first, (void) --__len1)
|
||||
{
|
||||
if (__len1 == 0)
|
||||
return;
|
||||
@ -4724,49 +4796,8 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__push_heap_front(_RandomAccessIterator __first, _RandomAccessIterator, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
if (__len > 1)
|
||||
{
|
||||
difference_type __p = 0;
|
||||
_RandomAccessIterator __pp = __first;
|
||||
difference_type __c = 2;
|
||||
_RandomAccessIterator __cp = __first + __c;
|
||||
if (__c == __len || __comp(*__cp, *(__cp - 1)))
|
||||
{
|
||||
--__c;
|
||||
--__cp;
|
||||
}
|
||||
if (__comp(*__pp, *__cp))
|
||||
{
|
||||
value_type __t(_VSTD::move(*__pp));
|
||||
do
|
||||
{
|
||||
*__pp = _VSTD::move(*__cp);
|
||||
__pp = __cp;
|
||||
__p = __c;
|
||||
__c = (__p + 1) * 2;
|
||||
if (__c > __len)
|
||||
break;
|
||||
__cp = __first + __c;
|
||||
if (__c == __len || __comp(*__cp, *(__cp - 1)))
|
||||
{
|
||||
--__c;
|
||||
--__cp;
|
||||
}
|
||||
} while (__comp(__t, *__cp));
|
||||
*__pp = _VSTD::move(__t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__push_heap_back(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
|
||||
__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
@ -4799,10 +4830,10 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
|
||||
__debug_less<_Compare> __c(__comp);
|
||||
__push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first);
|
||||
__sift_up<_Comp_ref>(__first, __last, __c, __last - __first);
|
||||
#else // _LIBCPP_DEBUG
|
||||
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
|
||||
__push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first);
|
||||
__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
|
||||
#endif // _LIBCPP_DEBUG
|
||||
}
|
||||
|
||||
@ -4816,6 +4847,60 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
|
||||
// pop_heap
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
void
|
||||
__sift_down(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
|
||||
_RandomAccessIterator __start)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
|
||||
// left-child of __start is at 2 * __start + 1
|
||||
// right-child of __start is at 2 * __start + 2
|
||||
difference_type __child = __start - __first;
|
||||
|
||||
if (__len < 2 || (__len - 2) / 2 < __child)
|
||||
return;
|
||||
|
||||
__child = 2 * __child + 1;
|
||||
_RandomAccessIterator __child_i = __first + __child;
|
||||
|
||||
if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
|
||||
// right-child exists and is greater than left-child
|
||||
++__child_i;
|
||||
++__child;
|
||||
}
|
||||
|
||||
// check if we are in heap-order
|
||||
if (__comp(*__child_i, *__start))
|
||||
// we are, __start is larger than it's largest child
|
||||
return;
|
||||
|
||||
value_type __top(_VSTD::move(*__start));
|
||||
do
|
||||
{
|
||||
// we are not in heap-order, swap the parent with it's largest child
|
||||
*__start = _VSTD::move(*__child_i);
|
||||
__start = __child_i;
|
||||
|
||||
if ((__len - 2) / 2 < __child)
|
||||
break;
|
||||
|
||||
// recompute the child based off of the updated parent
|
||||
__child = 2 * __child + 1;
|
||||
__child_i = __first + __child;
|
||||
|
||||
if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
|
||||
// right-child exists and is greater than left-child
|
||||
++__child_i;
|
||||
++__child;
|
||||
}
|
||||
|
||||
// check if we are in heap-order
|
||||
} while (!__comp(*__child_i, __top));
|
||||
*__start = _VSTD::move(__top);
|
||||
}
|
||||
|
||||
template <class _Compare, class _RandomAccessIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
@ -4825,7 +4910,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
|
||||
if (__len > 1)
|
||||
{
|
||||
swap(*__first, *--__last);
|
||||
__push_heap_front<_Compare>(__first, __last, __comp, __len-1);
|
||||
__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4862,10 +4947,11 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
|
||||
difference_type __n = __last - __first;
|
||||
if (__n > 1)
|
||||
{
|
||||
__last = __first;
|
||||
++__last;
|
||||
for (difference_type __i = 1; __i < __n;)
|
||||
__push_heap_back<_Compare>(__first, ++__last, __comp, ++__i);
|
||||
// start from the first parent, there is no need to consider children
|
||||
for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
|
||||
{
|
||||
__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4940,7 +5026,7 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _R
|
||||
if (__comp(*__i, *__first))
|
||||
{
|
||||
swap(*__i, *__first);
|
||||
__push_heap_front<_Compare>(__first, __middle, __comp, __len);
|
||||
__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
|
||||
}
|
||||
}
|
||||
__sort_heap<_Compare>(__first, __middle, __comp);
|
||||
@ -4981,15 +5067,15 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __r = __result_first;
|
||||
if (__r != __result_last)
|
||||
{
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len = 0;
|
||||
for (; __first != __last && __r != __result_last; ++__first, ++__r, ++__len)
|
||||
for (; __first != __last && __r != __result_last; (void) ++__first, ++__r)
|
||||
*__r = *__first;
|
||||
__make_heap<_Compare>(__result_first, __r, __comp);
|
||||
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
|
||||
for (; __first != __last; ++__first)
|
||||
if (__comp(*__first, *__result_first))
|
||||
{
|
||||
*__result_first = *__first;
|
||||
__push_heap_front<_Compare>(__result_first, __r, __comp, __len);
|
||||
__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
|
||||
}
|
||||
__sort_heap<_Compare>(__result_first, __r, __comp);
|
||||
}
|
||||
@ -5503,7 +5589,7 @@ bool
|
||||
__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
|
||||
{
|
||||
for (; __first2 != __last2; ++__first1, ++__first2)
|
||||
for (; __first2 != __last2; ++__first1, (void) ++__first2)
|
||||
{
|
||||
if (__first1 == __last1 || __comp(*__first1, *__first2))
|
||||
return true;
|
||||
|
@ -533,9 +533,13 @@ void atomic_signal_fence(memory_order m) noexcept;
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_THREADS
|
||||
#error <atomic> is not supported on this single threaded system
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if !__has_feature(cxx_atomic)
|
||||
#if !__has_feature(cxx_atomic) && _GNUC_VER < 407
|
||||
#error <atomic> is not implemented
|
||||
#else
|
||||
|
||||
@ -545,6 +549,257 @@ typedef enum memory_order
|
||||
memory_order_release, memory_order_acq_rel, memory_order_seq_cst
|
||||
} memory_order;
|
||||
|
||||
#if _GNUC_VER >= 407
|
||||
namespace __gcc_atomic {
|
||||
template <typename T>
|
||||
struct __gcc_atomic_t {
|
||||
__gcc_atomic_t() _NOEXCEPT {}
|
||||
explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {}
|
||||
T __a_value;
|
||||
};
|
||||
#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
|
||||
|
||||
template <typename T> T __create();
|
||||
|
||||
template <typename __Tp, typename __Td>
|
||||
typename enable_if<sizeof(__Tp()->__a_value = __create<__Td>()), char>::type
|
||||
__test_atomic_assignable(int);
|
||||
template <typename T, typename U>
|
||||
__two __test_atomic_assignable(...);
|
||||
|
||||
template <typename __Tp, typename __Td>
|
||||
struct __can_assign {
|
||||
static const bool value =
|
||||
sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char);
|
||||
};
|
||||
|
||||
static inline constexpr int __to_gcc_order(memory_order __order) {
|
||||
// Avoid switch statement to make this a constexpr.
|
||||
return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
|
||||
(__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
|
||||
(__order == memory_order_release ? __ATOMIC_RELEASE:
|
||||
(__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST:
|
||||
(__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL:
|
||||
__ATOMIC_CONSUME))));
|
||||
}
|
||||
|
||||
} // namespace __gcc_atomic
|
||||
|
||||
template <typename _Tp>
|
||||
static inline
|
||||
typename enable_if<
|
||||
__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type
|
||||
__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
|
||||
__a->__a_value = __val;
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline
|
||||
typename enable_if<
|
||||
!__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value &&
|
||||
__gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type
|
||||
__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
|
||||
// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
|
||||
// the default operator= in an object is not volatile, a byte-by-byte copy
|
||||
// is required.
|
||||
volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value);
|
||||
volatile char* end = to + sizeof(_Tp);
|
||||
char* from = reinterpret_cast<char*>(&__val);
|
||||
while (to != end) {
|
||||
*to++ = *from++;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) {
|
||||
__a->__a_value = __val;
|
||||
}
|
||||
|
||||
static inline void __c11_atomic_thread_fence(memory_order __order) {
|
||||
__atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
static inline void __c11_atomic_signal_fence(memory_order __order) {
|
||||
__atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
static inline bool __c11_atomic_is_lock_free(size_t __size) {
|
||||
return __atomic_is_lock_free(__size, 0);
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val,
|
||||
memory_order __order) {
|
||||
return __atomic_store(&__a->__a_value, &__val,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val,
|
||||
memory_order __order) {
|
||||
return __atomic_store(&__a->__a_value, &__val,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
|
||||
memory_order __order) {
|
||||
_Tp __ret;
|
||||
__atomic_load(&__a->__a_value, &__ret,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
|
||||
_Tp __ret;
|
||||
__atomic_load(&__a->__a_value, &__ret,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a,
|
||||
_Tp __value, memory_order __order) {
|
||||
_Tp __ret;
|
||||
__atomic_exchange(&__a->__a_value, &__value, &__ret,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value,
|
||||
memory_order __order) {
|
||||
_Tp __ret;
|
||||
__atomic_exchange(&__a->__a_value, &__value, &__ret,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline bool __c11_atomic_compare_exchange_strong(
|
||||
volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
|
||||
memory_order __success, memory_order __failure) {
|
||||
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
|
||||
false,
|
||||
__gcc_atomic::__to_gcc_order(__success),
|
||||
__gcc_atomic::__to_gcc_order(__failure));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline bool __c11_atomic_compare_exchange_strong(
|
||||
_Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success,
|
||||
memory_order __failure) {
|
||||
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
|
||||
false,
|
||||
__gcc_atomic::__to_gcc_order(__success),
|
||||
__gcc_atomic::__to_gcc_order(__failure));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline bool __c11_atomic_compare_exchange_weak(
|
||||
volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
|
||||
memory_order __success, memory_order __failure) {
|
||||
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
|
||||
true,
|
||||
__gcc_atomic::__to_gcc_order(__success),
|
||||
__gcc_atomic::__to_gcc_order(__failure));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline bool __c11_atomic_compare_exchange_weak(
|
||||
_Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success,
|
||||
memory_order __failure) {
|
||||
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
|
||||
true,
|
||||
__gcc_atomic::__to_gcc_order(__success),
|
||||
__gcc_atomic::__to_gcc_order(__failure));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
struct __skip_amt { enum {value = 1}; };
|
||||
|
||||
template <typename _Tp>
|
||||
struct __skip_amt<_Tp*> { enum {value = sizeof(_Tp)}; };
|
||||
|
||||
// FIXME: Haven't figured out what the spec says about using arrays with
|
||||
// atomic_fetch_add. Force a failure rather than creating bad behavior.
|
||||
template <typename _Tp>
|
||||
struct __skip_amt<_Tp[]> { };
|
||||
template <typename _Tp, int n>
|
||||
struct __skip_amt<_Tp[n]> { };
|
||||
|
||||
template <typename _Tp, typename _Td>
|
||||
static inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a,
|
||||
_Td __delta, memory_order __order) {
|
||||
return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp, typename _Td>
|
||||
static inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta,
|
||||
memory_order __order) {
|
||||
return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp, typename _Td>
|
||||
static inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a,
|
||||
_Td __delta, memory_order __order) {
|
||||
return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp, typename _Td>
|
||||
static inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta,
|
||||
memory_order __order) {
|
||||
return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a,
|
||||
_Tp __pattern, memory_order __order) {
|
||||
return __atomic_fetch_and(&__a->__a_value, __pattern,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a,
|
||||
_Tp __pattern, memory_order __order) {
|
||||
return __atomic_fetch_and(&__a->__a_value, __pattern,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a,
|
||||
_Tp __pattern, memory_order __order) {
|
||||
return __atomic_fetch_or(&__a->__a_value, __pattern,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern,
|
||||
memory_order __order) {
|
||||
return __atomic_fetch_or(&__a->__a_value, __pattern,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a,
|
||||
_Tp __pattern, memory_order __order) {
|
||||
return __atomic_fetch_xor(&__a->__a_value, __pattern,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern,
|
||||
memory_order __order) {
|
||||
return __atomic_fetch_xor(&__a->__a_value, __pattern,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
}
|
||||
#endif // _GNUC_VER >= 407
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
@ -1528,4 +1783,6 @@ typedef atomic<uintmax_t> atomic_uintmax_t;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_ATOMIC
|
||||
|
@ -249,9 +249,9 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR
|
||||
__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
#if __SIZE_WIDTH__ == 64
|
||||
#if __SIZEOF_SIZE_T__ == 8
|
||||
: __first_{__v}
|
||||
#elif __SIZE_WIDTH__ == 32
|
||||
#elif __SIZEOF_SIZE_T__ == 4
|
||||
: __first_{__v, __v >> __bits_per_word}
|
||||
#else
|
||||
#error This constructor has not been ported to this platform
|
||||
|
@ -926,6 +926,7 @@ public:
|
||||
static time_point from_time_t(time_t __t) _NOEXCEPT;
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
|
||||
class _LIBCPP_TYPE_VIS steady_clock
|
||||
{
|
||||
public:
|
||||
@ -939,6 +940,9 @@ public:
|
||||
};
|
||||
|
||||
typedef steady_clock high_resolution_clock;
|
||||
#else
|
||||
typedef system_clock high_resolution_clock;
|
||||
#endif
|
||||
|
||||
} // chrono
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -115,6 +115,8 @@ public:
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable_any
|
||||
@ -253,4 +255,6 @@ void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_CONDITION_VARIABLE
|
||||
|
@ -35,12 +35,6 @@ Types:
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#define __need_NULL
|
||||
#define __need_ptrdiff_t
|
||||
#define __need_size_t
|
||||
#endif // __GLIBC__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
@ -52,7 +46,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
using ::ptrdiff_t;
|
||||
using ::size_t;
|
||||
|
||||
#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
|
||||
// Re-use the compiler's <stddef.h> max_align_t where possible.
|
||||
using ::max_align_t;
|
||||
#else
|
||||
typedef long double max_align_t;
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_NULLPTR
|
||||
|
||||
|
@ -1208,7 +1208,7 @@ public:
|
||||
deque()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
{}
|
||||
_LIBCPP_INLINE_VISIBILITY deque(const allocator_type& __a) : __base(__a) {}
|
||||
_LIBCPP_INLINE_VISIBILITY explicit deque(const allocator_type& __a) : __base(__a) {}
|
||||
explicit deque(size_type __n);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
explicit deque(size_type __n, const _Allocator& __a);
|
||||
@ -1588,7 +1588,7 @@ deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
|
||||
{
|
||||
iterator __i = __base::begin();
|
||||
iterator __e = __base::end();
|
||||
for (; __f != __l && __i != __e; ++__f, ++__i)
|
||||
for (; __f != __l && __i != __e; ++__f, (void) ++__i)
|
||||
*__i = *__f;
|
||||
if (__f != __l)
|
||||
__append(__f, __l);
|
||||
@ -2160,7 +2160,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
|
||||
if (__n > __de)
|
||||
{
|
||||
__m = __de < __n / 2 ? _VSTD::next(__f, __de) : _VSTD::prev(__l, __n - __de);
|
||||
for (_BiIter __j = __m; __j != __l; ++__i, ++__j, ++__base::size())
|
||||
for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__base::size())
|
||||
__alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);
|
||||
__n = __de;
|
||||
}
|
||||
@ -2200,7 +2200,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
|
||||
if (__n > __back_capacity)
|
||||
__add_back_capacity(__n - __back_capacity);
|
||||
// __n <= __back_capacity
|
||||
for (iterator __i = __base::end(); __f != __l; ++__i, ++__f, ++__base::size())
|
||||
for (iterator __i = __base::end(); __f != __l; ++__i, (void) ++__f, ++__base::size())
|
||||
__alloc_traits::construct(__a, _VSTD::addressof(*__i), *__f);
|
||||
}
|
||||
|
||||
|
24
contrib/libc++/include/experimental/__config
Normal file
24
contrib/libc++/include/experimental/__config
Normal file
@ -0,0 +1,24 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- __config ---------------------------------===//
|
||||
//
|
||||
// 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_CONFIG
|
||||
#define _LIBCPP_EXPERIMENTAL_CONFIG
|
||||
|
||||
#include <__config>
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } }
|
||||
#define _VSTD_EXPERIMENTAL std::experimental
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS } } }
|
||||
#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
|
||||
|
||||
#endif
|
@ -38,18 +38,18 @@ class dynarray
|
||||
public:
|
||||
// construct/copy/destroy:
|
||||
explicit dynarray(size_type c);
|
||||
template <typename Alloc>
|
||||
dynarray(size_type c, const Alloc& alloc);
|
||||
dynarray(size_type c, const T& v);
|
||||
template <typename Alloc>
|
||||
dynarray(size_type c, const T& v, const Alloc& alloc);
|
||||
dynarray(const dynarray& d);
|
||||
template <typename Alloc>
|
||||
dynarray(const dynarray& d, const Alloc& alloc);
|
||||
dynarray(initializer_list<T>);
|
||||
template <typename Alloc>
|
||||
dynarray(initializer_list<T>, const Alloc& alloc);
|
||||
|
||||
template <class Alloc>
|
||||
dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc);
|
||||
template <class Alloc>
|
||||
dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc);
|
||||
template <class Alloc>
|
||||
dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc);
|
||||
template <class Alloc>
|
||||
dynarray(allocator_arg_t, const Alloc& a, initializer_list<T>, const Alloc& alloc);
|
||||
dynarray& operator=(const dynarray&) = delete;
|
||||
~dynarray();
|
||||
|
||||
@ -147,12 +147,12 @@ private:
|
||||
assert(!"dynarray::allocation");
|
||||
#endif
|
||||
}
|
||||
return static_cast<value_type *> (::operator new (sizeof(value_type) * count));
|
||||
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
|
||||
}
|
||||
|
||||
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept
|
||||
{
|
||||
::operator delete (static_cast<void *> (__ptr));
|
||||
_VSTD::__deallocate (static_cast<void *> (__ptr));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -163,15 +163,15 @@ public:
|
||||
dynarray(initializer_list<value_type>);
|
||||
|
||||
// We're not implementing these right now.
|
||||
// Waiting for the resolution of LWG issue #2235
|
||||
// Updated with the resolution of LWG issue #2255
|
||||
// template <typename _Alloc>
|
||||
// dynarray(size_type __c, const _Alloc& __alloc);
|
||||
// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c);
|
||||
// template <typename _Alloc>
|
||||
// dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc);
|
||||
// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v);
|
||||
// template <typename _Alloc>
|
||||
// dynarray(const dynarray& __d, const _Alloc& __alloc);
|
||||
// dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d);
|
||||
// template <typename _Alloc>
|
||||
// dynarray(initializer_list<value_type>, const _Alloc& __alloc);
|
||||
// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>);
|
||||
|
||||
dynarray& operator=(const dynarray&) = delete;
|
||||
~dynarray();
|
||||
|
@ -16,131 +16,147 @@
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <initializer_list>
|
||||
namespace std { namespace experimental { inline namespace fundamentals_v1 {
|
||||
|
||||
namespace std { namespace experimental {
|
||||
// 5.3, optional for object types
|
||||
template <class T> class optional;
|
||||
|
||||
// optional for object types
|
||||
template <class T>
|
||||
class optional
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
// 5.4, In-place construction
|
||||
struct in_place_t{};
|
||||
constexpr in_place_t in_place{};
|
||||
|
||||
// constructors
|
||||
constexpr optional() noexcept;
|
||||
constexpr optional(nullopt_t) noexcept;
|
||||
optional(const optional&);
|
||||
optional(optional&&) noexcept(is_nothrow_move_constructible<T>::value);
|
||||
constexpr optional(const T&);
|
||||
constexpr optional(T&&);
|
||||
template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
|
||||
template <class U, class... Args>
|
||||
constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
|
||||
// 5.5, No-value state indicator
|
||||
struct nullopt_t{see below};
|
||||
constexpr nullopt_t nullopt(unspecified);
|
||||
|
||||
// destructor
|
||||
~optional();
|
||||
// 5.6, Class bad_optional_access
|
||||
class bad_optional_access;
|
||||
|
||||
// assignment
|
||||
optional& operator=(nullopt_t) noexcept;
|
||||
optional& operator=(const optional&);
|
||||
optional& operator=(optional&&)
|
||||
noexcept(is_nothrow_move_assignable<T>::value &&
|
||||
is_nothrow_move_constructible<T>::value);
|
||||
template <class U> optional& operator=(U&&);
|
||||
template <class... Args> void emplace(Args&&...);
|
||||
template <class U, class... Args> void emplace(initializer_list<U>, Args&&...);
|
||||
// 5.7, Relational operators
|
||||
template <class T>
|
||||
constexpr bool operator==(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator!=(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator<(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator>(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator<=(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator>=(const optional<T>&, const optional<T>&);
|
||||
|
||||
// swap
|
||||
void swap(optional&)
|
||||
noexcept(is_nothrow_move_constructible<T>::value &&
|
||||
noexcept(swap(declval<T&>(), declval<T&>())));
|
||||
// 5.8, Comparison with nullopt
|
||||
template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
|
||||
|
||||
// observers
|
||||
constexpr T const* operator->() const;
|
||||
T* operator->();
|
||||
constexpr T const& operator*() const;
|
||||
T& operator*();
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
constexpr T const& value() const;
|
||||
T& value();
|
||||
template <class U> constexpr T value_or(U&&) const&;
|
||||
template <class U> T value_or(U&&) &&;
|
||||
};
|
||||
// 5.9, Comparison with T
|
||||
template <class T> constexpr bool operator==(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator==(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator!=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator!=(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<=(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator>(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator>(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator>=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator>=(const T&, const optional<T>&);
|
||||
|
||||
// In-place construction
|
||||
struct in_place_t{};
|
||||
constexpr in_place_t in_place{};
|
||||
// 5.10, Specialized algorithms
|
||||
template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
|
||||
template <class T> constexpr optional<see below> make_optional(T&&);
|
||||
|
||||
// Disengaged state indicator
|
||||
struct nullopt_t{see below};
|
||||
constexpr nullopt_t nullopt(unspecified);
|
||||
template <class T>
|
||||
class optional
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
// class bad_optional_access
|
||||
class bad_optional_access
|
||||
: public logic_error
|
||||
{
|
||||
public:
|
||||
explicit bad_optional_access(const string& what_arg);
|
||||
explicit bad_optional_access(const char* what_arg);
|
||||
};
|
||||
// 5.3.1, Constructors
|
||||
constexpr optional() noexcept;
|
||||
constexpr optional(nullopt_t) noexcept;
|
||||
optional(const optional&);
|
||||
optional(optional&&) noexcept(see below);
|
||||
constexpr optional(const T&);
|
||||
constexpr optional(T&&);
|
||||
template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
|
||||
template <class U, class... Args>
|
||||
constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
|
||||
|
||||
// Relational operators
|
||||
template <class T> constexpr bool operator==(const optional<T>&, const optional<T>&);
|
||||
template <class T> constexpr bool operator< (const optional<T>&, const optional<T>&);
|
||||
// 5.3.2, Destructor
|
||||
~optional();
|
||||
|
||||
// Comparison with nullopt
|
||||
template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
|
||||
// 5.3.3, Assignment
|
||||
optional& operator=(nullopt_t) noexcept;
|
||||
optional& operator=(const optional&);
|
||||
optional& operator=(optional&&) noexcept(see below);
|
||||
template <class U> optional& operator=(U&&);
|
||||
template <class... Args> void emplace(Args&&...);
|
||||
template <class U, class... Args>
|
||||
void emplace(initializer_list<U>, Args&&...);
|
||||
|
||||
// Comparison with T
|
||||
template <class T> constexpr bool operator==(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator==(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<(const T&, const optional<T>&);
|
||||
// 5.3.4, Swap
|
||||
void swap(optional&) noexcept(see below);
|
||||
|
||||
// Specialized algorithms
|
||||
template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
|
||||
template <class T> constexpr optional<typename decay<T>::type> make_optional(T&&);
|
||||
// 5.3.5, Observers
|
||||
constexpr T const* operator ->() const;
|
||||
constexpr T* operator ->();
|
||||
constexpr T const& operator *() const &;
|
||||
constexpr T& operator *() &;
|
||||
constexpr T&& operator *() &&;
|
||||
constexpr const T&& operator *() const &&;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
constexpr T const& value() const &;
|
||||
constexpr T& value() &;
|
||||
constexpr T&& value() &&;
|
||||
constexpr const T&& value() const &&;
|
||||
template <class U> constexpr T value_or(U&&) const &;
|
||||
template <class U> constexpr T value_or(U&&) &&;
|
||||
|
||||
// hash support
|
||||
template <class T> struct hash;
|
||||
template <class T> struct hash<optional<T>>;
|
||||
private:
|
||||
T* val; // exposition only
|
||||
};
|
||||
|
||||
}} // std::experimental
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
|
||||
// 5.11, Hash support
|
||||
template <class T> struct hash;
|
||||
template <class T> struct hash<experimental::optional<T>>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <experimental/__config>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace std { namespace experimental {
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
||||
class _LIBCPP_EXCEPTION_ABI bad_optional_access
|
||||
: public logic_error
|
||||
: public std::logic_error
|
||||
{
|
||||
public:
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
_LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const string& __arg)
|
||||
: logic_error(__arg) {}
|
||||
_LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const char* __arg)
|
||||
: logic_error(__arg) {}
|
||||
_LIBCPP_INLINE_VISIBILITY bad_optional_access(const bad_optional_access&) noexcept = default;
|
||||
_LIBCPP_INLINE_VISIBILITY bad_optional_access& operator=(const bad_optional_access&) noexcept = default;
|
||||
#else
|
||||
private:
|
||||
bad_optional_access(const bad_optional_access&);
|
||||
bad_optional_access& operator=(const bad_optional_access&);
|
||||
public:
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
// Get the key function ~bad_optional_access() into the dylib even if not compiling for C++1y
|
||||
bad_optional_access() : std::logic_error("Bad optional Access") {}
|
||||
|
||||
// Get the key function ~bad_optional_access() into the dylib
|
||||
virtual ~bad_optional_access() _NOEXCEPT;
|
||||
};
|
||||
|
||||
}} // std::experimental
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
@ -148,20 +164,14 @@ public:
|
||||
#include <type_traits>
|
||||
#include <new>
|
||||
#include <__functional_base>
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
# include <__debug>
|
||||
#else
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace std { namespace experimental { inline namespace __library_fundamentals_v1 {
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
struct in_place_t {};
|
||||
constexpr in_place_t in_place{};
|
||||
@ -507,7 +517,7 @@ public:
|
||||
constexpr value_type const& value() const
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
throw bad_optional_access("optional<T>::value: not engaged");
|
||||
throw bad_optional_access();
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
@ -515,7 +525,7 @@ public:
|
||||
value_type& value()
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
throw bad_optional_access("optional<T>::value: not engaged");
|
||||
throw bad_optional_access();
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
@ -560,6 +570,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
// Comparisons between optionals
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
@ -573,6 +584,15 @@ operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
return *__x == *__y;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
@ -583,9 +603,38 @@ operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
return false;
|
||||
if (!static_cast<bool>(__x))
|
||||
return true;
|
||||
return less<_Tp>{}(*__x, *__y);
|
||||
return *__x < *__y;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
|
||||
// Comparisons with nullopt
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
@ -604,6 +653,24 @@ operator==(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
@ -622,6 +689,61 @@ operator<(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>&, nullopt_t) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
// Comparisons with T
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
@ -640,6 +762,24 @@ operator==(const _Tp& __v, const optional<_Tp>& __x)
|
||||
return static_cast<bool>(__x) ? *__x == __v : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? !(*__x == __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? !(*__x == __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
@ -658,6 +798,61 @@ operator<(const _Tp& __v, const optional<_Tp>& __x)
|
||||
return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return !(__x > __v);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return !(__v > __x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? __v < __x : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? __x < __v : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return !(__x < __v);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return !(__v < __x);
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
@ -675,7 +870,7 @@ make_optional(_Tp&& __v)
|
||||
return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
|
||||
}
|
||||
|
||||
}}} // namespace std::experimental::__library_fundamentals_v1
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@ -696,4 +891,4 @@ _LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
#endif // _LIBCPP_ARRAY
|
||||
#endif // _LIBCPP_OPTIONAL
|
||||
|
815
contrib/libc++/include/experimental/string_view
Normal file
815
contrib/libc++/include/experimental/string_view
Normal file
@ -0,0 +1,815 @@
|
||||
// -*- 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_LFTS_STRING_VIEW
|
||||
#define _LIBCPP_LFTS_STRING_VIEW
|
||||
|
||||
/*
|
||||
string_view synopsis
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace library_fundamentals_v1 {
|
||||
|
||||
// 7.2, Class template basic_string_view
|
||||
template<class charT, class traits = char_traits<charT>>
|
||||
class basic_string_view;
|
||||
|
||||
// 7.9, basic_string_view non-member comparison functions
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator==(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator!=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator< (basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator> (basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator<=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator>=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
// see below, sufficient additional overloads of comparison functions
|
||||
|
||||
// 7.10, Inserters and extractors
|
||||
template<class charT, class traits>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os,
|
||||
basic_string_view<charT, traits> str);
|
||||
|
||||
// basic_string_view typedef names
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
|
||||
template<class charT, class traits = char_traits<charT>>
|
||||
class basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef traits traits_type;
|
||||
typedef charT value_type;
|
||||
typedef charT* pointer;
|
||||
typedef const charT* const_pointer;
|
||||
typedef charT& reference;
|
||||
typedef const charT& const_reference;
|
||||
typedef implementation-defined const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static constexpr size_type npos = size_type(-1);
|
||||
|
||||
// 7.3, basic_string_view constructors and assignment operators
|
||||
constexpr basic_string_view() noexcept;
|
||||
constexpr basic_string_view(const basic_string_view&) noexcept = default;
|
||||
basic_string_view& operator=(const basic_string_view&) noexcept = default;
|
||||
template<class Allocator>
|
||||
basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept;
|
||||
constexpr basic_string_view(const charT* str);
|
||||
constexpr basic_string_view(const charT* str, size_type len);
|
||||
|
||||
// 7.4, basic_string_view iterator support
|
||||
constexpr const_iterator begin() const noexcept;
|
||||
constexpr const_iterator end() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
// 7.5, basic_string_view capacity
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type length() const noexcept;
|
||||
constexpr size_type max_size() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// 7.6, basic_string_view element access
|
||||
constexpr const_reference operator[](size_type pos) const;
|
||||
constexpr const_reference at(size_type pos) const;
|
||||
constexpr const_reference front() const;
|
||||
constexpr const_reference back() const;
|
||||
constexpr const_pointer data() const noexcept;
|
||||
|
||||
// 7.7, basic_string_view modifiers
|
||||
constexpr void clear() noexcept;
|
||||
constexpr void remove_prefix(size_type n);
|
||||
constexpr void remove_suffix(size_type n);
|
||||
constexpr void swap(basic_string_view& s) noexcept;
|
||||
|
||||
// 7.8, basic_string_view string operations
|
||||
template<class Allocator>
|
||||
explicit operator basic_string<charT, traits, Allocator>() const;
|
||||
template<class Allocator = allocator<charT>>
|
||||
basic_string<charT, traits, Allocator> to_string(
|
||||
const Allocator& a = Allocator()) const;
|
||||
|
||||
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
||||
|
||||
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
||||
constexpr int compare(basic_string_view s) const noexcept;
|
||||
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1,
|
||||
basic_string_view s, size_type pos2, size_type n2) const;
|
||||
constexpr int compare(const charT* s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1,
|
||||
const charT* s, size_type n2) const;
|
||||
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
|
||||
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
|
||||
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
||||
|
||||
private:
|
||||
const_pointer data_; // exposition only
|
||||
size_type size_; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
|
||||
// 7.11, Hash support
|
||||
template <class T> struct hash;
|
||||
template <> struct hash<experimental::string_view>;
|
||||
template <> struct hash<experimental::u16string_view>;
|
||||
template <> struct hash<experimental::u32string_view>;
|
||||
template <> struct hash<experimental::wstring_view>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
|
||||
class _LIBCPP_TYPE_VIS_ONLY basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef _Traits traits_type;
|
||||
typedef _CharT value_type;
|
||||
typedef const _CharT* pointer;
|
||||
typedef const _CharT* const_pointer;
|
||||
typedef const _CharT& reference;
|
||||
typedef const _CharT& const_reference;
|
||||
typedef const_pointer const_iterator; // See [string.view.iterators]
|
||||
typedef const_iterator iterator;
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
|
||||
|
||||
// [string.view.cons], construct/copy
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
template<class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
|
||||
: __data (__str.data()), __size(__str.size()) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s, size_type __len)
|
||||
: __data(__s), __size(__len)
|
||||
{
|
||||
// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr");
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s)
|
||||
: __data(__s), __size(_Traits::length(__s)) {}
|
||||
|
||||
// [string.view.iterators], iterators
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT { return cbegin(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT { return cend(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT { return __data; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT { return __data + __size; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
// [string.view.capacity], capacity
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type length() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
|
||||
empty() const _NOEXCEPT { return __size == 0; }
|
||||
|
||||
// [string.view.access], element access
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference operator[](size_type __pos) const { return __data[__pos]; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type __pos) const
|
||||
{
|
||||
return __pos >= size()
|
||||
? throw out_of_range("string_view::at")
|
||||
: __data[__pos];
|
||||
// if (__pos >= size())
|
||||
// throw out_of_range("string_view::at");
|
||||
// return __data[__pos];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer data() const _NOEXCEPT { return __data; }
|
||||
|
||||
// [string.view.modifiers], modifiers:
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
__data = nullptr;
|
||||
__size = 0;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_prefix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(n <= size(), "remove_prefix() can't remove more than size()");
|
||||
__data += __n;
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_suffix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(n <= size(), "remove_suffix() can't remove more than size()");
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_string_view& __other) _NOEXCEPT
|
||||
{
|
||||
const value_type *__p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
|
||||
size_type __sz = __size;
|
||||
__size = __other.__size;
|
||||
__other.__size = __sz;
|
||||
// _VSTD::swap( __data, __other.__data );
|
||||
// _VSTD::swap( __size, __other.__size );
|
||||
}
|
||||
|
||||
// [string.view.ops], string operations:
|
||||
template<class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
|
||||
{ return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
|
||||
|
||||
template<class _Allocator = allocator<_CharT> >
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
to_string( const _Allocator& __a = _Allocator()) const
|
||||
{ return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); }
|
||||
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{
|
||||
if ( __pos > size())
|
||||
throw out_of_range("string_view::copy");
|
||||
size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
_VSTD::copy_n(begin() + __pos, __rlen, __s );
|
||||
return __rlen;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR
|
||||
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
|
||||
{
|
||||
// if (__pos > size())
|
||||
// throw out_of_range("string_view::substr");
|
||||
// size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
// return basic_string_view(data() + __pos, __rlen);
|
||||
return __pos > size()
|
||||
? throw out_of_range("string_view::substr")
|
||||
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
|
||||
{
|
||||
size_type __rlen = _VSTD::min( size(), __sv.size());
|
||||
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
|
||||
if ( __retval == 0 ) // first __rlen chars matched
|
||||
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
|
||||
return __retval;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare( size_type __pos1, size_type __n1,
|
||||
basic_string_view _sv, size_type __pos2, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(const _CharT* __s) const
|
||||
{
|
||||
return compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
|
||||
}
|
||||
|
||||
// find
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): recieved nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos = 0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// rfind
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): recieved nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{ return find(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{ return rfind(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): recieved nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
private:
|
||||
const value_type* __data;
|
||||
size_type __size;
|
||||
};
|
||||
|
||||
|
||||
// [string.view.comparison]
|
||||
// operator ==
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
|
||||
// operator !=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
|
||||
// operator <
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
|
||||
// operator >
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
|
||||
// operator <=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
|
||||
// operator >=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
// [string.view.io]
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
|
||||
{
|
||||
return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
|
||||
}
|
||||
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// [string.view.hash]
|
||||
// Shamelessly stolen from <string>
|
||||
template<class _CharT, class _Traits>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> >
|
||||
: public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
|
||||
{
|
||||
size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
|
||||
};
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
size_t
|
||||
hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
|
||||
const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
|
||||
{
|
||||
return __do_string_hash(__val.data(), __val.data() + __val.size());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _CharT, class _Traits>
|
||||
__quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
|
||||
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_LFTS_STRING_VIEW
|
423
contrib/libc++/include/experimental/type_traits
Normal file
423
contrib/libc++/include/experimental/type_traits
Normal file
@ -0,0 +1,423 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- type_traits -------------------------------===//
|
||||
//
|
||||
// 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_TYPE_TRAITS
|
||||
#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
|
||||
|
||||
/**
|
||||
experimental/type_traits synopsis
|
||||
|
||||
// C++1y
|
||||
#include <type_traits>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.10.4.1, primary type categories
|
||||
template <class T> constexpr bool is_void_v
|
||||
= is_void<T>::value;
|
||||
template <class T> constexpr bool is_null_pointer_v
|
||||
= is_null_pointer<T>::value;
|
||||
template <class T> constexpr bool is_integral_v
|
||||
= is_integral<T>::value;
|
||||
template <class T> constexpr bool is_floating_point_v
|
||||
= is_floating_point<T>::value;
|
||||
template <class T> constexpr bool is_array_v
|
||||
= is_array<T>::value;
|
||||
template <class T> constexpr bool is_pointer_v
|
||||
= is_pointer<T>::value;
|
||||
template <class T> constexpr bool is_lvalue_reference_v
|
||||
= is_lvalue_reference<T>::value;
|
||||
template <class T> constexpr bool is_rvalue_reference_v
|
||||
= is_rvalue_reference<T>::value;
|
||||
template <class T> constexpr bool is_member_object_pointer_v
|
||||
= is_member_object_pointer<T>::value;
|
||||
template <class T> constexpr bool is_member_function_pointer_v
|
||||
= is_member_function_pointer<T>::value;
|
||||
template <class T> constexpr bool is_enum_v
|
||||
= is_enum<T>::value;
|
||||
template <class T> constexpr bool is_union_v
|
||||
= is_union<T>::value;
|
||||
template <class T> constexpr bool is_class_v
|
||||
= is_class<T>::value;
|
||||
template <class T> constexpr bool is_function_v
|
||||
= is_function<T>::value;
|
||||
|
||||
// See C++14 20.10.4.2, composite type categories
|
||||
template <class T> constexpr bool is_reference_v
|
||||
= is_reference<T>::value;
|
||||
template <class T> constexpr bool is_arithmetic_v
|
||||
= is_arithmetic<T>::value;
|
||||
template <class T> constexpr bool is_fundamental_v
|
||||
= is_fundamental<T>::value;
|
||||
template <class T> constexpr bool is_object_v
|
||||
= is_object<T>::value;
|
||||
template <class T> constexpr bool is_scalar_v
|
||||
= is_scalar<T>::value;
|
||||
template <class T> constexpr bool is_compound_v
|
||||
= is_compound<T>::value;
|
||||
template <class T> constexpr bool is_member_pointer_v
|
||||
= is_member_pointer<T>::value;
|
||||
|
||||
// See C++14 20.10.4.3, type properties
|
||||
template <class T> constexpr bool is_const_v
|
||||
= is_const<T>::value;
|
||||
template <class T> constexpr bool is_volatile_v
|
||||
= is_volatile<T>::value;
|
||||
template <class T> constexpr bool is_trivial_v
|
||||
= is_trivial<T>::value;
|
||||
template <class T> constexpr bool is_trivially_copyable_v
|
||||
= is_trivially_copyable<T>::value;
|
||||
template <class T> constexpr bool is_standard_layout_v
|
||||
= is_standard_layout<T>::value;
|
||||
template <class T> constexpr bool is_pod_v
|
||||
= is_pod<T>::value;
|
||||
template <class T> constexpr bool is_literal_type_v
|
||||
= is_literal_type<T>::value;
|
||||
template <class T> constexpr bool is_empty_v
|
||||
= is_empty<T>::value;
|
||||
template <class T> constexpr bool is_polymorphic_v
|
||||
= is_polymorphic<T>::value;
|
||||
template <class T> constexpr bool is_abstract_v
|
||||
= is_abstract<T>::value;
|
||||
template <class T> constexpr bool is_final_v
|
||||
= is_final<T>::value;
|
||||
template <class T> constexpr bool is_signed_v
|
||||
= is_signed<T>::value;
|
||||
template <class T> constexpr bool is_unsigned_v
|
||||
= is_unsigned<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_constructible_v
|
||||
= is_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_default_constructible_v
|
||||
= is_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_copy_constructible_v
|
||||
= is_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_move_constructible_v
|
||||
= is_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_assignable_v
|
||||
= is_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_copy_assignable_v
|
||||
= is_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_move_assignable_v
|
||||
= is_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_destructible_v
|
||||
= is_destructible<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_trivially_constructible_v
|
||||
= is_trivially_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_trivially_default_constructible_v
|
||||
= is_trivially_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_trivially_copy_constructible_v
|
||||
= is_trivially_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_trivially_move_constructible_v
|
||||
= is_trivially_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_trivially_assignable_v
|
||||
= is_trivially_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_trivially_copy_assignable_v
|
||||
= is_trivially_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_trivially_move_assignable_v
|
||||
= is_trivially_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_trivially_destructible_v
|
||||
= is_trivially_destructible<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_nothrow_constructible_v
|
||||
= is_nothrow_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_nothrow_default_constructible_v
|
||||
= is_nothrow_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_copy_constructible_v
|
||||
= is_nothrow_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_move_constructible_v
|
||||
= is_nothrow_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_nothrow_assignable_v
|
||||
= is_nothrow_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_nothrow_copy_assignable_v
|
||||
= is_nothrow_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<T>::value;
|
||||
template <class T> constexpr bool has_virtual_destructor_v
|
||||
= has_virtual_destructor<T>::value;
|
||||
|
||||
// See C++14 20.10.5, type property queries
|
||||
template <class T> constexpr size_t alignment_of_v
|
||||
= alignment_of<T>::value;
|
||||
template <class T> constexpr size_t rank_v
|
||||
= rank<T>::value;
|
||||
template <class T, unsigned I = 0> constexpr size_t extent_v
|
||||
= extent<T, I>::value;
|
||||
|
||||
// See C++14 20.10.6, type relations
|
||||
template <class T, class U> constexpr bool is_same_v
|
||||
= is_same<T, U>::value;
|
||||
template <class Base, class Derived> constexpr bool is_base_of_v
|
||||
= is_base_of<Base, Derived>::value;
|
||||
template <class From, class To> constexpr bool is_convertible_v
|
||||
= is_convertible<From, To>::value;
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
template <class> class invocation_type; // not defined
|
||||
template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
|
||||
template <class> class raw_invocation_type; // not defined
|
||||
template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;
|
||||
|
||||
template <class T>
|
||||
using invocation_type_t = typename invocation_type<T>::type;
|
||||
template <class T>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<T>::type;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#if __has_feature(cxx_variable_templates)
|
||||
|
||||
// C++14 20.10.4.1, primary type categories
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
|
||||
= is_void<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
|
||||
= is_null_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
|
||||
= is_integral<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
|
||||
= is_floating_point<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
|
||||
= is_array<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
|
||||
= is_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
|
||||
= is_lvalue_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
|
||||
= is_rvalue_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
|
||||
= is_member_object_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
|
||||
= is_member_function_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
|
||||
= is_enum<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
|
||||
= is_union<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
|
||||
= is_class<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
|
||||
= is_function<_Tp>::value;
|
||||
|
||||
// C++14 20.10.4.2, composite type categories
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
|
||||
= is_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
|
||||
= is_arithmetic<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
|
||||
= is_fundamental<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
|
||||
= is_object<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
|
||||
= is_scalar<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
|
||||
= is_compound<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
|
||||
= is_member_pointer<_Tp>::value;
|
||||
|
||||
// C++14 20.10.4.3, type properties
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
|
||||
= is_const<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
|
||||
= is_volatile<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
|
||||
= is_trivial<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
|
||||
= is_trivially_copyable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
|
||||
= is_standard_layout<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
|
||||
= is_pod<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
|
||||
= is_literal_type<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
|
||||
= is_empty<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
|
||||
= is_polymorphic<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
|
||||
= is_abstract<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
|
||||
= is_final<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
|
||||
= is_signed<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
|
||||
= is_unsigned<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
|
||||
= is_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
|
||||
= is_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
|
||||
= is_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
|
||||
= is_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
|
||||
= is_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
|
||||
= is_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
|
||||
= is_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
|
||||
= is_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
|
||||
= is_trivially_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
|
||||
= is_trivially_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
|
||||
= is_trivially_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
|
||||
= is_trivially_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
|
||||
= is_trivially_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
|
||||
= is_trivially_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
|
||||
= is_trivially_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
|
||||
= is_trivially_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
|
||||
= is_nothrow_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
|
||||
= is_nothrow_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
|
||||
= is_nothrow_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
|
||||
= is_nothrow_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
|
||||
= is_nothrow_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
|
||||
= is_nothrow_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
|
||||
= has_virtual_destructor<_Tp>::value;
|
||||
|
||||
// C++14 20.10.5, type properties queries
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
|
||||
= alignment_of<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
|
||||
= rank<_Tp>::value;
|
||||
|
||||
template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
|
||||
= extent<_Tp, _Id>::value;
|
||||
|
||||
// C++14 20.10.6, type relations
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
|
||||
= is_same<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
|
||||
= is_base_of<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
|
||||
= is_convertible<_Tp, _Up>::value;
|
||||
|
||||
#endif /* __has_feature(cxx_variable_templates) */
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
/*
|
||||
template <class>
|
||||
class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type;
|
||||
|
||||
template <class _Fn, class ..._Args>
|
||||
class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>;
|
||||
|
||||
template <class>
|
||||
class _LIBCPP_TYPE_VIS_ONLY invokation_type;
|
||||
|
||||
template <class _Fn, class ..._Args>
|
||||
class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>;
|
||||
|
||||
template <class _Tp>
|
||||
using invokation_type_t = typename invokation_type<_Tp>::type;
|
||||
|
||||
template <class _Tp>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
|
||||
*/
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */
|
44
contrib/libc++/include/experimental/utility
Normal file
44
contrib/libc++/include/experimental/utility
Normal file
@ -0,0 +1,44 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- utility ----------------------------------===//
|
||||
//
|
||||
// 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_UTILITY
|
||||
#define _LIBCPP_EXPERIMENTAL_UTILITY
|
||||
|
||||
/*
|
||||
experimental/utility synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
3.1.2, erased-type placeholder
|
||||
struct erased_type { };
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
# include <experimental/__config>
|
||||
|
||||
# include <utility>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
struct _LIBCPP_TYPE_VIS_ONLY erased_type { };
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */
|
@ -19,8 +19,7 @@
|
||||
namespace __gnu_cxx {
|
||||
using namespace std;
|
||||
|
||||
template <typename _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash : public std::hash<_Tp>
|
||||
{ };
|
||||
template <typename _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash { };
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*>
|
||||
: public unary_function<const char*, size_t>
|
||||
@ -41,6 +40,96 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *>
|
||||
return __do_string_hash<const char *>(__c, __c + strlen(__c));
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char>
|
||||
: public unary_function<char, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(char __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
|
||||
: public unary_function<signed char, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(signed char __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
|
||||
: public unary_function<unsigned char, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned char __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<short>
|
||||
: public unary_function<short, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(short __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
|
||||
: public unary_function<unsigned short, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned short __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<int>
|
||||
: public unary_function<int, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(int __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
|
||||
: public unary_function<unsigned int, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned int __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<long>
|
||||
: public unary_function<long, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(long __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
|
||||
: public unary_function<unsigned long, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned long __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_EXT_HASH
|
||||
|
@ -430,9 +430,9 @@ public:
|
||||
typedef const value_type& reference;
|
||||
typedef typename __pointer_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<value_type>
|
||||
rebind<const value_type>
|
||||
#else
|
||||
rebind<value_type>::other
|
||||
rebind<const value_type>::other
|
||||
#endif
|
||||
pointer;
|
||||
|
||||
|
@ -188,7 +188,6 @@ template <class _Tp, class _VoidPtr> struct __forward_list_node;
|
||||
template <class _NodePtr>
|
||||
struct __forward_begin_node
|
||||
{
|
||||
typedef __forward_begin_node __self;
|
||||
typedef _NodePtr pointer;
|
||||
|
||||
pointer __next_;
|
||||
@ -197,16 +196,22 @@ struct __forward_begin_node
|
||||
};
|
||||
|
||||
template <class _Tp, class _VoidPtr>
|
||||
struct __forward_list_node
|
||||
: public __forward_begin_node
|
||||
<
|
||||
typename pointer_traits<_VoidPtr>::template
|
||||
struct _LIBCPP_HIDDEN __begin_node_of
|
||||
{
|
||||
typedef __forward_begin_node
|
||||
<
|
||||
typename pointer_traits<_VoidPtr>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<__forward_list_node<_Tp, _VoidPtr> >
|
||||
rebind<__forward_list_node<_Tp, _VoidPtr> >
|
||||
#else
|
||||
rebind<__forward_list_node<_Tp, _VoidPtr> >::other
|
||||
rebind<__forward_list_node<_Tp, _VoidPtr> >::other
|
||||
#endif
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _VoidPtr>
|
||||
struct __forward_list_node
|
||||
: public __begin_node_of<_Tp, _VoidPtr>::type
|
||||
{
|
||||
typedef _Tp value_type;
|
||||
|
||||
@ -357,9 +362,9 @@ protected:
|
||||
typedef _Tp value_type;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
|
||||
typedef __forward_list_node<value_type, void_pointer> __node;
|
||||
typedef typename __node::__self __begin_node;
|
||||
typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
|
||||
typedef __forward_list_node<value_type, void_pointer> __node;
|
||||
typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
|
||||
typedef typename allocator_traits<allocator_type>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__node>
|
||||
@ -986,7 +991,7 @@ forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
|
||||
iterator __i = before_begin();
|
||||
iterator __j = _VSTD::next(__i);
|
||||
iterator __e = end();
|
||||
for (; __j != __e && __f != __l; ++__i, ++__j, ++__f)
|
||||
for (; __j != __e && __f != __l; ++__i, (void) ++__j, ++__f)
|
||||
*__j = *__f;
|
||||
if (__j == __e)
|
||||
insert_after(__i, __f, __l);
|
||||
@ -1196,7 +1201,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
for (++__f; __f != __l; ++__f, __last = __last->__next_)
|
||||
for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_)))
|
||||
{
|
||||
__h.reset(__node_traits::allocate(__a, 1));
|
||||
__node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
|
||||
@ -1416,6 +1421,7 @@ template <class _Tp, class _Alloc>
|
||||
void
|
||||
forward_list<_Tp, _Alloc>::remove(const value_type& __v)
|
||||
{
|
||||
forward_list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
|
||||
iterator __e = end();
|
||||
for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
|
||||
{
|
||||
@ -1424,7 +1430,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
|
||||
iterator __j = _VSTD::next(__i, 2);
|
||||
for (; __j != __e && *__j == __v; ++__j)
|
||||
;
|
||||
erase_after(__i, __j);
|
||||
__deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
|
||||
if (__j == __e)
|
||||
break;
|
||||
__i = __j;
|
||||
|
@ -1421,7 +1421,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
|
||||
static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
|
||||
template <class _R2, class ..._Ap>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;}
|
||||
static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;}
|
||||
|
||||
template <class _Fp, bool = !is_same<_Fp, function>::value &&
|
||||
__invokable<_Fp&, _ArgTypes...>::value>
|
||||
@ -1617,21 +1617,22 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
|
||||
if (__not_null(__f))
|
||||
{
|
||||
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
|
||||
if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
|
||||
typedef typename __alloc_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<_FF>
|
||||
#else
|
||||
rebind_alloc<_FF>::other
|
||||
#endif
|
||||
_Ap;
|
||||
_Ap __a(__a0);
|
||||
if (sizeof(_FF) <= sizeof(__buf_) &&
|
||||
is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
::new (__f_) _FF(_VSTD::move(__f));
|
||||
::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef typename __alloc_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<_FF>
|
||||
#else
|
||||
rebind_alloc<_FF>::other
|
||||
#endif
|
||||
_Ap;
|
||||
_Ap __a(__a0);
|
||||
typedef __allocator_destructor<_Ap> _Dp;
|
||||
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
|
||||
::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
|
||||
@ -1857,15 +1858,15 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_of<_Ti&, _Uj...>::type
|
||||
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
|
||||
{
|
||||
return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...);
|
||||
return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
|
||||
}
|
||||
|
||||
template <class _Ti, class ..._Uj>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
typename __lazy_enable_if
|
||||
<
|
||||
is_bind_expression<_Ti>::value,
|
||||
typename __invoke_of<_Ti&, _Uj...>::type
|
||||
__invoke_of<_Ti&, _Uj...>
|
||||
>::type
|
||||
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
|
||||
{
|
||||
@ -1892,7 +1893,7 @@ typename enable_if
|
||||
__mu(_Ti&, _Uj& __uj)
|
||||
{
|
||||
const size_t _Indx = is_placeholder<_Ti>::value - 1;
|
||||
return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj));
|
||||
return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
|
||||
}
|
||||
|
||||
template <class _Ti, class _Uj>
|
||||
@ -2019,7 +2020,7 @@ typename __bind_return<_Fp, _BoundArgs, _Args>::type
|
||||
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
|
||||
_Args&& __args)
|
||||
{
|
||||
return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...);
|
||||
return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
|
||||
}
|
||||
|
||||
template<class _Fp, class ..._BoundArgs>
|
||||
|
@ -374,6 +374,10 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_THREADS
|
||||
#error <future> is not supported on this single threaded system
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
//enum class future_errc
|
||||
@ -779,9 +783,12 @@ __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT
|
||||
{
|
||||
if (this->__state_ & base::__constructed)
|
||||
reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp();
|
||||
typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
|
||||
typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _A;
|
||||
typedef allocator_traits<_A> _ATraits;
|
||||
typedef pointer_traits<typename _ATraits::pointer> _PTraits;
|
||||
_A __a(__alloc_);
|
||||
this->~__assoc_state_alloc();
|
||||
__a.deallocate(this, 1);
|
||||
__a.deallocate(_PTraits::pointer_to(*this), 1);
|
||||
}
|
||||
|
||||
template <class _Rp, class _Alloc>
|
||||
@ -802,9 +809,12 @@ template <class _Rp, class _Alloc>
|
||||
void
|
||||
__assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT
|
||||
{
|
||||
typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
|
||||
typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _A;
|
||||
typedef allocator_traits<_A> _ATraits;
|
||||
typedef pointer_traits<typename _ATraits::pointer> _PTraits;
|
||||
_A __a(__alloc_);
|
||||
this->~__assoc_state_alloc();
|
||||
__a.deallocate(this, 1);
|
||||
__a.deallocate(_PTraits::pointer_to(*this), 1);
|
||||
}
|
||||
|
||||
template <class _Alloc>
|
||||
@ -825,9 +835,12 @@ template <class _Alloc>
|
||||
void
|
||||
__assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT
|
||||
{
|
||||
typename _Alloc::template rebind<__assoc_sub_state_alloc>::other __a(__alloc_);
|
||||
typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _A;
|
||||
typedef allocator_traits<_A> _ATraits;
|
||||
typedef pointer_traits<typename _ATraits::pointer> _PTraits;
|
||||
_A __a(__alloc_);
|
||||
this->~__assoc_sub_state_alloc();
|
||||
__a.deallocate(this, 1);
|
||||
__a.deallocate(_PTraits::pointer_to(*this), 1);
|
||||
}
|
||||
|
||||
template <class _Rp, class _Fp>
|
||||
@ -1410,12 +1423,13 @@ template <class _Rp>
|
||||
template <class _Alloc>
|
||||
promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)
|
||||
{
|
||||
typedef typename _Alloc::template rebind<__assoc_state_alloc<_Rp, _Alloc> >::other _A2;
|
||||
typedef __assoc_state_alloc<_Rp, _Alloc> _State;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
_A2 __a(__a0);
|
||||
unique_ptr<__assoc_state_alloc<_Rp, _Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1));
|
||||
::new(__hold.get()) __assoc_state_alloc<_Rp, _Alloc>(__a0);
|
||||
__state_ = __hold.release();
|
||||
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
|
||||
__state_ = _VSTD::addressof(*__hold.release());
|
||||
}
|
||||
|
||||
template <class _Rp>
|
||||
@ -1583,12 +1597,13 @@ template <class _Rp>
|
||||
template <class _Alloc>
|
||||
promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)
|
||||
{
|
||||
typedef typename _Alloc::template rebind<__assoc_state_alloc<_Rp&, _Alloc> >::other _A2;
|
||||
typedef __assoc_state_alloc<_Rp&, _Alloc> _State;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
_A2 __a(__a0);
|
||||
unique_ptr<__assoc_state_alloc<_Rp&, _Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1));
|
||||
::new(__hold.get()) __assoc_state_alloc<_Rp&, _Alloc>(__a0);
|
||||
__state_ = __hold.release();
|
||||
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
|
||||
__state_ = _VSTD::addressof(*__hold.release());
|
||||
}
|
||||
|
||||
template <class _Rp>
|
||||
@ -1719,12 +1734,13 @@ public:
|
||||
template <class _Alloc>
|
||||
promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
|
||||
{
|
||||
typedef typename _Alloc::template rebind<__assoc_sub_state_alloc<_Alloc> >::other _A2;
|
||||
typedef __assoc_sub_state_alloc<_Alloc> _State;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
_A2 __a(__a0);
|
||||
unique_ptr<__assoc_sub_state_alloc<_Alloc>, _D2> __hold(__a.allocate(1), _D2(__a, 1));
|
||||
::new(__hold.get()) __assoc_sub_state_alloc<_Alloc>(__a0);
|
||||
__state_ = __hold.release();
|
||||
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
|
||||
__state_ = _VSTD::addressof(*__hold.release());
|
||||
}
|
||||
|
||||
template <class _Rp>
|
||||
@ -1804,10 +1820,12 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
|
||||
void
|
||||
__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate()
|
||||
{
|
||||
typedef typename _Alloc::template rebind<__packaged_task_func>::other _Ap;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap;
|
||||
typedef allocator_traits<_Ap> _ATraits;
|
||||
typedef pointer_traits<typename _ATraits::pointer> _PTraits;
|
||||
_Ap __a(__f_.second());
|
||||
__f_.~__compressed_pair<_Fp, _Alloc>();
|
||||
__a.deallocate(this, 1);
|
||||
__a.deallocate(_PTraits::pointer_to(*this), 1);
|
||||
}
|
||||
|
||||
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
|
||||
@ -1872,7 +1890,7 @@ template <class _Fp>
|
||||
__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
|
||||
: __f_(nullptr)
|
||||
{
|
||||
typedef typename remove_reference<_Fp>::type _FR;
|
||||
typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
|
||||
typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
|
||||
if (sizeof(_FF) <= sizeof(__buf_))
|
||||
{
|
||||
@ -1896,8 +1914,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
|
||||
allocator_arg_t, const _Alloc& __a0, _Fp&& __f)
|
||||
: __f_(nullptr)
|
||||
{
|
||||
typedef allocator_traits<_Alloc> __alloc_traits;
|
||||
typedef typename remove_reference<_Fp>::type _FR;
|
||||
typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
|
||||
typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
|
||||
if (sizeof(_FF) <= sizeof(__buf_))
|
||||
{
|
||||
@ -1906,18 +1923,13 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef typename __alloc_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<_FF>
|
||||
#else
|
||||
rebind_alloc<_FF>::other
|
||||
#endif
|
||||
_Ap;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap;
|
||||
_Ap __a(__a0);
|
||||
typedef __allocator_destructor<_Ap> _Dp;
|
||||
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
|
||||
::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
|
||||
__f_ = __hold.release();
|
||||
::new (static_cast<void*>(_VSTD::addressof(*__hold.get())))
|
||||
_FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
|
||||
__f_ = _VSTD::addressof(*__hold.release());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2612,4 +2624,6 @@ future<void>::share()
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_FUTURE
|
||||
|
@ -519,15 +519,16 @@ std::basic_ostream<_CharT, _Traits> &
|
||||
__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
|
||||
_ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
|
||||
{
|
||||
__os << __delim;
|
||||
_VSTD::basic_string<_CharT, _Traits> __str;
|
||||
__str.push_back(__delim);
|
||||
for ( ; __first != __last; ++ __first )
|
||||
{
|
||||
if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
|
||||
__os << __escape;
|
||||
__os << *__first;
|
||||
__str.push_back(__escape);
|
||||
__str.push_back(*__first);
|
||||
}
|
||||
__os << __delim;
|
||||
return __os;
|
||||
__str.push_back(__delim);
|
||||
return __put_character_sequence(__os, __str.data(), __str.size());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _String>
|
||||
|
@ -216,7 +216,7 @@ storage-class-specifier const error_category& iostream_category() noexcept;
|
||||
#include <__locale>
|
||||
#include <system_error>
|
||||
|
||||
#if __has_feature(cxx_atomic)
|
||||
#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
#include <atomic> // for __xindex_
|
||||
#endif
|
||||
|
||||
@ -367,7 +367,7 @@ private:
|
||||
int* __index_;
|
||||
size_t __event_size_;
|
||||
size_t __event_cap_;
|
||||
#if __has_feature(cxx_atomic)
|
||||
#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
static atomic<int> __xindex_;
|
||||
#else
|
||||
static int __xindex_;
|
||||
|
@ -82,6 +82,13 @@ public:
|
||||
pos_type tellg();
|
||||
basic_istream& seekg(pos_type);
|
||||
basic_istream& seekg(off_type, ios_base::seekdir);
|
||||
protected:
|
||||
basic_istream(const basic_istream& rhs) = delete;
|
||||
basic_istream(basic_istream&& rhs);
|
||||
// 27.7.2.1.2 Assign/swap:
|
||||
basic_istream& operator=(const basic_istream& rhs) = delete;
|
||||
basic_istream& operator=(basic_istream&& rhs);
|
||||
void swap(basic_istream& rhs);
|
||||
};
|
||||
|
||||
// 27.7.1.2.3 character extraction templates:
|
||||
@ -184,13 +191,22 @@ protected:
|
||||
_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
|
||||
basic_istream& operator=(basic_istream&& __rhs);
|
||||
#endif
|
||||
void swap(basic_istream& __rhs);
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
basic_istream (const basic_istream& __rhs) = delete;
|
||||
basic_istream& operator=(const basic_istream& __rhs) = delete;
|
||||
#else
|
||||
basic_istream (const basic_istream& __rhs); // not defined
|
||||
basic_istream& operator=(const basic_istream& __rhs); // not defined
|
||||
#endif
|
||||
#endif
|
||||
public:
|
||||
|
||||
// 27.7.1.1.3 Prefix/suffix:
|
||||
|
@ -138,6 +138,8 @@ template <class Iterator>
|
||||
reverse_iterator<Iterator>
|
||||
operator+(typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x);
|
||||
|
||||
template <class Iterator> reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14
|
||||
|
||||
template <class Container>
|
||||
class back_insert_iterator
|
||||
{
|
||||
@ -322,11 +324,23 @@ template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); //
|
||||
template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
|
||||
template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14
|
||||
|
||||
// 24.8, container access:
|
||||
template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
|
||||
template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
|
||||
template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
|
||||
template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
|
||||
template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
|
||||
template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
|
||||
template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
|
||||
template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
|
||||
template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <__functional_base>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
#include <iosfwd>
|
||||
@ -335,11 +349,7 @@ template <class C> auto crend(const C& c) -> decltype(std::rend(c)); //
|
||||
#include <Availability.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
# include <__debug>
|
||||
#else
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -364,10 +374,10 @@ public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
template <class _Iter, bool> struct ____iterator_traits {};
|
||||
template <class _Iter, bool> struct __iterator_traits_impl {};
|
||||
|
||||
template <class _Iter>
|
||||
struct ____iterator_traits<_Iter, true>
|
||||
struct __iterator_traits_impl<_Iter, true>
|
||||
{
|
||||
typedef typename _Iter::difference_type difference_type;
|
||||
typedef typename _Iter::value_type value_type;
|
||||
@ -380,7 +390,7 @@ template <class _Iter, bool> struct __iterator_traits {};
|
||||
|
||||
template <class _Iter>
|
||||
struct __iterator_traits<_Iter, true>
|
||||
: ____iterator_traits
|
||||
: __iterator_traits_impl
|
||||
<
|
||||
_Iter,
|
||||
is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
|
||||
@ -534,7 +544,7 @@ class _LIBCPP_TYPE_VIS_ONLY reverse_iterator
|
||||
typename iterator_traits<_Iter>::reference>
|
||||
{
|
||||
private:
|
||||
mutable _Iter __t;
|
||||
mutable _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
|
||||
protected:
|
||||
_Iter current;
|
||||
public:
|
||||
@ -548,8 +558,8 @@ public:
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY reverse_iterator(const reverse_iterator<_Up>& __u)
|
||||
: __t(__u.base()), current(__u.base()) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _Iter base() const {return current;}
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const {__t = current; return *--__t;}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());}
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return _VSTD::addressof(operator*());}
|
||||
_LIBCPP_INLINE_VISIBILITY reverse_iterator& operator++() {--current; return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY reverse_iterator operator++(int)
|
||||
{reverse_iterator __tmp(*this); --current; return __tmp;}
|
||||
@ -632,6 +642,15 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i
|
||||
return reverse_iterator<_Iter>(__x.base() - __n);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Iter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
|
||||
{
|
||||
return reverse_iterator<_Iter>(__i);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Container>
|
||||
class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator
|
||||
: public iterator<output_iterator_tag,
|
||||
@ -645,7 +664,7 @@ protected:
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(&__x) {}
|
||||
_LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
|
||||
{container->push_back(__value_); return *this;}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -678,7 +697,7 @@ protected:
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(&__x) {}
|
||||
_LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
|
||||
{container->push_front(__value_); return *this;}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -713,7 +732,7 @@ public:
|
||||
typedef _Container container_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
|
||||
: container(&__x), iter(__i) {}
|
||||
: container(_VSTD::addressof(__x)), iter(__i) {}
|
||||
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
|
||||
{iter = container->insert(iter, __value_); ++iter; return *this;}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -1386,7 +1405,7 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n,
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Np>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp*
|
||||
begin(_Tp (&__array)[_Np])
|
||||
{
|
||||
@ -1394,7 +1413,7 @@ begin(_Tp (&__array)[_Np])
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Np>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp*
|
||||
end(_Tp (&__array)[_Np])
|
||||
{
|
||||
@ -1466,17 +1485,17 @@ reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
|
||||
}
|
||||
|
||||
template <class _Cp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
auto cbegin(const _Cp& __c) -> decltype(begin(__c))
|
||||
{
|
||||
return _VSTD::begin(__c);
|
||||
return begin(__c);
|
||||
}
|
||||
|
||||
template <class _Cp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
auto cend(const _Cp& __c) -> decltype(end(__c))
|
||||
{
|
||||
return _VSTD::end(__c);
|
||||
return end(__c);
|
||||
}
|
||||
|
||||
template <class _Cp>
|
||||
@ -1560,6 +1579,36 @@ end(const _Cp& __c)
|
||||
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _C>
|
||||
constexpr auto size(const _C& __c) -> decltype(__c.size()) { return __c.size(); }
|
||||
|
||||
template <class _Tp, size_t _N>
|
||||
constexpr size_t size(const _Tp (&__array)[_N]) noexcept { return _N; }
|
||||
|
||||
template <class _C>
|
||||
constexpr auto empty(const _C& __c) -> decltype(__c.empty()) { return __c.empty(); }
|
||||
|
||||
template <class _Tp, size_t _N>
|
||||
constexpr bool empty(const _Tp (&__array)[_N]) noexcept { return false; }
|
||||
|
||||
template <class _Ep>
|
||||
constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
|
||||
|
||||
template <class _C> constexpr
|
||||
auto data(_C& __c) -> decltype(__c.data()) { return __c.data(); }
|
||||
|
||||
template <class _C> constexpr
|
||||
auto data(const _C& __c) -> decltype(__c.data()) { return __c.data(); }
|
||||
|
||||
template <class _Tp, size_t _N>
|
||||
constexpr _Tp* data(_Tp (&__array)[_N]) noexcept { return __array; }
|
||||
|
||||
template <class _Ep>
|
||||
constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
|
||||
#endif
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ITERATOR
|
||||
|
@ -235,9 +235,9 @@ protected:
|
||||
|
||||
static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
|
||||
static _LIBCPP_CONSTEXPR const bool is_bounded = true;
|
||||
static _LIBCPP_CONSTEXPR const bool is_modulo = true;
|
||||
static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value;
|
||||
|
||||
#if __i386__ || __x86_64__
|
||||
#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__)
|
||||
static _LIBCPP_CONSTEXPR const bool traps = true;
|
||||
#else
|
||||
static _LIBCPP_CONSTEXPR const bool traps = false;
|
||||
@ -768,7 +768,7 @@ template <class _Tp>
|
||||
template <class _Tp>
|
||||
_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
|
||||
template <class _Tp>
|
||||
const int numeric_limits<const volatile _Tp>::max_digits10;
|
||||
_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10;
|
||||
template <class _Tp>
|
||||
_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
|
||||
template <class _Tp>
|
||||
|
@ -179,11 +179,7 @@ template <class T, class Alloc>
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
# include <__debug>
|
||||
#else
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -214,10 +210,13 @@ struct __list_node_base
|
||||
pointer __next_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_node_base()
|
||||
: __prev_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this))),
|
||||
__next_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this)))
|
||||
{}
|
||||
__list_node_base() : __prev_(__self()), __next_(__self()) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer __self()
|
||||
{
|
||||
return static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp, class _VoidPtr>
|
||||
@ -753,20 +752,14 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
||||
swap(__sz(), __c.__sz());
|
||||
swap(__end_, __c.__end_);
|
||||
if (__sz() == 0)
|
||||
__end_.__next_ = __end_.__prev_ = static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
||||
__end_.__next_ = __end_.__prev_ = __end_.__self();
|
||||
else
|
||||
__end_.__prev_->__next_ = __end_.__next_->__prev_
|
||||
= static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
||||
__end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self();
|
||||
if (__c.__sz() == 0)
|
||||
__c.__end_.__next_ = __c.__end_.__prev_
|
||||
= static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
|
||||
__c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self();
|
||||
else
|
||||
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_
|
||||
= static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
|
||||
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self();
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__libcpp_db* __db = __get_db();
|
||||
__c_node* __cn1 = __db->__find_c_and_lock(this);
|
||||
@ -1059,7 +1052,9 @@ public:
|
||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
||||
private:
|
||||
static void __link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l);
|
||||
static void __link_nodes (__node_pointer __p, __node_pointer __f, __node_pointer __l);
|
||||
void __link_nodes_at_front(__node_pointer __f, __node_pointer __l);
|
||||
void __link_nodes_at_back (__node_pointer __f, __node_pointer __l);
|
||||
iterator __iterator(size_type __n);
|
||||
template <class _Comp>
|
||||
static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
|
||||
@ -1081,6 +1076,31 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p
|
||||
__l->__next_ = __p;
|
||||
}
|
||||
|
||||
// Link in nodes [__f, __l] at the front of the list
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l)
|
||||
{
|
||||
__f->__prev_ = base::__end_.__self();
|
||||
__l->__next_ = base::__end_.__next_;
|
||||
__l->__next_->__prev_ = __l;
|
||||
base::__end_.__next_ = __f;
|
||||
}
|
||||
|
||||
// Link in nodes [__f, __l] at the front of the list
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l)
|
||||
{
|
||||
__l->__next_ = base::__end_.__self();
|
||||
__f->__prev_ = base::__end_.__prev_;
|
||||
__f->__prev_->__next_ = __f;
|
||||
base::__end_.__prev_ = __l;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename list<_Tp, _Alloc>::iterator
|
||||
@ -1502,7 +1522,7 @@ list<_Tp, _Alloc>::push_front(const value_type& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
||||
__link_nodes_at_front(__hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1515,8 +1535,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
||||
__link_nodes_at_back(__hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1531,7 +1550,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
||||
__link_nodes_at_front(__hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1544,8 +1563,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
||||
__link_nodes_at_back(__hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1561,7 +1579,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
||||
__link_nodes_at_front(__hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1575,8 +1593,7 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
||||
__link_nodes_at_back(__hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1826,8 +1843,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
|
||||
__link_nodes_at_back(__r.__ptr_, __e.__ptr_);
|
||||
base::__sz() += __ds;
|
||||
}
|
||||
}
|
||||
@ -2038,16 +2054,18 @@ template <class _Tp, class _Alloc>
|
||||
void
|
||||
list<_Tp, _Alloc>::remove(const value_type& __x)
|
||||
{
|
||||
for (iterator __i = begin(), __e = end(); __i != __e;)
|
||||
list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
|
||||
for (const_iterator __i = begin(), __e = end(); __i != __e;)
|
||||
{
|
||||
if (*__i == __x)
|
||||
{
|
||||
iterator __j = _VSTD::next(__i);
|
||||
const_iterator __j = _VSTD::next(__i);
|
||||
for (; __j != __e && *__j == __x; ++__j)
|
||||
;
|
||||
__i = erase(__i, __j);
|
||||
__deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
|
||||
__i = __j;
|
||||
if (__i != __e)
|
||||
__i = _VSTD::next(__i);
|
||||
++__i;
|
||||
}
|
||||
else
|
||||
++__i;
|
||||
@ -2068,7 +2086,7 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred)
|
||||
;
|
||||
__i = erase(__i, __j);
|
||||
if (__i != __e)
|
||||
__i = _VSTD::next(__i);
|
||||
++__i;
|
||||
}
|
||||
else
|
||||
++__i;
|
||||
|
@ -193,9 +193,14 @@ template <class charT> class messages_byname;
|
||||
#include <ctime>
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
#include <support/win32/locale_win32.h>
|
||||
#else // _LIBCPP_MSVCRT
|
||||
#elif defined(_NEWLIB_VERSION)
|
||||
// FIXME: replace all the uses of _NEWLIB_VERSION with __NEWLIB__ preceded by an
|
||||
// include of <sys/cdefs.h> once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
|
||||
// has had a chance to bake for a bit
|
||||
#include <support/newlib/xlocale.h>
|
||||
#elif !defined(__ANDROID__)
|
||||
#include <nl_types.h>
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Availability.h>
|
||||
@ -229,7 +234,8 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
|
||||
// OSX has nice foo_l() functions that let you turn off use of the global
|
||||
// locale. Linux, not so much. The following functions avoid the locale when
|
||||
// that's possible and otherwise do the wrong thing. FIXME.
|
||||
#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX)
|
||||
#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \
|
||||
defined(_NEWLIB_VERSION)
|
||||
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
|
||||
@ -417,7 +423,7 @@ int __sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
|
||||
// and failbit is set in __err.
|
||||
// Else an iterator pointing to the matching keyword is found. If more than
|
||||
// one keyword matches, an iterator to the first matching keyword is returned.
|
||||
// If on exit __b == __e, eofbit is set in __err. If __case_senstive is false,
|
||||
// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
|
||||
// __ct is used to force to lower case before comparing characters.
|
||||
// Examples:
|
||||
// Keywords: "a", "abb"
|
||||
@ -450,7 +456,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
|
||||
size_t __n_does_match = 0; // but none of them definitely do
|
||||
// Initialize all statuses to __might_match, except for "" keywords are __does_match
|
||||
unsigned char* __st = __status;
|
||||
for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
|
||||
for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
|
||||
{
|
||||
if (!__ky->empty())
|
||||
*__st = __might_match;
|
||||
@ -476,7 +482,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
|
||||
// If the keyword doesn't match this character, then change the keyword
|
||||
// to doesn't match
|
||||
__st = __status;
|
||||
for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
|
||||
for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
|
||||
{
|
||||
if (*__st == __might_match)
|
||||
{
|
||||
@ -510,7 +516,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
|
||||
if (__n_might_match + __n_does_match > 1)
|
||||
{
|
||||
__st = __status;
|
||||
for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
|
||||
for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st)
|
||||
{
|
||||
if (*__st == __does_match && __ky->size() != __indx+1)
|
||||
{
|
||||
@ -525,7 +531,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e,
|
||||
if (__b == __e)
|
||||
__err |= ios_base::eofbit;
|
||||
// Return the first matching result
|
||||
for (__st = __status; __kb != __ke; ++__kb, ++__st)
|
||||
for (__st = __status; __kb != __ke; ++__kb, (void) ++__st)
|
||||
if (*__st == __does_match)
|
||||
break;
|
||||
if (__kb == __ke)
|
||||
@ -1180,11 +1186,11 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
|
||||
break;
|
||||
}
|
||||
// Stage 3
|
||||
__a[sizeof(__a)-1] = 0;
|
||||
__buf.resize(__a_end - __a);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
if (sscanf_l(__a, _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
|
||||
if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
|
||||
#else
|
||||
if (__sscanf_l(__a, __cloc(), "%p", &__v) != 1)
|
||||
if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1)
|
||||
#endif
|
||||
__err = ios_base::failbit;
|
||||
// EOF checked
|
||||
@ -1851,7 +1857,7 @@ __get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
|
||||
return 0;
|
||||
}
|
||||
int __r = __ct.narrow(__c, 0) - '0';
|
||||
for (++__b, --__n; __b != __e && __n > 0; ++__b, --__n)
|
||||
for (++__b, (void) --__n; __b != __e && __n > 0; ++__b, (void) --__n)
|
||||
{
|
||||
// get next digit
|
||||
__c = *__b;
|
||||
@ -1871,7 +1877,7 @@ public:
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
class _LIBCPP_TYPE_VIS __time_get_c_storage
|
||||
class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage
|
||||
{
|
||||
protected:
|
||||
typedef basic_string<_CharT> string_type;
|
||||
@ -2038,7 +2044,7 @@ template <class _CharT, class _InputIterator>
|
||||
locale::id
|
||||
time_get<_CharT, _InputIterator>::id;
|
||||
|
||||
// time_get primatives
|
||||
// time_get primitives
|
||||
|
||||
template <class _CharT, class _InputIterator>
|
||||
void
|
||||
@ -2259,7 +2265,7 @@ time_get<_CharT, _InputIterator>::__get_percent(iter_type& __b, iter_type __e,
|
||||
__err |= ios_base::eofbit;
|
||||
}
|
||||
|
||||
// time_get end primatives
|
||||
// time_get end primitives
|
||||
|
||||
template <class _CharT, class _InputIterator>
|
||||
_InputIterator
|
||||
@ -2509,7 +2515,7 @@ protected:
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
class _LIBCPP_TYPE_VIS __time_get_storage
|
||||
class _LIBCPP_TYPE_VIS_ONLY __time_get_storage
|
||||
: public __time_get
|
||||
{
|
||||
protected:
|
||||
@ -2964,6 +2970,8 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
|
||||
size_t __cur_cap = static_cast<size_t>(__e-__b.get()) * sizeof(_Tp);
|
||||
size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ?
|
||||
2 * __cur_cap : numeric_limits<size_t>::max();
|
||||
if (__new_cap == 0)
|
||||
__new_cap = sizeof(_Tp);
|
||||
size_t __n_off = static_cast<size_t>(__n - __b.get());
|
||||
_Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap);
|
||||
if (__t == 0)
|
||||
@ -3673,14 +3681,14 @@ template <class _CharT>
|
||||
typename messages<_CharT>::catalog
|
||||
messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
|
||||
return -1;
|
||||
#else // _WIN32
|
||||
#else // _WIN32 || __ANDROID__
|
||||
catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
|
||||
if (__cat != -1)
|
||||
__cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
|
||||
return __cat;
|
||||
#endif // _WIN32
|
||||
#endif // _WIN32 || __ANDROID__
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
@ -3688,7 +3696,7 @@ typename messages<_CharT>::string_type
|
||||
messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dflt) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
|
||||
return __dflt;
|
||||
#else // _WIN32
|
||||
string __ndflt;
|
||||
@ -3710,7 +3718,7 @@ template <class _CharT>
|
||||
void
|
||||
messages<_CharT>::do_close(catalog __c) const
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
|
||||
if (__c != -1)
|
||||
__c <<= 1;
|
||||
nl_catd __cat = (nl_catd)__c;
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
template<typename K>
|
||||
const_iterator find(const K& x) const; // C++14
|
||||
template<typename K>
|
||||
size_type count(const K& x) const;
|
||||
size_type count(const K& x) const; // C++14
|
||||
|
||||
size_type count(const key_type& k) const;
|
||||
iterator lower_bound(const key_type& k);
|
||||
@ -353,7 +353,7 @@ public:
|
||||
template<typename K>
|
||||
const_iterator find(const K& x) const; // C++14
|
||||
template<typename K>
|
||||
size_type count(const K& x) const;
|
||||
size_type count(const K& x) const; // C++14
|
||||
|
||||
size_type count(const key_type& k) const;
|
||||
iterator lower_bound(const key_type& k);
|
||||
@ -835,11 +835,18 @@ public:
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit map(const key_compare& __comp = key_compare())
|
||||
map()
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_default_constructible<key_compare>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__vc(key_compare())) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit map(const key_compare& __comp)
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__vc(__comp)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1097,6 +1104,12 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const
|
||||
{return __tree_.__count_unique(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
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);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
{return __tree_.lower_bound(__k);}
|
||||
@ -1568,11 +1581,18 @@ public:
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit multimap(const key_compare& __comp = key_compare())
|
||||
multimap()
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_default_constructible<key_compare>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__vc(key_compare())) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit multimap(const key_compare& __comp)
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__vc(__comp)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1820,6 +1840,12 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const
|
||||
{return __tree_.__count_multi(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
|
||||
count(const _K2& __k) {return __tree_.__count_multi(__k);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
{return __tree_.lower_bound(__k);}
|
||||
|
@ -479,6 +479,8 @@ public:
|
||||
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
|
||||
weak_ptr(weak_ptr const& r) noexcept;
|
||||
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
|
||||
weak_ptr(weak_ptr&& r) noexcept; // C++14
|
||||
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
|
||||
|
||||
// destructor
|
||||
~weak_ptr();
|
||||
@ -487,6 +489,8 @@ public:
|
||||
weak_ptr& operator=(weak_ptr const& r) noexcept;
|
||||
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
|
||||
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
|
||||
weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14
|
||||
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
|
||||
|
||||
// modifiers
|
||||
void swap(weak_ptr& r) noexcept;
|
||||
@ -606,7 +610,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
||||
#include <cassert>
|
||||
#endif
|
||||
|
||||
#if __has_feature(cxx_atomic)
|
||||
#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
@ -1446,7 +1450,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
|
||||
{__construct(__has_construct<allocator_type, pointer, _Args...>(),
|
||||
{__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
|
||||
__a, __p, _VSTD::forward<_Args>(__args)...);}
|
||||
#else // _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _Tp>
|
||||
@ -1627,9 +1631,9 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||
{return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));}
|
||||
{return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{::operator delete((void*)__p);}
|
||||
{_VSTD::__deallocate((void*)__p);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
@ -1717,9 +1721,9 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||
{return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));}
|
||||
{return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{::operator delete((void*)__p);}
|
||||
{_VSTD::__deallocate((void*)__p);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
@ -2001,8 +2005,8 @@ public:
|
||||
tuple<_Args2...> __second_args,
|
||||
__tuple_indices<_I1...>,
|
||||
__tuple_indices<_I2...>)
|
||||
: __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...),
|
||||
__second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
|
||||
: __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
|
||||
__second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
|
||||
{}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
@ -2015,7 +2019,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T1>::value)
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(__first_, __x.__first_);
|
||||
@ -2092,8 +2096,8 @@ public:
|
||||
tuple<_Args2...> __second_args,
|
||||
__tuple_indices<_I1...>,
|
||||
__tuple_indices<_I2...>)
|
||||
: _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...),
|
||||
__second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
|
||||
: _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
|
||||
__second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
|
||||
{}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
@ -2106,7 +2110,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T1>::value)
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(__second_, __x.__second_);
|
||||
@ -2184,8 +2188,8 @@ public:
|
||||
tuple<_Args2...> __second_args,
|
||||
__tuple_indices<_I1...>,
|
||||
__tuple_indices<_I2...>)
|
||||
: _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...),
|
||||
__first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...)
|
||||
: _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...),
|
||||
__first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...)
|
||||
|
||||
{}
|
||||
|
||||
@ -2199,7 +2203,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T1>::value)
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(__first_, __x.__first_);
|
||||
@ -2274,8 +2278,8 @@ public:
|
||||
tuple<_Args2...> __second_args,
|
||||
__tuple_indices<_I1...>,
|
||||
__tuple_indices<_I2...>)
|
||||
: _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...),
|
||||
_T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
|
||||
: _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
|
||||
_T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
|
||||
{}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
@ -2288,7 +2292,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T1>::value)
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -2371,7 +2375,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T1>::value)
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{base::swap(__x);}
|
||||
};
|
||||
|
||||
@ -2380,7 +2384,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
|
||||
__is_nothrow_swappable<_T1>::value)
|
||||
__is_nothrow_swappable<_T2>::value)
|
||||
{__x.swap(__y);}
|
||||
|
||||
// __same_or_less_cv_qualified
|
||||
@ -2397,13 +2401,14 @@ template <class _Ptr1, class _Ptr2>
|
||||
struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false>
|
||||
: false_type {};
|
||||
|
||||
template <class _Ptr1, class _Ptr2, bool = is_scalar<_Ptr1>::value &&
|
||||
!is_pointer<_Ptr1>::value>
|
||||
template <class _Ptr1, class _Ptr2, bool = is_pointer<_Ptr1>::value ||
|
||||
is_same<_Ptr1, _Ptr2>::value ||
|
||||
__has_element_type<_Ptr1>::value>
|
||||
struct __same_or_less_cv_qualified
|
||||
: __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {};
|
||||
|
||||
template <class _Ptr1, class _Ptr2>
|
||||
struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true>
|
||||
struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false>
|
||||
: false_type {};
|
||||
|
||||
// default_delete
|
||||
@ -2666,23 +2671,21 @@ public:
|
||||
"unique_ptr constructed with null function pointer deleter");
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Pp,
|
||||
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p,
|
||||
typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT
|
||||
: __ptr_(__p)
|
||||
{
|
||||
static_assert(!is_pointer<deleter_type>::value,
|
||||
"unique_ptr constructed with null function pointer deleter");
|
||||
}
|
||||
|
||||
template <class _Pp,
|
||||
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type
|
||||
>
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional<
|
||||
is_reference<deleter_type>::value,
|
||||
deleter_type,
|
||||
typename add_lvalue_reference<const deleter_type>::type>::type __d)
|
||||
typename add_lvalue_reference<const deleter_type>::type>::type __d,
|
||||
typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
|
||||
_NOEXCEPT
|
||||
: __ptr_(__p, __d) {}
|
||||
|
||||
@ -2693,10 +2696,10 @@ public:
|
||||
_NOEXCEPT
|
||||
: __ptr_(pointer(), __d) {}
|
||||
|
||||
template <class _Pp,
|
||||
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference<deleter_type>::type&& __d)
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p,
|
||||
typename remove_reference<deleter_type>::type&& __d,
|
||||
typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
|
||||
_NOEXCEPT
|
||||
: __ptr_(__p, _VSTD::move(__d))
|
||||
{
|
||||
@ -2811,10 +2814,10 @@ public:
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Pp,
|
||||
class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type
|
||||
reset(_Pp __p) _NOEXCEPT
|
||||
{
|
||||
pointer __tmp = __ptr_.first();
|
||||
__ptr_.first() = __p;
|
||||
@ -3657,7 +3660,7 @@ template <class _Tp, class _Dp, class _Alloc>
|
||||
const void*
|
||||
__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT
|
||||
{
|
||||
return __t == typeid(_Dp) ? &__data_.first().second() : 0;
|
||||
return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_NO_RTTI
|
||||
@ -3674,9 +3677,13 @@ template <class _Tp, class _Dp, class _Alloc>
|
||||
void
|
||||
__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
|
||||
{
|
||||
typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second());
|
||||
typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _A;
|
||||
typedef allocator_traits<_A> _ATraits;
|
||||
typedef pointer_traits<typename _ATraits::pointer> _PTraits;
|
||||
|
||||
_A __a(__data_.second());
|
||||
__data_.second().~_Alloc();
|
||||
__a.deallocate(this, 1);
|
||||
__a.deallocate(_PTraits::pointer_to(*this), 1);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
@ -3739,9 +3746,12 @@ template <class _Tp, class _Alloc>
|
||||
void
|
||||
__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
|
||||
{
|
||||
typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first());
|
||||
typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _A;
|
||||
typedef allocator_traits<_A> _ATraits;
|
||||
typedef pointer_traits<typename _ATraits::pointer> _PTraits;
|
||||
_A __a(__data_.first());
|
||||
__data_.first().~_Alloc();
|
||||
__a.deallocate(this, 1);
|
||||
__a.deallocate(_PTraits::pointer_to(*this), 1);
|
||||
}
|
||||
|
||||
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this;
|
||||
@ -3759,27 +3769,15 @@ private:
|
||||
public:
|
||||
_LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
|
||||
_LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
|
||||
template<class _Yp,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_convertible<_Yp*, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
explicit shared_ptr(_Yp* __p);
|
||||
template<class _Yp, class _Dp,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_convertible<_Yp*, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(_Yp* __p, _Dp __d);
|
||||
template<class _Yp, class _Dp, class _Alloc,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_convertible<_Yp*, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(_Yp* __p, _Dp __d, _Alloc __a);
|
||||
template<class _Yp>
|
||||
explicit shared_ptr(_Yp* __p,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
|
||||
template<class _Yp, class _Dp>
|
||||
shared_ptr(_Yp* __p, _Dp __d,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
|
||||
template<class _Yp, class _Dp, class _Alloc>
|
||||
shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
|
||||
template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
|
||||
template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
|
||||
template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
|
||||
@ -3797,59 +3795,52 @@ public:
|
||||
template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
|
||||
typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat());
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template<class _Yp,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_convertible<_Yp*, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(auto_ptr<_Yp>&& __r);
|
||||
template<class _Yp>
|
||||
shared_ptr(auto_ptr<_Yp>&& __r,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
|
||||
#else
|
||||
template<class _Yp,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_convertible<_Yp*, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(auto_ptr<_Yp> __r);
|
||||
template<class _Yp>
|
||||
shared_ptr(auto_ptr<_Yp> __r,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Yp, class _Dp,
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>&&,
|
||||
typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat());
|
||||
template <class _Yp, class _Dp,
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>&&,
|
||||
typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat());
|
||||
template <class _Yp, class _Dp>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>&&,
|
||||
typename enable_if
|
||||
<
|
||||
!is_lvalue_reference<_Dp>::value &&
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
|
||||
__nat
|
||||
>::type = __nat());
|
||||
template <class _Yp, class _Dp>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>&&,
|
||||
typename enable_if
|
||||
<
|
||||
is_lvalue_reference<_Dp>::value &&
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
|
||||
__nat
|
||||
>::type = __nat());
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Yp, class _Dp,
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
|
||||
>::type
|
||||
> shared_ptr(unique_ptr<_Yp, _Dp>,
|
||||
typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat());
|
||||
template <class _Yp, class _Dp,
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value
|
||||
>::type
|
||||
>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>,
|
||||
typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat());
|
||||
template <class _Yp, class _Dp>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>,
|
||||
typename enable_if
|
||||
<
|
||||
!is_lvalue_reference<_Dp>::value &&
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
|
||||
__nat
|
||||
>::type = __nat());
|
||||
template <class _Yp, class _Dp>
|
||||
shared_ptr(unique_ptr<_Yp, _Dp>,
|
||||
typename enable_if
|
||||
<
|
||||
is_lvalue_reference<_Dp>::value &&
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
|
||||
__nat
|
||||
>::type = __nat());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
~shared_ptr();
|
||||
@ -4039,8 +4030,9 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
template<class _Yp, class>
|
||||
shared_ptr<_Tp>::shared_ptr(_Yp* __p)
|
||||
template<class _Yp>
|
||||
shared_ptr<_Tp>::shared_ptr(_Yp* __p,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
|
||||
: __ptr_(__p)
|
||||
{
|
||||
unique_ptr<_Yp> __hold(__p);
|
||||
@ -4051,8 +4043,9 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p)
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
template<class _Yp, class _Dp, class>
|
||||
shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d)
|
||||
template<class _Yp, class _Dp>
|
||||
shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
|
||||
: __ptr_(__p)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -4094,8 +4087,9 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
template<class _Yp, class _Dp, class _Alloc, class>
|
||||
shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a)
|
||||
template<class _Yp, class _Dp, class _Alloc>
|
||||
shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
|
||||
: __ptr_(__p)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -4103,12 +4097,13 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a)
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
_A2 __a2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__p, __d, __a);
|
||||
__cntrl_ = __hold2.release();
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__p, __d, __a);
|
||||
__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__enable_weak_this(__p);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
@ -4130,12 +4125,13 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
_A2 __a2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__p, __d, __a);
|
||||
__cntrl_ = __hold2.release();
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__p, __d, __a);
|
||||
__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
@ -4208,12 +4204,13 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template<class _Tp>
|
||||
template<class _Yp, class>
|
||||
template<class _Yp>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r)
|
||||
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
|
||||
#else
|
||||
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r)
|
||||
shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
|
||||
#endif
|
||||
typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
|
||||
: __ptr_(__r.get())
|
||||
{
|
||||
typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
|
||||
@ -4223,13 +4220,19 @@ shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r)
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
template <class _Yp, class _Dp, class>
|
||||
template <class _Yp, class _Dp>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
|
||||
#else
|
||||
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
|
||||
#endif
|
||||
typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type)
|
||||
typename enable_if
|
||||
<
|
||||
!is_lvalue_reference<_Dp>::value &&
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
|
||||
__nat
|
||||
>::type)
|
||||
: __ptr_(__r.get())
|
||||
{
|
||||
typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
|
||||
@ -4239,13 +4242,19 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
template <class _Yp, class _Dp, class>
|
||||
template <class _Yp, class _Dp>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
|
||||
#else
|
||||
shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
|
||||
#endif
|
||||
typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type)
|
||||
typename enable_if
|
||||
<
|
||||
is_lvalue_reference<_Dp>::value &&
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
|
||||
__nat
|
||||
>::type)
|
||||
: __ptr_(__r.get())
|
||||
{
|
||||
typedef __shared_ptr_pointer<_Yp*,
|
||||
@ -4282,14 +4291,15 @@ shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
|
||||
{
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
_A2 __a2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
@ -4373,14 +4383,15 @@ shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a)
|
||||
{
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
_Alloc2 __alloc2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__a);
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__a);
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
@ -4391,14 +4402,15 @@ shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0)
|
||||
{
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
_Alloc2 __alloc2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__a, __a0);
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__a, __a0);
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
@ -4409,14 +4421,15 @@ shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
|
||||
{
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
_Alloc2 __alloc2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1);
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__a, __a0, __a1);
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
@ -4427,14 +4440,15 @@ shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
|
||||
{
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
_Alloc2 __alloc2(__a);
|
||||
unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
|
||||
::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2);
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__a, __a0, __a1, __a2);
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
@ -5262,7 +5276,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
|
||||
|
||||
#if __has_feature(cxx_atomic)
|
||||
#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
class _LIBCPP_TYPE_VIS __sp_mut
|
||||
{
|
||||
@ -5388,7 +5402,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v
|
||||
return atomic_compare_exchange_weak(__p, __v, __w);
|
||||
}
|
||||
|
||||
#endif // __has_feature(cxx_atomic)
|
||||
#endif // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
//enum class
|
||||
struct _LIBCPP_TYPE_VIS pointer_safety
|
||||
|
472
contrib/libc++/include/module.modulemap
Normal file
472
contrib/libc++/include/module.modulemap
Normal file
@ -0,0 +1,472 @@
|
||||
module std [system] {
|
||||
// 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++.
|
||||
module algorithm {
|
||||
header "algorithm"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module array {
|
||||
header "array"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module atomic {
|
||||
header "atomic"
|
||||
export *
|
||||
requires cplusplus11
|
||||
}
|
||||
module bitset {
|
||||
header "bitset"
|
||||
export string
|
||||
export iosfwd
|
||||
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 *
|
||||
}
|
||||
module complex {
|
||||
header "complex"
|
||||
export *
|
||||
}
|
||||
module condition_variable {
|
||||
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
|
||||
export *
|
||||
}
|
||||
module exception {
|
||||
header "exception"
|
||||
export *
|
||||
}
|
||||
module forward_list {
|
||||
header "forward_list"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module fstream {
|
||||
header "fstream"
|
||||
export *
|
||||
}
|
||||
module functional {
|
||||
header "functional"
|
||||
export *
|
||||
}
|
||||
module future {
|
||||
header "future"
|
||||
export *
|
||||
}
|
||||
module initializer_list {
|
||||
header "initializer_list"
|
||||
export *
|
||||
}
|
||||
module iomanip {
|
||||
header "iomanip"
|
||||
export *
|
||||
}
|
||||
module ios {
|
||||
header "ios"
|
||||
export iosfwd
|
||||
export *
|
||||
}
|
||||
module iosfwd {
|
||||
header "iosfwd"
|
||||
export *
|
||||
}
|
||||
module iostream {
|
||||
header "iostream"
|
||||
export ios
|
||||
export streambuf
|
||||
export istream
|
||||
export ostream
|
||||
export *
|
||||
}
|
||||
module istream {
|
||||
header "istream"
|
||||
// FIXME: should re-export ios, streambuf?
|
||||
export *
|
||||
}
|
||||
module iterator {
|
||||
header "iterator"
|
||||
export *
|
||||
}
|
||||
module limits {
|
||||
header "limits"
|
||||
export *
|
||||
}
|
||||
module list {
|
||||
header "list"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module locale {
|
||||
header "locale"
|
||||
export *
|
||||
}
|
||||
module map {
|
||||
header "map"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module memory {
|
||||
header "memory"
|
||||
export *
|
||||
}
|
||||
module mutex {
|
||||
header "mutex"
|
||||
export *
|
||||
}
|
||||
module new {
|
||||
header "new"
|
||||
export *
|
||||
}
|
||||
module numeric {
|
||||
header "numeric"
|
||||
export *
|
||||
}
|
||||
module ostream {
|
||||
header "ostream"
|
||||
// FIXME: should re-export ios, streambuf?
|
||||
export *
|
||||
}
|
||||
module queue {
|
||||
header "queue"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module random {
|
||||
header "random"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module ratio {
|
||||
header "ratio"
|
||||
export *
|
||||
}
|
||||
module regex {
|
||||
header "regex"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module scoped_allocator {
|
||||
header "scoped_allocator"
|
||||
export *
|
||||
}
|
||||
module set {
|
||||
header "set"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module sstream {
|
||||
header "sstream"
|
||||
// FIXME: should re-export istream, ostream, ios, streambuf, string?
|
||||
export *
|
||||
}
|
||||
module stack {
|
||||
header "stack"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module stdexcept {
|
||||
header "stdexcept"
|
||||
export *
|
||||
}
|
||||
module streambuf {
|
||||
header "streambuf"
|
||||
export *
|
||||
}
|
||||
module string {
|
||||
header "string"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module strstream {
|
||||
header "strstream"
|
||||
requires !cplusplus11
|
||||
}
|
||||
module system_error {
|
||||
header "system_error"
|
||||
export *
|
||||
}
|
||||
module thread {
|
||||
header "thread"
|
||||
export *
|
||||
}
|
||||
module tuple {
|
||||
header "tuple"
|
||||
export *
|
||||
}
|
||||
module type_traits {
|
||||
header "type_traits"
|
||||
export *
|
||||
}
|
||||
module typeindex {
|
||||
header "typeindex"
|
||||
export *
|
||||
}
|
||||
module typeinfo {
|
||||
header "typeinfo"
|
||||
export *
|
||||
}
|
||||
module unordered_map {
|
||||
header "unordered_map"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module unordered_set {
|
||||
header "unordered_set"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module utility {
|
||||
header "utility"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module valarray {
|
||||
header "valarray"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module vector {
|
||||
header "vector"
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
|
||||
// FIXME: These should be private.
|
||||
module __bit_reference { header "__bit_reference" export * }
|
||||
module __config { header "__config" export * }
|
||||
module __debug { header "__debug" export * }
|
||||
module __functional_base { header "__functional_base" export * }
|
||||
module __hash_table { header "__hash_table" export * }
|
||||
module __locale { header "__locale" export * }
|
||||
module __mutex_base { header "__mutex_base" export * }
|
||||
module __split_buffer { header "__split_buffer" export * }
|
||||
module __sso_allocator { header "__sso_allocator" export * }
|
||||
module __std_stream { header "__std_stream" export * }
|
||||
module __tree { header "__tree" export * }
|
||||
module __tuple { header "__tuple" export * }
|
||||
module __undef_min_max { header "__undef_min_max" export * }
|
||||
}
|
@ -178,6 +178,7 @@ template<class Callable, class ...Args>
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#include <tuple>
|
||||
#endif
|
||||
#include <sched.h>
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
@ -187,6 +188,8 @@ template<class Callable, class ...Args>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
class _LIBCPP_TYPE_VIS recursive_mutex
|
||||
{
|
||||
pthread_mutex_t __m_;
|
||||
@ -425,7 +428,9 @@ lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
struct _LIBCPP_TYPE_VIS once_flag;
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
struct _LIBCPP_TYPE_VIS_ONLY once_flag;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
|
@ -147,4 +147,24 @@ inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _N
|
||||
inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {}
|
||||
inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {}
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
|
||||
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||
return ::operator new(__size);
|
||||
#else
|
||||
return __builtin_operator_new(__size);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
|
||||
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||
::operator delete(__ptr);
|
||||
#else
|
||||
__builtin_operator_delete(__ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_NEW
|
||||
|
@ -91,7 +91,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
__init = __init + *__first1 * *__first2;
|
||||
return __init;
|
||||
}
|
||||
@ -102,7 +102,7 @@ _Tp
|
||||
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
|
||||
_Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
|
||||
return __init;
|
||||
}
|
||||
@ -116,7 +116,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t(*__first);
|
||||
*__result = __t;
|
||||
for (++__first, ++__result; __first != __last; ++__first, ++__result)
|
||||
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
__t = __t + *__first;
|
||||
*__result = __t;
|
||||
@ -135,7 +135,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t(*__first);
|
||||
*__result = __t;
|
||||
for (++__first, ++__result; __first != __last; ++__first, ++__result)
|
||||
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
__t = __binary_op(__t, *__first);
|
||||
*__result = __t;
|
||||
@ -153,7 +153,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t1(*__first);
|
||||
*__result = __t1;
|
||||
for (++__first, ++__result; __first != __last; ++__first, ++__result)
|
||||
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t2(*__first);
|
||||
*__result = __t2 - __t1;
|
||||
@ -173,7 +173,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t1(*__first);
|
||||
*__result = __t1;
|
||||
for (++__first, ++__result; __first != __last; ++__first, ++__result)
|
||||
for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
typename iterator_traits<_InputIterator>::value_type __t2(*__first);
|
||||
*__result = __binary_op(__t2, __t1);
|
||||
@ -188,7 +188,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__value_)
|
||||
for (; __first != __last; ++__first, (void) ++__value_)
|
||||
*__first = __value_;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,13 @@ public:
|
||||
pos_type tellp();
|
||||
basic_ostream& seekp(pos_type);
|
||||
basic_ostream& seekp(off_type, ios_base::seekdir);
|
||||
protected:
|
||||
basic_ostream(const basic_ostream& rhs) = delete;
|
||||
basic_ostream(basic_ostream&& rhs);
|
||||
// 27.7.3.3 Assign/swap
|
||||
basic_ostream& operator=(basic_ostream& rhs) = delete;
|
||||
basic_ostream& operator=(const basic_ostream&& rhs);
|
||||
void swap(basic_ostream& rhs);
|
||||
};
|
||||
|
||||
// 27.7.2.6.4 character inserters
|
||||
@ -162,14 +169,19 @@ protected:
|
||||
#endif
|
||||
|
||||
// 27.7.2.3 Assign/swap
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
basic_ostream& operator=(const basic_ostream&) = delete;
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream& operator=(basic_ostream&& __rhs);
|
||||
#endif
|
||||
void swap(basic_ostream& __rhs);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
basic_ostream (const basic_ostream& __rhs) = delete;
|
||||
basic_ostream& operator=(const basic_ostream& __rhs) = delete;
|
||||
#else
|
||||
basic_ostream (const basic_ostream& __rhs); // not defined
|
||||
basic_ostream& operator=(const basic_ostream& __rhs); // not defined
|
||||
#endif
|
||||
public:
|
||||
|
||||
// 27.7.2.4 Prefix/suffix:
|
||||
@ -729,7 +741,8 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
|
||||
__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
|
||||
const _CharT* __str, size_t __len)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
@ -740,11 +753,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
|
||||
{
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
&__c,
|
||||
__str,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
&__c + 1 :
|
||||
&__c,
|
||||
&__c + 1,
|
||||
__str + __len :
|
||||
__str,
|
||||
__str + __len,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
@ -759,6 +772,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
|
||||
return __os;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
|
||||
{
|
||||
return _VSTD::__put_character_sequence(__os, &__c, 1);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
|
||||
@ -796,129 +817,28 @@ template<class _Traits>
|
||||
basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, char __c)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<char, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<char, _Traits> _Ip;
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
&__c,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
&__c + 1 :
|
||||
&__c,
|
||||
&__c + 1,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
return _VSTD::__put_character_sequence(__os, &__c, 1);
|
||||
}
|
||||
|
||||
template<class _Traits>
|
||||
basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<char, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<char, _Traits> _Ip;
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
(char*)&__c,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
(char*)&__c + 1 :
|
||||
(char*)&__c,
|
||||
(char*)&__c + 1,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
|
||||
}
|
||||
|
||||
template<class _Traits>
|
||||
basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<char, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<char, _Traits> _Ip;
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
(char*)&__c,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
(char*)&__c + 1 :
|
||||
(char*)&__c,
|
||||
(char*)&__c + 1,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
size_t __len = _Traits::length(__str);
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
__str,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
__str + __len :
|
||||
__str,
|
||||
__str + __len,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
@ -971,99 +891,23 @@ template<class _Traits>
|
||||
basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<char, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<char, _Traits> _Ip;
|
||||
size_t __len = _Traits::length(__str);
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
__str,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
__str + __len :
|
||||
__str,
|
||||
__str + __len,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
|
||||
}
|
||||
|
||||
template<class _Traits>
|
||||
basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<char, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<char, _Traits> _Ip;
|
||||
size_t __len = _Traits::length((const char*)__str);
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
(const char*)__str,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
(const char*)__str + __len :
|
||||
(const char*)__str,
|
||||
(const char*)__str + __len,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
const char *__s = (const char *) __str;
|
||||
return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
|
||||
}
|
||||
|
||||
template<class _Traits>
|
||||
basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<char, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<char, _Traits> _Ip;
|
||||
size_t __len = _Traits::length((const char*)__str);
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
(const char*)__str,
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
(const char*)__str + __len :
|
||||
(const char*)__str,
|
||||
(const char*)__str + __len,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
const char *__s = (const char *) __str;
|
||||
return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
@ -1233,33 +1077,7 @@ basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
||||
const basic_string<_CharT, _Traits, _Allocator>& __str)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
size_t __len = __str.size();
|
||||
if (__pad_and_output(_Ip(__os),
|
||||
__str.data(),
|
||||
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
||||
__str.data() + __len :
|
||||
__str.data(),
|
||||
__str.data() + __len,
|
||||
__os,
|
||||
__os.fill()).failed())
|
||||
__os.setstate(ios_base::badbit | ios_base::failbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
|
@ -3475,9 +3475,9 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
|
||||
|
||||
class _LIBCPP_TYPE_VIS random_device
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
#if !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM))
|
||||
int __f_;
|
||||
#endif // defined(_WIN32)
|
||||
#endif // !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM))
|
||||
public:
|
||||
// types
|
||||
typedef unsigned result_type;
|
||||
@ -4009,6 +4009,8 @@ binomial_distribution<_IntType>::param_type::param_type(result_type __t, double
|
||||
}
|
||||
}
|
||||
|
||||
// Reference: Kemp, C.D. (1986). `A modal method for generating binomial
|
||||
// variables', Commun. Statist. - Theor. Meth. 15(3), 805-813.
|
||||
template<class _IntType>
|
||||
template<class _URNG>
|
||||
_IntType
|
||||
@ -4035,7 +4037,8 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
|
||||
if (__u < 0)
|
||||
return __rd - 1;
|
||||
}
|
||||
--__rd;
|
||||
if ( __rd != 0 )
|
||||
--__rd;
|
||||
++__ru;
|
||||
if (__ru <= __pr.__t_)
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ class match_results
|
||||
public:
|
||||
typedef sub_match<BidirectionalIterator> value_type;
|
||||
typedef const value_type& const_reference;
|
||||
typedef const_reference reference;
|
||||
typedef value_type& reference;
|
||||
typedef /implementation-defined/ const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
|
||||
@ -546,6 +546,13 @@ template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
const basic_regex<charT, traits>& e,
|
||||
regex_constants::match_flag_type flags = regex_constants::match_default);
|
||||
|
||||
template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
bool
|
||||
regex_match(const basic_string<charT, ST, SA>&& s,
|
||||
match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
|
||||
|
||||
template <class charT, class traits>
|
||||
bool
|
||||
regex_match(const charT* str, const basic_regex<charT, traits>& e,
|
||||
@ -594,6 +601,13 @@ template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
const basic_regex<charT, traits>& e,
|
||||
regex_constants::match_flag_type flags = regex_constants::match_default);
|
||||
|
||||
template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
bool
|
||||
regex_search(const basic_string<charT, ST, SA>&& s,
|
||||
match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
|
||||
|
||||
template <class OutputIterator, class BidirectionalIterator,
|
||||
class traits, class charT, class ST, class SA>
|
||||
OutputIterator
|
||||
@ -655,6 +669,10 @@ public:
|
||||
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type& re,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default);
|
||||
regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type&& __re,
|
||||
regex_constants::match_flag_type __m
|
||||
= regex_constants::match_default) = delete; // C++14
|
||||
regex_iterator(const regex_iterator&);
|
||||
regex_iterator& operator=(const regex_iterator&);
|
||||
|
||||
@ -690,16 +708,29 @@ public:
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type& re, int submatch = 0,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default);
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type&& re, int submatch = 0,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type& re, const vector<int>& submatches,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default);
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type&& re, const vector<int>& submatches,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type& re, initializer_list<int> submatches,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default);
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type&& re, initializer_list<int> submatches,
|
||||
regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
|
||||
template <size_t N>
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type& re, const int (&submatches)[N],
|
||||
regex_constants::match_flag_type m = regex_constants::match_default);
|
||||
template <size_t N>
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
const regex_type& re, const int (&submatches)[N],
|
||||
regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;
|
||||
regex_token_iterator(const regex_token_iterator&);
|
||||
regex_token_iterator& operator=(const regex_token_iterator&);
|
||||
|
||||
@ -1161,7 +1192,8 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
|
||||
|
||||
// lookup_classname
|
||||
|
||||
ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase);
|
||||
regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
|
||||
__get_classname(const char* __s, bool __icase);
|
||||
|
||||
template <class _CharT>
|
||||
template <class _ForwardIterator>
|
||||
@ -2153,8 +2185,8 @@ class __bracket_expression
|
||||
vector<pair<string_type, string_type> > __ranges_;
|
||||
vector<pair<_CharT, _CharT> > __digraphs_;
|
||||
vector<string_type> __equivalences_;
|
||||
ctype_base::mask __mask_;
|
||||
ctype_base::mask __neg_mask_;
|
||||
typename regex_traits<_CharT>::char_class_type __mask_;
|
||||
typename regex_traits<_CharT>::char_class_type __neg_mask_;
|
||||
bool __negate_;
|
||||
bool __icase_;
|
||||
bool __collate_;
|
||||
@ -2250,10 +2282,10 @@ public:
|
||||
void __add_equivalence(const string_type& __s)
|
||||
{__equivalences_.push_back(__s);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __add_class(ctype_base::mask __mask)
|
||||
void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
|
||||
{__mask_ |= __mask;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __add_neg_class(ctype_base::mask __mask)
|
||||
void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
|
||||
{__neg_mask_ |= __mask;}
|
||||
};
|
||||
|
||||
@ -3310,10 +3342,14 @@ basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
|
||||
_ForwardIterator __temp = _VSTD::next(__first);
|
||||
if (__temp != __last)
|
||||
{
|
||||
if (*__first == '\\' && '1' <= *__temp && *__temp <= '9')
|
||||
{
|
||||
__push_back_ref(*__temp - '0');
|
||||
__first = ++__temp;
|
||||
if (*__first == '\\')
|
||||
{
|
||||
int __val = __traits_.value(*__temp, 10);
|
||||
if (__val >= 1 && __val <= 9)
|
||||
{
|
||||
__push_back_ref(__val);
|
||||
__first = ++__temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4052,14 +4088,19 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
|
||||
_ForwardIterator __last,
|
||||
int& __c)
|
||||
{
|
||||
if (__first != __last && '0' <= *__first && *__first <= '9')
|
||||
if (__first != __last )
|
||||
{
|
||||
__c = *__first - '0';
|
||||
for (++__first; __first != __last && '0' <= *__first && *__first <= '9';
|
||||
++__first)
|
||||
int __val = __traits_.value(*__first, 10);
|
||||
if ( __val != -1 )
|
||||
{
|
||||
__c *= 10;
|
||||
__c += *__first - '0';
|
||||
__c = __val;
|
||||
for (++__first;
|
||||
__first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
|
||||
++__first)
|
||||
{
|
||||
__c *= 10;
|
||||
__c += __val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __first;
|
||||
@ -4501,6 +4542,13 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
|
||||
__push_char(_CharT(__sum));
|
||||
++__first;
|
||||
break;
|
||||
case '0':
|
||||
if (__str)
|
||||
*__str = _CharT(0);
|
||||
else
|
||||
__push_char(_CharT(0));
|
||||
++__first;
|
||||
break;
|
||||
default:
|
||||
if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
|
||||
{
|
||||
@ -4878,7 +4926,7 @@ bool
|
||||
operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
|
||||
const sub_match<_BiIter>& __y)
|
||||
{
|
||||
return __y.compare(__x.c_str()) == 0;
|
||||
return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
|
||||
}
|
||||
|
||||
template <class _BiIter, class _ST, class _SA>
|
||||
@ -4896,7 +4944,7 @@ bool
|
||||
operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
|
||||
const sub_match<_BiIter>& __y)
|
||||
{
|
||||
return __y.compare(__x.c_str()) > 0;
|
||||
return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
|
||||
}
|
||||
|
||||
template <class _BiIter, class _ST, class _SA>
|
||||
@ -4931,7 +4979,7 @@ bool
|
||||
operator==(const sub_match<_BiIter>& __x,
|
||||
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
|
||||
{
|
||||
return __x.compare(__y.c_str()) == 0;
|
||||
return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
|
||||
}
|
||||
|
||||
template <class _BiIter, class _ST, class _SA>
|
||||
@ -4949,7 +4997,7 @@ bool
|
||||
operator<(const sub_match<_BiIter>& __x,
|
||||
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
|
||||
{
|
||||
return __x.compare(__y.c_str()) < 0;
|
||||
return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
|
||||
}
|
||||
|
||||
template <class _BiIter, class _ST, class _SA>
|
||||
@ -5223,7 +5271,7 @@ private:
|
||||
public:
|
||||
_BidirectionalIterator __position_start_;
|
||||
typedef const value_type& const_reference;
|
||||
typedef const_reference reference;
|
||||
typedef value_type& reference;
|
||||
typedef typename __container_type::const_iterator const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
|
||||
@ -5934,6 +5982,15 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s,
|
||||
return __r;
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
|
||||
bool
|
||||
regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
|
||||
match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
|
||||
const basic_regex<_Cp, _Tp>& __e,
|
||||
regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
|
||||
#endif
|
||||
|
||||
// regex_match
|
||||
|
||||
template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
|
||||
@ -5986,6 +6043,16 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
|
||||
return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
|
||||
match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
|
||||
const basic_regex<_CharT, _Traits>& __e,
|
||||
regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
@ -6031,7 +6098,14 @@ public:
|
||||
regex_iterator();
|
||||
regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type& __re,
|
||||
regex_constants::match_flag_type __m = regex_constants::match_default);
|
||||
regex_constants::match_flag_type __m
|
||||
= regex_constants::match_default);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type&& __re,
|
||||
regex_constants::match_flag_type __m
|
||||
= regex_constants::match_default) = delete;
|
||||
#endif
|
||||
|
||||
bool operator==(const regex_iterator& __x) const;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -6147,16 +6221,38 @@ public:
|
||||
const regex_type& __re, int __submatch = 0,
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type&& __re, int __submatch = 0,
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default) = delete;
|
||||
#endif
|
||||
|
||||
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type& __re, const vector<int>& __submatches,
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type&& __re, const vector<int>& __submatches,
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default) = delete;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type& __re,
|
||||
initializer_list<int> __submatches,
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default);
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
|
||||
const regex_type&& __re,
|
||||
initializer_list<int> __submatches,
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default) = delete;
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
template <size_t _Np>
|
||||
regex_token_iterator(_BidirectionalIterator __a,
|
||||
@ -6165,6 +6261,16 @@ public:
|
||||
const int (&__submatches)[_Np],
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <std::size_t _Np>
|
||||
regex_token_iterator(_BidirectionalIterator __a,
|
||||
_BidirectionalIterator __b,
|
||||
const regex_type&& __re,
|
||||
const int (&__submatches)[_Np],
|
||||
regex_constants::match_flag_type __m =
|
||||
regex_constants::match_default) = delete;
|
||||
#endif
|
||||
|
||||
regex_token_iterator(const regex_token_iterator&);
|
||||
regex_token_iterator& operator=(const regex_token_iterator&);
|
||||
|
||||
@ -6188,6 +6294,12 @@ public:
|
||||
|
||||
private:
|
||||
void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
|
||||
void __establish_result () {
|
||||
if (__subs_[_N_] == -1)
|
||||
__result_ = &__position_->prefix();
|
||||
else
|
||||
__result_ = &(*__position_)[__subs_[_N_]];
|
||||
}
|
||||
};
|
||||
|
||||
template <class _BidirectionalIterator, class _CharT, class _Traits>
|
||||
@ -6205,12 +6317,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
|
||||
__init(_BidirectionalIterator __a, _BidirectionalIterator __b)
|
||||
{
|
||||
if (__position_ != _Position())
|
||||
{
|
||||
if (__subs_[_N_] == -1)
|
||||
__result_ = &__position_->prefix();
|
||||
else
|
||||
__result_ = &(*__position_)[__subs_[_N_]];
|
||||
}
|
||||
__establish_result ();
|
||||
else if (__subs_[_N_] == -1)
|
||||
{
|
||||
__suffix_.matched = true;
|
||||
@ -6287,7 +6394,9 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
|
||||
__subs_(__x.__subs_)
|
||||
{
|
||||
if (__x.__result_ == &__x.__suffix_)
|
||||
__result_ == &__suffix_;
|
||||
__result_ = &__suffix_;
|
||||
else if ( __result_ != nullptr )
|
||||
__establish_result ();
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _CharT, class _Traits>
|
||||
@ -6299,12 +6408,15 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
|
||||
{
|
||||
__position_ = __x.__position_;
|
||||
if (__x.__result_ == &__x.__suffix_)
|
||||
__result_ == &__suffix_;
|
||||
__result_ = &__suffix_;
|
||||
else
|
||||
__result_ = __x.__result_;
|
||||
__suffix_ = __x.__suffix_;
|
||||
_N_ = __x._N_;
|
||||
__subs_ = __x.__subs_;
|
||||
|
||||
if ( __result_ != nullptr && __result_ != &__suffix_ )
|
||||
__establish_result();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -6337,22 +6449,14 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
|
||||
else if (_N_ + 1 < __subs_.size())
|
||||
{
|
||||
++_N_;
|
||||
if (__subs_[_N_] == -1)
|
||||
__result_ = &__position_->prefix();
|
||||
else
|
||||
__result_ = &(*__position_)[__subs_[_N_]];
|
||||
__establish_result();
|
||||
}
|
||||
else
|
||||
{
|
||||
_N_ = 0;
|
||||
++__position_;
|
||||
if (__position_ != _Position())
|
||||
{
|
||||
if (__subs_[_N_] == -1)
|
||||
__result_ = &__position_->prefix();
|
||||
else
|
||||
__result_ = &(*__position_)[__subs_[_N_]];
|
||||
}
|
||||
__establish_result();
|
||||
else
|
||||
{
|
||||
if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
|
||||
|
@ -425,14 +425,22 @@ public:
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit set(const value_compare& __comp = value_compare())
|
||||
set()
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_default_constructible<key_compare>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__comp) {}
|
||||
: __tree_(value_compare()) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
set(const value_compare& __comp, const allocator_type& __a)
|
||||
explicit set(const value_compare& __comp)
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__comp) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit set(const value_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__comp, __a) {}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -655,6 +663,12 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const
|
||||
{return __tree_.__count_unique(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
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);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
{return __tree_.lower_bound(__k);}
|
||||
@ -822,14 +836,22 @@ public:
|
||||
|
||||
// construct/copy/destroy:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit multiset(const value_compare& __comp = value_compare())
|
||||
multiset()
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_default_constructible<key_compare>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__comp) {}
|
||||
: __tree_(value_compare()) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
multiset(const value_compare& __comp, const allocator_type& __a)
|
||||
explicit multiset(const value_compare& __comp)
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_default_constructible<allocator_type>::value &&
|
||||
is_nothrow_copy_constructible<key_compare>::value)
|
||||
: __tree_(__comp) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit multiset(const value_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__comp, __a) {}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1050,6 +1072,12 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const
|
||||
{return __tree_.__count_multi(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
|
||||
count(const _K2& __k) {return __tree_.__count_multi(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
|
@ -19,14 +19,14 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
class shared_mutex
|
||||
class shared_timed_mutex
|
||||
{
|
||||
public:
|
||||
shared_mutex();
|
||||
~shared_mutex();
|
||||
shared_timed_mutex();
|
||||
~shared_timed_mutex();
|
||||
|
||||
shared_mutex(const shared_mutex&) = delete;
|
||||
shared_mutex& operator=(const shared_mutex&) = delete;
|
||||
shared_timed_mutex(const shared_timed_mutex&) = delete;
|
||||
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
|
||||
|
||||
// Exclusive ownership
|
||||
void lock(); // blocking
|
||||
@ -112,9 +112,13 @@ template <class Mutex>
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_THREADS
|
||||
#error <shared_mutex> is not supported on this single threaded system
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TYPE_VIS shared_mutex
|
||||
class _LIBCPP_TYPE_VIS shared_timed_mutex
|
||||
{
|
||||
mutex __mut_;
|
||||
condition_variable __gate1_;
|
||||
@ -124,11 +128,11 @@ class _LIBCPP_TYPE_VIS shared_mutex
|
||||
static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
|
||||
static const unsigned __n_readers_ = ~__write_entered_;
|
||||
public:
|
||||
shared_mutex();
|
||||
_LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
|
||||
shared_timed_mutex();
|
||||
_LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
|
||||
|
||||
shared_mutex(const shared_mutex&) = delete;
|
||||
shared_mutex& operator=(const shared_mutex&) = delete;
|
||||
shared_timed_mutex(const shared_timed_mutex&) = delete;
|
||||
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
|
||||
|
||||
// Exclusive ownership
|
||||
void lock();
|
||||
@ -163,7 +167,7 @@ public:
|
||||
|
||||
template <class _Clock, class _Duration>
|
||||
bool
|
||||
shared_mutex::try_lock_until(
|
||||
shared_timed_mutex::try_lock_until(
|
||||
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
||||
{
|
||||
unique_lock<mutex> __lk(__mut_);
|
||||
@ -198,7 +202,7 @@ shared_mutex::try_lock_until(
|
||||
|
||||
template <class _Clock, class _Duration>
|
||||
bool
|
||||
shared_mutex::try_lock_shared_until(
|
||||
shared_timed_mutex::try_lock_shared_until(
|
||||
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
||||
{
|
||||
unique_lock<mutex> __lk(__mut_);
|
||||
@ -232,7 +236,7 @@ private:
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock() noexcept
|
||||
shared_lock() _NOEXCEPT
|
||||
: __m_(nullptr),
|
||||
__owns_(false)
|
||||
{}
|
||||
@ -244,7 +248,7 @@ public:
|
||||
{__m_->lock_shared();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(mutex_type& __m, defer_lock_t) noexcept
|
||||
shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
|
||||
: __m_(&__m),
|
||||
__owns_(false)
|
||||
{}
|
||||
@ -288,7 +292,7 @@ public:
|
||||
shared_lock& operator=(shared_lock const&) = delete;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(shared_lock&& __u) noexcept
|
||||
shared_lock(shared_lock&& __u) _NOEXCEPT
|
||||
: __m_(__u.__m_),
|
||||
__owns_(__u.__owns_)
|
||||
{
|
||||
@ -297,7 +301,7 @@ public:
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock& operator=(shared_lock&& __u) noexcept
|
||||
shared_lock& operator=(shared_lock&& __u) _NOEXCEPT
|
||||
{
|
||||
if (__owns_)
|
||||
__m_->unlock_shared();
|
||||
@ -320,14 +324,14 @@ public:
|
||||
|
||||
// Setters
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(shared_lock& __u) noexcept
|
||||
void swap(shared_lock& __u) _NOEXCEPT
|
||||
{
|
||||
_VSTD::swap(__m_, __u.__m_);
|
||||
_VSTD::swap(__owns_, __u.__owns_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
mutex_type* release() noexcept
|
||||
mutex_type* release() _NOEXCEPT
|
||||
{
|
||||
mutex_type* __m = __m_;
|
||||
__m_ = nullptr;
|
||||
@ -337,13 +341,13 @@ public:
|
||||
|
||||
// Getters
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool owns_lock() const noexcept {return __owns_;}
|
||||
bool owns_lock() const _NOEXCEPT {return __owns_;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit operator bool () const noexcept {return __owns_;}
|
||||
explicit operator bool () const _NOEXCEPT {return __owns_;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
mutex_type* mutex() const noexcept {return __m_;}
|
||||
mutex_type* mutex() const _NOEXCEPT {return __m_;}
|
||||
};
|
||||
|
||||
template <class _Mutex>
|
||||
@ -409,11 +413,13 @@ shared_lock<_Mutex>::unlock()
|
||||
template <class _Mutex>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
|
||||
swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT
|
||||
{__x.swap(__y);}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
#endif // _LIBCPP_SHARED_MUTEX
|
||||
|
@ -325,11 +325,16 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
|
||||
__p = const_cast<char_type*>(__str_.data());
|
||||
if (__binp != -1)
|
||||
this->setg(__p + __binp, __p + __ninp, __p + __einp);
|
||||
else
|
||||
this->setg(nullptr, nullptr, nullptr);
|
||||
if (__bout != -1)
|
||||
{
|
||||
this->setp(__p + __bout, __p + __eout);
|
||||
this->pbump(__nout);
|
||||
}
|
||||
else
|
||||
this->setp(nullptr, nullptr);
|
||||
|
||||
__hm_ = __hm == -1 ? nullptr : __p + __hm;
|
||||
__mode_ = __rhs.__mode_;
|
||||
__p = const_cast<char_type*>(__rhs.__str_.data());
|
||||
|
@ -50,6 +50,14 @@ public:
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP___REFSTRING
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
class _LIBCPP_HIDDEN __libcpp_refstring {
|
||||
const char *__imp_ _LIBCPP_UNUSED;
|
||||
};
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
#endif
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
@ -57,7 +65,7 @@ class _LIBCPP_EXCEPTION_ABI logic_error
|
||||
: public exception
|
||||
{
|
||||
private:
|
||||
void* __imp_;
|
||||
_VSTD::__libcpp_refstring __imp_;
|
||||
public:
|
||||
explicit logic_error(const string&);
|
||||
explicit logic_error(const char*);
|
||||
@ -74,7 +82,7 @@ class _LIBCPP_EXCEPTION_ABI runtime_error
|
||||
: public exception
|
||||
{
|
||||
private:
|
||||
void* __imp_;
|
||||
_VSTD::__libcpp_refstring __imp_;
|
||||
public:
|
||||
explicit runtime_error(const string&);
|
||||
explicit runtime_error(const char*);
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
basic_string& operator+=(initializer_list<value_type>);
|
||||
|
||||
basic_string& append(const basic_string& str);
|
||||
basic_string& append(const basic_string& str, size_type pos, size_type n);
|
||||
basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
|
||||
basic_string& append(const value_type* s, size_type n);
|
||||
basic_string& append(const value_type* s);
|
||||
basic_string& append(size_type n, value_type c);
|
||||
@ -178,7 +178,7 @@ public:
|
||||
|
||||
basic_string& assign(const basic_string& str);
|
||||
basic_string& assign(basic_string&& str);
|
||||
basic_string& assign(const basic_string& str, size_type pos, size_type n);
|
||||
basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
|
||||
basic_string& assign(const value_type* s, size_type n);
|
||||
basic_string& assign(const value_type* s);
|
||||
basic_string& assign(size_type n, value_type c);
|
||||
@ -189,7 +189,7 @@ public:
|
||||
basic_string& insert(size_type pos1, const basic_string& str);
|
||||
basic_string& insert(size_type pos1, const basic_string& str,
|
||||
size_type pos2, size_type n);
|
||||
basic_string& insert(size_type pos, const value_type* s, size_type n);
|
||||
basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14
|
||||
basic_string& insert(size_type pos, const value_type* s);
|
||||
basic_string& insert(size_type pos, size_type n, value_type c);
|
||||
iterator insert(const_iterator p, value_type c);
|
||||
@ -204,7 +204,7 @@ public:
|
||||
|
||||
basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
|
||||
basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2);
|
||||
size_type pos2, size_type n2=npos); // C++14
|
||||
basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);
|
||||
basic_string& replace(size_type pos, size_type n1, const value_type* s);
|
||||
basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
|
||||
@ -261,7 +261,7 @@ public:
|
||||
int compare(const basic_string& str) const noexcept;
|
||||
int compare(size_type pos1, size_type n1, const basic_string& str) const;
|
||||
int compare(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2) const;
|
||||
size_type pos2, size_type n2=npos) const; // C++14
|
||||
int compare(const value_type* s) const noexcept;
|
||||
int compare(size_type pos1, size_type n1, const value_type* s) const;
|
||||
int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
|
||||
@ -453,6 +453,8 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
@ -507,14 +509,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
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);
|
||||
@ -524,20 +523,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
|
||||
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);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
@ -634,51 +628,37 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return (unsigned char)__c1 < (unsigned char)__c2;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return memcmp(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_t length(const char_type* __s) {return strlen(__s);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
static inline size_t length(const char_type* __s) {return strlen(__s);}
|
||||
static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{return (const char_type*)memchr(__s, to_int_type(__a), __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return (char_type*)memmove(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return (char_type*)memcpy(__s1, __s2, __n);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
{return (char_type*)memset(__s, to_int_type(__a), __n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type((unsigned char)__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
@ -693,52 +673,38 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
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)
|
||||
static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return wmemcmp(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_t length(const char_type* __s)
|
||||
static inline size_t length(const char_type* __s)
|
||||
{return wcslen(__s);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{return (const char_type*)wmemchr(__s, __a, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return (char_type*)wmemmove(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return (char_type*)wmemcpy(__s1, __s2, __n);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
{return (char_type*)wmemset(__s, __a, __n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(WEOF);}
|
||||
};
|
||||
|
||||
@ -753,14 +719,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
|
||||
typedef u16streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
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);
|
||||
@ -770,20 +733,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
|
||||
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);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(0xDFFF);}
|
||||
};
|
||||
|
||||
@ -874,14 +832,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
|
||||
typedef u32streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
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);
|
||||
@ -891,20 +846,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
|
||||
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);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(0xFFFFFFFF);}
|
||||
};
|
||||
|
||||
@ -988,6 +938,191 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
|
||||
// helper fns for basic_string
|
||||
|
||||
// __str_find
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_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 _SizeT, class _Traits, _SizeT __npos>
|
||||
_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 || __sz - __pos < __n)
|
||||
return __npos;
|
||||
if (__n == 0)
|
||||
return __pos;
|
||||
const _CharT* __r =
|
||||
_VSTD::__search(__p + __pos, __p + __sz,
|
||||
__s, __s + __n, _Traits::eq,
|
||||
random_access_iterator_tag(), random_access_iterator_tag());
|
||||
if (__r == __p + __sz)
|
||||
return __npos;
|
||||
return static_cast<_SizeT>(__r - __p);
|
||||
}
|
||||
|
||||
|
||||
// __str_rfind
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_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>
|
||||
_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>
|
||||
_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>
|
||||
_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>
|
||||
_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>
|
||||
_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>
|
||||
_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>
|
||||
_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>
|
||||
size_t _LIBCPP_INLINE_VISIBILITY __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));
|
||||
}
|
||||
|
||||
// basic_string
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -1324,7 +1459,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& append(const basic_string& __str);
|
||||
basic_string& append(const basic_string& __str, size_type __pos, size_type __n);
|
||||
basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
|
||||
basic_string& append(const value_type* __s, size_type __n);
|
||||
basic_string& append(const value_type* __s);
|
||||
basic_string& append(size_type __n, value_type __c);
|
||||
@ -1363,7 +1498,7 @@ public:
|
||||
basic_string& assign(basic_string&& str)
|
||||
{*this = _VSTD::move(str); return *this;}
|
||||
#endif
|
||||
basic_string& assign(const basic_string& __str, size_type __pos, size_type __n);
|
||||
basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
|
||||
basic_string& assign(const value_type* __s, size_type __n);
|
||||
basic_string& assign(const value_type* __s);
|
||||
basic_string& assign(size_type __n, value_type __c);
|
||||
@ -1389,7 +1524,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& insert(size_type __pos1, const basic_string& __str);
|
||||
basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n);
|
||||
basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
|
||||
basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
|
||||
basic_string& insert(size_type __pos, const value_type* __s);
|
||||
basic_string& insert(size_type __pos, size_type __n, value_type __c);
|
||||
@ -1425,7 +1560,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
|
||||
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2);
|
||||
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
|
||||
basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
|
||||
basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
|
||||
basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
|
||||
@ -1517,7 +1652,7 @@ public:
|
||||
int compare(const basic_string& __str) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
|
||||
int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const;
|
||||
int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;
|
||||
int compare(const value_type* __s) const _NOEXCEPT;
|
||||
int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
|
||||
int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
|
||||
@ -1951,11 +2086,13 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
|
||||
: __r_(__a)
|
||||
{
|
||||
if (__a == __str.__alloc() || !__str.__is_long())
|
||||
__r_.first().__r = __str.__r_.first().__r;
|
||||
else
|
||||
if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
|
||||
__init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
|
||||
__str.__zero();
|
||||
else
|
||||
{
|
||||
__r_.first().__r = __str.__r_.first().__r;
|
||||
__str.__zero();
|
||||
}
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
if (__is_long())
|
||||
@ -2078,7 +2215,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
|
||||
__set_long_cap(__cap+1);
|
||||
__set_long_size(__sz);
|
||||
}
|
||||
for (; __first != __last; ++__first, ++__p)
|
||||
for (; __first != __last; ++__first, (void) ++__p)
|
||||
traits_type::assign(*__p, *__first);
|
||||
traits_type::assign(*__p, value_type());
|
||||
}
|
||||
@ -2209,7 +2346,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign recieved nullptr");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr");
|
||||
size_type __cap = capacity();
|
||||
if (__cap >= __n)
|
||||
{
|
||||
@ -2383,7 +2520,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::assign recieved nullptr");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr");
|
||||
return assign(__s, traits_type::length(__s));
|
||||
}
|
||||
|
||||
@ -2393,7 +2530,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append recieved nullptr");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr");
|
||||
size_type __cap = capacity();
|
||||
size_type __sz = size();
|
||||
if (__cap - __sz >= __n)
|
||||
@ -2530,7 +2667,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::append recieved nullptr");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr");
|
||||
return append(__s, traits_type::length(__s));
|
||||
}
|
||||
|
||||
@ -2540,7 +2677,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert recieved nullptr");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos > __sz)
|
||||
this->__throw_out_of_range();
|
||||
@ -2692,7 +2829,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::insert recieved nullptr");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr");
|
||||
return insert(__pos, __s, traits_type::length(__s));
|
||||
}
|
||||
|
||||
@ -2743,7 +2880,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
|
||||
{
|
||||
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace recieved nullptr");
|
||||
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos > __sz)
|
||||
this->__throw_out_of_range();
|
||||
@ -2875,7 +3012,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::replace recieved nullptr");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr");
|
||||
return replace(__pos, __n1, __s, traits_type::length(__s));
|
||||
}
|
||||
|
||||
@ -3243,18 +3380,9 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
|
||||
size_type __pos,
|
||||
size_type __n) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): recieved nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos > __sz || __sz - __pos < __n)
|
||||
return npos;
|
||||
if (__n == 0)
|
||||
return __pos;
|
||||
const value_type* __p = data();
|
||||
const value_type* __r = _VSTD::search(__p + __pos, __p + __sz, __s, __s + __n,
|
||||
__traits_eq<traits_type>());
|
||||
if (__r == __p + __sz)
|
||||
return npos;
|
||||
return static_cast<size_type>(__r - __p);
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3263,7 +3391,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
return find(__str.data(), __pos, __str.size());
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __str.data(), __pos, __str.size());
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3272,8 +3401,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find(): recieved nullptr");
|
||||
return find(__s, __pos, traits_type::length(__s));
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3281,14 +3411,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
size_type __sz = size();
|
||||
if (__pos >= __sz)
|
||||
return npos;
|
||||
const value_type* __p = data();
|
||||
const value_type* __r = traits_type::find(__p + __pos, __sz - __pos, __c);
|
||||
if (__r == 0)
|
||||
return npos;
|
||||
return static_cast<size_type>(__r - __p);
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
// rfind
|
||||
@ -3299,19 +3423,9 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
|
||||
size_type __pos,
|
||||
size_type __n) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): recieved nullptr");
|
||||
size_type __sz = size();
|
||||
__pos = _VSTD::min(__pos, __sz);
|
||||
if (__n < __sz - __pos)
|
||||
__pos += __n;
|
||||
else
|
||||
__pos = __sz;
|
||||
const value_type* __p = data();
|
||||
const value_type* __r = _VSTD::find_end(__p, __p + __pos, __s, __s + __n,
|
||||
__traits_eq<traits_type>());
|
||||
if (__n > 0 && __r == __p + __pos)
|
||||
return npos;
|
||||
return static_cast<size_type>(__r - __p);
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3320,7 +3434,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
return rfind(__str.data(), __pos, __str.size());
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __str.data(), __pos, __str.size());
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3329,8 +3444,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::rfind(): recieved nullptr");
|
||||
return rfind(__s, __pos, traits_type::length(__s));
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3338,21 +3454,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
size_type __sz = size();
|
||||
if (__sz)
|
||||
{
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
const value_type* __p = data();
|
||||
for (const value_type* __ps = __p + __pos; __ps != __p;)
|
||||
{
|
||||
if (traits_type::eq(*--__ps, __c))
|
||||
return static_cast<size_type>(__ps - __p);
|
||||
}
|
||||
}
|
||||
return npos;
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
// find_first_of
|
||||
@ -3363,16 +3466,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
|
||||
size_type __pos,
|
||||
size_type __n) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): recieved nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos >= __sz || __n == 0)
|
||||
return npos;
|
||||
const value_type* __p = data();
|
||||
const value_type* __r = _VSTD::find_first_of(__p + __pos, __p + __sz, __s,
|
||||
__s + __n, __traits_eq<traits_type>());
|
||||
if (__r == __p + __sz)
|
||||
return npos;
|
||||
return static_cast<size_type>(__r - __p);
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3381,7 +3477,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
return find_first_of(__str.data(), __pos, __str.size());
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __str.data(), __pos, __str.size());
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3390,8 +3487,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): recieved nullptr");
|
||||
return find_first_of(__s, __pos, traits_type::length(__s));
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3411,23 +3509,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
|
||||
size_type __pos,
|
||||
size_type __n) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): recieved nullptr");
|
||||
if (__n != 0)
|
||||
{
|
||||
size_type __sz = size();
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
const value_type* __p = data();
|
||||
for (const value_type* __ps = __p + __pos; __ps != __p;)
|
||||
{
|
||||
const value_type* __r = traits_type::find(__s, __n, *--__ps);
|
||||
if (__r)
|
||||
return static_cast<size_type>(__ps - __p);
|
||||
}
|
||||
}
|
||||
return npos;
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3436,7 +3520,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
return find_last_of(__str.data(), __pos, __str.size());
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __str.data(), __pos, __str.size());
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3445,8 +3530,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): recieved nullptr");
|
||||
return find_last_of(__s, __pos, traits_type::length(__s));
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3466,17 +3552,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _
|
||||
size_type __pos,
|
||||
size_type __n) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): recieved nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos < __sz)
|
||||
{
|
||||
const value_type* __p = data();
|
||||
const value_type* __pe = __p + __sz;
|
||||
for (const value_type* __ps = __p + __pos; __ps != __pe; ++__ps)
|
||||
if (traits_type::find(__s, __n, *__ps) == 0)
|
||||
return static_cast<size_type>(__ps - __p);
|
||||
}
|
||||
return npos;
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3485,7 +3563,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
return find_first_not_of(__str.data(), __pos, __str.size());
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __str.data(), __pos, __str.size());
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3494,8 +3573,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): recieved nullptr");
|
||||
return find_first_not_of(__s, __pos, traits_type::length(__s));
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3504,16 +3584,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
size_type __sz = size();
|
||||
if (__pos < __sz)
|
||||
{
|
||||
const value_type* __p = data();
|
||||
const value_type* __pe = __p + __sz;
|
||||
for (const value_type* __ps = __p + __pos; __ps != __pe; ++__ps)
|
||||
if (!traits_type::eq(*__ps, __c))
|
||||
return static_cast<size_type>(__ps - __p);
|
||||
}
|
||||
return npos;
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
// find_last_not_of
|
||||
@ -3524,17 +3596,9 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __
|
||||
size_type __pos,
|
||||
size_type __n) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): recieved nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
const value_type* __p = data();
|
||||
for (const value_type* __ps = __p + __pos; __ps != __p;)
|
||||
if (traits_type::find(__s, __n, *--__ps) == 0)
|
||||
return static_cast<size_type>(__ps - __p);
|
||||
return npos;
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3543,7 +3607,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
return find_last_not_of(__str.data(), __pos, __str.size());
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __str.data(), __pos, __str.size());
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3552,8 +3617,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): recieved nullptr");
|
||||
return find_last_not_of(__s, __pos, traits_type::length(__s));
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
@ -3562,16 +3628,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
{
|
||||
size_type __sz = size();
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
const value_type* __p = data();
|
||||
for (const value_type* __ps = __p + __pos; __ps != __p;)
|
||||
if (!traits_type::eq(*--__ps, __c))
|
||||
return static_cast<size_type>(__ps - __p);
|
||||
return npos;
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
// compare
|
||||
@ -3623,7 +3681,7 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
int
|
||||
basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
|
||||
return compare(0, npos, __s, traits_type::length(__s));
|
||||
}
|
||||
|
||||
@ -3633,7 +3691,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
|
||||
size_type __n1,
|
||||
const value_type* __s) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
|
||||
return compare(__pos1, __n1, __s, traits_type::length(__s));
|
||||
}
|
||||
|
||||
@ -3644,7 +3702,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
|
||||
const value_type* __s,
|
||||
size_type __n2) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): recieved nullptr");
|
||||
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
|
||||
size_type __sz = size();
|
||||
if (__pos1 > __sz || __n2 == npos)
|
||||
this->__throw_out_of_range();
|
||||
@ -4060,13 +4118,6 @@ template<class _CharT, class _Traits, class _Allocator>
|
||||
const typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::npos;
|
||||
|
||||
template<class _Ptr>
|
||||
size_t _LIBCPP_INLINE_VISIBILITY __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 _Traits, class _Allocator>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY hash<basic_string<_CharT, _Traits, _Allocator> >
|
||||
: public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t>
|
||||
|
@ -99,6 +99,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
|
||||
#include <tuple>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -106,6 +107,10 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
|
||||
|
||||
#define __STDCPP_THREADS__ __cplusplus
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_THREADS
|
||||
#error <thread> is not supported on this single threaded system
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
@ -455,4 +460,6 @@ void yield() _NOEXCEPT {sched_yield();}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_THREAD
|
||||
|
@ -74,7 +74,7 @@ const unspecified ignore;
|
||||
|
||||
template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
|
||||
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
|
||||
template <class... T> tuple<T&...> tie(T&...) noexcept;
|
||||
template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
|
||||
template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
|
||||
|
||||
// 20.4.1.4, tuple helper classes:
|
||||
@ -82,13 +82,15 @@ template <class T> class tuple_size; // undefined
|
||||
template <class... T> class tuple_size<tuple<T...>>;
|
||||
template <intsize_t I, class T> class tuple_element; // undefined
|
||||
template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
|
||||
|
||||
// 20.4.1.5, element access:
|
||||
template <intsize_t I, class... T>
|
||||
typename tuple_element<I, tuple<T...>>::type&
|
||||
get(tuple<T...>&) noexcept; // constexpr in C++14
|
||||
template <intsize_t I, class... T>
|
||||
typename tuple_element<I, tuple<T...>>::type const&
|
||||
typename const tuple_element<I, tuple<T...>>::type &
|
||||
get(const tuple<T...>&) noexcept; // constexpr in C++14
|
||||
template <intsize_t I, class... T>
|
||||
typename tuple_element<I, tuple<T...>>::type&&
|
||||
@ -152,6 +154,11 @@ 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
|
||||
|
||||
template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
|
||||
@ -203,7 +210,13 @@ public:
|
||||
"Attempted to default construct a reference element in a tuple");}
|
||||
|
||||
template <class _Tp,
|
||||
class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
|
||||
class = typename enable_if<
|
||||
__lazy_and<
|
||||
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
||||
, is_constructible<_Hp, _Tp>
|
||||
>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
|
||||
: value(_VSTD::forward<_Tp>(__t))
|
||||
@ -261,17 +274,8 @@ public:
|
||||
>::value)),
|
||||
"Attempted to construct a reference element in a tuple with an rvalue");}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
__tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
|
||||
: value(__t.get())
|
||||
{static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
__tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value)
|
||||
: value(_VSTD::forward<_Hp>(__t.get()))
|
||||
{}
|
||||
__tuple_leaf(const __tuple_leaf& __t) = default;
|
||||
__tuple_leaf(__tuple_leaf&& __t) = default;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -318,7 +322,13 @@ public:
|
||||
: _Hp(__a) {}
|
||||
|
||||
template <class _Tp,
|
||||
class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
|
||||
class = typename enable_if<
|
||||
__lazy_and<
|
||||
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
||||
, is_constructible<_Hp, _Tp>
|
||||
>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
|
||||
: _Hp(_VSTD::forward<_Tp>(__t)) {}
|
||||
@ -338,6 +348,9 @@ public:
|
||||
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
|
||||
: _Hp(_VSTD::forward<_Tp>(__t), __a) {}
|
||||
|
||||
__tuple_leaf(__tuple_leaf const &) = default;
|
||||
__tuple_leaf(__tuple_leaf &&) = default;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__tuple_leaf&
|
||||
@ -363,19 +376,18 @@ template <class ..._Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __swallow(_Tp&&...) _NOEXCEPT {}
|
||||
|
||||
template <bool ...> struct __all;
|
||||
template <bool ..._Pred>
|
||||
struct __all
|
||||
: is_same<__all<_Pred...>, __all<(_Pred, true)...>>
|
||||
{ };
|
||||
|
||||
template <>
|
||||
struct __all<>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
template <class _Tp>
|
||||
struct __all_default_constructible;
|
||||
|
||||
template <bool _B0, bool ... _Bp>
|
||||
struct __all<_B0, _Bp...>
|
||||
{
|
||||
static const bool value = _B0 && __all<_Bp...>::value;
|
||||
};
|
||||
template <class ..._Tp>
|
||||
struct __all_default_constructible<__tuple_types<_Tp...>>
|
||||
: __all<is_default_constructible<_Tp>::value...>
|
||||
{ };
|
||||
|
||||
// __tuple_impl
|
||||
|
||||
@ -499,6 +511,9 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
|
||||
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
|
||||
public:
|
||||
|
||||
template <bool _Dummy = true, class _Up = typename enable_if<
|
||||
__all<(_Dummy && is_default_constructible<_Tp>::value)...>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR tuple()
|
||||
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
|
||||
@ -534,6 +549,12 @@ public:
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
__all_default_constructible<
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value,
|
||||
bool
|
||||
>::type = false
|
||||
@ -541,7 +562,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
tuple(_Up&&... __u)
|
||||
_NOEXCEPT_((
|
||||
is_nothrow_constructible<
|
||||
is_nothrow_constructible<base,
|
||||
typename __make_tuple_indices<sizeof...(_Up)>::type,
|
||||
typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
|
||||
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
|
||||
@ -574,6 +595,12 @@ public:
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
__all_default_constructible<
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value,
|
||||
bool
|
||||
>::type =false
|
||||
@ -582,7 +609,7 @@ public:
|
||||
explicit
|
||||
tuple(_Up&&... __u)
|
||||
_NOEXCEPT_((
|
||||
is_nothrow_constructible<
|
||||
is_nothrow_constructible<base,
|
||||
typename __make_tuple_indices<sizeof...(_Up)>::type,
|
||||
typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
|
||||
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
|
||||
@ -607,6 +634,12 @@ public:
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
__all_default_constructible<
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value
|
||||
>::type
|
||||
>
|
||||
@ -796,7 +829,7 @@ constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
|
||||
// tie
|
||||
|
||||
template <class ..._Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
tuple<_Tp&...>
|
||||
tie(_Tp&... __t) _NOEXCEPT
|
||||
{
|
||||
@ -816,13 +849,13 @@ namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>()
|
||||
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
|
||||
|
||||
template <class _Tp>
|
||||
struct ___make_tuple_return
|
||||
struct __make_tuple_return_impl
|
||||
{
|
||||
typedef _Tp type;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct ___make_tuple_return<reference_wrapper<_Tp> >
|
||||
struct __make_tuple_return_impl<reference_wrapper<_Tp> >
|
||||
{
|
||||
typedef _Tp& type;
|
||||
};
|
||||
@ -830,7 +863,7 @@ struct ___make_tuple_return<reference_wrapper<_Tp> >
|
||||
template <class _Tp>
|
||||
struct __make_tuple_return
|
||||
{
|
||||
typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
|
||||
typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
|
||||
};
|
||||
|
||||
template <class... _Tp>
|
||||
@ -856,7 +889,7 @@ struct __tuple_equal
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool operator()(const _Tp& __x, const _Up& __y)
|
||||
{
|
||||
return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
|
||||
return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
|
||||
}
|
||||
};
|
||||
|
||||
@ -895,7 +928,7 @@ struct __tuple_less
|
||||
bool operator()(const _Tp& __x, const _Up& __y)
|
||||
{
|
||||
return __tuple_less<_Ip-1>()(__x, __y) ||
|
||||
(!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
|
||||
(!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1044,8 +1077,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
|
||||
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
|
||||
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
|
||||
{
|
||||
return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
|
||||
get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
|
||||
return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
|
||||
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
|
||||
}
|
||||
|
||||
template <class _Tuple0, class _Tuple1, class ..._Tuples>
|
||||
@ -1060,8 +1093,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
|
||||
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
|
||||
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
|
||||
(forward_as_tuple(
|
||||
_VSTD::forward<_Types>(get<_I0>(__t))...,
|
||||
get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
|
||||
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
|
||||
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
|
||||
),
|
||||
_VSTD::forward<_Tuple1>(__t1),
|
||||
_VSTD::forward<_Tuples>(__tpls)...);
|
||||
@ -1090,8 +1123,8 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
pair<_T1, _T2>::pair(piecewise_construct_t,
|
||||
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
|
||||
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
|
||||
: first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
|
||||
second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
|
||||
: first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
|
||||
second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
|
||||
{
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -60,6 +60,7 @@ public:
|
||||
#include <__config>
|
||||
#include <exception>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -73,32 +74,75 @@ 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;
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit type_info(const char* __n)
|
||||
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
|
||||
: __type_name(__n) {}
|
||||
#else
|
||||
: __type_name(reinterpret_cast<uintptr_t>(__n)) {}
|
||||
#endif
|
||||
|
||||
public:
|
||||
virtual ~type_info();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char* name() const _NOEXCEPT {return __type_name;}
|
||||
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
|
||||
|
||||
_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
|
||||
|
||||
_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
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const type_info& __arg) const _NOEXCEPT
|
||||
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
|
||||
{return __type_name == __arg.__type_name;}
|
||||
#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;}
|
||||
#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
|
||||
};
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI bad_cast
|
||||
|
@ -351,6 +351,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
@ -325,6 +325,8 @@ template <class Value, class Hash, class Pred, class Alloc>
|
||||
#include <__hash_table>
|
||||
#include <functional>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
@ -101,30 +101,30 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
||||
template <class T> class tuple_size;
|
||||
template <size_t I, class T> class tuple_element;
|
||||
|
||||
template <class T1, class T2> struct tuple_size<std::pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<0, std::pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
|
||||
template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
typename tuple_element<I, std::pair<T1, T2> >::type&
|
||||
get(std::pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
typename tuple_element<I, pair<T1, T2> >::type&
|
||||
get(pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
const typename const tuple_element<I, std::pair<T1, T2> >::type&
|
||||
get(const std::pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
const typename const tuple_element<I, pair<T1, T2> >::type&
|
||||
get(const pair<T1, T2>&) noexcept; // constexpr in C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
typename tuple_element<I, std::pair<T1, T2> >::type&&
|
||||
get(std::pair<T1, T2>&&) noexcept; // constexpr in C++14
|
||||
typename tuple_element<I, pair<T1, T2> >::type&&
|
||||
get(pair<T1, T2>&&) noexcept; // constexpr in C++14
|
||||
|
||||
template<class T1, class T2>
|
||||
constexpr T1& get(std::pair<T1, T2>&) noexcept; // C++14
|
||||
constexpr T1& get(pair<T1, T2>&) noexcept; // C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
constexpr T1 const& get(std::pair<T1, T2> const &) noexcept; // C++14
|
||||
constexpr T1 const& get(pair<T1, T2> const &) noexcept; // C++14
|
||||
|
||||
template<size_t I, class T1, class T2>
|
||||
constexpr T1&& get(std::pair<T1, T2>&&) noexcept; // C++14
|
||||
constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
|
||||
|
||||
// C++14
|
||||
|
||||
@ -207,7 +207,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator2
|
||||
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
|
||||
{
|
||||
for(; __first1 != __last1; ++__first1, ++__first2)
|
||||
for(; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
swap(*__first1, *__first2);
|
||||
return __first2;
|
||||
}
|
||||
@ -345,9 +345,9 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair(_Tuple&& __p)
|
||||
: first(_VSTD::forward<typename tuple_element<0,
|
||||
typename __make_tuple_types<_Tuple>::type>::type>(get<0>(__p))),
|
||||
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>(get<1>(__p)))
|
||||
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p)))
|
||||
{}
|
||||
|
||||
|
||||
@ -465,13 +465,13 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
|
||||
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
|
||||
|
||||
template <class _Tp>
|
||||
struct ___make_pair_return
|
||||
struct __make_pair_return_impl
|
||||
{
|
||||
typedef _Tp type;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct ___make_pair_return<reference_wrapper<_Tp>>
|
||||
struct __make_pair_return_impl<reference_wrapper<_Tp>>
|
||||
{
|
||||
typedef _Tp& type;
|
||||
};
|
||||
@ -479,7 +479,7 @@ struct ___make_pair_return<reference_wrapper<_Tp>>
|
||||
template <class _Tp>
|
||||
struct __make_pair_return
|
||||
{
|
||||
typedef typename ___make_pair_return<typename decay<_Tp>::type>::type type;
|
||||
typedef typename __make_pair_return_impl<typename decay<_Tp>::type>::type type;
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
|
@ -345,6 +345,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
|
||||
#include <initializer_list>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <new>
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
@ -1219,6 +1220,7 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const
|
||||
const value_type* __s = __sa.__vp_;
|
||||
for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
|
||||
*__t = *__s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
@ -2089,6 +2091,7 @@ mask_array<_Tp>::operator=(const mask_array& __ma) const
|
||||
size_t __n = __1d_.size();
|
||||
for (size_t __i = 0; __i < __n; ++__i)
|
||||
__vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
@ -2636,7 +2639,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<result_type*>(::operator new(__n * sizeof(result_type)));
|
||||
static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
|
||||
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
|
||||
::new (__r.__end_) result_type(__expr_[__i]);
|
||||
}
|
||||
@ -2670,7 +2673,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
|
||||
{
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2695,7 +2698,7 @@ valarray<_Tp>::valarray(const valarray& __v)
|
||||
{
|
||||
if (__v.size())
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__v.size() * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2736,7 +2739,7 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
|
||||
size_t __n = __il.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2764,7 +2767,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
|
||||
size_t __n = __sa.__size_;
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2790,7 +2793,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
|
||||
size_t __n = __ga.__1d_.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2819,7 +2822,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
|
||||
size_t __n = __ma.__1d_.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2848,7 +2851,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
|
||||
size_t __n = __ia.__1d_.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -3133,7 +3136,7 @@ valarray<_Tp>::operator+() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(+*__p);
|
||||
}
|
||||
@ -3150,7 +3153,7 @@ valarray<_Tp>::operator-() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(-*__p);
|
||||
}
|
||||
@ -3167,7 +3170,7 @@ valarray<_Tp>::operator~() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(~*__p);
|
||||
}
|
||||
@ -3184,7 +3187,7 @@ valarray<_Tp>::operator!() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<bool*>(::operator new(__n * sizeof(bool)));
|
||||
static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) bool(!*__p);
|
||||
}
|
||||
@ -3504,7 +3507,7 @@ valarray<_Tp>::shift(int __i) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
const value_type* __sb;
|
||||
value_type* __tb;
|
||||
value_type* __te;
|
||||
@ -3542,7 +3545,7 @@ valarray<_Tp>::cshift(int __i) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__i %= static_cast<int>(__n);
|
||||
const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
|
||||
for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
|
||||
@ -3563,7 +3566,7 @@ valarray<_Tp>::apply(value_type __f(value_type)) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(__f(*__p));
|
||||
}
|
||||
@ -3580,7 +3583,7 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(__f(*__p));
|
||||
}
|
||||
@ -3595,12 +3598,12 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
|
||||
{
|
||||
while (__end_ != __begin_)
|
||||
(--__end_)->~value_type();
|
||||
::operator delete(__begin_);
|
||||
_VSTD::__deallocate(__begin_);
|
||||
__begin_ = __end_ = nullptr;
|
||||
}
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
|
@ -276,11 +276,7 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
# include <__debug>
|
||||
#else
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -483,6 +479,7 @@ class _LIBCPP_TYPE_VIS_ONLY vector
|
||||
{
|
||||
private:
|
||||
typedef __vector_base<_Tp, _Allocator> __base;
|
||||
typedef allocator<_Tp> __default_allocator_type;
|
||||
public:
|
||||
typedef vector __self;
|
||||
typedef _Tp value_type;
|
||||
@ -749,7 +746,9 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
size_type __old_size = size();
|
||||
__base::clear();
|
||||
__annotate_shrink(__old_size);
|
||||
__invalidate_all_iterators();
|
||||
}
|
||||
|
||||
@ -785,7 +784,6 @@ private:
|
||||
void
|
||||
>::type
|
||||
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
|
||||
void __move_construct_at_end(pointer __first, pointer __last);
|
||||
void __append(size_type __n);
|
||||
void __append(size_type __n, const_reference __x);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -816,7 +814,9 @@ private:
|
||||
}
|
||||
__get_db()->unlock();
|
||||
#endif
|
||||
size_type __old_size = size();
|
||||
__base::__destruct_at_end(__new_last);
|
||||
__annotate_shrink(__old_size);
|
||||
}
|
||||
template <class _Up>
|
||||
void
|
||||
@ -830,17 +830,76 @@ private:
|
||||
void
|
||||
__emplace_back_slow_path(_Args&&... __args);
|
||||
#endif
|
||||
// The following functions are no-ops outside of AddressSanitizer mode.
|
||||
// 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
|
||||
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
|
||||
{
|
||||
__annotate_contiguous_container(data(), data() + capacity(),
|
||||
data() + capacity(), data() + __current_size);
|
||||
}
|
||||
void __annotate_delete() const
|
||||
{
|
||||
__annotate_contiguous_container(data(), data() + capacity(),
|
||||
data() + size(), data() + capacity());
|
||||
}
|
||||
void __annotate_increase(size_type __n) const
|
||||
{
|
||||
__annotate_contiguous_container(data(), data() + capacity(),
|
||||
data() + size(), data() + size() + __n);
|
||||
}
|
||||
void __annotate_shrink(size_type __old_size) const
|
||||
{
|
||||
__annotate_contiguous_container(data(), data() + capacity(),
|
||||
data() + __old_size, data() + size());
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_ASAN
|
||||
// The annotation for size increase should happen before the actual increase,
|
||||
// but if an exception is thrown after that the annotation has to be undone.
|
||||
struct __RAII_IncreaseAnnotator {
|
||||
__RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1)
|
||||
: __commit(false), __v(__v), __n(__n) {
|
||||
__v.__annotate_increase(__n);
|
||||
}
|
||||
void __done() { __commit = true; }
|
||||
~__RAII_IncreaseAnnotator() {
|
||||
if (__commit) return;
|
||||
__v.__annotate_shrink(__v.size() + __n);
|
||||
}
|
||||
bool __commit;
|
||||
size_type __n;
|
||||
const vector &__v;
|
||||
};
|
||||
#else
|
||||
struct __RAII_IncreaseAnnotator {
|
||||
inline __RAII_IncreaseAnnotator(const vector &, size_type __n = 1) {}
|
||||
inline void __done() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
|
||||
{
|
||||
__annotate_delete();
|
||||
__alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
|
||||
_VSTD::swap(this->__begin_, __v.__begin_);
|
||||
_VSTD::swap(this->__end_, __v.__end_);
|
||||
_VSTD::swap(this->__end_cap(), __v.__end_cap());
|
||||
__v.__first_ = __v.__begin_;
|
||||
__annotate_new(size());
|
||||
__invalidate_all_iterators();
|
||||
}
|
||||
|
||||
@ -848,6 +907,7 @@ template <class _Tp, class _Allocator>
|
||||
typename vector<_Tp, _Allocator>::pointer
|
||||
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
|
||||
{
|
||||
__annotate_delete();
|
||||
pointer __r = __v.__begin_;
|
||||
__alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_);
|
||||
__alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_);
|
||||
@ -855,6 +915,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
|
||||
_VSTD::swap(this->__end_, __v.__end_);
|
||||
_VSTD::swap(this->__end_cap(), __v.__end_cap());
|
||||
__v.__first_ = __v.__begin_;
|
||||
__annotate_new(size());
|
||||
__invalidate_all_iterators();
|
||||
return __r;
|
||||
}
|
||||
@ -874,6 +935,7 @@ vector<_Tp, _Allocator>::allocate(size_type __n)
|
||||
this->__throw_length_error();
|
||||
this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
|
||||
this->__end_cap() = this->__begin_ + __n;
|
||||
__annotate_new(0);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
@ -922,9 +984,11 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
|
||||
allocator_type& __a = this->__alloc();
|
||||
do
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
|
||||
++this->__end_;
|
||||
--__n;
|
||||
__annotator.__done();
|
||||
} while (__n > 0);
|
||||
}
|
||||
|
||||
@ -942,9 +1006,11 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
|
||||
allocator_type& __a = this->__alloc();
|
||||
do
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x);
|
||||
++this->__end_;
|
||||
--__n;
|
||||
__annotator.__done();
|
||||
} while (__n > 0);
|
||||
}
|
||||
|
||||
@ -960,20 +1026,9 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
|
||||
allocator_type& __a = this->__alloc();
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
|
||||
++this->__end_;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
vector<_Tp, _Allocator>::__move_construct_at_end(pointer __first, pointer __last)
|
||||
{
|
||||
allocator_type& __a = this->__alloc();
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
|
||||
_VSTD::move(*__first));
|
||||
__annotator.__done();
|
||||
++this->__end_;
|
||||
}
|
||||
}
|
||||
@ -1284,10 +1339,10 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
{
|
||||
deallocate();
|
||||
__base::__move_assign_alloc(__c); // this can throw
|
||||
this->__begin_ = __c.__begin_;
|
||||
this->__end_ = __c.__end_;
|
||||
this->__end_cap() = __c.__end_cap();
|
||||
__base::__move_assign_alloc(__c);
|
||||
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->swap(this, &__c);
|
||||
@ -1535,8 +1590,10 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
|
||||
{
|
||||
if (this->__end_ != this->__end_cap())
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
__alloc_traits::construct(this->__alloc(),
|
||||
_VSTD::__to_raw_pointer(this->__end_), __x);
|
||||
__annotator.__done();
|
||||
++this->__end_;
|
||||
}
|
||||
else
|
||||
@ -1552,9 +1609,11 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
|
||||
{
|
||||
if (this->__end_ < this->__end_cap())
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
__alloc_traits::construct(this->__alloc(),
|
||||
_VSTD::__to_raw_pointer(this->__end_),
|
||||
_VSTD::move(__x));
|
||||
__annotator.__done();
|
||||
++this->__end_;
|
||||
}
|
||||
else
|
||||
@ -1584,9 +1643,11 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
|
||||
{
|
||||
if (this->__end_ < this->__end_cap())
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
__alloc_traits::construct(this->__alloc(),
|
||||
_VSTD::__to_raw_pointer(this->__end_),
|
||||
_VSTD::forward<_Args>(__args)...);
|
||||
__annotator.__done();
|
||||
++this->__end_;
|
||||
}
|
||||
else
|
||||
@ -1666,6 +1727,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
|
||||
pointer __p = this->__begin_ + (__position - begin());
|
||||
if (this->__end_ < this->__end_cap())
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
if (__p == this->__end_)
|
||||
{
|
||||
__alloc_traits::construct(this->__alloc(),
|
||||
@ -1680,6 +1742,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
|
||||
++__xr;
|
||||
*__p = *__xr;
|
||||
}
|
||||
__annotator.__done();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1705,6 +1768,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
|
||||
pointer __p = this->__begin_ + (__position - begin());
|
||||
if (this->__end_ < this->__end_cap())
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
if (__p == this->__end_)
|
||||
{
|
||||
__alloc_traits::construct(this->__alloc(),
|
||||
@ -1717,6 +1781,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
|
||||
__move_range(__p, this->__end_, __p + 1);
|
||||
*__p = _VSTD::move(__x);
|
||||
}
|
||||
__annotator.__done();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1743,6 +1808,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
|
||||
pointer __p = this->__begin_ + (__position - begin());
|
||||
if (this->__end_ < this->__end_cap())
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this);
|
||||
if (__p == this->__end_)
|
||||
{
|
||||
__alloc_traits::construct(this->__alloc(),
|
||||
@ -1756,6 +1822,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
|
||||
__move_range(__p, this->__end_, __p + 1);
|
||||
*__p = _VSTD::move(__tmp);
|
||||
}
|
||||
__annotator.__done();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1794,7 +1861,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
|
||||
}
|
||||
if (__n > 0)
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this, __n);
|
||||
__move_range(__p, __old_last, __p + __old_n);
|
||||
__annotator.__done();
|
||||
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
|
||||
if (__p <= __xr && __xr < this->__end_)
|
||||
__xr += __old_n;
|
||||
@ -1904,7 +1973,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
|
||||
}
|
||||
if (__n > 0)
|
||||
{
|
||||
__RAII_IncreaseAnnotator __annotator(*this, __n);
|
||||
__move_range(__p, __old_last, __p + __old_n);
|
||||
__annotator.__done();
|
||||
_VSTD::copy(__first, __m, __p);
|
||||
}
|
||||
}
|
||||
@ -2297,7 +2368,7 @@ private:
|
||||
void deallocate() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __align_it(size_type __new_size) _NOEXCEPT
|
||||
{return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);};
|
||||
{return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);};
|
||||
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
|
||||
_LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
|
||||
template <class _ForwardIterator>
|
||||
@ -2796,10 +2867,10 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
{
|
||||
deallocate();
|
||||
__move_assign_alloc(__c);
|
||||
this->__begin_ = __c.__begin_;
|
||||
this->__size_ = __c.__size_;
|
||||
this->__cap() = __c.__cap();
|
||||
__move_assign_alloc(__c);
|
||||
__c.__begin_ = nullptr;
|
||||
__c.__cap() = __c.__size_ = 0;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
#include "algorithm"
|
||||
#include "random"
|
||||
#include "mutex"
|
||||
@ -48,12 +47,16 @@ 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 pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
unsigned __rs_default::__c_ = 0;
|
||||
|
||||
__rs_default::__rs_default()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
pthread_mutex_lock(&__rs_mut);
|
||||
#endif
|
||||
__c_ = 1;
|
||||
}
|
||||
|
||||
@ -64,8 +67,12 @@ __rs_default::__rs_default(const __rs_default&)
|
||||
|
||||
__rs_default::~__rs_default()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
if (--__c_ == 0)
|
||||
pthread_mutex_unlock(&__rs_mut);
|
||||
#else
|
||||
--__c_;
|
||||
#endif
|
||||
}
|
||||
|
||||
__rs_default::result_type
|
||||
|
@ -46,6 +46,7 @@ system_clock::from_time_t(time_t t) _NOEXCEPT
|
||||
return system_clock::time_point(seconds(t));
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
|
||||
// steady_clock
|
||||
|
||||
const bool steady_clock::is_steady;
|
||||
@ -108,10 +109,8 @@ steady_clock::now() _NOEXCEPT
|
||||
}
|
||||
|
||||
#else // __APPLE__
|
||||
// FIXME: We assume that clock_gettime(CLOCK_MONOTONIC) works on
|
||||
// non-apple systems. Instead, we should check _POSIX_TIMERS and
|
||||
// _POSIX_MONOTONIC_CLOCK and fall back to something else if those
|
||||
// don't exist.
|
||||
// FIXME: if _LIBCPP_HAS_NO_MONOTONIC_CLOCK, then clock_gettime isn't going to
|
||||
// work. It may be possible to fall back on something else, depending on the system.
|
||||
|
||||
// Warning: If this is not truly steady, then it is non-conforming. It is
|
||||
// better for it to not exist and have the rest of libc++ use system_clock
|
||||
@ -127,6 +126,8 @@ steady_clock::now() _NOEXCEPT
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK
|
||||
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -7,6 +7,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "__config"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#include "condition_variable"
|
||||
#include "thread"
|
||||
#include "system_error"
|
||||
@ -32,7 +36,7 @@ condition_variable::notify_all() _NOEXCEPT
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::wait(unique_lock<mutex>& lk)
|
||||
condition_variable::wait(unique_lock<mutex>& lk) _NOEXCEPT
|
||||
{
|
||||
if (!lk.owns_lock())
|
||||
__throw_system_error(EPERM,
|
||||
@ -44,7 +48,7 @@ condition_variable::wait(unique_lock<mutex>& lk)
|
||||
|
||||
void
|
||||
condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
|
||||
chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp)
|
||||
chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) _NOEXCEPT
|
||||
{
|
||||
using namespace chrono;
|
||||
if (!lk.owns_lock())
|
||||
@ -79,3 +83,5 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
@ -35,6 +35,7 @@ __get_const_db()
|
||||
namespace
|
||||
{
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
typedef mutex mutex_type;
|
||||
typedef lock_guard<mutex_type> WLock;
|
||||
typedef lock_guard<mutex_type> RLock;
|
||||
@ -45,6 +46,7 @@ mut()
|
||||
static mutex_type m;
|
||||
return m;
|
||||
}
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
@ -108,7 +110,9 @@ __libcpp_db::~__libcpp_db()
|
||||
void*
|
||||
__libcpp_db::__find_c_from_i(void* __i) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
RLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
_LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database.");
|
||||
return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
|
||||
@ -117,7 +121,9 @@ __libcpp_db::__find_c_from_i(void* __i) const
|
||||
void
|
||||
__libcpp_db::__insert_ic(void* __i, const void* __c)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
if (__cbeg_ == __cend_)
|
||||
return;
|
||||
size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
|
||||
@ -138,7 +144,9 @@ __libcpp_db::__insert_ic(void* __i, const void* __c)
|
||||
__c_node*
|
||||
__libcpp_db::__insert_c(void* __c)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_))
|
||||
{
|
||||
size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
|
||||
@ -184,7 +192,9 @@ __libcpp_db::__insert_c(void* __c)
|
||||
void
|
||||
__libcpp_db::__erase_i(void* __i)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
if (__ibeg_ != __iend_)
|
||||
{
|
||||
size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
|
||||
@ -215,7 +225,9 @@ __libcpp_db::__erase_i(void* __i)
|
||||
void
|
||||
__libcpp_db::__invalidate_all(void* __c)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
if (__cend_ != __cbeg_)
|
||||
{
|
||||
size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
|
||||
@ -239,17 +251,23 @@ __libcpp_db::__invalidate_all(void* __c)
|
||||
__c_node*
|
||||
__libcpp_db::__find_c_and_lock(void* __c) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
mut().lock();
|
||||
#endif
|
||||
if (__cend_ == __cbeg_)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
mut().unlock();
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
|
||||
__c_node* p = __cbeg_[hc];
|
||||
if (p == nullptr)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
mut().unlock();
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
while (p->__c_ != __c)
|
||||
@ -257,7 +275,9 @@ __libcpp_db::__find_c_and_lock(void* __c) const
|
||||
p = p->__next_;
|
||||
if (p == nullptr)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
mut().unlock();
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -281,13 +301,17 @@ __libcpp_db::__find_c(void* __c) const
|
||||
void
|
||||
__libcpp_db::unlock() const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
mut().unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
__libcpp_db::__erase_c(void* __c)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
if (__cend_ != __cbeg_)
|
||||
{
|
||||
size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
|
||||
@ -322,7 +346,9 @@ __libcpp_db::__erase_c(void* __c)
|
||||
void
|
||||
__libcpp_db::__iterator_copy(void* __i, const void* __i0)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
__i_node* i0 = __find_iterator(__i0);
|
||||
__c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr;
|
||||
@ -348,7 +374,9 @@ __libcpp_db::__iterator_copy(void* __i, const void* __i0)
|
||||
bool
|
||||
__libcpp_db::__dereferenceable(const void* __i) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
RLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
return i != nullptr && i->__c_ != nullptr && i->__c_->__dereferenceable(__i);
|
||||
}
|
||||
@ -356,7 +384,9 @@ __libcpp_db::__dereferenceable(const void* __i) const
|
||||
bool
|
||||
__libcpp_db::__decrementable(const void* __i) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
RLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i);
|
||||
}
|
||||
@ -364,7 +394,9 @@ __libcpp_db::__decrementable(const void* __i) const
|
||||
bool
|
||||
__libcpp_db::__addable(const void* __i, ptrdiff_t __n) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
RLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
return i != nullptr && i->__c_ != nullptr && i->__c_->__addable(__i, __n);
|
||||
}
|
||||
@ -372,7 +404,9 @@ __libcpp_db::__addable(const void* __i, ptrdiff_t __n) const
|
||||
bool
|
||||
__libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
RLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n);
|
||||
}
|
||||
@ -380,7 +414,9 @@ __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
|
||||
bool
|
||||
__libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
RLock _(mut());
|
||||
#endif
|
||||
__i_node* i = __find_iterator(__i);
|
||||
__i_node* j = __find_iterator(__j);
|
||||
__c_node* ci = i != nullptr ? i->__c_ : nullptr;
|
||||
@ -391,7 +427,9 @@ __libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
|
||||
void
|
||||
__libcpp_db::swap(void* c1, void* c2)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_);
|
||||
__c_node* p1 = __cbeg_[hc];
|
||||
_LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A");
|
||||
@ -420,7 +458,9 @@ __libcpp_db::swap(void* c1, void* c2)
|
||||
void
|
||||
__libcpp_db::__insert_i(void* __i)
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
WLock _(mut());
|
||||
#endif
|
||||
__insert_iterator(__i);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) && !defined(LIBCXXRT)
|
||||
#include <cxxabi.h>
|
||||
|
||||
using namespace __cxxabiv1;
|
||||
|
@ -7,6 +7,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "__config"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#include "future"
|
||||
#include "string"
|
||||
|
||||
@ -26,8 +30,13 @@ __future_error_category::name() const _NOEXCEPT
|
||||
return "future";
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wswitch"
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
#endif
|
||||
|
||||
string
|
||||
__future_error_category::message(int ev) const
|
||||
@ -50,7 +59,11 @@ __future_error_category::message(int ev) const
|
||||
return string("unspecified future_errc value\n");
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
const error_category&
|
||||
future_category() _NOEXCEPT
|
||||
@ -289,3 +302,5 @@ shared_future<void>::operator=(const shared_future& __rhs)
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
@ -136,7 +136,7 @@ const unsigned indices[] =
|
||||
// The algorithm creates a list of small primes, plus an open-ended list of
|
||||
// potential primes. All prime numbers are potential prime numbers. However
|
||||
// some potential prime numbers are not prime. In an ideal world, all potential
|
||||
// prime numbers would be prime. Candiate prime numbers are chosen as the next
|
||||
// prime numbers would be prime. Candidate prime numbers are chosen as the next
|
||||
// highest potential prime. Then this number is tested for prime by dividing it
|
||||
// by all potential prime numbers less than the sqrt of the candidate.
|
||||
//
|
||||
|
@ -7,8 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
|
||||
#include "__config"
|
||||
#include "ios"
|
||||
#include "streambuf"
|
||||
#include "istream"
|
||||
@ -54,9 +53,9 @@ string
|
||||
__iostream_category::message(int ev) const
|
||||
{
|
||||
if (ev != static_cast<int>(io_errc::stream)
|
||||
#ifdef ELAST
|
||||
&& ev <= ELAST
|
||||
#endif
|
||||
#ifdef _LIBCPP_ELAST
|
||||
&& ev <= _LIBCPP_ELAST
|
||||
#endif // _LIBCPP_ELAST
|
||||
)
|
||||
return __do_message::message(ev);
|
||||
return string("unspecified iostream_category error");
|
||||
@ -134,7 +133,7 @@ locale
|
||||
ios_base::imbue(const locale& newloc)
|
||||
{
|
||||
static_assert(sizeof(locale) == sizeof(__loc_), "");
|
||||
locale& loc_storage = *(locale*)&__loc_;
|
||||
locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
|
||||
locale oldloc = loc_storage;
|
||||
loc_storage = newloc;
|
||||
__call_callbacks(imbue_event);
|
||||
@ -144,17 +143,27 @@ ios_base::imbue(const locale& newloc)
|
||||
locale
|
||||
ios_base::getloc() const
|
||||
{
|
||||
const locale& loc_storage = *(locale*)&__loc_;
|
||||
const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
|
||||
return loc_storage;
|
||||
}
|
||||
|
||||
// xalloc
|
||||
#if __has_feature(cxx_atomic)
|
||||
#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
|
||||
#else
|
||||
int ios_base::__xindex_ = 0;
|
||||
#endif
|
||||
|
||||
template <typename _Tp>
|
||||
static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
|
||||
{ // Precondition: __req_size > __current_cap
|
||||
const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
|
||||
if (__req_size < mx/2)
|
||||
return _VSTD::max(2 * __current_cap, __req_size);
|
||||
else
|
||||
return mx;
|
||||
}
|
||||
|
||||
int
|
||||
ios_base::xalloc()
|
||||
{
|
||||
@ -167,13 +176,8 @@ ios_base::iword(int index)
|
||||
size_t req_size = static_cast<size_t>(index)+1;
|
||||
if (req_size > __iarray_cap_)
|
||||
{
|
||||
size_t newcap;
|
||||
const size_t mx = std::numeric_limits<size_t>::max();
|
||||
if (req_size < mx/2)
|
||||
newcap = _VSTD::max(2 * __iarray_cap_, req_size);
|
||||
else
|
||||
newcap = mx;
|
||||
long* iarray = (long*)realloc(__iarray_, newcap * sizeof(long));
|
||||
size_t newcap = __ios_new_cap<long>(req_size, __iarray_cap_);
|
||||
long* iarray = static_cast<long*>(realloc(__iarray_, newcap * sizeof(long)));
|
||||
if (iarray == 0)
|
||||
{
|
||||
setstate(badbit);
|
||||
@ -182,8 +186,9 @@ ios_base::iword(int index)
|
||||
return error;
|
||||
}
|
||||
__iarray_ = iarray;
|
||||
for (long* p = __iarray_ + __iarray_size_; __iarray_cap_ < newcap; ++__iarray_cap_, ++p)
|
||||
for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p)
|
||||
*p = 0;
|
||||
__iarray_cap_ = newcap;
|
||||
}
|
||||
__iarray_size_ = max<size_t>(__iarray_size_, req_size);
|
||||
return __iarray_[index];
|
||||
@ -195,13 +200,8 @@ ios_base::pword(int index)
|
||||
size_t req_size = static_cast<size_t>(index)+1;
|
||||
if (req_size > __parray_cap_)
|
||||
{
|
||||
size_t newcap;
|
||||
const size_t mx = std::numeric_limits<size_t>::max();
|
||||
if (req_size < mx/2)
|
||||
newcap = _VSTD::max(2 * __parray_cap_, req_size);
|
||||
else
|
||||
newcap = mx;
|
||||
void** parray = (void**)realloc(__parray_, newcap * sizeof(void*));
|
||||
size_t newcap = __ios_new_cap<void *>(req_size, __iarray_cap_);
|
||||
void** parray = static_cast<void**>(realloc(__parray_, newcap * sizeof(void *)));
|
||||
if (parray == 0)
|
||||
{
|
||||
setstate(badbit);
|
||||
@ -210,8 +210,9 @@ ios_base::pword(int index)
|
||||
return error;
|
||||
}
|
||||
__parray_ = parray;
|
||||
for (void** p = __parray_ + __parray_size_; __parray_cap_ < newcap; ++__parray_cap_, ++p)
|
||||
for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p)
|
||||
*p = 0;
|
||||
__parray_cap_ = newcap;
|
||||
}
|
||||
__parray_size_ = max<size_t>(__parray_size_, req_size);
|
||||
return __parray_[index];
|
||||
@ -225,20 +226,16 @@ ios_base::register_callback(event_callback fn, int index)
|
||||
size_t req_size = __event_size_ + 1;
|
||||
if (req_size > __event_cap_)
|
||||
{
|
||||
size_t newcap;
|
||||
const size_t mx = std::numeric_limits<size_t>::max();
|
||||
if (req_size < mx/2)
|
||||
newcap = _VSTD::max(2 * __event_cap_, req_size);
|
||||
else
|
||||
newcap = mx;
|
||||
event_callback* fns = (event_callback*)realloc(__fn_, newcap * sizeof(event_callback));
|
||||
size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
|
||||
event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
|
||||
if (fns == 0)
|
||||
setstate(badbit);
|
||||
__fn_ = fns;
|
||||
int* indxs = (int*)realloc(__index_, newcap * sizeof(int));
|
||||
int* indxs = static_cast<int *>(realloc(__index_, newcap * sizeof(int)));
|
||||
if (indxs == 0)
|
||||
setstate(badbit);
|
||||
__index_ = indxs;
|
||||
__event_cap_ = newcap;
|
||||
}
|
||||
__fn_[__event_size_] = fn;
|
||||
__index_[__event_size_] = index;
|
||||
@ -248,7 +245,7 @@ ios_base::register_callback(event_callback fn, int index)
|
||||
ios_base::~ios_base()
|
||||
{
|
||||
__call_callbacks(erase_event);
|
||||
locale& loc_storage = *(locale*)&__loc_;
|
||||
locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
|
||||
loc_storage.~locale();
|
||||
free(__fn_);
|
||||
free(__index_);
|
||||
@ -299,19 +296,22 @@ void
|
||||
ios_base::copyfmt(const ios_base& rhs)
|
||||
{
|
||||
// If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
|
||||
// Don't alter *this until all needed resources are aquired
|
||||
// Don't alter *this until all needed resources are acquired
|
||||
unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
|
||||
unique_ptr<int, void (*)(void*)> new_ints(0, free);
|
||||
unique_ptr<long, void (*)(void*)> new_longs(0, free);
|
||||
unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
|
||||
if (__event_cap_ < rhs.__event_size_)
|
||||
{
|
||||
new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_));
|
||||
size_t newesize = sizeof(event_callback) * rhs.__event_size_;
|
||||
new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (!new_callbacks)
|
||||
throw bad_alloc();
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_));
|
||||
|
||||
size_t newisize = sizeof(int) * rhs.__event_size_;
|
||||
new_ints.reset(static_cast<int *>(malloc(newisize)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (!new_ints)
|
||||
throw bad_alloc();
|
||||
@ -319,7 +319,8 @@ ios_base::copyfmt(const ios_base& rhs)
|
||||
}
|
||||
if (__iarray_cap_ < rhs.__iarray_size_)
|
||||
{
|
||||
new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_));
|
||||
size_t newsize = sizeof(long) * rhs.__iarray_size_;
|
||||
new_longs.reset(static_cast<long*>(malloc(newsize)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (!new_longs)
|
||||
throw bad_alloc();
|
||||
@ -327,7 +328,8 @@ ios_base::copyfmt(const ios_base& rhs)
|
||||
}
|
||||
if (__parray_cap_ < rhs.__parray_size_)
|
||||
{
|
||||
new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_));
|
||||
size_t newsize = sizeof(void*) * rhs.__parray_size_;
|
||||
new_pointers.reset(static_cast<void**>(malloc(newsize)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (!new_pointers)
|
||||
throw bad_alloc();
|
||||
@ -337,8 +339,8 @@ ios_base::copyfmt(const ios_base& rhs)
|
||||
__fmtflags_ = rhs.__fmtflags_;
|
||||
__precision_ = rhs.__precision_;
|
||||
__width_ = rhs.__width_;
|
||||
locale& lhs_loc = *(locale*)&__loc_;
|
||||
locale& rhs_loc = *(locale*)&rhs.__loc_;
|
||||
locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
|
||||
const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
|
||||
lhs_loc = rhs_loc;
|
||||
if (__event_cap_ < rhs.__event_size_)
|
||||
{
|
||||
@ -381,7 +383,7 @@ ios_base::move(ios_base& rhs)
|
||||
__rdstate_ = rhs.__rdstate_;
|
||||
__exceptions_ = rhs.__exceptions_;
|
||||
__rdbuf_ = 0;
|
||||
locale& rhs_loc = *(locale*)&rhs.__loc_;
|
||||
locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
|
||||
::new(&__loc_) locale(rhs_loc);
|
||||
__fn_ = rhs.__fn_;
|
||||
rhs.__fn_ = 0;
|
||||
@ -413,8 +415,8 @@ ios_base::swap(ios_base& rhs) _NOEXCEPT
|
||||
_VSTD::swap(__width_, rhs.__width_);
|
||||
_VSTD::swap(__rdstate_, rhs.__rdstate_);
|
||||
_VSTD::swap(__exceptions_, rhs.__exceptions_);
|
||||
locale& lhs_loc = *(locale*)&__loc_;
|
||||
locale& rhs_loc = *(locale*)&rhs.__loc_;
|
||||
locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
|
||||
locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
|
||||
_VSTD::swap(lhs_loc, rhs_loc);
|
||||
_VSTD::swap(__fn_, rhs.__fn_);
|
||||
_VSTD::swap(__index_, rhs.__index_);
|
||||
|
@ -7,8 +7,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
|
||||
// On Solaris, we need to define something to make the C99 parts of localeconv
|
||||
// visible.
|
||||
#ifdef __sun__
|
||||
@ -30,9 +28,9 @@
|
||||
#include "__sso_allocator"
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
#include <support/win32/locale_win32.h>
|
||||
#else // _LIBCPP_MSVCRT
|
||||
#elif !defined(__ANDROID__)
|
||||
#include <langinfo.h>
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -68,7 +66,7 @@ make(A0 a0)
|
||||
{
|
||||
static typename aligned_storage<sizeof(T)>::type buf;
|
||||
::new (&buf) T(a0);
|
||||
return *(T*)&buf;
|
||||
return *reinterpret_cast<T*>(&buf);
|
||||
}
|
||||
|
||||
template <class T, class A0, class A1>
|
||||
@ -78,7 +76,7 @@ make(A0 a0, A1 a1)
|
||||
{
|
||||
static typename aligned_storage<sizeof(T)>::type buf;
|
||||
::new (&buf) T(a0, a1);
|
||||
return *(T*)&buf;
|
||||
return *reinterpret_cast<T*>(&buf);
|
||||
}
|
||||
|
||||
template <class T, class A0, class A1, class A2>
|
||||
@ -88,7 +86,7 @@ make(A0 a0, A1 a1, A2 a2)
|
||||
{
|
||||
static typename aligned_storage<sizeof(T)>::type buf;
|
||||
::new (&buf) T(a0, a1, a2);
|
||||
return *(T*)&buf;
|
||||
return *reinterpret_cast<T*>(&buf);
|
||||
}
|
||||
|
||||
template <typename T, size_t N>
|
||||
@ -177,7 +175,7 @@ locale::__imp::__imp(size_t refs)
|
||||
facets_.clear();
|
||||
install(&make<_VSTD::collate<char> >(1u));
|
||||
install(&make<_VSTD::collate<wchar_t> >(1u));
|
||||
install(&make<_VSTD::ctype<char> >((ctype_base::mask*)0, false, 1u));
|
||||
install(&make<_VSTD::ctype<char> >(nullptr, false, 1u));
|
||||
install(&make<_VSTD::ctype<wchar_t> >(1u));
|
||||
install(&make<codecvt<char, char, mbstate_t> >(1u));
|
||||
install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
|
||||
@ -461,7 +459,7 @@ locale::__imp::make_classic()
|
||||
{
|
||||
// only one thread can get in here and it only gets in once
|
||||
static aligned_storage<sizeof(locale)>::type buf;
|
||||
locale* c = (locale*)&buf;
|
||||
locale* c = reinterpret_cast<locale*>(&buf);
|
||||
c->__locale_ = &make<__imp>(1u);
|
||||
return *c;
|
||||
}
|
||||
@ -479,7 +477,7 @@ locale::__imp::make_global()
|
||||
// only one thread can get in here and it only gets in once
|
||||
static aligned_storage<sizeof(locale)>::type buf;
|
||||
::new (&buf) locale(locale::classic());
|
||||
return *(locale*)&buf;
|
||||
return *reinterpret_cast<locale*>(&buf);
|
||||
}
|
||||
|
||||
locale&
|
||||
@ -1036,7 +1034,9 @@ ctype<char>::classic_table() _NOEXCEPT
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
return *__ctype_b_loc();
|
||||
#elif defined(_AIX)
|
||||
return (const unsigned long *)__lc_ctype_ptr->obj->mask;
|
||||
return (const unsigned int *)__lc_ctype_ptr->obj->mask;
|
||||
#elif defined(__ANDROID__)
|
||||
return reinterpret_cast<const unsigned char*>(_ctype_) + 1;
|
||||
#else
|
||||
// Platform not supported: abort so the person doing the port knows what to
|
||||
// fix
|
||||
@ -1615,9 +1615,9 @@ int
|
||||
codecvt<wchar_t, char, mbstate_t>::do_encoding() const _NOEXCEPT
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
if (mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0)
|
||||
if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
|
||||
#else
|
||||
if (__mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0)
|
||||
if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
|
||||
#endif
|
||||
{
|
||||
// stateless encoding
|
||||
@ -1743,8 +1743,8 @@ utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm
|
||||
return codecvt_base::error;
|
||||
if (to_end-to_nxt < 4)
|
||||
return codecvt_base::partial;
|
||||
if ((((((unsigned long)wc1 & 0x03C0) >> 6) + 1) << 16) +
|
||||
(((unsigned long)wc1 & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode)
|
||||
if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
|
||||
((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
|
||||
return codecvt_base::error;
|
||||
++frm_nxt;
|
||||
uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
|
||||
@ -1820,8 +1820,8 @@ utf16_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm
|
||||
return codecvt_base::error;
|
||||
if (to_end-to_nxt < 4)
|
||||
return codecvt_base::partial;
|
||||
if ((((((unsigned long)wc1 & 0x03C0) >> 6) + 1) << 16) +
|
||||
(((unsigned long)wc1 & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode)
|
||||
if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
|
||||
((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
|
||||
return codecvt_base::error;
|
||||
++frm_nxt;
|
||||
uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
|
||||
@ -1944,9 +1944,9 @@ utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nx
|
||||
return codecvt_base::error;
|
||||
if (to_end-to_nxt < 2)
|
||||
return codecvt_base::partial;
|
||||
if (((((unsigned long)c1 & 7) << 18) +
|
||||
(((unsigned long)c2 & 0x3F) << 12) +
|
||||
(((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
|
||||
if ((((c1 & 7UL) << 18) +
|
||||
((c2 & 0x3FUL) << 12) +
|
||||
((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
|
||||
return codecvt_base::error;
|
||||
*to_nxt = static_cast<uint16_t>(
|
||||
0xD800
|
||||
@ -2065,9 +2065,9 @@ utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nx
|
||||
return codecvt_base::error;
|
||||
if (to_end-to_nxt < 2)
|
||||
return codecvt_base::partial;
|
||||
if (((((unsigned long)c1 & 7) << 18) +
|
||||
(((unsigned long)c2 & 0x3F) << 12) +
|
||||
(((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
|
||||
if ((((c1 & 7UL) << 18) +
|
||||
((c2 & 0x3FUL) << 12) +
|
||||
((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
|
||||
return codecvt_base::error;
|
||||
*to_nxt = static_cast<uint32_t>(
|
||||
0xD800
|
||||
@ -2174,9 +2174,9 @@ utf8_to_utf16_length(const uint8_t* frm, const uint8_t* frm_end,
|
||||
}
|
||||
if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
|
||||
break;
|
||||
if (((((unsigned long)c1 & 7) << 18) +
|
||||
(((unsigned long)c2 & 0x3F) << 12) +
|
||||
(((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
|
||||
if ((((c1 & 7UL) << 18) +
|
||||
((c2 & 0x3FUL) << 12) +
|
||||
((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
|
||||
break;
|
||||
++nchar16_t;
|
||||
frm_nxt += 4;
|
||||
|
@ -9,8 +9,10 @@
|
||||
|
||||
#define _LIBCPP_BUILDING_MEMORY
|
||||
#include "memory"
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
#include "mutex"
|
||||
#include "thread"
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@ -109,7 +111,7 @@ __shared_weak_count::lock() _NOEXCEPT
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_NO_RTTI
|
||||
#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
|
||||
|
||||
const void*
|
||||
__shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
|
||||
@ -119,7 +121,7 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
|
||||
|
||||
#endif // _LIBCPP_NO_RTTI
|
||||
|
||||
#if __has_feature(cxx_atomic)
|
||||
#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
static const std::size_t __sp_mut_count = 16;
|
||||
static pthread_mutex_t mut_back_imp[__sp_mut_count] =
|
||||
@ -172,7 +174,7 @@ __get_sp_mut(const void* p)
|
||||
return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
|
||||
}
|
||||
|
||||
#endif // __has_feature(cxx_atomic)
|
||||
#endif // __has_feature(cxx_atomic) && !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
void
|
||||
declare_reachable(void*)
|
||||
@ -208,7 +210,7 @@ align(size_t alignment, size_t size, void*& ptr, size_t& space)
|
||||
if (size <= space)
|
||||
{
|
||||
char* p1 = static_cast<char*>(ptr);
|
||||
char* p2 = (char*)((size_t)(p1 + (alignment - 1)) & -alignment);
|
||||
char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment);
|
||||
size_t d = static_cast<size_t>(p2 - p1);
|
||||
if (d <= space - size)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "cassert"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
const defer_lock_t defer_lock = {};
|
||||
const try_to_lock_t try_to_lock = {};
|
||||
@ -206,18 +207,42 @@ recursive_timed_mutex::unlock() _NOEXCEPT
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
// If dispatch_once_f ever handles C++ exceptions, and if one can get to it
|
||||
// without illegal macros (unexpected macros not beginning with _UpperCase or
|
||||
// __lowercase), and if it stops spinning waiting threads, then call_once should
|
||||
// call into dispatch_once_f instead of here. Relevant radar this code needs to
|
||||
// keep in sync with: 7741191.
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
|
||||
#endif
|
||||
|
||||
void
|
||||
__call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
|
||||
{
|
||||
#if defined(_LIBCPP_HAS_NO_THREADS)
|
||||
if (flag == 0)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
flag = 1;
|
||||
func(arg);
|
||||
flag = ~0ul;
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
flag = 0ul;
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
pthread_mutex_lock(&mut);
|
||||
while (flag == 1)
|
||||
pthread_cond_wait(&cv, &mut);
|
||||
@ -248,6 +273,8 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
|
||||
}
|
||||
else
|
||||
pthread_mutex_unlock(&mut);
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) && !defined(LIBCXXRT)
|
||||
#include <cxxabi.h>
|
||||
|
||||
#ifndef _LIBCPPABI_VERSION
|
||||
@ -167,7 +167,7 @@ set_new_handler(new_handler handler) _NOEXCEPT
|
||||
new_handler
|
||||
get_new_handler() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__new_handler, (new_handler)0);
|
||||
return __sync_fetch_and_add(&__new_handler, nullptr);
|
||||
}
|
||||
|
||||
#endif // !__GLIBCXX__
|
||||
@ -200,6 +200,12 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char*
|
||||
bad_array_new_length::what() const _NOEXCEPT
|
||||
{
|
||||
return "bad_array_new_length";
|
||||
}
|
||||
|
||||
#endif //LIBCXXRT
|
||||
|
||||
const char*
|
||||
@ -216,12 +222,6 @@ bad_array_length::~bad_array_length() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char*
|
||||
bad_array_new_length::what() const _NOEXCEPT
|
||||
{
|
||||
return "bad_array_new_length";
|
||||
}
|
||||
|
||||
#endif // _LIBCPPABI_VERSION
|
||||
|
||||
#ifndef LIBSTDCXX
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#include "experimental/optional"
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{ namespace experimental {
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
@ -22,4 +21,4 @@ bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
|
||||
|
||||
#endif
|
||||
|
||||
}} // std::experimental
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
@ -11,23 +11,27 @@
|
||||
// Must be defined before including stdlib.h to enable rand_s().
|
||||
#define _CRT_RAND_S
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#include "random"
|
||||
#include "system_error"
|
||||
|
||||
#ifdef __sun__
|
||||
#if defined(__sun__)
|
||||
#define rename solaris_headers_are_broken
|
||||
#endif
|
||||
#endif // defined(__sun__)
|
||||
#if !defined(_WIN32)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif // defined(_WIN32)
|
||||
#endif // !defined(_WIN32)
|
||||
#include <errno.h>
|
||||
#if defined(_LIBCPP_USING_NACL_RANDOM)
|
||||
#include <nacl/nacl_random.h>
|
||||
#endif // defined(_LIBCPP_USING_NACL_RANDOM)
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
random_device::random_device(const string&)
|
||||
{
|
||||
}
|
||||
@ -45,11 +49,43 @@ random_device::operator()()
|
||||
__throw_system_error(err, "random_device rand_s failed.");
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
|
||||
#elif defined(_LIBCPP_USING_NACL_RANDOM)
|
||||
|
||||
random_device::random_device(const string& __token)
|
||||
{
|
||||
if (__token != "/dev/urandom")
|
||||
__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
|
||||
int error = nacl_secure_random_init();
|
||||
if (error)
|
||||
__throw_system_error(error, ("random device failed to open " + __token).c_str());
|
||||
}
|
||||
|
||||
random_device::~random_device()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned
|
||||
random_device::operator()()
|
||||
{
|
||||
unsigned r;
|
||||
size_t n = sizeof(r);
|
||||
char* p = reinterpret_cast<char*>(&r);
|
||||
size_t bytes_written;
|
||||
int error = nacl_secure_random(&r, n, &bytes_written);
|
||||
if (error != 0)
|
||||
__throw_system_error(error, "random_device failed getting bytes");
|
||||
else if (bytes_written != n)
|
||||
__throw_runtime_error("random_device failed to obtain enough bytes");
|
||||
return r;
|
||||
}
|
||||
|
||||
#else // !defined(_WIN32) && !defined(_LIBCPP_USING_NACL_RANDOM)
|
||||
|
||||
random_device::random_device(const string& __token)
|
||||
: __f_(open(__token.c_str(), O_RDONLY))
|
||||
{
|
||||
if (__f_ <= 0)
|
||||
if (__f_ < 0)
|
||||
__throw_system_error(errno, ("random_device failed to open " + __token).c_str());
|
||||
}
|
||||
|
||||
@ -62,10 +98,26 @@ unsigned
|
||||
random_device::operator()()
|
||||
{
|
||||
unsigned r;
|
||||
read(__f_, &r, sizeof(r));
|
||||
size_t n = sizeof(r);
|
||||
char* p = reinterpret_cast<char*>(&r);
|
||||
while (n > 0)
|
||||
{
|
||||
ssize_t s = read(__f_, p, n);
|
||||
if (s == 0)
|
||||
__throw_system_error(ENODATA, "random_device got EOF");
|
||||
if (s == -1)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
__throw_system_error(errno, "random_device got an unexpected error");
|
||||
continue;
|
||||
}
|
||||
n -= static_cast<size_t>(s);
|
||||
p += static_cast<size_t>(s);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#endif // defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)
|
||||
|
||||
double
|
||||
random_device::entropy() const _NOEXCEPT
|
||||
|
@ -69,8 +69,10 @@ regex_error::~regex_error() throw() {}
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
struct collationnames
|
||||
{
|
||||
@ -78,7 +80,9 @@ struct collationnames
|
||||
char char_;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
const collationnames collatenames[] =
|
||||
{
|
||||
@ -195,16 +199,20 @@ const collationnames collatenames[] =
|
||||
{"zero", 0x30}
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
struct classnames
|
||||
{
|
||||
const char* elem_;
|
||||
ctype_base::mask mask_;
|
||||
regex_traits<char>::char_class_type mask_;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
const classnames ClassNames[] =
|
||||
{
|
||||
@ -246,12 +254,12 @@ __get_collation_name(const char* s)
|
||||
return r;
|
||||
}
|
||||
|
||||
ctype_base::mask
|
||||
regex_traits<char>::char_class_type
|
||||
__get_classname(const char* s, bool __icase)
|
||||
{
|
||||
const classnames* i =
|
||||
_VSTD::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
|
||||
ctype_base::mask r = 0;
|
||||
regex_traits<char>::char_class_type r = 0;
|
||||
if (i != end(ClassNames) && strcmp(s, i->elem_) == 0)
|
||||
{
|
||||
r = i->mask_;
|
||||
|
@ -7,12 +7,15 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "__config"
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#define _LIBCPP_BUILDING_SHARED_MUTEX
|
||||
#include "shared_mutex"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
shared_mutex::shared_mutex()
|
||||
shared_timed_mutex::shared_timed_mutex()
|
||||
: __state_(0)
|
||||
{
|
||||
}
|
||||
@ -20,7 +23,7 @@ shared_mutex::shared_mutex()
|
||||
// Exclusive ownership
|
||||
|
||||
void
|
||||
shared_mutex::lock()
|
||||
shared_timed_mutex::lock()
|
||||
{
|
||||
unique_lock<mutex> lk(__mut_);
|
||||
while (__state_ & __write_entered_)
|
||||
@ -31,7 +34,7 @@ shared_mutex::lock()
|
||||
}
|
||||
|
||||
bool
|
||||
shared_mutex::try_lock()
|
||||
shared_timed_mutex::try_lock()
|
||||
{
|
||||
unique_lock<mutex> lk(__mut_);
|
||||
if (__state_ == 0)
|
||||
@ -43,7 +46,7 @@ shared_mutex::try_lock()
|
||||
}
|
||||
|
||||
void
|
||||
shared_mutex::unlock()
|
||||
shared_timed_mutex::unlock()
|
||||
{
|
||||
lock_guard<mutex> _(__mut_);
|
||||
__state_ = 0;
|
||||
@ -53,7 +56,7 @@ shared_mutex::unlock()
|
||||
// Shared ownership
|
||||
|
||||
void
|
||||
shared_mutex::lock_shared()
|
||||
shared_timed_mutex::lock_shared()
|
||||
{
|
||||
unique_lock<mutex> lk(__mut_);
|
||||
while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
|
||||
@ -64,7 +67,7 @@ shared_mutex::lock_shared()
|
||||
}
|
||||
|
||||
bool
|
||||
shared_mutex::try_lock_shared()
|
||||
shared_timed_mutex::try_lock_shared()
|
||||
{
|
||||
unique_lock<mutex> lk(__mut_);
|
||||
unsigned num_readers = __state_ & __n_readers_;
|
||||
@ -79,7 +82,7 @@ shared_mutex::try_lock_shared()
|
||||
}
|
||||
|
||||
void
|
||||
shared_mutex::unlock_shared()
|
||||
shared_timed_mutex::unlock_shared()
|
||||
{
|
||||
lock_guard<mutex> _(__mut_);
|
||||
unsigned num_readers = (__state_ & __n_readers_) - 1;
|
||||
@ -99,3 +102,5 @@ shared_mutex::unlock_shared()
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
@ -7,123 +7,42 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "__refstring"
|
||||
#include "stdexcept"
|
||||
#include "new"
|
||||
#include "string"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "system_error"
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <cxxabi.h>
|
||||
#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
|
||||
/* For _LIBCPPABI_VERSION */
|
||||
#if __has_include(<cxxabi.h>) || defined(__APPLE_) || defined(LIBCXXRT)
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
|
||||
// Note: optimize for size
|
||||
|
||||
#if ! defined(_LIBCPP_MSVC)
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class __libcpp_nmstr
|
||||
{
|
||||
private:
|
||||
const char* str_;
|
||||
|
||||
typedef std::size_t unused_t;
|
||||
typedef std::ptrdiff_t count_t;
|
||||
|
||||
static const std::ptrdiff_t offset = static_cast<std::ptrdiff_t>(2*sizeof(unused_t) +
|
||||
sizeof(count_t));
|
||||
|
||||
count_t& count() const _NOEXCEPT {return (count_t&)(*(str_ - sizeof(count_t)));}
|
||||
public:
|
||||
explicit __libcpp_nmstr(const char* msg);
|
||||
__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT;
|
||||
__libcpp_nmstr& operator=(const __libcpp_nmstr& s) _NOEXCEPT;
|
||||
~__libcpp_nmstr();
|
||||
const char* c_str() const _NOEXCEPT {return str_;}
|
||||
};
|
||||
|
||||
__libcpp_nmstr::__libcpp_nmstr(const char* msg)
|
||||
{
|
||||
std::size_t len = strlen(msg);
|
||||
str_ = new char[len + 1 + offset];
|
||||
unused_t* c = (unused_t*)str_;
|
||||
c[0] = c[1] = len;
|
||||
str_ += offset;
|
||||
count() = 0;
|
||||
std::memcpy(const_cast<char*>(c_str()), msg, len + 1);
|
||||
}
|
||||
|
||||
inline
|
||||
__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT
|
||||
: str_(s.str_)
|
||||
{
|
||||
__sync_add_and_fetch(&count(), 1);
|
||||
}
|
||||
|
||||
__libcpp_nmstr&
|
||||
__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT
|
||||
{
|
||||
const char* p = str_;
|
||||
str_ = s.str_;
|
||||
__sync_add_and_fetch(&count(), 1);
|
||||
if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 0)
|
||||
delete [] (p-offset);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
__libcpp_nmstr::~__libcpp_nmstr()
|
||||
{
|
||||
if (__sync_add_and_fetch(&count(), count_t(-1)) < 0)
|
||||
delete [] (str_ - offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if ! defined(_LIBCPP_MSVC)
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
logic_error::logic_error(const string& msg)
|
||||
logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
::new(&s) __libcpp_nmstr(msg.c_str());
|
||||
}
|
||||
|
||||
logic_error::logic_error(const char* msg)
|
||||
logic_error::logic_error(const char* msg) : __imp_(msg)
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
::new(&s) __libcpp_nmstr(msg);
|
||||
}
|
||||
|
||||
logic_error::logic_error(const logic_error& le) _NOEXCEPT
|
||||
logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
::new(&s) __libcpp_nmstr((const __libcpp_nmstr&)le.__imp_);
|
||||
}
|
||||
|
||||
logic_error&
|
||||
logic_error::operator=(const logic_error& le) _NOEXCEPT
|
||||
{
|
||||
__libcpp_nmstr& s1 = (__libcpp_nmstr&)__imp_;
|
||||
const __libcpp_nmstr& s2 = (const __libcpp_nmstr&)le.__imp_;
|
||||
s1 = s2;
|
||||
__imp_ = le.__imp_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -131,43 +50,33 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT
|
||||
|
||||
logic_error::~logic_error() _NOEXCEPT
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
s.~__libcpp_nmstr();
|
||||
}
|
||||
|
||||
const char*
|
||||
logic_error::what() const _NOEXCEPT
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
return s.c_str();
|
||||
return __imp_.c_str();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
runtime_error::runtime_error(const string& msg)
|
||||
runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
::new(&s) __libcpp_nmstr(msg.c_str());
|
||||
}
|
||||
|
||||
runtime_error::runtime_error(const char* msg)
|
||||
runtime_error::runtime_error(const char* msg) : __imp_(msg)
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
::new(&s) __libcpp_nmstr(msg);
|
||||
}
|
||||
|
||||
runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
|
||||
: __imp_(le.__imp_)
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
::new(&s) __libcpp_nmstr((const __libcpp_nmstr&)le.__imp_);
|
||||
}
|
||||
|
||||
runtime_error&
|
||||
runtime_error::operator=(const runtime_error& le) _NOEXCEPT
|
||||
{
|
||||
__libcpp_nmstr& s1 = (__libcpp_nmstr&)__imp_;
|
||||
const __libcpp_nmstr& s2 = (const __libcpp_nmstr&)le.__imp_;
|
||||
s1 = s2;
|
||||
__imp_ = le.__imp_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -175,15 +84,12 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT
|
||||
|
||||
runtime_error::~runtime_error() _NOEXCEPT
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
s.~__libcpp_nmstr();
|
||||
}
|
||||
|
||||
const char*
|
||||
runtime_error::what() const _NOEXCEPT
|
||||
{
|
||||
__libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
|
||||
return s.c_str();
|
||||
return __imp_.c_str();
|
||||
}
|
||||
|
||||
domain_error::~domain_error() _NOEXCEPT {}
|
||||
|
@ -7,8 +7,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
|
||||
#include "string"
|
||||
#include "cstdlib"
|
||||
#include "cwchar"
|
||||
@ -65,7 +63,7 @@ inline
|
||||
V
|
||||
as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
|
||||
{
|
||||
typename S::value_type* ptr;
|
||||
typename S::value_type* ptr = nullptr;
|
||||
const typename S::value_type* const p = str.c_str();
|
||||
typename remove_reference<decltype(errno)>::type errno_save = errno;
|
||||
errno = 0;
|
||||
@ -182,7 +180,7 @@ inline
|
||||
V
|
||||
as_float_helper(const string& func, const S& str, size_t* idx, F f )
|
||||
{
|
||||
typename S::value_type* ptr;
|
||||
typename S::value_type* ptr = nullptr;
|
||||
const typename S::value_type* const p = str.c_str();
|
||||
typename remove_reference<decltype(errno)>::type errno_save = errno;
|
||||
errno = 0;
|
||||
|
@ -61,7 +61,7 @@ strstreambuf::strstreambuf(const char* __gnext, streamsize __n)
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init((char*)__gnext, __n, nullptr);
|
||||
__init(const_cast<char *>(__gnext), __n, nullptr);
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg)
|
||||
@ -70,7 +70,7 @@ strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init((char*)__gnext, __n, (char*)__pbeg);
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n)
|
||||
@ -79,7 +79,7 @@ strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n)
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init((char*)__gnext, __n, nullptr);
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg)
|
||||
@ -88,7 +88,7 @@ strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init((char*)__gnext, __n, (char*)__pbeg);
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n)
|
||||
@ -97,7 +97,7 @@ strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n)
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init((char*)__gnext, __n, nullptr);
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
|
||||
}
|
||||
|
||||
strstreambuf::~strstreambuf()
|
||||
@ -186,7 +186,7 @@ strstreambuf::overflow(int_type __c)
|
||||
}
|
||||
*pptr() = static_cast<char>(__c);
|
||||
pbump(1);
|
||||
return int_type((unsigned char)__c);
|
||||
return int_type(static_cast<unsigned char>(__c));
|
||||
}
|
||||
|
||||
strstreambuf::int_type
|
||||
@ -222,7 +222,7 @@ strstreambuf::underflow()
|
||||
return EOF;
|
||||
setg(eback(), gptr(), pptr());
|
||||
}
|
||||
return int_type((unsigned char)*gptr());
|
||||
return int_type(static_cast<unsigned char>(*gptr()));
|
||||
}
|
||||
|
||||
strstreambuf::pos_type
|
||||
|
@ -7,7 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_BUILDING_SYSTEM_ERROR
|
||||
#define _LIBCPP_BUILDING_SYSTEM_ERROR
|
||||
#include "__config"
|
||||
#include "system_error"
|
||||
#include "string"
|
||||
#include "cstring"
|
||||
@ -65,10 +66,10 @@ __generic_error_category::name() const _NOEXCEPT
|
||||
string
|
||||
__generic_error_category::message(int ev) const
|
||||
{
|
||||
#ifdef ELAST
|
||||
if (ev > ELAST)
|
||||
#ifdef _LIBCPP_ELAST
|
||||
if (ev > _LIBCPP_ELAST)
|
||||
return string("unspecified generic_category error");
|
||||
#endif // ELAST
|
||||
#endif // _LIBCPP_ELAST
|
||||
return __do_message::message(ev);
|
||||
}
|
||||
|
||||
@ -97,20 +98,20 @@ __system_error_category::name() const _NOEXCEPT
|
||||
string
|
||||
__system_error_category::message(int ev) const
|
||||
{
|
||||
#ifdef ELAST
|
||||
if (ev > ELAST)
|
||||
#ifdef _LIBCPP_ELAST
|
||||
if (ev > _LIBCPP_ELAST)
|
||||
return string("unspecified system_category error");
|
||||
#endif // ELAST
|
||||
#endif // _LIBCPP_ELAST
|
||||
return __do_message::message(ev);
|
||||
}
|
||||
|
||||
error_condition
|
||||
__system_error_category::default_error_condition(int ev) const _NOEXCEPT
|
||||
{
|
||||
#ifdef ELAST
|
||||
if (ev > ELAST)
|
||||
#ifdef _LIBCPP_ELAST
|
||||
if (ev > _LIBCPP_ELAST)
|
||||
return error_condition(ev, system_category());
|
||||
#endif // ELAST
|
||||
#endif // _LIBCPP_ELAST
|
||||
return error_condition(ev, generic_category());
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,9 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "__config"
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#include "thread"
|
||||
#include "exception"
|
||||
#include "vector"
|
||||
@ -14,10 +17,10 @@
|
||||
#include "limits"
|
||||
#include <sys/types.h>
|
||||
#if !defined(_WIN32)
|
||||
#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
|
||||
#include <sys/sysctl.h>
|
||||
#endif // !__sun__ && !__linux__ && !_AIX
|
||||
#include <unistd.h>
|
||||
# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__)
|
||||
# include <sys/sysctl.h>
|
||||
# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__)
|
||||
# include <unistd.h>
|
||||
#endif // !_WIN32
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
@ -121,7 +124,9 @@ sleep_for(const chrono::nanoseconds& ns)
|
||||
ts.tv_sec = ts_sec_max;
|
||||
ts.tv_nsec = giga::num - 1;
|
||||
}
|
||||
nanosleep(&ts, 0);
|
||||
|
||||
while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +149,7 @@ class _LIBCPP_HIDDEN __hidden_allocator
|
||||
|
||||
T* allocate(size_t __n)
|
||||
{return static_cast<T*>(::operator new(__n * sizeof(T)));}
|
||||
void deallocate(T* __p, size_t) {::operator delete((void*)__p);}
|
||||
void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));}
|
||||
|
||||
size_t max_size() const {return size_t(~0) / sizeof(T);}
|
||||
};
|
||||
@ -223,3 +228,5 @@ __thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s)
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
@ -7,8 +7,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
|
||||
#include "valarray"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
@ -75,6 +75,7 @@ STD_HEADERS= __bit_reference\
|
||||
__hash_table\
|
||||
__locale\
|
||||
__mutex_base\
|
||||
__refstring\
|
||||
__split_buffer\
|
||||
__sso_allocator\
|
||||
__std_stream\
|
||||
@ -176,8 +177,12 @@ STD+= ${LIBCXXRTDIR}/${hdr}
|
||||
.endfor
|
||||
STDDIR= ${CXXINCLUDEDIR}
|
||||
|
||||
EXP_HEADERS= dynarray\
|
||||
optional
|
||||
EXP_HEADERS= __config\
|
||||
dynarray\
|
||||
optional\
|
||||
string_view\
|
||||
type_traits\
|
||||
utility
|
||||
|
||||
.for hdr in ${EXP_HEADERS}
|
||||
EXP+= ${HDRDIR}/experimental/${hdr}
|
||||
|
Loading…
Reference in New Issue
Block a user