Update libc++ to release_39 branch r279689.
This commit is contained in:
commit
7c82a1ece4
@ -37,6 +37,10 @@ E: mclow.lists@gmail.com
|
||||
E: marshall@idio.com
|
||||
D: C++14 support, patches and bug fixes.
|
||||
|
||||
N: Jonathan B Coe
|
||||
E: jbcoe@me.com
|
||||
D: Implementation of propagate_const.
|
||||
|
||||
N: Eric Fiselier
|
||||
E: eric@efcs.ca
|
||||
D: LFTS support, patches and 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-2015 by the contributors listed in CREDITS.TXT
|
||||
Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
33
contrib/libc++/include/__bsd_locale_defaults.h
Normal file
33
contrib/libc++/include/__bsd_locale_defaults.h
Normal file
@ -0,0 +1,33 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------- __bsd_locale_defaults.h -----------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// The BSDs have lots of *_l functions. We don't want to define those symbols
|
||||
// on other platforms though, for fear of conflicts with user code. So here,
|
||||
// we will define the mapping from an internal macro to the real BSD symbol.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
|
||||
#define _LIBCPP_BSD_LOCALE_DEFAULTS_H
|
||||
|
||||
#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)
|
||||
#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc)
|
||||
#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc)
|
||||
#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc)
|
||||
#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc)
|
||||
#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc)
|
||||
#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l)
|
||||
#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l)
|
||||
#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l)
|
||||
#define __libcpp_localeconv_l(l) localeconv_l(l)
|
||||
#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l)
|
||||
#define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__)
|
||||
#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__)
|
||||
#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)
|
||||
|
||||
#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H
|
138
contrib/libc++/include/__bsd_locale_fallbacks.h
Normal file
138
contrib/libc++/include/__bsd_locale_fallbacks.h
Normal file
@ -0,0 +1,138 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------- __bsd_locale_fallbacks.h ----------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// The BSDs have lots of *_l functions. This file provides reimplementations
|
||||
// of those functions for non-BSD platforms.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
typedef _VSTD::remove_pointer<locale_t>::type __use_locale_struct;
|
||||
typedef _VSTD::unique_ptr<__use_locale_struct, decltype(&uselocale)> __locale_raii;
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return MB_CUR_MAX;
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
wint_t __libcpp_btowc_l(int __c, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return btowc(__c);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_wctob_l(wint_t __c, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return wctob(__c);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return wcrtomb(__s, __wc, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return mbrtowc(__pwc, __s, __n, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return mbtowc(__pwc, __pmb, __max);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return mbrlen(__s, __n, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
lconv *__libcpp_localeconv_l(locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return localeconv();
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
return mbsrtowcs(__dest, __src, __len, __ps);
|
||||
}
|
||||
|
||||
inline
|
||||
int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
int __res = vsnprintf(__s, __n, __format, __va);
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
int __res = vasprintf(__s, __format, __va);
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
__locale_raii __current( uselocale(__l), uselocale );
|
||||
int __res = vsscanf(__s, __format, __va);
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
@ -27,7 +27,7 @@
|
||||
#define _GNUC_VER 0
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_VERSION 3800
|
||||
#define _LIBCPP_VERSION 3900
|
||||
|
||||
#ifndef _LIBCPP_ABI_VERSION
|
||||
#define _LIBCPP_ABI_VERSION 1
|
||||
@ -41,6 +41,22 @@
|
||||
#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
|
||||
// Fix undefined behavior in how std::list stores it's linked nodes.
|
||||
#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
|
||||
// Fix undefined behavior in how __tree stores its end and parent nodes.
|
||||
#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
|
||||
#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
|
||||
#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
|
||||
#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
|
||||
#elif _LIBCPP_ABI_VERSION == 1
|
||||
// Feature macros for disabling pre ABI v1 features. All of these options
|
||||
// are deprecated.
|
||||
#if defined(__FreeBSD__)
|
||||
#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
|
||||
use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
|
||||
@ -178,6 +194,12 @@
|
||||
# endif
|
||||
#endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
|
||||
|
||||
#if __has_attribute(__no_sanitize__)
|
||||
#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
|
||||
#else
|
||||
#define _LIBCPP_NO_CFI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// only really useful for a DLL
|
||||
@ -236,6 +258,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_PREFERRED_OVERLOAD
|
||||
# if __has_attribute(__enable_if__)
|
||||
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_TYPE_VIS_ONLY
|
||||
# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
|
||||
#endif
|
||||
@ -283,7 +311,7 @@ typedef __char16_t char16_t;
|
||||
typedef __char32_t char32_t;
|
||||
#endif
|
||||
|
||||
#if !(__has_feature(cxx_exceptions))
|
||||
#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
|
||||
#define _LIBCPP_NO_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
@ -305,8 +333,6 @@ typedef __char32_t char32_t;
|
||||
# define _LIBCPP_NORETURN __attribute__ ((noreturn))
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_UNUSED __attribute__((__unused__))
|
||||
|
||||
#if !(__has_feature(cxx_default_function_template_args))
|
||||
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
|
||||
#endif
|
||||
@ -434,8 +460,8 @@ namespace std {
|
||||
#endif
|
||||
|
||||
// Allow for build-time disabling of unsigned integer sanitization
|
||||
#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
|
||||
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned-integer-overflow")))
|
||||
#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
|
||||
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
|
||||
#endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
@ -445,8 +471,6 @@ 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)
|
||||
@ -461,8 +485,6 @@ namespace std {
|
||||
#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
|
||||
@ -494,6 +516,7 @@ namespace std {
|
||||
#define _LIBCPP_HAS_NO_VARIADICS
|
||||
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#define _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
#define _LIBCPP_HAS_NO_NOEXCEPT
|
||||
|
||||
#else // __GXX_EXPERIMENTAL_CXX0X__
|
||||
@ -517,6 +540,7 @@ namespace std {
|
||||
#if _GNUC_VER < 406
|
||||
#define _LIBCPP_HAS_NO_NOEXCEPT
|
||||
#define _LIBCPP_HAS_NO_NULLPTR
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
#endif
|
||||
|
||||
#if _GNUC_VER < 407
|
||||
@ -552,7 +576,6 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
|
||||
#define _LIBCPP_HAS_NO_NOEXCEPT
|
||||
#define __alignof__ __alignof
|
||||
#define _LIBCPP_NORETURN __declspec(noreturn)
|
||||
#define _LIBCPP_UNUSED
|
||||
#define _ALIGNAS(x) __declspec(align(x))
|
||||
#define _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
@ -574,7 +597,6 @@ namespace std {
|
||||
#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
|
||||
#define _ATTRIBUTE(x) __attribute__((x))
|
||||
#define _LIBCPP_NORETURN __attribute__((noreturn))
|
||||
#define _LIBCPP_UNUSED
|
||||
|
||||
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
|
||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
@ -655,6 +677,12 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_DEFAULT = default;
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
#define _LIBCPP_EQUAL_DELETE
|
||||
#else
|
||||
#define _LIBCPP_EQUAL_DELETE = delete
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _NOALIAS __attribute__((__malloc__))
|
||||
#else
|
||||
@ -712,10 +740,12 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \
|
||||
!defined(__CloudABI__)
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
// Most unix variants have catopen. These are the specific ones that don't.
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
|
||||
#define _LIBCPP_HAS_CATOPEN 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define _DECLARE_C99_LDBL_MATH 1
|
||||
@ -729,24 +759,13 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_WCTYPE_IS_MASK
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
# 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 15 // current year, or date of c++17 ratification
|
||||
# define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
|
||||
# endif
|
||||
#endif // _LIBCPP_STD_VER
|
||||
|
||||
@ -770,6 +789,12 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
|
||||
#else
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
|
||||
#else
|
||||
@ -797,6 +822,25 @@ extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
# define _LIBCPP_WEAK __attribute__((__weak__))
|
||||
#endif
|
||||
|
||||
// Thread API
|
||||
#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
# if defined(__FreeBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__linux__) || \
|
||||
defined(__APPLE__) || \
|
||||
defined(__CloudABI__) || \
|
||||
defined(__sun__)
|
||||
# define _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
# else
|
||||
# error "No thread API"
|
||||
# endif // _LIBCPP_HAS_THREAD_API
|
||||
#endif // _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
|
||||
_LIBCPP_HAS_NO_THREADS is not defined.
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
|
||||
_LIBCPP_HAS_NO_THREADS is defined.
|
||||
@ -840,7 +884,20 @@ extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
|
||||
#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
|
||||
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
#define _LIBCPP_CXX03_LANG
|
||||
#else
|
||||
#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
|
||||
#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
|
||||
&& __has_attribute(acquire_capability))
|
||||
#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
@ -38,8 +38,6 @@ struct _LIBCPP_TYPE_VIS_ONLY binary_function
|
||||
typedef _Result result_type;
|
||||
};
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_result_type
|
||||
{
|
||||
@ -306,75 +304,19 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
// __invoke
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
// bullets 1 and 2
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
-> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
{
|
||||
return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
-> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
{
|
||||
return ((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
// bullets 3 and 4
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
-> decltype(_VSTD::forward<_A0>(__a0).*__f)
|
||||
{
|
||||
return _VSTD::forward<_A0>(__a0).*__f;
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
-> decltype((*_VSTD::forward<_A0>(__a0)).*__f)
|
||||
{
|
||||
return (*_VSTD::forward<_A0>(__a0)).*__f;
|
||||
}
|
||||
|
||||
// bullet 5
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _Args&& ...__args)
|
||||
-> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
|
||||
{
|
||||
return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
template <class _Tp, class ..._Args>
|
||||
struct __invoke_return
|
||||
{
|
||||
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
|
||||
};
|
||||
|
||||
#else // _LIBCPP_HAS_NO_VARIADICS
|
||||
#else // defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
#include <__functional_base_03>
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
|
||||
template <class _Ret>
|
||||
@ -577,10 +519,6 @@ public:
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
};
|
||||
|
||||
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_impl<typename remove_cv<_Tp>::type> {};
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
#include <__undef_min_max>
|
||||
#include <__undef___deallocate>
|
||||
@ -29,6 +30,29 @@
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Key, class _Tp>
|
||||
union __hash_value_type;
|
||||
#else
|
||||
template <class _Key, class _Tp>
|
||||
struct __hash_value_type;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Tp>
|
||||
struct __is_hash_value_type_imp : false_type {};
|
||||
|
||||
template <class _Key, class _Value>
|
||||
struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {};
|
||||
|
||||
template <class ..._Args>
|
||||
struct __is_hash_value_type : false_type {};
|
||||
|
||||
template <class _One>
|
||||
struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
|
||||
#endif
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
size_t __next_prime(size_t __n);
|
||||
|
||||
@ -49,10 +73,10 @@ struct __hash_node
|
||||
typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
|
||||
>
|
||||
{
|
||||
typedef _Tp value_type;
|
||||
typedef _Tp __node_value_type;
|
||||
|
||||
size_t __hash_;
|
||||
value_type __value_;
|
||||
__node_value_type __value_;
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -66,7 +90,8 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t
|
||||
__constrain_hash(size_t __h, size_t __bc)
|
||||
{
|
||||
return !(__bc & (__bc - 1)) ? __h & (__bc - 1) : __h % __bc;
|
||||
return !(__bc & (__bc - 1)) ? __h & (__bc - 1) :
|
||||
(__h < __bc ? __h : __h % __bc);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -76,24 +101,173 @@ __next_hash_pow2(size_t __n)
|
||||
return size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1));
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc> class __hash_table;
|
||||
|
||||
template <class _NodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_iterator;
|
||||
template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
|
||||
template <class _NodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator;
|
||||
template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
|
||||
template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator;
|
||||
template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
|
||||
|
||||
template <class _Tp>
|
||||
struct __hash_key_value_types {
|
||||
static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, "");
|
||||
typedef _Tp key_type;
|
||||
typedef _Tp __node_value_type;
|
||||
typedef _Tp __container_value_type;
|
||||
static const bool __is_map = false;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static key_type const& __get_key(_Tp const& __v) {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type const& __get_value(__node_value_type const& __v) {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type* __get_ptr(__node_value_type& __n) {
|
||||
return _VSTD::addressof(__n);
|
||||
}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type&& __move(__node_value_type& __v) {
|
||||
return _VSTD::move(__v);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp>
|
||||
struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef __hash_value_type<_Key, _Tp> __node_value_type;
|
||||
typedef pair<const _Key, _Tp> __container_value_type;
|
||||
typedef pair<_Key, _Tp> __nc_value_type;
|
||||
typedef __container_value_type __map_value_type;
|
||||
static const bool __is_map = true;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static key_type const& __get_key(__container_value_type const& __v) {
|
||||
return __v.first;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
|
||||
__container_value_type const&>::type
|
||||
__get_value(_Up& __t) {
|
||||
return __t.__cc;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
|
||||
__container_value_type const&>::type
|
||||
__get_value(_Up& __t) {
|
||||
return __t;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type* __get_ptr(__node_value_type& __n) {
|
||||
return _VSTD::addressof(__n.__cc);
|
||||
}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __nc_value_type&& __move(__node_value_type& __v) {
|
||||
return _VSTD::move(__v.__nc);
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,
|
||||
bool = _KVTypes::__is_map>
|
||||
struct __hash_map_pointer_types {};
|
||||
|
||||
template <class _Tp, class _AllocPtr, class _KVTypes>
|
||||
struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
|
||||
typedef typename _KVTypes::__map_value_type _Mv;
|
||||
typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
|
||||
__map_value_type_pointer;
|
||||
typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
|
||||
__const_map_value_type_pointer;
|
||||
};
|
||||
|
||||
template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
|
||||
struct __hash_node_types;
|
||||
|
||||
template <class _NodePtr, class _Tp, class _VoidPtr>
|
||||
struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> >
|
||||
: public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, _VoidPtr>
|
||||
|
||||
{
|
||||
typedef __hash_key_value_types<_Tp> __base;
|
||||
|
||||
public:
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
|
||||
|
||||
typedef typename pointer_traits<_NodePtr>::element_type __node_type;
|
||||
typedef _NodePtr __node_pointer;
|
||||
|
||||
typedef __hash_node_base<__node_pointer> __node_base_type;
|
||||
typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type
|
||||
__node_base_pointer;
|
||||
|
||||
typedef _Tp __node_value_type;
|
||||
typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
|
||||
__node_value_type_pointer;
|
||||
typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
|
||||
__const_node_value_type_pointer;
|
||||
private:
|
||||
static_assert(!is_const<__node_type>::value,
|
||||
"_NodePtr should never be a pointer to const");
|
||||
static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
|
||||
"_VoidPtr does not point to unqualified void type");
|
||||
static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
|
||||
_NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class _HashIterator>
|
||||
struct __hash_node_types_from_iterator;
|
||||
template <class _NodePtr>
|
||||
struct __hash_node_types_from_iterator<__hash_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
|
||||
template <class _NodePtr>
|
||||
struct __hash_node_types_from_iterator<__hash_const_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
|
||||
template <class _NodePtr>
|
||||
struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
|
||||
template <class _NodePtr>
|
||||
struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
|
||||
|
||||
|
||||
template <class _NodeValueTp, class _VoidPtr>
|
||||
struct __make_hash_node_types {
|
||||
typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
|
||||
typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr;
|
||||
typedef __hash_node_types<_NodePtr> type;
|
||||
};
|
||||
|
||||
template <class _NodePtr>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __hash_iterator
|
||||
{
|
||||
typedef _NodePtr __node_pointer;
|
||||
typedef __hash_node_types<_NodePtr> _NodeTypes;
|
||||
typedef _NodePtr __node_pointer;
|
||||
|
||||
__node_pointer __node_;
|
||||
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type;
|
||||
typedef typename pointer_traits<__node_pointer>::difference_type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename _NodeTypes::__node_value_type value_type;
|
||||
typedef typename _NodeTypes::difference_type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef typename _NodeTypes::__node_value_type_pointer pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
@ -202,25 +376,24 @@ private:
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
|
||||
};
|
||||
|
||||
template <class _ConstNodePtr>
|
||||
template <class _NodePtr>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator
|
||||
{
|
||||
typedef _ConstNodePtr __node_pointer;
|
||||
static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, "");
|
||||
typedef __hash_node_types<_NodePtr> _NodeTypes;
|
||||
typedef _NodePtr __node_pointer;
|
||||
|
||||
__node_pointer __node_;
|
||||
|
||||
typedef typename remove_const<
|
||||
typename pointer_traits<__node_pointer>::element_type
|
||||
>::type __node;
|
||||
__node_pointer __node_;
|
||||
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename __node::value_type value_type;
|
||||
typedef typename pointer_traits<__node_pointer>::difference_type difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename __rebind_pointer<__node_pointer, const value_type>::type pointer;
|
||||
typedef typename __rebind_pointer<__node_pointer, __node>::type __non_const_node_pointer;
|
||||
typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator;
|
||||
typedef __hash_iterator<_NodePtr> __non_const_iterator;
|
||||
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename _NodeTypes::__node_value_type value_type;
|
||||
typedef typename _NodeTypes::difference_type difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
|
||||
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
@ -336,24 +509,22 @@ private:
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
|
||||
};
|
||||
|
||||
template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
|
||||
|
||||
template <class _NodePtr>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator
|
||||
{
|
||||
typedef _NodePtr __node_pointer;
|
||||
typedef __hash_node_types<_NodePtr> _NodeTypes;
|
||||
typedef _NodePtr __node_pointer;
|
||||
|
||||
__node_pointer __node_;
|
||||
size_t __bucket_;
|
||||
size_t __bucket_count_;
|
||||
|
||||
typedef pointer_traits<__node_pointer> __pointer_traits;
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename __pointer_traits::element_type::value_type value_type;
|
||||
typedef typename __pointer_traits::difference_type difference_type;
|
||||
typedef typename _NodeTypes::__node_value_type value_type;
|
||||
typedef typename _NodeTypes::difference_type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
|
||||
typedef typename _NodeTypes::__node_value_type_pointer pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT
|
||||
{
|
||||
@ -476,7 +647,8 @@ private:
|
||||
template <class _ConstNodePtr>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator
|
||||
{
|
||||
typedef _ConstNodePtr __node_pointer;
|
||||
typedef __hash_node_types<_ConstNodePtr> _NodeTypes;
|
||||
typedef _ConstNodePtr __node_pointer;
|
||||
|
||||
__node_pointer __node_;
|
||||
size_t __bucket_;
|
||||
@ -487,18 +659,15 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator
|
||||
typedef typename remove_const<__node>::type __non_const_node;
|
||||
typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
|
||||
__non_const_node_pointer;
|
||||
|
||||
public:
|
||||
typedef __hash_local_iterator<__non_const_node_pointer>
|
||||
__non_const_iterator;
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename remove_const<
|
||||
typename __pointer_traits::element_type::value_type
|
||||
>::type value_type;
|
||||
typedef typename __pointer_traits::difference_type difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename __rebind_pointer<__node_pointer, const value_type>::type
|
||||
pointer;
|
||||
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename _NodeTypes::__node_value_type value_type;
|
||||
typedef typename _NodeTypes::difference_type difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
|
||||
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT
|
||||
@ -686,10 +855,11 @@ class __hash_node_destructor
|
||||
{
|
||||
typedef _Alloc allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::value_type::value_type value_type;
|
||||
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
private:
|
||||
typedef __hash_node_types<pointer> _NodeTypes;
|
||||
|
||||
allocator_type& __na_;
|
||||
|
||||
@ -709,7 +879,7 @@ public:
|
||||
void operator()(pointer __p) _NOEXCEPT
|
||||
{
|
||||
if (__value_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_));
|
||||
__alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));
|
||||
if (__p)
|
||||
__alloc_traits::deallocate(__na_, __p, 1);
|
||||
}
|
||||
@ -728,23 +898,47 @@ public:
|
||||
|
||||
private:
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename
|
||||
__make_hash_node_types<value_type, typename __alloc_traits::void_pointer>::type
|
||||
_NodeTypes;
|
||||
public:
|
||||
|
||||
typedef typename _NodeTypes::__node_value_type __node_value_type;
|
||||
typedef typename _NodeTypes::__container_value_type __container_value_type;
|
||||
typedef typename _NodeTypes::key_type key_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
#else
|
||||
typedef typename _NodeTypes::size_type size_type;
|
||||
#endif
|
||||
typedef typename _NodeTypes::difference_type difference_type;
|
||||
public:
|
||||
// Create __node
|
||||
typedef __hash_node<value_type, typename __alloc_traits::void_pointer> __node;
|
||||
|
||||
typedef typename _NodeTypes::__node_type __node;
|
||||
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
|
||||
typedef allocator_traits<__node_allocator> __node_traits;
|
||||
typedef typename __node_traits::pointer __node_pointer;
|
||||
typedef typename __node_traits::pointer __node_const_pointer;
|
||||
typedef __hash_node_base<__node_pointer> __first_node;
|
||||
typedef typename __rebind_pointer<__node_pointer, __first_node>::type
|
||||
__node_base_pointer;
|
||||
typedef typename _NodeTypes::__void_pointer __void_pointer;
|
||||
typedef typename _NodeTypes::__node_pointer __node_pointer;
|
||||
typedef typename _NodeTypes::__node_pointer __node_const_pointer;
|
||||
typedef typename _NodeTypes::__node_base_type __first_node;
|
||||
typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
|
||||
|
||||
private:
|
||||
// check for sane allocator pointer rebinding semantics. Rebinding the
|
||||
// allocator for a new pointer type should be exactly the same as rebinding
|
||||
// the pointer using 'pointer_traits'.
|
||||
static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
|
||||
"Allocator does not rebind pointers in a sane manner.");
|
||||
typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type
|
||||
__node_base_allocator;
|
||||
typedef allocator_traits<__node_base_allocator> __node_base_traits;
|
||||
static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
|
||||
"Allocator does not rebind pointers in a sane manner.");
|
||||
|
||||
private:
|
||||
|
||||
@ -755,10 +949,10 @@ private:
|
||||
typedef typename __bucket_list_deleter::pointer __node_pointer_pointer;
|
||||
|
||||
// --- Member data begin ---
|
||||
__bucket_list __bucket_list_;
|
||||
__compressed_pair<__first_node, __node_allocator> __p1_;
|
||||
__compressed_pair<size_type, hasher> __p2_;
|
||||
__compressed_pair<float, key_equal> __p3_;
|
||||
__bucket_list __bucket_list_;
|
||||
__compressed_pair<__first_node, __node_allocator> __p1_;
|
||||
__compressed_pair<size_type, hasher> __p2_;
|
||||
__compressed_pair<float, key_equal> __p3_;
|
||||
// --- Member data end ---
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -809,7 +1003,7 @@ public:
|
||||
explicit __hash_table(const allocator_type& __a);
|
||||
__hash_table(const __hash_table& __u);
|
||||
__hash_table(const __hash_table& __u, const allocator_type& __a);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__hash_table(__hash_table&& __u)
|
||||
_NOEXCEPT_(
|
||||
is_nothrow_move_constructible<__bucket_list>::value &&
|
||||
@ -818,11 +1012,11 @@ public:
|
||||
is_nothrow_move_constructible<hasher>::value &&
|
||||
is_nothrow_move_constructible<key_equal>::value);
|
||||
__hash_table(__hash_table&& __u, const allocator_type& __a);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
~__hash_table();
|
||||
|
||||
__hash_table& operator=(const __hash_table& __u);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_table& operator=(__hash_table&& __u)
|
||||
_NOEXCEPT_(
|
||||
@ -848,41 +1042,103 @@ public:
|
||||
iterator __node_insert_multi(const_iterator __p,
|
||||
__node_pointer __nd);
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
template <class... _Args>
|
||||
pair<iterator, bool> __emplace_unique(_Args&&... __args);
|
||||
template <class... _Args>
|
||||
iterator __emplace_multi(_Args&&... __args);
|
||||
template <class... _Args>
|
||||
iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Key, class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _ValueTp>
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> __insert_unique_value(_ValueTp&& __x);
|
||||
#else
|
||||
pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);
|
||||
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> __insert_unique_value(const value_type& __x);
|
||||
pair<iterator, bool> __emplace_unique(_Pp&& __x) {
|
||||
return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
|
||||
__can_extract_key<_Pp, key_type>());
|
||||
}
|
||||
|
||||
template <class _First, class _Second>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<
|
||||
__can_extract_map_key<_First, key_type, __container_value_type>::value,
|
||||
pair<iterator, bool>
|
||||
>::type __emplace_unique(_First&& __f, _Second&& __s) {
|
||||
return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
|
||||
_VSTD::forward<_Second>(__s));
|
||||
}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> __emplace_unique(_Args&&... __args) {
|
||||
return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool>
|
||||
__emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {
|
||||
return __emplace_unique_impl(_VSTD::forward<_Pp>(__x));
|
||||
}
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool>
|
||||
__emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {
|
||||
return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x));
|
||||
}
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool>
|
||||
__emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {
|
||||
return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x));
|
||||
}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator __emplace_multi(_Args&&... __args);
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
|
||||
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool>
|
||||
__insert_unique(__container_value_type&& __x) {
|
||||
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));
|
||||
}
|
||||
|
||||
template <class _Pp, class = typename enable_if<
|
||||
!__is_same_uncvref<_Pp, __container_value_type>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> __insert_unique(_Pp&& __x) {
|
||||
return __emplace_unique(_VSTD::forward<_Pp>(__x));
|
||||
}
|
||||
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator __insert_multi(_Pp&& __x) {
|
||||
return __emplace_multi(_VSTD::forward<_Pp>(__x));
|
||||
}
|
||||
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator __insert_multi(const_iterator __p, _Pp&& __x) {
|
||||
return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));
|
||||
}
|
||||
|
||||
#else // !defined(_LIBCPP_CXX03_LANG)
|
||||
template <class _Key, class _Args>
|
||||
pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
|
||||
|
||||
iterator __insert_multi(const __container_value_type& __x);
|
||||
iterator __insert_multi(const_iterator __p, const __container_value_type& __x);
|
||||
#endif
|
||||
|
||||
pair<iterator, bool> __insert_unique(const value_type& __x);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
pair<iterator, bool> __insert_unique(value_type&& __x);
|
||||
template <class _Pp>
|
||||
pair<iterator, bool> __insert_unique(_Pp&& __x);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Pp>
|
||||
iterator __insert_multi(_Pp&& __x);
|
||||
template <class _Pp>
|
||||
iterator __insert_multi(const_iterator __p, _Pp&& __x);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
iterator __insert_multi(const value_type& __x);
|
||||
iterator __insert_multi(const_iterator __p, const value_type& __x);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> __insert_unique(const __container_value_type& __x) {
|
||||
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
|
||||
}
|
||||
|
||||
void clear() _NOEXCEPT;
|
||||
void rehash(size_type __n);
|
||||
@ -1042,16 +1298,17 @@ public:
|
||||
private:
|
||||
void __rehash(size_type __n);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class ..._Args>
|
||||
__node_holder __construct_node(_Args&& ...__args);
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
__node_holder __construct_node(value_type&& __v, size_t __hash);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node(const value_type& __v);
|
||||
__node_holder __construct_node(_Args&& ...__args);
|
||||
|
||||
template <class _First, class ..._Rest>
|
||||
__node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
__node_holder __construct_node(const __container_value_type& __v);
|
||||
__node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v);
|
||||
#endif
|
||||
__node_holder __construct_node(const value_type& __v, size_t __hash);
|
||||
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __copy_assign_alloc(const __hash_table& __u)
|
||||
@ -1061,6 +1318,7 @@ private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __copy_assign_alloc(const __hash_table&, false_type) {}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
void __move_assign(__hash_table& __u, false_type);
|
||||
void __move_assign(__hash_table& __u, true_type)
|
||||
_NOEXCEPT_(
|
||||
@ -1087,6 +1345,7 @@ private:
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
void __deallocate(__node_pointer __np) _NOEXCEPT;
|
||||
__node_pointer __detach() _NOEXCEPT;
|
||||
@ -1163,7 +1422,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
|
||||
@ -1212,11 +1471,15 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
|
||||
{
|
||||
static_assert((is_copy_constructible<key_equal>::value),
|
||||
"Predicate must be copy-constructible.");
|
||||
static_assert((is_copy_constructible<hasher>::value),
|
||||
"Hasher must be copy-constructible.");
|
||||
__deallocate(__p1_.first().__next_);
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__erase_c(this);
|
||||
@ -1277,7 +1540,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np)
|
||||
}
|
||||
__get_db()->unlock();
|
||||
#endif
|
||||
__node_traits::destroy(__na, _VSTD::addressof(__np->__value_));
|
||||
__node_traits::destroy(__na, _NodeTypes::__get_ptr(__np->__value_));
|
||||
__node_traits::deallocate(__na, __np, 1);
|
||||
__np = __next;
|
||||
}
|
||||
@ -1296,7 +1559,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
|
||||
return __cache;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
void
|
||||
@ -1369,8 +1632,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
|
||||
const_iterator __i = __u.begin();
|
||||
while (__u.size() != 0)
|
||||
{
|
||||
__node_holder __h =
|
||||
__construct_node(_VSTD::move(__u.remove(__i++)->__value_));
|
||||
__node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_));
|
||||
__node_insert_multi(__h.get());
|
||||
__h.release();
|
||||
}
|
||||
@ -1392,7 +1654,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
@ -1400,6 +1662,11 @@ void
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
typedef iterator_traits<_InputIterator> _ITraits;
|
||||
typedef typename _ITraits::value_type _ItValueType;
|
||||
static_assert((is_same<_ItValueType, __container_value_type>::value),
|
||||
"__assign_unique may only be called with the containers value type");
|
||||
|
||||
if (bucket_count() != 0)
|
||||
{
|
||||
__node_pointer __cache = __detach();
|
||||
@ -1434,6 +1701,12 @@ void
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
typedef iterator_traits<_InputIterator> _ITraits;
|
||||
typedef typename _ITraits::value_type _ItValueType;
|
||||
static_assert((is_same<_ItValueType, __container_value_type>::value ||
|
||||
is_same<_ItValueType, __node_value_type>::value),
|
||||
"__assign_multi may only be called with the containers value type"
|
||||
" or the nodes value type");
|
||||
if (bucket_count() != 0)
|
||||
{
|
||||
__node_pointer __cache = __detach();
|
||||
@ -1459,7 +1732,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
|
||||
__deallocate(__cache);
|
||||
}
|
||||
for (; __first != __last; ++__first)
|
||||
__insert_multi(*__first);
|
||||
__insert_multi(_NodeTypes::__get_value(*__first));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
@ -1685,31 +1958,24 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
|
||||
return __node_insert_multi(__cp);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
|
||||
{
|
||||
return __insert_unique_value(__x);
|
||||
}
|
||||
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _ValueTp>
|
||||
template <class _Key, class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(_ValueTp&& __x)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
|
||||
#else
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _Key, class _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(const value_type& __x)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
|
||||
#endif
|
||||
{
|
||||
#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
|
||||
typedef const value_type& _ValueTp;
|
||||
#endif
|
||||
size_t __hash = hash_function()(__x);
|
||||
|
||||
size_t __hash = hash_function()(__k);
|
||||
size_type __bc = bucket_count();
|
||||
bool __inserted = false;
|
||||
__node_pointer __nd;
|
||||
@ -1724,13 +1990,17 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(const value_type
|
||||
__constrain_hash(__nd->__hash_, __bc) == __chash;
|
||||
__nd = __nd->__next_)
|
||||
{
|
||||
if (key_eq()(__nd->__value_, __x))
|
||||
if (key_eq()(__nd->__value_, __k))
|
||||
goto __done;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_ValueTp>(__x), __hash);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
|
||||
#else
|
||||
__node_holder __h = __construct_node_hash(__hash, __args);
|
||||
#endif
|
||||
if (size()+1 > __bc * max_load_factor() || __bc == 0)
|
||||
{
|
||||
rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
|
||||
@ -1742,7 +2012,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(const value_type
|
||||
__node_pointer __pn = __bucket_list_[__chash];
|
||||
if (__pn == nullptr)
|
||||
{
|
||||
__pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
__pn = static_cast<__node_pointer>(static_cast<__void_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())));
|
||||
__h->__next_ = __pn->__next_;
|
||||
__pn->__next_ = __h.get();
|
||||
// fix up __bucket_list_
|
||||
@ -1768,13 +2038,12 @@ __done:
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class... _Args>
|
||||
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique(_Args&&... __args)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
pair<iterator, bool> __r = __node_insert_unique(__h.get());
|
||||
@ -1811,64 +2080,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
|
||||
return __r;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(value_type&& __x)
|
||||
{
|
||||
return __insert_unique_value(_VSTD::move(__x));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _Pp>
|
||||
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(_Pp&& __x)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
|
||||
pair<iterator, bool> __r = __node_insert_unique(__h.get());
|
||||
if (__r.second)
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _Pp>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(_Pp&& __x)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
|
||||
iterator __r = __node_insert_multi(__h.get());
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _Pp>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
|
||||
_Pp&& __x)
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||
"unordered container::insert(const_iterator, rvalue) called with an iterator not"
|
||||
" referring to this unordered container");
|
||||
#endif
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
|
||||
iterator __r = __node_insert_multi(__p, __h.get());
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const value_type& __x)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x)
|
||||
{
|
||||
__node_holder __h = __construct_node(__x);
|
||||
iterator __r = __node_insert_multi(__h.get());
|
||||
@ -1879,7 +2095,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const value_type& __x)
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
|
||||
const value_type& __x)
|
||||
const __container_value_type& __x)
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||
@ -1892,7 +2108,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
|
||||
return __r;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
void
|
||||
@ -1986,10 +2202,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
|
||||
if (__nd != nullptr)
|
||||
{
|
||||
for (__nd = __nd->__next_; __nd != nullptr &&
|
||||
__constrain_hash(__nd->__hash_, __bc) == __chash;
|
||||
(__nd->__hash_ == __hash
|
||||
|| __constrain_hash(__nd->__hash_, __bc) == __chash);
|
||||
__nd = __nd->__next_)
|
||||
{
|
||||
if (key_eq()(__nd->__value_, __k))
|
||||
if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(__nd, this);
|
||||
#else
|
||||
@ -2015,10 +2232,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
|
||||
if (__nd != nullptr)
|
||||
{
|
||||
for (__nd = __nd->__next_; __nd != nullptr &&
|
||||
__constrain_hash(__nd->__hash_, __bc) == __chash;
|
||||
(__hash == __nd->__hash_ || __constrain_hash(__nd->__hash_, __bc) == __chash);
|
||||
__nd = __nd->__next_)
|
||||
{
|
||||
if (key_eq()(__nd->__value_, __k))
|
||||
if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return const_iterator(__nd, this);
|
||||
#else
|
||||
@ -2031,70 +2248,74 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
|
||||
return end();
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class ..._Args>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args)
|
||||
{
|
||||
static_assert(!__is_hash_value_type<_Args...>::value,
|
||||
"Construct cannot be called with a hash value type");
|
||||
__node_allocator& __na = __node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__h.get_deleter().__value_constructed = true;
|
||||
__h->__hash_ = hash_function()(__h->__value_);
|
||||
__h->__next_ = nullptr;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
template <class _First, class ..._Rest>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v,
|
||||
size_t __hash)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(
|
||||
size_t __hash, _First&& __f, _Rest&& ...__rest)
|
||||
{
|
||||
static_assert(!__is_hash_value_type<_First, _Rest...>::value,
|
||||
"Construct cannot be called with a hash value type");
|
||||
__node_allocator& __na = __node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::move(__v));
|
||||
__node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_),
|
||||
_VSTD::forward<_First>(__f),
|
||||
_VSTD::forward<_Rest>(__rest)...);
|
||||
__h.get_deleter().__value_constructed = true;
|
||||
__h->__hash_ = __hash;
|
||||
__h->__next_ = nullptr;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v)
|
||||
{
|
||||
__node_allocator& __na = __node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
|
||||
__node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
|
||||
__h.get_deleter().__value_constructed = true;
|
||||
__h->__hash_ = hash_function()(__h->__value_);
|
||||
__h->__next_ = nullptr;
|
||||
return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v,
|
||||
size_t __hash)
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash,
|
||||
const __container_value_type& __v)
|
||||
{
|
||||
__node_allocator& __na = __node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
|
||||
__node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
|
||||
__h.get_deleter().__value_constructed = true;
|
||||
__h->__hash_ = __hash;
|
||||
__h->__next_ = nullptr;
|
||||
return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
|
||||
|
@ -14,9 +14,7 @@
|
||||
#include <__config>
|
||||
#include <chrono>
|
||||
#include <system_error>
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <__threading_support>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -26,29 +24,41 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
class _LIBCPP_TYPE_VIS mutex
|
||||
#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
|
||||
# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
|
||||
# else
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
|
||||
# endif
|
||||
#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
|
||||
|
||||
class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
|
||||
{
|
||||
pthread_mutex_t __m_;
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
|
||||
#else
|
||||
__libcpp_mutex_t __m_;
|
||||
#endif
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
|
||||
constexpr mutex() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
#else
|
||||
mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
|
||||
mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
|
||||
#endif
|
||||
~mutex();
|
||||
~mutex();
|
||||
|
||||
private:
|
||||
mutex(const mutex&);// = delete;
|
||||
mutex& operator=(const mutex&);// = delete;
|
||||
|
||||
public:
|
||||
void lock();
|
||||
bool try_lock() _NOEXCEPT;
|
||||
void unlock() _NOEXCEPT;
|
||||
void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
|
||||
bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
|
||||
void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
|
||||
|
||||
typedef pthread_mutex_t* native_handle_type;
|
||||
typedef __libcpp_mutex_t* native_handle_type;
|
||||
_LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
|
||||
};
|
||||
|
||||
@ -70,8 +80,21 @@ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Forward declare lock_guard as a variadic template even in C++03 to keep
|
||||
// the mangling consistent between dialects.
|
||||
#if defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
|
||||
template <class ..._Mutexes>
|
||||
class _LIBCPP_TYPE_VIS_ONLY lock_guard;
|
||||
#endif
|
||||
|
||||
template <class _Mutex>
|
||||
class _LIBCPP_TYPE_VIS_ONLY lock_guard
|
||||
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
|
||||
#if !defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
|
||||
lock_guard
|
||||
#else
|
||||
lock_guard<_Mutex>
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
typedef _Mutex mutex_type;
|
||||
@ -81,17 +104,17 @@ private:
|
||||
public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit lock_guard(mutex_type& __m)
|
||||
explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
|
||||
: __m_(__m) {__m_.lock();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
lock_guard(mutex_type& __m, adopt_lock_t)
|
||||
lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
|
||||
: __m_(__m) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~lock_guard() {__m_.unlock();}
|
||||
~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
|
||||
|
||||
private:
|
||||
lock_guard(lock_guard const&);// = delete;
|
||||
lock_guard& operator=(lock_guard const&);// = delete;
|
||||
lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE;
|
||||
lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE;
|
||||
};
|
||||
|
||||
template <class _Mutex>
|
||||
@ -109,24 +132,24 @@ public:
|
||||
unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit unique_lock(mutex_type& __m)
|
||||
: __m_(&__m), __owns_(true) {__m_->lock();}
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
|
||||
: __m_(&__m), __owns_(false) {}
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(false) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, try_to_lock_t)
|
||||
: __m_(&__m), __owns_(__m.try_lock()) {}
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, adopt_lock_t)
|
||||
: __m_(&__m), __owns_(true) {}
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(true) {}
|
||||
template <class _Clock, class _Duration>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
|
||||
: __m_(&__m), __owns_(__m.try_lock_until(__t)) {}
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
|
||||
template <class _Rep, class _Period>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
|
||||
: __m_(&__m), __owns_(__m.try_lock_for(__d)) {}
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~unique_lock()
|
||||
{
|
||||
@ -268,13 +291,18 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable
|
||||
{
|
||||
pthread_cond_t __cv_;
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
|
||||
#else
|
||||
__libcpp_condvar_t __cv_;
|
||||
#endif
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {}
|
||||
constexpr condition_variable() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
#else
|
||||
condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
|
||||
condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
|
||||
#endif
|
||||
~condition_variable();
|
||||
|
||||
@ -313,7 +341,7 @@ public:
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred);
|
||||
|
||||
typedef pthread_cond_t* native_handle_type;
|
||||
typedef __libcpp_condvar_t* native_handle_type;
|
||||
_LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;}
|
||||
|
||||
private:
|
||||
|
205
contrib/libc++/include/__threading_support
Normal file
205
contrib/libc++/include/__threading_support
Normal file
@ -0,0 +1,205 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_THREADING_SUPPORT
|
||||
#define _LIBCPP_THREADING_SUPPORT
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
|
||||
// Mutex
|
||||
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
typedef pthread_mutex_t __libcpp_mutex_t;
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int __ec = pthread_mutexattr_init(&attr);
|
||||
if (__ec) return __ec;
|
||||
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (__ec)
|
||||
{
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return __ec;
|
||||
}
|
||||
__ec = pthread_mutex_init(__m, &attr);
|
||||
if (__ec)
|
||||
{
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return __ec;
|
||||
}
|
||||
__ec = pthread_mutexattr_destroy(&attr);
|
||||
if (__ec)
|
||||
{
|
||||
pthread_mutex_destroy(__m);
|
||||
return __ec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
|
||||
{
|
||||
return pthread_mutex_lock(__m);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
|
||||
{
|
||||
return pthread_mutex_trylock(__m);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
|
||||
{
|
||||
return pthread_mutex_unlock(__m);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t* __m)
|
||||
{
|
||||
return pthread_mutex_destroy(__m);
|
||||
}
|
||||
|
||||
// Condition variable
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
|
||||
typedef pthread_cond_t __libcpp_condvar_t;
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
|
||||
{
|
||||
return pthread_cond_signal(__cv);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
|
||||
{
|
||||
return pthread_cond_broadcast(__cv);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
|
||||
{
|
||||
return pthread_cond_wait(__cv, __m);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts)
|
||||
{
|
||||
return pthread_cond_timedwait(__cv, __m, __ts);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
|
||||
{
|
||||
return pthread_cond_destroy(__cv);
|
||||
}
|
||||
|
||||
// Thread id
|
||||
typedef pthread_t __libcpp_thread_id;
|
||||
|
||||
// Returns non-zero if the thread ids are equal, otherwise 0
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return pthread_equal(t1, t2) != 0;
|
||||
}
|
||||
|
||||
// Returns non-zero if t1 < t2, otherwise 0
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return t1 < t2;
|
||||
}
|
||||
|
||||
// Thread
|
||||
typedef pthread_t __libcpp_thread_t;
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg)
|
||||
{
|
||||
return pthread_create(__t, 0, __func, __arg);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id()
|
||||
{
|
||||
return pthread_self();
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
|
||||
{
|
||||
return *__t;
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_thread_join(__libcpp_thread_t* __t)
|
||||
{
|
||||
return pthread_join(*__t, 0);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_thread_detach(__libcpp_thread_t* __t)
|
||||
{
|
||||
return pthread_detach(*__t);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
void __libcpp_thread_yield()
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
// Thread local storage
|
||||
typedef pthread_key_t __libcpp_tl_key;
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit)(void*))
|
||||
{
|
||||
return pthread_key_create(__key, __at_exit);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
void* __libcpp_tl_get(__libcpp_tl_key __key)
|
||||
{
|
||||
return pthread_getspecific(__key);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
void __libcpp_tl_set(__libcpp_tl_key __key, void* __p)
|
||||
{
|
||||
pthread_setspecific(__key, __p);
|
||||
}
|
||||
|
||||
#else // !_LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
#error "No thread API selected."
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_THREADING_SUPPORT
|
File diff suppressed because it is too large
Load Diff
@ -68,6 +68,80 @@ template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_li
|
||||
// tuple specializations
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
|
||||
template <size_t...> struct __tuple_indices {};
|
||||
|
||||
template <class _IdxType, _IdxType... _Values>
|
||||
struct __integer_sequence {
|
||||
template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
|
||||
using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
|
||||
|
||||
template <size_t _Sp>
|
||||
using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
|
||||
};
|
||||
|
||||
#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
|
||||
namespace __detail {
|
||||
|
||||
template<typename _Tp, size_t ..._Extra> struct __repeat;
|
||||
template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
|
||||
typedef __integer_sequence<_Tp,
|
||||
_Np...,
|
||||
sizeof...(_Np) + _Np...,
|
||||
2 * sizeof...(_Np) + _Np...,
|
||||
3 * sizeof...(_Np) + _Np...,
|
||||
4 * sizeof...(_Np) + _Np...,
|
||||
5 * sizeof...(_Np) + _Np...,
|
||||
6 * sizeof...(_Np) + _Np...,
|
||||
7 * sizeof...(_Np) + _Np...,
|
||||
_Extra...> type;
|
||||
};
|
||||
|
||||
template<size_t _Np> struct __parity;
|
||||
template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
|
||||
|
||||
template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
|
||||
template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
|
||||
template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
|
||||
template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
|
||||
template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
|
||||
template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
|
||||
template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
|
||||
template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
|
||||
|
||||
template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
|
||||
template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
|
||||
template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
|
||||
|
||||
#if __has_builtin(__make_integer_seq)
|
||||
template <size_t _Ep, size_t _Sp>
|
||||
using __make_indices_imp =
|
||||
typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
|
||||
__to_tuple_indices<_Sp>;
|
||||
#else
|
||||
template <size_t _Ep, size_t _Sp>
|
||||
using __make_indices_imp =
|
||||
typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
|
||||
|
||||
#endif
|
||||
|
||||
template <size_t _Ep, size_t _Sp = 0>
|
||||
struct __make_tuple_indices
|
||||
{
|
||||
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
|
||||
typedef __make_indices_imp<_Ep, _Sp> type;
|
||||
};
|
||||
|
||||
|
||||
template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
|
||||
|
||||
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
|
||||
@ -95,8 +169,6 @@ get(const tuple<_Tp...>&&) _NOEXCEPT;
|
||||
|
||||
// pair specializations
|
||||
|
||||
template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
|
||||
|
||||
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
|
||||
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
@ -151,57 +223,48 @@ get(const array<_Tp, _Size>&&) _NOEXCEPT;
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
|
||||
// __make_tuple_indices
|
||||
|
||||
template <size_t...> struct __tuple_indices {};
|
||||
|
||||
template <size_t _Sp, class _IntTuple, size_t _Ep>
|
||||
struct __make_indices_imp;
|
||||
|
||||
template <size_t _Sp, size_t ..._Indices, size_t _Ep>
|
||||
struct __make_indices_imp<_Sp, __tuple_indices<_Indices...>, _Ep>
|
||||
{
|
||||
typedef typename __make_indices_imp<_Sp+1, __tuple_indices<_Indices..., _Sp>, _Ep>::type type;
|
||||
};
|
||||
|
||||
template <size_t _Ep, size_t ..._Indices>
|
||||
struct __make_indices_imp<_Ep, __tuple_indices<_Indices...>, _Ep>
|
||||
{
|
||||
typedef __tuple_indices<_Indices...> type;
|
||||
};
|
||||
|
||||
template <size_t _Ep, size_t _Sp = 0>
|
||||
struct __make_tuple_indices
|
||||
{
|
||||
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
|
||||
typedef typename __make_indices_imp<_Sp, __tuple_indices<>, _Ep>::type type;
|
||||
};
|
||||
|
||||
// __tuple_types
|
||||
|
||||
template <class ..._Tp> struct __tuple_types {};
|
||||
|
||||
template <size_t _Ip>
|
||||
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<> >
|
||||
#if !__has_builtin(__type_pack_element)
|
||||
|
||||
namespace __indexer_detail {
|
||||
|
||||
template <size_t _Idx, class _Tp>
|
||||
struct __indexed { using type = _Tp; };
|
||||
|
||||
template <class _Types, class _Indexes> struct __indexer;
|
||||
|
||||
template <class ..._Types, size_t ..._Idx>
|
||||
struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
|
||||
: __indexed<_Idx, _Types>...
|
||||
{};
|
||||
|
||||
template <size_t _Idx, class _Tp>
|
||||
__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
|
||||
|
||||
} // namespace __indexer_detail
|
||||
|
||||
template <size_t _Idx, class ..._Types>
|
||||
using __type_pack_element = typename decltype(
|
||||
__indexer_detail::__at_index<_Idx>(
|
||||
__indexer_detail::__indexer<
|
||||
__tuple_types<_Types...>,
|
||||
typename __make_tuple_indices<sizeof...(_Types)>::type
|
||||
>{})
|
||||
)::type;
|
||||
#endif
|
||||
|
||||
template <size_t _Ip, class ..._Types>
|
||||
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Types...>>
|
||||
{
|
||||
public:
|
||||
static_assert(_Ip == 0, "tuple_element index out of range");
|
||||
static_assert(_Ip != 0, "tuple_element index out of range");
|
||||
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
|
||||
typedef __type_pack_element<_Ip, _Types...> type;
|
||||
};
|
||||
|
||||
template <class _Hp, class ..._Tp>
|
||||
class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, __tuple_types<_Hp, _Tp...> >
|
||||
{
|
||||
public:
|
||||
typedef _Hp type;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Hp, class ..._Tp>
|
||||
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Hp, _Tp...> >
|
||||
{
|
||||
public:
|
||||
typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...> >::type type;
|
||||
};
|
||||
|
||||
template <class ..._Tp>
|
||||
class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> >
|
||||
@ -211,6 +274,46 @@ class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> >
|
||||
|
||||
template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
|
||||
|
||||
template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
|
||||
struct __apply_cv_mf;
|
||||
template <>
|
||||
struct __apply_cv_mf<false, false, false> {
|
||||
template <class _Tp> using __apply = _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<false, true, false> {
|
||||
template <class _Tp> using __apply = const _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<false, false, true> {
|
||||
template <class _Tp> using __apply = volatile _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<false, true, true> {
|
||||
template <class _Tp> using __apply = const volatile _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, false, false> {
|
||||
template <class _Tp> using __apply = _Tp&;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, true, false> {
|
||||
template <class _Tp> using __apply = const _Tp&;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, false, true> {
|
||||
template <class _Tp> using __apply = volatile _Tp&;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, true, true> {
|
||||
template <class _Tp> using __apply = const volatile _Tp&;
|
||||
};
|
||||
template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
|
||||
using __apply_cv_t = __apply_cv_mf<
|
||||
is_lvalue_reference<_Tp>::value,
|
||||
is_const<_RawTp>::value,
|
||||
is_volatile<_RawTp>::value>;
|
||||
|
||||
// __make_tuple_types
|
||||
|
||||
// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
|
||||
@ -218,59 +321,73 @@ template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type
|
||||
// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
|
||||
// lvalue_reference type, then __tuple_types<_Types&...> is the result.
|
||||
|
||||
template <class _TupleTypes, class _Tp, size_t _Sp, size_t _Ep>
|
||||
struct __make_tuple_types_imp;
|
||||
template <class _TupleTypes, class _TupleIndices>
|
||||
struct __make_tuple_types_flat;
|
||||
|
||||
template <class ..._Types, class _Tp, size_t _Sp, size_t _Ep>
|
||||
struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Sp, _Ep>
|
||||
{
|
||||
typedef typename remove_reference<_Tp>::type _Tpr;
|
||||
typedef typename __make_tuple_types_imp<__tuple_types<_Types...,
|
||||
typename conditional<is_lvalue_reference<_Tp>::value,
|
||||
typename tuple_element<_Sp, _Tpr>::type&,
|
||||
typename tuple_element<_Sp, _Tpr>::type>::type>,
|
||||
_Tp, _Sp+1, _Ep>::type type;
|
||||
template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
|
||||
struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
|
||||
// Specialization for pair, tuple, and __tuple_types
|
||||
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
|
||||
using __apply_quals = __tuple_types<
|
||||
typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
|
||||
>;
|
||||
};
|
||||
|
||||
template <class ..._Types, class _Tp, size_t _Ep>
|
||||
struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Ep, _Ep>
|
||||
{
|
||||
typedef __tuple_types<_Types...> type;
|
||||
template <class _Vt, size_t _Np, size_t ..._Idx>
|
||||
struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
|
||||
template <size_t>
|
||||
using __value_type = _Vt;
|
||||
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
|
||||
using __apply_quals = __tuple_types<
|
||||
typename _ApplyFn::template __apply<__value_type<_Idx>>...
|
||||
>;
|
||||
};
|
||||
|
||||
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value, size_t _Sp = 0>
|
||||
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
|
||||
size_t _Sp = 0,
|
||||
bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
|
||||
struct __make_tuple_types
|
||||
{
|
||||
static_assert(_Sp <= _Ep, "__make_tuple_types input error");
|
||||
typedef typename __make_tuple_types_imp<__tuple_types<>, _Tp, _Sp, _Ep>::type type;
|
||||
using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
|
||||
using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
|
||||
using type = typename _Maker::template __apply_quals<_Tp>;
|
||||
};
|
||||
|
||||
template <class ..._Types, size_t _Ep>
|
||||
struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
|
||||
typedef __tuple_types<_Types...> type;
|
||||
};
|
||||
|
||||
template <class ..._Types, size_t _Ep>
|
||||
struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
|
||||
typedef __tuple_types<_Types...> type;
|
||||
};
|
||||
|
||||
template <bool ..._Preds>
|
||||
struct __all_dummy;
|
||||
|
||||
template <bool ..._Pred>
|
||||
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<(_Pred, true)...>>;
|
||||
|
||||
struct __tuple_sfinae_base {
|
||||
template <template <class, class...> class _Trait,
|
||||
class ..._LArgs, class ..._RArgs>
|
||||
static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
|
||||
-> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
|
||||
template <template <class...> class>
|
||||
static auto __do_test(...) -> false_type;
|
||||
|
||||
template <class _FromArgs, class _ToArgs>
|
||||
using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
|
||||
template <class _FromArgs, class _ToArgs>
|
||||
using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
|
||||
template <class _FromArgs, class _ToArgs>
|
||||
using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
|
||||
};
|
||||
|
||||
// __tuple_convertible
|
||||
|
||||
template <class, class>
|
||||
struct __tuple_convertible_imp : public false_type {};
|
||||
|
||||
template <class _Tp0, class ..._Tp, class _Up0, class ..._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<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
|
||||
template <>
|
||||
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
|
||||
@ -278,36 +395,14 @@ struct __tuple_convertible
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_convertible<_Tp, _Up, true, true>
|
||||
: public __tuple_convertible_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value, _Tp, _Up>
|
||||
{};
|
||||
|
||||
// __tuple_constructible
|
||||
|
||||
template <class, class>
|
||||
struct __tuple_constructible_imp : public false_type {};
|
||||
|
||||
template <class _Tp0, class ..._Tp, class _Up0, class ..._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<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
|
||||
template <>
|
||||
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<
|
||||
: public __tuple_sfinae_base::__convertible<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
// __tuple_constructible
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_constructible
|
||||
@ -315,36 +410,14 @@ struct __tuple_constructible
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_constructible<_Tp, _Up, true, true>
|
||||
: public __tuple_constructible_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value, _Tp, _Up>
|
||||
{};
|
||||
|
||||
// __tuple_assignable
|
||||
|
||||
template <class, class>
|
||||
struct __tuple_assignable_imp : public false_type {};
|
||||
|
||||
template <class _Tp0, class ..._Tp, class _Up0, class ..._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<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
|
||||
|
||||
template <>
|
||||
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<
|
||||
: public __tuple_sfinae_base::__constructible<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
// __tuple_assignable
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_assignable
|
||||
@ -352,8 +425,10 @@ struct __tuple_assignable
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_assignable<_Tp, _Up, true, true>
|
||||
: public __tuple_assignable_apply<tuple_size<typename remove_reference<_Tp>::type>::value ==
|
||||
tuple_size<_Up>::value, _Tp, _Up>
|
||||
: public __tuple_sfinae_base::__assignable<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up&>::type
|
||||
>
|
||||
{};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
@ -9,10 +9,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifdef __deallocate
|
||||
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
_LIBCPP_WARNING("macro __deallocate is incompatible with C++. #undefining __deallocate")
|
||||
#else
|
||||
#warning: macro __deallocate is incompatible with C++. #undefining __deallocate
|
||||
#endif
|
||||
#endif
|
||||
#undef __deallocate
|
||||
#endif
|
||||
|
@ -9,21 +9,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifdef min
|
||||
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
||||
#if defined(_MSC_VER) && ! defined(__clang__)
|
||||
_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
|
||||
"before any Windows header. #undefing min")
|
||||
#else
|
||||
#warning: macro min is incompatible with C++. #undefing min
|
||||
#endif
|
||||
#endif
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#ifdef max
|
||||
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
||||
#if defined(_MSC_VER) && ! defined(__clang__)
|
||||
_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
|
||||
"before any Windows header. #undefing max")
|
||||
#else
|
||||
#warning: macro max is incompatible with C++. #undefing max
|
||||
#endif
|
||||
#endif
|
||||
#undef max
|
||||
#endif
|
||||
|
@ -543,6 +543,12 @@ template<class T, class Compare>
|
||||
T
|
||||
min(initializer_list<T> t, Compare comp); // constexpr in C++14
|
||||
|
||||
template<class T>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi ); // C++17
|
||||
|
||||
template<class T, class Compare>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp ); // C++17
|
||||
|
||||
template <class ForwardIterator>
|
||||
ForwardIterator
|
||||
max_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
|
||||
@ -624,7 +630,7 @@ template <class BidirectionalIterator, class Compare>
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <utility> // needed to provide swap_ranges.
|
||||
#include <memory>
|
||||
#include <iterator>
|
||||
#include <cstddef>
|
||||
@ -1415,20 +1421,20 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
// search
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
_ForwardIterator1
|
||||
pair<_ForwardIterator1, _ForwardIterator1>
|
||||
__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
|
||||
forward_iterator_tag, forward_iterator_tag)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
return __first1; // Everything matches an empty sequence
|
||||
return make_pair(__first1, __first1); // Everything matches an empty sequence
|
||||
while (true)
|
||||
{
|
||||
// Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
|
||||
while (true)
|
||||
{
|
||||
if (__first1 == __last1) // return __last1 if no element matches *__first2
|
||||
return __last1;
|
||||
return make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
@ -1439,9 +1445,9 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
while (true)
|
||||
{
|
||||
if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
|
||||
return __first1;
|
||||
return make_pair(__first1, __m1);
|
||||
if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
|
||||
return __last1;
|
||||
return make_pair(__last1, __last1);
|
||||
if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
|
||||
{
|
||||
++__first1;
|
||||
@ -1452,20 +1458,21 @@ __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_RandomAccessIterator1, _RandomAccessIterator1>
|
||||
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag)
|
||||
{
|
||||
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type _D1;
|
||||
typedef typename std::iterator_traits<_RandomAccessIterator2>::difference_type _D2;
|
||||
typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
|
||||
typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
|
||||
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
|
||||
_D2 __len2 = __last2 - __first2;
|
||||
const _D2 __len2 = __last2 - __first2;
|
||||
if (__len2 == 0)
|
||||
return __first1;
|
||||
_D1 __len1 = __last1 - __first1;
|
||||
return make_pair(__first1, __first1);
|
||||
const _D1 __len1 = __last1 - __first1;
|
||||
if (__len1 < __len2)
|
||||
return __last1;
|
||||
return make_pair(__last1, __last1);
|
||||
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
|
||||
while (true)
|
||||
{
|
||||
@ -1473,7 +1480,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
while (true)
|
||||
{
|
||||
if (__first1 == __s)
|
||||
return __last1;
|
||||
return make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
@ -1505,7 +1512,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
case 0:
|
||||
return __last1;
|
||||
return make_pair(__last1, __last1);
|
||||
}
|
||||
__phase2:
|
||||
#endif // !_LIBCPP_UNROLL_LOOPS
|
||||
@ -1515,7 +1522,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
while (true)
|
||||
{
|
||||
if (++__m2 == __last2)
|
||||
return __first1;
|
||||
return make_pair(__first1, __first1 + __len2);
|
||||
++__m1; // no need to check range on __m1 because __s guarantees we have enough source
|
||||
if (!__pred(*__m1, *__m2))
|
||||
{
|
||||
@ -1555,7 +1562,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
if (!__pred(*__m1, *__m2))
|
||||
break;
|
||||
case 0:
|
||||
return __first1;
|
||||
return make_pair(__first1, __first1 + __len2);
|
||||
}
|
||||
__continue:
|
||||
++__first1;
|
||||
@ -1571,8 +1578,9 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
{
|
||||
return _VSTD::__search<typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first1, __last1, __first2, __last2, __pred,
|
||||
typename std::iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename std::iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category())
|
||||
.first;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
@ -1581,8 +1589,8 @@ _ForwardIterator1
|
||||
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
|
||||
{
|
||||
typedef typename std::iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename std::iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
@ -2657,6 +2665,27 @@ max(initializer_list<_Tp> __t)
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
// clamp
|
||||
template<class _Tp, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
const _Tp&
|
||||
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
|
||||
{
|
||||
_LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
|
||||
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
|
||||
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
const _Tp&
|
||||
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
|
||||
{
|
||||
return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
|
||||
}
|
||||
#endif
|
||||
|
||||
// minmax_element
|
||||
|
||||
template <class _ForwardIterator, class _Compare>
|
||||
@ -5725,34 +5754,6 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
|
||||
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_integral<_Tp>::value,
|
||||
_Tp
|
||||
>::type
|
||||
__rotate_left(_Tp __t, _Tp __n = 1)
|
||||
{
|
||||
const unsigned __bits = static_cast<unsigned>(sizeof(_Tp) * __CHAR_BIT__ - 1);
|
||||
__n &= __bits;
|
||||
return static_cast<_Tp>((__t << __n) | (static_cast<typename make_unsigned<_Tp>::type>(__t) >> (__bits - __n)));
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_integral<_Tp>::value,
|
||||
_Tp
|
||||
>::type
|
||||
__rotate_right(_Tp __t, _Tp __n = 1)
|
||||
{
|
||||
const unsigned __bits = static_cast<unsigned>(sizeof(_Tp) * __CHAR_BIT__ - 1);
|
||||
__n &= __bits;
|
||||
return static_cast<_Tp>((__t << (__bits - __n)) | (static_cast<typename make_unsigned<_Tp>::type>(__t) >> __n));
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ALGORITHM
|
||||
|
@ -34,7 +34,7 @@ struct array
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
void fill(const T& u);
|
||||
void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
|
||||
void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
|
||||
|
||||
// iterators:
|
||||
iterator begin() noexcept;
|
||||
@ -141,8 +141,15 @@ struct _LIBCPP_TYPE_VIS_ONLY array
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
|
||||
{_VSTD::fill_n(__elems_, _Size, __u);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
{_VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
|
||||
void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
|
||||
{ __swap_dispatch((std::integral_constant<bool, _Size == 0>()), __a); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_dispatch(std::true_type, array&) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_dispatch(std::false_type, array& __a)
|
||||
{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -276,11 +283,12 @@ template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
_Size == 0 ||
|
||||
__is_swappable<_Tp>::value,
|
||||
void
|
||||
>::type
|
||||
swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
|
||||
_NOEXCEPT_(noexcept(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
namespace std
|
||||
{
|
||||
|
||||
// feature test macro
|
||||
|
||||
#define __cpp_lib_atomic_is_always_lock_free // as specified by SG10
|
||||
|
||||
// order and consistency
|
||||
|
||||
typedef enum memory_order
|
||||
@ -89,6 +93,7 @@ void
|
||||
template <class T>
|
||||
struct atomic
|
||||
{
|
||||
static constexpr bool is_always_lock_free;
|
||||
bool is_lock_free() const volatile noexcept;
|
||||
bool is_lock_free() const noexcept;
|
||||
void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
|
||||
@ -127,6 +132,7 @@ struct atomic
|
||||
template <>
|
||||
struct atomic<integral>
|
||||
{
|
||||
static constexpr bool is_always_lock_free;
|
||||
bool is_lock_free() const volatile noexcept;
|
||||
bool is_lock_free() const noexcept;
|
||||
void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
|
||||
@ -202,6 +208,7 @@ struct atomic<integral>
|
||||
template <class T>
|
||||
struct atomic<T*>
|
||||
{
|
||||
static constexpr bool is_always_lock_free;
|
||||
bool is_lock_free() const volatile noexcept;
|
||||
bool is_lock_free() const noexcept;
|
||||
void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
|
||||
@ -508,6 +515,15 @@ typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
|
||||
typedef atomic<int_fast64_t> atomic_int_fast64_t;
|
||||
typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
|
||||
|
||||
typedef atomic<int8_t> atomic_int8_t;
|
||||
typedef atomic<uint8_t> atomic_uint8_t;
|
||||
typedef atomic<int16_t> atomic_int16_t;
|
||||
typedef atomic<uint16_t> atomic_uint16_t;
|
||||
typedef atomic<int32_t> atomic_int32_t;
|
||||
typedef atomic<uint32_t> atomic_uint32_t;
|
||||
typedef atomic<int64_t> atomic_int64_t;
|
||||
typedef atomic<uint64_t> atomic_uint64_t;
|
||||
|
||||
typedef atomic<intptr_t> atomic_intptr_t;
|
||||
typedef atomic<uintptr_t> atomic_uintptr_t;
|
||||
typedef atomic<size_t> atomic_size_t;
|
||||
@ -540,6 +556,11 @@ void atomic_signal_fence(memory_order m) noexcept;
|
||||
#error <atomic> is not implemented
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
// FIXME: use the right feature test macro value as chose by SG10.
|
||||
# define __cpp_lib_atomic_is_always_lock_free 201603L
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
typedef enum memory_order
|
||||
@ -825,6 +846,17 @@ kill_dependency(_Tp __y) _NOEXCEPT
|
||||
return __y;
|
||||
}
|
||||
|
||||
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
|
||||
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
|
||||
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
|
||||
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
|
||||
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
|
||||
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
|
||||
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
|
||||
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
|
||||
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
|
||||
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
|
||||
|
||||
// general atomic<T>
|
||||
|
||||
template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
|
||||
@ -832,6 +864,10 @@ struct __atomic_base // false
|
||||
{
|
||||
mutable _Atomic(_Tp) __a_;
|
||||
|
||||
#if defined(__cpp_lib_atomic_is_always_lock_free)
|
||||
static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0);
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is_lock_free() const volatile _NOEXCEPT
|
||||
{
|
||||
@ -920,6 +956,11 @@ private:
|
||||
#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
};
|
||||
|
||||
#if defined(__cpp_lib_atomic_is_always_lock_free)
|
||||
template <class _Tp, bool __b>
|
||||
_LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free;
|
||||
#endif
|
||||
|
||||
// atomic<Integral>
|
||||
|
||||
template <class _Tp>
|
||||
@ -1657,7 +1698,7 @@ typedef struct atomic_flag
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
|
||||
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
atomic_flag(const atomic_flag&) = delete;
|
||||
@ -1779,6 +1820,15 @@ typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
|
||||
typedef atomic<int_fast64_t> atomic_int_fast64_t;
|
||||
typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
|
||||
|
||||
typedef atomic< int8_t> atomic_int8_t;
|
||||
typedef atomic<uint8_t> atomic_uint8_t;
|
||||
typedef atomic< int16_t> atomic_int16_t;
|
||||
typedef atomic<uint16_t> atomic_uint16_t;
|
||||
typedef atomic< int32_t> atomic_int32_t;
|
||||
typedef atomic<uint32_t> atomic_uint32_t;
|
||||
typedef atomic< int64_t> atomic_int64_t;
|
||||
typedef atomic<uint64_t> atomic_uint64_t;
|
||||
|
||||
typedef atomic<intptr_t> atomic_intptr_t;
|
||||
typedef atomic<uintptr_t> atomic_uintptr_t;
|
||||
typedef atomic<size_t> atomic_size_t;
|
||||
@ -1789,17 +1839,6 @@ typedef atomic<uintmax_t> atomic_uintmax_t;
|
||||
#define ATOMIC_FLAG_INIT {false}
|
||||
#define ATOMIC_VAR_INIT(__v) {__v}
|
||||
|
||||
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
|
||||
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
|
||||
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
|
||||
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
|
||||
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
|
||||
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
|
||||
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
|
||||
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
|
||||
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
|
||||
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ATOMIC
|
||||
|
@ -656,7 +656,7 @@ __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <size_t _Size> class _LIBCPP_TYPE_VIS_ONLY bitset;
|
||||
template <size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> >;
|
||||
template <size_t _Size> struct hash<bitset<_Size> >;
|
||||
|
||||
template <size_t _Size>
|
||||
class _LIBCPP_TYPE_VIS_ONLY bitset
|
||||
|
@ -44,6 +44,63 @@ int toupper(int c);
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifdef isalnum
|
||||
#undef isalnum
|
||||
#endif
|
||||
|
||||
#ifdef isalpha
|
||||
#undef isalpha
|
||||
#endif
|
||||
|
||||
#ifdef isblank
|
||||
#undef isblank
|
||||
#endif
|
||||
|
||||
#ifdef iscntrl
|
||||
#undef iscntrl
|
||||
#endif
|
||||
|
||||
#ifdef isdigit
|
||||
#undef isdigit
|
||||
#endif
|
||||
|
||||
#ifdef isgraph
|
||||
#undef isgraph
|
||||
#endif
|
||||
|
||||
#ifdef islower
|
||||
#undef islower
|
||||
#endif
|
||||
|
||||
#ifdef isprint
|
||||
#undef isprint
|
||||
#endif
|
||||
|
||||
#ifdef ispunct
|
||||
#undef ispunct
|
||||
#endif
|
||||
|
||||
#ifdef isspace
|
||||
#undef isspace
|
||||
#endif
|
||||
|
||||
#ifdef isupper
|
||||
#undef isupper
|
||||
#endif
|
||||
|
||||
#ifdef isxdigit
|
||||
#undef isxdigit
|
||||
#endif
|
||||
|
||||
#ifdef tolower
|
||||
#undef tolower
|
||||
#endif
|
||||
|
||||
#ifdef toupper
|
||||
#undef toupper
|
||||
#endif
|
||||
|
||||
|
||||
using ::isalnum;
|
||||
using ::isalpha;
|
||||
using ::isblank;
|
||||
|
@ -209,6 +209,10 @@ floating_point hypot (arithmetic x, arithmetic y);
|
||||
float hypotf(float x, float y);
|
||||
long double hypotl(long double x, long double y);
|
||||
|
||||
double hypot(double x, double y, double z); // C++17
|
||||
float hypot(float x, float y, float z); // C++17
|
||||
long double hypot(long double x, long double y, long double z); // C++17
|
||||
|
||||
int ilogb (arithmetic x);
|
||||
int ilogbf(float x);
|
||||
int ilogbl(long double x);
|
||||
@ -548,6 +552,30 @@ using ::lgamma;
|
||||
using ::lgammaf;
|
||||
#endif // __sun__
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
|
||||
|
||||
template <class _A1, class _A2, class _A3>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::__lazy_enable_if
|
||||
<
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value &&
|
||||
std::is_arithmetic<_A3>::value,
|
||||
std::__promote<_A1, _A2, _A3>
|
||||
>::type
|
||||
hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
|
||||
{
|
||||
typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
|
||||
static_assert((!(std::is_same<_A1, __result_type>::value &&
|
||||
std::is_same<_A2, __result_type>::value &&
|
||||
std::is_same<_A3, __result_type>::value)), "");
|
||||
return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CMATH
|
||||
|
@ -332,7 +332,9 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f)
|
||||
: __re_(__re), __im_(__im) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
|
||||
@ -388,7 +390,9 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0)
|
||||
: __re_(__re), __im_(__im) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR complex(const complex<float>& __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
|
||||
@ -444,7 +448,9 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
|
||||
: __re_(__re), __im_(__im) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR complex(const complex<float>& __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR complex(const complex<double>& __c);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
|
||||
@ -490,32 +496,32 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
complex<float>::complex(const complex<double>& __c)
|
||||
: __re_(__c.real()), __im_(__c.imag()) {}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
complex<float>::complex(const complex<long double>& __c)
|
||||
: __re_(__c.real()), __im_(__c.imag()) {}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
complex<double>::complex(const complex<float>& __c)
|
||||
: __re_(__c.real()), __im_(__c.imag()) {}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
complex<double>::complex(const complex<long double>& __c)
|
||||
: __re_(__c.real()), __im_(__c.imag()) {}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
complex<long double>::complex(const complex<float>& __c)
|
||||
: __re_(__c.real()), __im_(__c.imag()) {}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
complex<long double>::complex(const complex<double>& __c)
|
||||
: __re_(__c.real()), __im_(__c.imag()) {}
|
||||
@ -1399,7 +1405,7 @@ acos(const complex<_Tp>& __x)
|
||||
}
|
||||
if (isinf(__x.imag()))
|
||||
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
||||
if (__x.real() == 0)
|
||||
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
|
||||
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
||||
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
|
||||
if (signbit(__x.imag()))
|
||||
|
@ -78,30 +78,13 @@ using ::strcmp;
|
||||
using ::strncmp;
|
||||
using ::strcoll;
|
||||
using ::strxfrm;
|
||||
|
||||
using ::memchr;
|
||||
|
||||
using ::strchr;
|
||||
|
||||
using ::strcspn;
|
||||
|
||||
using ::strpbrk;
|
||||
|
||||
using ::strrchr;
|
||||
|
||||
using ::strspn;
|
||||
|
||||
using ::strstr;
|
||||
|
||||
// MSVCRT, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus
|
||||
#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
|
||||
inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
using ::strtok;
|
||||
#endif
|
||||
|
@ -157,30 +157,11 @@ using ::wcscmp;
|
||||
using ::wcscoll;
|
||||
using ::wcsncmp;
|
||||
using ::wcsxfrm;
|
||||
|
||||
#ifdef _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS
|
||||
using ::wcschr;
|
||||
using ::wcspbrk;
|
||||
using ::wcsrchr;
|
||||
using ::wcsstr;
|
||||
using ::wmemchr;
|
||||
#else
|
||||
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
|
||||
#endif
|
||||
|
||||
using ::wcscspn;
|
||||
using ::wcslen;
|
||||
using ::wcsspn;
|
||||
|
@ -2026,7 +2026,7 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type __tmp(_VSTD::forward<_Args>(__args)...);
|
||||
__temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
|
||||
iterator __b = __base::begin();
|
||||
iterator __bm1 = _VSTD::prev(__b);
|
||||
__alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
|
||||
@ -2034,7 +2034,7 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
|
||||
++__base::size();
|
||||
if (__pos > 1)
|
||||
__b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
|
||||
*__b = _VSTD::move(__tmp);
|
||||
*__b = _VSTD::move(__tmp.get());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2050,14 +2050,14 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type __tmp(_VSTD::forward<_Args>(__args)...);
|
||||
__temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
|
||||
iterator __e = __base::end();
|
||||
iterator __em1 = _VSTD::prev(__e);
|
||||
__alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
|
||||
++__base::size();
|
||||
if (__de > 1)
|
||||
__e = _VSTD::move_backward(__e - __de, __em1, __e);
|
||||
*--__e = _VSTD::move(__tmp);
|
||||
*--__e = _VSTD::move(__tmp.get());
|
||||
}
|
||||
}
|
||||
return __base::begin() + __pos;
|
||||
|
@ -80,6 +80,10 @@ template <class E> void rethrow_if_nested(const E& e);
|
||||
#include <__config>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#if defined(_LIBCPP_NO_EXCEPTIONS)
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -251,4 +255,19 @@ rethrow_if_nested(const _Ep&, typename enable_if<
|
||||
|
||||
} // std
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Exception>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline void __libcpp_throw(_Exception const& __e) {
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw __e;
|
||||
#else
|
||||
_VSTD::fprintf(stderr, "%s\n", __e.what());
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_EXCEPTION
|
||||
|
@ -25,8 +25,26 @@
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS } } }
|
||||
#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } }
|
||||
#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr {
|
||||
#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
|
||||
#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \
|
||||
namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
|
||||
#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem { \
|
||||
inline namespace v1 {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
|
||||
} } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
|
||||
#define _VSTD_FS ::std::experimental::filesystem::v1
|
||||
|
||||
#endif
|
||||
|
90
contrib/libc++/include/experimental/__memory
Normal file
90
contrib/libc++/include/experimental/__memory
Normal file
@ -0,0 +1,90 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL___MEMORY
|
||||
#define _LIBCPP_EXPERIMENTAL___MEMORY
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <experimental/utility> // for erased_type
|
||||
#include <__functional_base>
|
||||
#include <type_traits>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
template <
|
||||
class _Tp, class _Alloc
|
||||
, bool = uses_allocator<_Tp, _Alloc>::value
|
||||
, bool = __has_allocator_type<_Tp>::value
|
||||
>
|
||||
struct __lfts_uses_allocator : public false_type {};
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {};
|
||||
|
||||
template <class _Tp, class _Alloc, bool HasAlloc>
|
||||
struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {};
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
struct __lfts_uses_allocator<_Tp, _Alloc, false, true>
|
||||
: public integral_constant<bool
|
||||
, is_convertible<_Alloc, typename _Tp::allocator_type>::value
|
||||
|| is_same<erased_type, typename _Tp::allocator_type>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template <bool _UsesAlloc, class _Tp, class _Alloc, class ..._Args>
|
||||
struct __lfts_uses_alloc_ctor_imp
|
||||
{
|
||||
static const int value = 0;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc, class ..._Args>
|
||||
struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...>
|
||||
{
|
||||
static const bool __ic_first
|
||||
= is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
|
||||
|
||||
static const bool __ic_second =
|
||||
conditional<
|
||||
__ic_first,
|
||||
false_type,
|
||||
is_constructible<_Tp, _Args..., _Alloc>
|
||||
>::type::value;
|
||||
|
||||
static_assert(__ic_first || __ic_second,
|
||||
"Request for uses allocator construction is ill-formed");
|
||||
|
||||
static const int value = __ic_first ? 1 : 2;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc, class ..._Args>
|
||||
struct __lfts_uses_alloc_ctor
|
||||
: integral_constant<int,
|
||||
__lfts_uses_alloc_ctor_imp<
|
||||
__lfts_uses_allocator<_Tp, _Alloc>::value
|
||||
, _Tp, _Alloc, _Args...
|
||||
>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template <class _Tp, class _Alloc, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __lfts_user_alloc_construct(
|
||||
_Tp * __store, const _Alloc & __a, _Args &&... __args)
|
||||
{
|
||||
_VSTD::__user_alloc_construct_impl(
|
||||
typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type()
|
||||
, __store, __a, _VSTD::forward<_Args>(__args)...
|
||||
);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL___MEMORY */
|
@ -53,7 +53,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
template <class _ForwardIterator, class _Searcher>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
|
||||
{ return __s(__f, __l); }
|
||||
{ return __s(__f, __l).first; }
|
||||
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
|
@ -113,10 +113,12 @@ class any;
|
||||
|
||||
template <class _ValueType>
|
||||
typename add_pointer<typename add_const<_ValueType>::type>::type
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
typename add_pointer<_ValueType>::type
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any_cast(any *) _NOEXCEPT;
|
||||
|
||||
namespace __any_imp
|
||||
@ -185,6 +187,7 @@ public:
|
||||
class _ValueType
|
||||
, class = __any_imp::_EnableIfNotAny<_ValueType>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(_ValueType && __value);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -212,6 +215,7 @@ public:
|
||||
class _ValueType
|
||||
, class = __any_imp::_EnableIfNotAny<_ValueType>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(_ValueType && __rhs);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
@ -221,6 +225,7 @@ public:
|
||||
if (__h) this->__call(_Action::_Destroy);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __rhs) _NOEXCEPT;
|
||||
|
||||
// 6.3.4 any observers
|
||||
@ -457,7 +462,6 @@ namespace __any_imp
|
||||
|
||||
|
||||
template <class _ValueType, class>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any::any(_ValueType && __v) : __h(nullptr)
|
||||
{
|
||||
typedef typename decay<_ValueType>::type _Tp;
|
||||
@ -468,7 +472,6 @@ any::any(_ValueType && __v) : __h(nullptr)
|
||||
}
|
||||
|
||||
template <class _ValueType, class>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & any::operator=(_ValueType && __v)
|
||||
{
|
||||
typedef typename decay<_ValueType>::type _Tp;
|
||||
@ -478,7 +481,7 @@ any & any::operator=(_ValueType && __v)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void any::swap(any & __rhs) _NOEXCEPT
|
||||
{
|
||||
if (__h && __rhs.__h) {
|
||||
@ -550,7 +553,7 @@ _ValueType any_cast(any && __v)
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
typename add_pointer<typename add_const<_ValueType>::type>::type
|
||||
any_cast(any const * __any) _NOEXCEPT
|
||||
{
|
||||
@ -560,7 +563,6 @@ any_cast(any const * __any) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename add_pointer<_ValueType>::type
|
||||
any_cast(any * __any) _NOEXCEPT
|
||||
{
|
||||
|
47
contrib/libc++/include/experimental/deque
Normal file
47
contrib/libc++/include/experimental/deque
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- deque ------------------------------------===//
|
||||
//
|
||||
// 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_DEQUE
|
||||
#define _LIBCPP_EXPERIMENTAL_DEQUE
|
||||
/*
|
||||
experimental/deque synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T>
|
||||
using deque = std::deque<T,polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <deque>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _ValueT>
|
||||
using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */
|
@ -159,9 +159,13 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit dynarray(size_type __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
dynarray(size_type __c, const value_type& __v);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
dynarray(const dynarray& __d);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
dynarray(initializer_list<value_type>);
|
||||
|
||||
// We're not implementing these right now.
|
||||
@ -176,6 +180,7 @@ public:
|
||||
// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>);
|
||||
|
||||
dynarray& operator=(const dynarray&) = delete;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~dynarray();
|
||||
|
||||
// iterators:
|
||||
@ -219,7 +224,7 @@ public:
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
|
||||
{
|
||||
__base_ = __allocate (__c);
|
||||
@ -229,7 +234,7 @@ dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
|
||||
{
|
||||
__base_ = __allocate (__c);
|
||||
@ -239,7 +244,7 @@ dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
|
||||
{
|
||||
size_t sz = __il.size();
|
||||
@ -251,7 +256,7 @@ dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
|
||||
{
|
||||
size_t sz = __d.size();
|
||||
@ -263,7 +268,7 @@ dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
dynarray<_Tp>::~dynarray()
|
||||
{
|
||||
value_type *__data = data () + __size_;
|
||||
|
2052
contrib/libc++/include/experimental/filesystem
Normal file
2052
contrib/libc++/include/experimental/filesystem
Normal file
File diff suppressed because it is too large
Load Diff
47
contrib/libc++/include/experimental/forward_list
Normal file
47
contrib/libc++/include/experimental/forward_list
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- forward_list -----------------------------===//
|
||||
//
|
||||
// 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_FORWARD_LIST
|
||||
#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST
|
||||
/*
|
||||
experimental/forward_list synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T>
|
||||
using forward_list = std::forward_list<T,polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <forward_list>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _ValueT>
|
||||
using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */
|
@ -119,9 +119,12 @@ public:
|
||||
|
||||
template <typename _ForwardIterator2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
|
||||
pair<_ForwardIterator2, _ForwardIterator2>
|
||||
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
|
||||
{
|
||||
return _VSTD::search(__f, __l, __first_, __last_, __pred_);
|
||||
return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
|
||||
typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
|
||||
typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
private:
|
||||
@ -233,7 +236,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename _RandomAccessIterator2>
|
||||
_RandomAccessIterator2
|
||||
pair<_RandomAccessIterator2, _RandomAccessIterator2>
|
||||
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
|
||||
{
|
||||
static_assert ( std::is_same<
|
||||
@ -242,12 +245,12 @@ public:
|
||||
>::value,
|
||||
"Corpus and Pattern iterators must point to the same type" );
|
||||
|
||||
if (__f == __l ) return __l; // empty corpus
|
||||
if (__first_ == __last_) return __f; // empty pattern
|
||||
if (__f == __l ) return make_pair(__l, __l); // empty corpus
|
||||
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
|
||||
|
||||
// If the pattern is larger than the corpus, we can't find it!
|
||||
if ( __pattern_length_ > _VSTD::distance (__f, __l))
|
||||
return __l;
|
||||
return make_pair(__l, __l);
|
||||
|
||||
// Do the search
|
||||
return this->__search(__f, __l);
|
||||
@ -262,7 +265,8 @@ public: // TODO private:
|
||||
shared_ptr<vector<difference_type>> __suffix_;
|
||||
|
||||
template <typename _RandomAccessIterator2>
|
||||
_RandomAccessIterator2 __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
|
||||
pair<_RandomAccessIterator2, _RandomAccessIterator2>
|
||||
__search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
|
||||
{
|
||||
_RandomAccessIterator2 __cur = __f;
|
||||
const _RandomAccessIterator2 __last = __l - __pattern_length_;
|
||||
@ -278,7 +282,7 @@ public: // TODO private:
|
||||
__j--;
|
||||
// We matched - we're done!
|
||||
if ( __j == 0 )
|
||||
return __cur;
|
||||
return make_pair(__cur, __cur + __pattern_length_);
|
||||
}
|
||||
|
||||
// Since we didn't match, figure out how far to skip forward
|
||||
@ -290,7 +294,7 @@ public: // TODO private:
|
||||
__cur += __suffix[ __j ];
|
||||
}
|
||||
|
||||
return __l; // We didn't find anything
|
||||
return make_pair(__l, __l); // We didn't find anything
|
||||
}
|
||||
|
||||
|
||||
@ -384,8 +388,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _RandomAccessIterator2>
|
||||
_RandomAccessIterator2
|
||||
template <typename _RandomAccessIterator2>
|
||||
pair<_RandomAccessIterator2, _RandomAccessIterator2>
|
||||
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
|
||||
{
|
||||
static_assert ( std::is_same<
|
||||
@ -394,12 +398,12 @@ public:
|
||||
>::value,
|
||||
"Corpus and Pattern iterators must point to the same type" );
|
||||
|
||||
if (__f == __l ) return __l; // empty corpus
|
||||
if (__first_ == __last_) return __f; // empty pattern
|
||||
if (__f == __l ) return make_pair(__l, __l); // empty corpus
|
||||
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
|
||||
|
||||
// If the pattern is larger than the corpus, we can't find it!
|
||||
if ( __pattern_length_ > _VSTD::distance (__f, __l))
|
||||
return __l;
|
||||
return make_pair(__l, __l);
|
||||
|
||||
// Do the search
|
||||
return this->__search(__f, __l);
|
||||
@ -413,7 +417,8 @@ private:
|
||||
shared_ptr<skip_table_type> __skip_;
|
||||
|
||||
template <typename _RandomAccessIterator2>
|
||||
_RandomAccessIterator2 __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const {
|
||||
pair<_RandomAccessIterator2, _RandomAccessIterator2>
|
||||
__search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const {
|
||||
_RandomAccessIterator2 __cur = __f;
|
||||
const _RandomAccessIterator2 __last = __l - __pattern_length_;
|
||||
const skip_table_type & __skip = *__skip_.get();
|
||||
@ -427,12 +432,12 @@ private:
|
||||
__j--;
|
||||
// We matched - we're done!
|
||||
if ( __j == 0 )
|
||||
return __cur;
|
||||
return make_pair(__cur, __cur + __pattern_length_);
|
||||
}
|
||||
__cur += __skip[__cur[__pattern_length_-1]];
|
||||
}
|
||||
|
||||
return __l;
|
||||
return make_pair(__l, __l);
|
||||
}
|
||||
};
|
||||
|
||||
|
114
contrib/libc++/include/experimental/iterator
Normal file
114
contrib/libc++/include/experimental/iterator
Normal file
@ -0,0 +1,114 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------- iterator -------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR
|
||||
#define _LIBCPP_EXPERIMENTAL_ITERATOR
|
||||
|
||||
/*
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v2 {
|
||||
|
||||
template <class DelimT, class charT = char, class traits = char_traits<charT>>
|
||||
class ostream_joiner {
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef traits traits_type;
|
||||
typedef basic_ostream<charT, traits> ostream_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
ostream_joiner(ostream_type& s, const DelimT& delimiter);
|
||||
ostream_joiner(ostream_type& s, DelimT&& delimiter);
|
||||
|
||||
template<typename T>
|
||||
ostream_joiner& operator=(const T& value);
|
||||
|
||||
ostream_joiner& operator*() noexcept;
|
||||
ostream_joiner& operator++() noexcept;
|
||||
ostream_joiner& operator++(int) noexcept;
|
||||
private:
|
||||
ostream_type* out_stream; // exposition only
|
||||
DelimT delim; // exposition only
|
||||
bool first_element; // exposition only
|
||||
};
|
||||
|
||||
template <class charT, class traits, class DelimT>
|
||||
ostream_joiner<decay_t<DelimT>, charT, traits>
|
||||
make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter);
|
||||
|
||||
} // inline namespace fundamentals_v2
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <iterator>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>>
|
||||
class ostream_joiner {
|
||||
public:
|
||||
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef basic_ostream<char_type,traits_type> ostream_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
ostream_joiner(ostream_type& __os, _Delim&& __d)
|
||||
: __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
|
||||
|
||||
ostream_joiner(ostream_type& __os, const _Delim& __d)
|
||||
: __out(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
ostream_joiner& operator=(const _Tp& __v)
|
||||
{
|
||||
if (!__first)
|
||||
*__out << __delim;
|
||||
__first = false;
|
||||
*__out << __v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ostream_joiner& operator*() _NOEXCEPT { return *this; }
|
||||
ostream_joiner& operator++() _NOEXCEPT { return *this; }
|
||||
ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
|
||||
|
||||
private:
|
||||
ostream_type* __out;
|
||||
_Delim __delim;
|
||||
bool __first;
|
||||
};
|
||||
|
||||
|
||||
template <class _CharT, class _Traits, class _Delim>
|
||||
ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
|
||||
make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)
|
||||
{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
|
47
contrib/libc++/include/experimental/list
Normal file
47
contrib/libc++/include/experimental/list
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- list ------------------------------------===//
|
||||
//
|
||||
// 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_LIST
|
||||
#define _LIBCPP_EXPERIMENTAL_LIST
|
||||
/*
|
||||
experimental/list synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T>
|
||||
using list = std::list<T,polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <list>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _ValueT>
|
||||
using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_LIST */
|
57
contrib/libc++/include/experimental/map
Normal file
57
contrib/libc++/include/experimental/map
Normal file
@ -0,0 +1,57 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------- map ------------------------------------===//
|
||||
//
|
||||
// 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_MAP
|
||||
#define _LIBCPP_EXPERIMENTAL_MAP
|
||||
/*
|
||||
experimental/map synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class Key, class T, class Compare = less<Key>>
|
||||
using map = std::map<Key, T, Compare,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
template <class Key, class T, class Compare = less<Key>>
|
||||
using multimap = std::multimap<Key, T, Compare,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <map>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _Key, class _Value, class _Compare = less<_Key>>
|
||||
using map = _VSTD::map<_Key, _Value, _Compare,
|
||||
polymorphic_allocator<pair<const _Key, _Value>>>;
|
||||
|
||||
template <class _Key, class _Value, class _Compare = less<_Key>>
|
||||
using multimap = _VSTD::multimap<_Key, _Value, _Compare,
|
||||
polymorphic_allocator<pair<const _Key, _Value>>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_MAP */
|
422
contrib/libc++/include/experimental/memory_resource
Normal file
422
contrib/libc++/include/experimental/memory_resource
Normal file
@ -0,0 +1,422 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------ memory_resource -----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE
|
||||
#define _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE
|
||||
|
||||
/**
|
||||
experimental/memory_resource synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
class memory_resource;
|
||||
|
||||
bool operator==(const memory_resource& a,
|
||||
const memory_resource& b) noexcept;
|
||||
bool operator!=(const memory_resource& a,
|
||||
const memory_resource& b) noexcept;
|
||||
|
||||
template <class Tp> class polymorphic_allocator;
|
||||
|
||||
template <class T1, class T2>
|
||||
bool operator==(const polymorphic_allocator<T1>& a,
|
||||
const polymorphic_allocator<T2>& b) noexcept;
|
||||
template <class T1, class T2>
|
||||
bool operator!=(const polymorphic_allocator<T1>& a,
|
||||
const polymorphic_allocator<T2>& b) noexcept;
|
||||
|
||||
// The name resource_adaptor_imp is for exposition only.
|
||||
template <class Allocator> class resource_adaptor_imp;
|
||||
|
||||
template <class Allocator>
|
||||
using resource_adaptor = resource_adaptor_imp<
|
||||
allocator_traits<Allocator>::rebind_alloc<char>>;
|
||||
|
||||
// Global memory resources
|
||||
memory_resource* new_delete_resource() noexcept;
|
||||
memory_resource* null_memory_resource() noexcept;
|
||||
|
||||
// The default memory resource
|
||||
memory_resource* set_default_resource(memory_resource* r) noexcept;
|
||||
memory_resource* get_default_resource() noexcept;
|
||||
|
||||
// Standard memory resources
|
||||
struct pool_options;
|
||||
class synchronized_pool_resource;
|
||||
class unsynchronized_pool_resource;
|
||||
class monotonic_buffer_resource;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <experimental/__memory>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
// Round __s up to next multiple of __a.
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s + __a > __s, "aligned allocation size overflows");
|
||||
return (__s + __a - 1) & ~(__a - 1);
|
||||
}
|
||||
|
||||
// 8.5, memory.resource
|
||||
class _LIBCPP_TYPE_VIS_ONLY memory_resource
|
||||
{
|
||||
static const size_t __max_align = alignof(max_align_t);
|
||||
|
||||
// 8.5.2, memory.resource.public
|
||||
public:
|
||||
virtual ~memory_resource() = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void* allocate(size_t __bytes, size_t __align = __max_align)
|
||||
{ return do_allocate(__bytes, __align); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void deallocate(void * __p, size_t __bytes, size_t __align = __max_align)
|
||||
{ do_deallocate(__p, __bytes, __align); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is_equal(memory_resource const & __other) const _NOEXCEPT
|
||||
{ return do_is_equal(__other); }
|
||||
|
||||
// 8.5.3, memory.resource.priv
|
||||
protected:
|
||||
virtual void* do_allocate(size_t, size_t) = 0;
|
||||
virtual void do_deallocate(void*, size_t, size_t) = 0;
|
||||
virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;
|
||||
};
|
||||
|
||||
// 8.5.4, memory.resource.eq
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(memory_resource const & __lhs,
|
||||
memory_resource const & __rhs) _NOEXCEPT
|
||||
{
|
||||
return &__lhs == &__rhs || __lhs.is_equal(__rhs);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(memory_resource const & __lhs,
|
||||
memory_resource const & __rhs) _NOEXCEPT
|
||||
{
|
||||
return !(__lhs == __rhs);
|
||||
}
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
memory_resource * new_delete_resource() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
memory_resource * null_memory_resource() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
memory_resource * get_default_resource() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;
|
||||
|
||||
// 8.6, memory.polymorphic.allocator.class
|
||||
|
||||
// 8.6.1, memory.polymorphic.allocator.overview
|
||||
template <class _ValueType>
|
||||
class _LIBCPP_TYPE_VIS_ONLY polymorphic_allocator
|
||||
{
|
||||
public:
|
||||
typedef _ValueType value_type;
|
||||
|
||||
// 8.6.2, memory.polymorphic.allocator.ctor
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
polymorphic_allocator() _NOEXCEPT
|
||||
: __res_(_VSTD_LFTS_PMR::get_default_resource())
|
||||
{}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
polymorphic_allocator(memory_resource * __r) _NOEXCEPT
|
||||
: __res_(__r)
|
||||
{}
|
||||
|
||||
polymorphic_allocator(polymorphic_allocator const &) = default;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
polymorphic_allocator(polymorphic_allocator<_Tp> const & __other) _NOEXCEPT
|
||||
: __res_(__other.resource())
|
||||
{}
|
||||
|
||||
polymorphic_allocator &
|
||||
operator=(polymorphic_allocator const &) = delete;
|
||||
|
||||
// 8.6.3, memory.polymorphic.allocator.mem
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType* allocate(size_t __n) {
|
||||
if (__n > max_size()) {
|
||||
__libcpp_throw(length_error(
|
||||
"std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size"));
|
||||
}
|
||||
return static_cast<_ValueType*>(
|
||||
__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))
|
||||
);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT {
|
||||
_LIBCPP_ASSERT(__n <= max_size(),
|
||||
"deallocate called for size which exceeds max_size()");
|
||||
__res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
|
||||
}
|
||||
|
||||
template <class _Tp, class ..._Ts>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(_Tp* __p, _Ts &&... __args)
|
||||
{
|
||||
_VSTD_LFTS::__lfts_user_alloc_construct(
|
||||
__p, resource(), _VSTD::forward<_Ts>(__args)...
|
||||
);
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class ..._Args1, class ..._Args2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
|
||||
tuple<_Args1...> __x, tuple<_Args2...> __y)
|
||||
{
|
||||
::new ((void*)__p) pair<_T1, _T2>(piecewise_construct
|
||||
, __transform_tuple(
|
||||
typename __lfts_uses_alloc_ctor<
|
||||
_T1, memory_resource*, _Args1...
|
||||
>::type()
|
||||
, _VSTD::move(__x)
|
||||
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
|
||||
)
|
||||
, __transform_tuple(
|
||||
typename __lfts_uses_alloc_ctor<
|
||||
_T2, memory_resource*, _Args2...
|
||||
>::type()
|
||||
, _VSTD::move(__y)
|
||||
, typename __make_tuple_indices<sizeof...(_Args2)>::type{}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(pair<_T1, _T2>* __p) {
|
||||
construct(__p, piecewise_construct, tuple<>(), tuple<>());
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(pair<_T1, _T2> * __p, _Up && __u, _Vp && __v) {
|
||||
construct(__p, piecewise_construct
|
||||
, _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__u))
|
||||
, _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__v)));
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _U1, class _U2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> const & __pr) {
|
||||
construct(__p, piecewise_construct
|
||||
, _VSTD::forward_as_tuple(__pr.first)
|
||||
, _VSTD::forward_as_tuple(__pr.second));
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _U1, class _U2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> && __pr){
|
||||
construct(__p, piecewise_construct
|
||||
, _VSTD::forward_as_tuple(_VSTD::forward<_U1>(__pr.first))
|
||||
, _VSTD::forward_as_tuple(_VSTD::forward<_U2>(__pr.second)));
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void destroy(_Tp * __p) _NOEXCEPT
|
||||
{ __p->~_Tp(); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t max_size() const _NOEXCEPT
|
||||
{ return numeric_limits<size_t>::max() / sizeof(value_type); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
polymorphic_allocator
|
||||
select_on_container_copy_construction() const _NOEXCEPT
|
||||
{ return polymorphic_allocator(); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
memory_resource * resource() const _NOEXCEPT
|
||||
{ return __res_; }
|
||||
|
||||
private:
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<_Args&&...>
|
||||
__transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,
|
||||
__tuple_indices<_Idx...>) const
|
||||
{
|
||||
return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<allocator_arg_t const&, memory_resource*, _Args&&...>
|
||||
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>) const
|
||||
{
|
||||
using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>;
|
||||
return _Tup(allocator_arg, resource(),
|
||||
_VSTD::get<_Idx>(_VSTD::move(__t))...);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<_Args&&..., memory_resource*>
|
||||
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>) const
|
||||
{
|
||||
using _Tup = tuple<_Args&&..., memory_resource*>;
|
||||
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
|
||||
}
|
||||
|
||||
memory_resource * __res_;
|
||||
};
|
||||
|
||||
// 8.6.4, memory.polymorphic.allocator.eq
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(polymorphic_allocator<_Tp> const & __lhs,
|
||||
polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
|
||||
{
|
||||
return *__lhs.resource() == *__rhs.resource();
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
|
||||
polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
|
||||
{
|
||||
return !(__lhs == __rhs);
|
||||
}
|
||||
|
||||
// 8.7, memory.resource.adaptor
|
||||
|
||||
// 8.7.1, memory.resource.adaptor.overview
|
||||
template <class _CharAlloc>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __resource_adaptor_imp
|
||||
: public memory_resource
|
||||
{
|
||||
using _CTraits = allocator_traits<_CharAlloc>;
|
||||
static_assert(is_same<typename _CTraits::value_type, char>::value
|
||||
&& is_same<typename _CTraits::pointer, char*>::value
|
||||
&& is_same<typename _CTraits::void_pointer, void*>::value, "");
|
||||
|
||||
static const size_t _MaxAlign = alignof(max_align_t);
|
||||
|
||||
using _Alloc = typename _CTraits::template rebind_alloc<
|
||||
typename aligned_storage<_MaxAlign, _MaxAlign>::type
|
||||
>;
|
||||
|
||||
using _ValueType = typename _Alloc::value_type;
|
||||
|
||||
_Alloc __alloc_;
|
||||
|
||||
public:
|
||||
typedef _CharAlloc allocator_type;
|
||||
|
||||
__resource_adaptor_imp() = default;
|
||||
__resource_adaptor_imp(__resource_adaptor_imp const &) = default;
|
||||
__resource_adaptor_imp(__resource_adaptor_imp &&) = default;
|
||||
|
||||
// 8.7.2, memory.resource.adaptor.ctor
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __resource_adaptor_imp(allocator_type const & __a)
|
||||
: __alloc_(__a)
|
||||
{}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __resource_adaptor_imp(allocator_type && __a)
|
||||
: __alloc_(_VSTD::move(__a))
|
||||
{}
|
||||
|
||||
__resource_adaptor_imp &
|
||||
operator=(__resource_adaptor_imp const &) = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const
|
||||
{ return __alloc_; }
|
||||
|
||||
// 8.7.3, memory.resource.adaptor.mem
|
||||
protected:
|
||||
virtual void * do_allocate(size_t __bytes, size_t)
|
||||
{
|
||||
if (__bytes > __max_size()) {
|
||||
__libcpp_throw(length_error(
|
||||
"std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)"
|
||||
" 'bytes' exceeds maximum supported size"));
|
||||
}
|
||||
size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;
|
||||
return __alloc_.allocate(__s);
|
||||
}
|
||||
|
||||
virtual void do_deallocate(void * __p, size_t __bytes, size_t)
|
||||
{
|
||||
_LIBCPP_ASSERT(__bytes <= __max_size(),
|
||||
"do_deallocate called for size which exceeds the maximum allocation size");
|
||||
size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;
|
||||
__alloc_.deallocate((_ValueType*)__p, __s);
|
||||
}
|
||||
|
||||
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT {
|
||||
__resource_adaptor_imp const * __p
|
||||
= dynamic_cast<__resource_adaptor_imp const *>(&__other);
|
||||
return __p ? __alloc_ == __p->__alloc_ : false;
|
||||
}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t __max_size() const _NOEXCEPT {
|
||||
return numeric_limits<size_t>::max() - _MaxAlign;
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Alloc>
|
||||
using resource_adaptor = __resource_adaptor_imp<
|
||||
typename allocator_traits<_Alloc>::template rebind_alloc<char>
|
||||
>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */
|
@ -517,7 +517,11 @@ public:
|
||||
constexpr value_type const& value() const
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_optional_access();
|
||||
#else
|
||||
assert(!"bad optional access");
|
||||
#endif
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
@ -525,7 +529,11 @@ public:
|
||||
value_type& value()
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_optional_access();
|
||||
#else
|
||||
assert(!"bad optional access");
|
||||
#endif
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
|
576
contrib/libc++/include/experimental/propagate_const
Normal file
576
contrib/libc++/include/experimental/propagate_const
Normal file
@ -0,0 +1,576 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------ propagate_const -----------------------------===//
|
||||
//
|
||||
// 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_PROPAGATE_CONST
|
||||
#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
|
||||
/*
|
||||
propagate_const synopsis
|
||||
|
||||
namespace std { namespace experimental { inline namespace fundamentals_v2 {
|
||||
|
||||
// [propagate_const]
|
||||
template <class T> class propagate_const;
|
||||
|
||||
// [propagate_const.underlying], underlying pointer access
|
||||
constexpr const _Tp& _VSTD_LFTS_V2::get_underlying(const propagate_const<T>& pt) noexcept;
|
||||
constexpr T& _VSTD_LFTS_V2::get_underlying(propagate_const<T>& pt) noexcept;
|
||||
|
||||
// [propagate_const.relational], relational operators
|
||||
template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t);
|
||||
template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu);
|
||||
template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t);
|
||||
template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu);
|
||||
template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
|
||||
// [propagate_const.algorithms], specialized algorithms
|
||||
template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below);
|
||||
|
||||
template <class T>
|
||||
class propagate_const
|
||||
{
|
||||
|
||||
public:
|
||||
typedef remove_reference_t<decltype(*declval<T&>())> element_type;
|
||||
|
||||
// [propagate_const.ctor], constructors
|
||||
constexpr propagate_const() = default;
|
||||
propagate_const(const propagate_const& p) = delete;
|
||||
constexpr propagate_const(propagate_const&& p) = default;
|
||||
template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below
|
||||
template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below
|
||||
|
||||
// [propagate_const.assignment], assignment
|
||||
propagate_const& operator=(const propagate_const& p) = delete;
|
||||
constexpr propagate_const& operator=(propagate_const&& p) = default;
|
||||
template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu);
|
||||
template <class U> constexpr propagate_const& operator=(U&& u); // see below
|
||||
|
||||
// [propagate_const.const_observers], const observers
|
||||
explicit constexpr operator bool() const;
|
||||
constexpr const element_type* operator->() const;
|
||||
constexpr operator const element_type*() const; // Not always defined
|
||||
constexpr const element_type& operator*() const;
|
||||
constexpr const element_type* get() const;
|
||||
|
||||
// [propagate_const.non_const_observers], non-const observers
|
||||
constexpr element_type* operator->();
|
||||
constexpr operator element_type*(); // Not always defined
|
||||
constexpr element_type& operator*();
|
||||
constexpr element_type* get();
|
||||
|
||||
// [propagate_const.modifiers], modifiers
|
||||
constexpr void swap(propagate_const& pt) noexcept(see below)
|
||||
|
||||
private:
|
||||
T t_; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v2
|
||||
} // namespace experimental
|
||||
|
||||
// [propagate_const.hash], hash support
|
||||
template <class T> struct hash<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
|
||||
// [propagate_const.comparison_function_objects], comparison function objects
|
||||
template <class T> struct equal_to<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct not_equal_to<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct less<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct greater<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct less_equal<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct greater_equal<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
class propagate_const;
|
||||
template <class _Up> _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
template <class _Up> _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
class propagate_const
|
||||
{
|
||||
public:
|
||||
typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type;
|
||||
|
||||
static_assert(!is_array<_Tp>::value,
|
||||
"Instantiation of propagate_const with an array type is ill-formed.");
|
||||
static_assert(!is_reference<_Tp>::value,
|
||||
"Instantiation of propagate_const with a reference type is ill-formed.");
|
||||
static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value),
|
||||
"Instantiation of propagate_const with a function-pointer type is ill-formed.");
|
||||
static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value),
|
||||
"Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
|
||||
|
||||
private:
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u)
|
||||
{
|
||||
return __u;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u)
|
||||
{
|
||||
return __get_pointer(__u.get());
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u)
|
||||
{
|
||||
return __u;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u)
|
||||
{
|
||||
return __get_pointer(__u.get());
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
struct __is_propagate_const : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Up>
|
||||
struct __is_propagate_const<propagate_const<_Up>> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
_Tp __t_;
|
||||
|
||||
public:
|
||||
|
||||
template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& ::_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
template <class _Up> friend _LIBCPP_CONSTEXPR _Up& ::_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_CONSTEXPR propagate_const() = default;
|
||||
|
||||
propagate_const(const propagate_const&) = delete;
|
||||
|
||||
_LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default;
|
||||
|
||||
template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value,bool> = true>
|
||||
explicit _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
|
||||
: __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu)))
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value,bool> = false>
|
||||
_LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
|
||||
: __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu)))
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value &&
|
||||
!__is_propagate_const<decay_t<_Up>>::value,bool> = true>
|
||||
explicit _LIBCPP_CONSTEXPR propagate_const(_Up&& __u)
|
||||
: __t_(std::forward<_Up>(__u))
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value &&
|
||||
!__is_propagate_const<decay_t<_Up>>::value,bool> = false>
|
||||
_LIBCPP_CONSTEXPR propagate_const(_Up&& __u)
|
||||
: __t_(std::forward<_Up>(__u))
|
||||
{
|
||||
}
|
||||
|
||||
propagate_const& operator=(const propagate_const&) = delete;
|
||||
|
||||
_LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default;
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu)
|
||||
{
|
||||
__t_ = std::move(_VSTD_LFTS_V2::get_underlying(__pu));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>>
|
||||
_LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u)
|
||||
{
|
||||
__t_ = std::forward<_Up>(__u);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR const element_type* get() const
|
||||
{
|
||||
return __get_pointer(__t_);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR element_type* get()
|
||||
{
|
||||
return __get_pointer(__t_);
|
||||
}
|
||||
|
||||
explicit _LIBCPP_CONSTEXPR operator bool() const
|
||||
{
|
||||
return get() != nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR const element_type* operator->() const
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
template <class _Tp_ = _Tp, class _Up = enable_if_t<is_convertible<
|
||||
const _Tp_, const element_type *>::value>>
|
||||
_LIBCPP_CONSTEXPR operator const element_type *() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR const element_type& operator*() const
|
||||
{
|
||||
return *get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR element_type* operator->()
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
template <class _Tp_ = _Tp, class _Up = enable_if_t<
|
||||
is_convertible<_Tp_, element_type *>::value>>
|
||||
_LIBCPP_CONSTEXPR operator element_type *() {
|
||||
return get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR element_type& operator*()
|
||||
{
|
||||
return *get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(__t_, __pt.__t_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) == nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt)
|
||||
{
|
||||
return nullptr == _VSTD_LFTS_V2::get_underlying(__pt);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) != nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt)
|
||||
{
|
||||
return nullptr != _VSTD_LFTS_V2::get_underlying(__pt);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) == _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) != _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) < _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) > _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) <= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) >= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) == __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) != __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) < __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) > __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) <= __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) >= __u;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t == _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t != _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t < _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t > _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t <= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t >= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT
|
||||
{
|
||||
return __pt.__t_;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT
|
||||
{
|
||||
return __pt.__t_;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_V2
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
struct hash<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef size_t result_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type;
|
||||
|
||||
size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const
|
||||
{
|
||||
return std::hash<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct equal_to<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct not_equal_to<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::not_equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct less<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::less<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct greater<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::greater<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct less_equal<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::less_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct greater_equal<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::greater_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
|
||||
|
62
contrib/libc++/include/experimental/regex
Normal file
62
contrib/libc++/include/experimental/regex
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------- regex ----------------------------------===//
|
||||
//
|
||||
// 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_REGEX
|
||||
#define _LIBCPP_EXPERIMENTAL_REGEX
|
||||
/*
|
||||
experimental/regex synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
using match_results =
|
||||
std::match_results<BidirectionalIterator,
|
||||
polymorphic_allocator<sub_match<BidirectionalIterator>>>;
|
||||
|
||||
typedef match_results<const char*> cmatch;
|
||||
typedef match_results<const wchar_t*> wcmatch;
|
||||
typedef match_results<string::const_iterator> smatch;
|
||||
typedef match_results<wstring::const_iterator> wsmatch;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <regex>
|
||||
#include <experimental/string>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _BiDirIter>
|
||||
using match_results =
|
||||
_VSTD::match_results<_BiDirIter,
|
||||
polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>;
|
||||
|
||||
typedef match_results<const char*> cmatch;
|
||||
typedef match_results<const wchar_t*> wcmatch;
|
||||
typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
|
||||
typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_REGEX */
|
57
contrib/libc++/include/experimental/set
Normal file
57
contrib/libc++/include/experimental/set
Normal file
@ -0,0 +1,57 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- list ------------------------------------===//
|
||||
//
|
||||
// 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_SET
|
||||
#define _LIBCPP_EXPERIMENTAL_SET
|
||||
/*
|
||||
experimental/set synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class Key, class T, class Compare = less<Key>>
|
||||
using set = std::set<Key, T, Compare,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
template <class Key, class T, class Compare = less<Key>>
|
||||
using multiset = std::multiset<Key, T, Compare,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <set>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _Value, class _Compare = less<_Value>>
|
||||
using set = _VSTD::set<_Value, _Compare,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
template <class _Value, class _Compare = less<_Value>>
|
||||
using multiset = _VSTD::multiset<_Value, _Compare,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_SET */
|
62
contrib/libc++/include/experimental/string
Normal file
62
contrib/libc++/include/experimental/string
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- string ----------------------------------===//
|
||||
//
|
||||
// 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_STRING
|
||||
#define _LIBCPP_EXPERIMENTAL_STRING
|
||||
/*
|
||||
experimental/string synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
// basic_string using polymorphic allocator in namespace pmr
|
||||
template <class charT, class traits = char_traits<charT>>
|
||||
using basic_string =
|
||||
std::basic_string<charT, traits, polymorphic_allocator<charT>>;
|
||||
|
||||
// basic_string typedef names using polymorphic allocator in namespace
|
||||
// std::experimental::pmr
|
||||
typedef basic_string<char> string;
|
||||
typedef basic_string<char16_t> u16string;
|
||||
typedef basic_string<char32_t> u32string;
|
||||
typedef basic_string<wchar_t> wstring;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <string>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _CharT, class _Traits = char_traits<_CharT>>
|
||||
using basic_string =
|
||||
_VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
|
||||
|
||||
typedef basic_string<char> string;
|
||||
typedef basic_string<char16_t> u16string;
|
||||
typedef basic_string<char32_t> u32string;
|
||||
typedef basic_string<wchar_t> wstring;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_STRING */
|
@ -180,6 +180,7 @@ namespace std {
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <iomanip>
|
||||
|
||||
#include <__debug>
|
||||
@ -227,7 +228,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
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_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
@ -280,7 +281,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
const_reference at(size_type __pos) const
|
||||
{
|
||||
return __pos >= size()
|
||||
? (throw out_of_range("string_view::at"), __data[0])
|
||||
? (__libcpp_throw(out_of_range("string_view::at")), __data[0])
|
||||
: __data[__pos];
|
||||
}
|
||||
|
||||
@ -351,7 +352,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{
|
||||
if ( __pos > size())
|
||||
throw out_of_range("string_view::copy");
|
||||
__libcpp_throw(out_of_range("string_view::copy"));
|
||||
size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
_VSTD::copy_n(begin() + __pos, __rlen, __s );
|
||||
return __rlen;
|
||||
@ -365,7 +366,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
// 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")
|
||||
? (__libcpp_throw((out_of_range("string_view::substr"))), basic_string_view())
|
||||
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
|
||||
}
|
||||
|
||||
@ -413,7 +414,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
@ -428,7 +429,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
@ -436,7 +437,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
@ -445,7 +446,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
@ -460,7 +461,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
@ -468,7 +469,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
@ -477,7 +478,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
@ -489,7 +490,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
@ -497,7 +498,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
@ -506,7 +507,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
@ -518,7 +519,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
@ -526,7 +527,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
@ -535,7 +536,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
@ -550,7 +551,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
@ -558,7 +559,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
@ -567,7 +568,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
@ -582,7 +583,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
@ -590,7 +591,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_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");
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
@ -57,9 +57,10 @@ _LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
|
||||
|
||||
template <class _Fn, class _Tuple, size_t ..._Id>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
|
||||
integer_sequence<size_t, _Id...>) {
|
||||
return _VSTD::__invoke(
|
||||
return _VSTD::__invoke_constexpr(
|
||||
_VSTD::forward<_Fn>(__f),
|
||||
_VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
|
||||
);
|
||||
|
65
contrib/libc++/include/experimental/unordered_map
Normal file
65
contrib/libc++/include/experimental/unordered_map
Normal file
@ -0,0 +1,65 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- unordered_map ------------------------------===//
|
||||
//
|
||||
// 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_UNORDERED_MAP
|
||||
#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP
|
||||
/*
|
||||
experimental/unordered_map synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class Key, class T,
|
||||
class Hash = hash<Key>,
|
||||
class Pred = equal_to<Key>>
|
||||
using unordered_map =
|
||||
std::unordered_map<Key, T, Hash, Pred,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
template <class Key, class T,
|
||||
class Hash = hash<Key>,
|
||||
class Pred = equal_to<Key>>
|
||||
using unordered_multimap =
|
||||
std::unordered_multimap<Key, T, Hash, Pred,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <unordered_map>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _Key, class _Value,
|
||||
class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
|
||||
using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred,
|
||||
polymorphic_allocator<pair<const _Key, _Value>>>;
|
||||
|
||||
template <class _Key, class _Value,
|
||||
class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
|
||||
using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred,
|
||||
polymorphic_allocator<pair<const _Key, _Value>>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */
|
59
contrib/libc++/include/experimental/unordered_set
Normal file
59
contrib/libc++/include/experimental/unordered_set
Normal file
@ -0,0 +1,59 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- unordered_set ------------------------------===//
|
||||
//
|
||||
// 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_UNORDERED_SET
|
||||
#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET
|
||||
/*
|
||||
experimental/unordered_set synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T, class Hash = hash<T>, class Pred = equal_to<T>>
|
||||
using unordered_set = std::unordered_set<T, Hash, Pred,
|
||||
polymorphic_allocator<T>>;
|
||||
|
||||
template <class T, class Hash = hash<T>, class Pred = equal_to<T>>
|
||||
using unordered_multiset = std::unordered_multiset<T, Hash, Pred,
|
||||
polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <unordered_set>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _Value,
|
||||
class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
|
||||
using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
template <class _Value,
|
||||
class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
|
||||
using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */
|
47
contrib/libc++/include/experimental/vector
Normal file
47
contrib/libc++/include/experimental/vector
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- vector ------------------------------------===//
|
||||
//
|
||||
// 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_VECTOR
|
||||
#define _LIBCPP_EXPERIMENTAL_VECTOR
|
||||
/*
|
||||
experimental/vector synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T>
|
||||
using vector = std::vector<T, polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <vector>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _ValueT>
|
||||
using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */
|
@ -309,7 +309,7 @@ class __hash_map_node_destructor
|
||||
{
|
||||
typedef _Alloc allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::value_type::value_type value_type;
|
||||
typedef typename __alloc_traits::value_type::__node_value_type value_type;
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
private:
|
||||
@ -549,6 +549,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -674,7 +675,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
@ -820,6 +821,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -927,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
|
@ -282,6 +282,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -385,7 +386,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
@ -502,6 +503,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -606,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
|
@ -183,15 +183,69 @@ template <class T, class Allocator>
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, class _VoidPtr> struct __forward_list_node;
|
||||
template <class _NodePtr> struct __forward_begin_node;
|
||||
|
||||
|
||||
template <class>
|
||||
struct __forward_list_node_value_type;
|
||||
|
||||
template <class _Tp, class _VoidPtr>
|
||||
struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
|
||||
typedef _Tp type;
|
||||
};
|
||||
|
||||
template <class _NodePtr>
|
||||
struct __forward_node_traits {
|
||||
|
||||
typedef typename remove_cv<
|
||||
typename pointer_traits<_NodePtr>::element_type>::type __node;
|
||||
typedef typename __forward_list_node_value_type<__node>::type __node_value_type;
|
||||
typedef _NodePtr __node_pointer;
|
||||
typedef __forward_begin_node<_NodePtr> __begin_node;
|
||||
typedef typename __rebind_pointer<_NodePtr, __begin_node>::type
|
||||
__begin_node_pointer;
|
||||
typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
|
||||
|
||||
#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)
|
||||
typedef __begin_node_pointer __iter_node_pointer;
|
||||
#else
|
||||
typedef typename conditional<
|
||||
is_pointer<__void_pointer>::value,
|
||||
__begin_node_pointer,
|
||||
__node_pointer
|
||||
>::type __iter_node_pointer;
|
||||
#endif
|
||||
|
||||
typedef typename conditional<
|
||||
is_same<__iter_node_pointer, __node_pointer>::value,
|
||||
__begin_node_pointer,
|
||||
__node_pointer
|
||||
>::type __non_iter_node_pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
|
||||
return __p;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __iter_node_pointer __as_iter_node(__non_iter_node_pointer __p) {
|
||||
return static_cast<__iter_node_pointer>(static_cast<__void_pointer>(__p));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _NodePtr>
|
||||
struct __forward_begin_node
|
||||
{
|
||||
typedef _NodePtr pointer;
|
||||
typedef typename __rebind_pointer<_NodePtr, __forward_begin_node>::type __begin_node_pointer;
|
||||
|
||||
pointer __next_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {}
|
||||
_LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__begin_node_pointer __next_as_begin() const {
|
||||
return static_cast<__begin_node_pointer>(__next_);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp, class _VoidPtr>
|
||||
@ -211,26 +265,49 @@ struct __forward_list_node
|
||||
value_type __value_;
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY forward_list;
|
||||
template<class _NodeConstPtr> class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator;
|
||||
|
||||
template <class _NodePtr>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator
|
||||
{
|
||||
typedef _NodePtr __node_pointer;
|
||||
typedef __forward_node_traits<_NodePtr> __traits;
|
||||
typedef typename __traits::__node_pointer __node_pointer;
|
||||
typedef typename __traits::__begin_node_pointer __begin_node_pointer;
|
||||
typedef typename __traits::__iter_node_pointer __iter_node_pointer;
|
||||
typedef typename __traits::__void_pointer __void_pointer;
|
||||
|
||||
__node_pointer __ptr_;
|
||||
__iter_node_pointer __ptr_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
|
||||
__begin_node_pointer __get_begin() const {
|
||||
return static_cast<__begin_node_pointer>(
|
||||
static_cast<__void_pointer>(__ptr_));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_pointer __get_unsafe_node_pointer() const {
|
||||
return static_cast<__node_pointer>(
|
||||
static_cast<__void_pointer>(__ptr_));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT
|
||||
: __ptr_(__traits::__as_iter_node(__p)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT
|
||||
: __ptr_(__traits::__as_iter_node(__p)) {}
|
||||
|
||||
template<class, class> friend class _LIBCPP_TYPE_VIS_ONLY forward_list;
|
||||
template<class> friend class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator;
|
||||
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename pointer_traits<__node_pointer>::element_type::value_type
|
||||
value_type;
|
||||
typedef typename __traits::__node_value_type value_type;
|
||||
typedef value_type& reference;
|
||||
typedef typename pointer_traits<__node_pointer>::difference_type
|
||||
difference_type;
|
||||
@ -240,14 +317,16 @@ public:
|
||||
__forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __ptr_->__value_;}
|
||||
reference operator*() const {return __get_unsafe_node_pointer()->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
|
||||
pointer operator->() const {
|
||||
return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__value_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_iterator& operator++()
|
||||
{
|
||||
__ptr_ = __ptr_->__next_;
|
||||
__ptr_ = __traits::__as_iter_node(__ptr_->__next_);
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -271,29 +350,50 @@ public:
|
||||
template <class _NodeConstPtr>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator
|
||||
{
|
||||
typedef _NodeConstPtr __node_const_pointer;
|
||||
static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), "");
|
||||
typedef _NodeConstPtr _NodePtr;
|
||||
|
||||
__node_const_pointer __ptr_;
|
||||
typedef __forward_node_traits<_NodePtr> __traits;
|
||||
typedef typename __traits::__node __node;
|
||||
typedef typename __traits::__node_pointer __node_pointer;
|
||||
typedef typename __traits::__begin_node_pointer __begin_node_pointer;
|
||||
typedef typename __traits::__iter_node_pointer __iter_node_pointer;
|
||||
typedef typename __traits::__void_pointer __void_pointer;
|
||||
|
||||
__iter_node_pointer __ptr_;
|
||||
|
||||
__begin_node_pointer __get_begin() const {
|
||||
return static_cast<__begin_node_pointer>(
|
||||
static_cast<__void_pointer>(__ptr_));
|
||||
}
|
||||
__node_pointer __get_unsafe_node_pointer() const {
|
||||
return static_cast<__node_pointer>(
|
||||
static_cast<__void_pointer>(__ptr_));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_const_iterator(__node_const_pointer __p) _NOEXCEPT
|
||||
: __ptr_(__p) {}
|
||||
explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT
|
||||
: __ptr_(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT
|
||||
: __ptr_(__traits::__as_iter_node(__p)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT
|
||||
: __ptr_(__traits::__as_iter_node(__p)) {}
|
||||
|
||||
typedef typename remove_const
|
||||
<
|
||||
typename pointer_traits<__node_const_pointer>::element_type
|
||||
>::type __node;
|
||||
typedef typename __rebind_pointer<__node_const_pointer, __node>::type __node_pointer;
|
||||
|
||||
template<class, class> friend class forward_list;
|
||||
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename __node::value_type value_type;
|
||||
typedef typename __traits::__node_value_type value_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename pointer_traits<__node_const_pointer>::difference_type
|
||||
typedef typename pointer_traits<__node_pointer>::difference_type
|
||||
difference_type;
|
||||
typedef typename __rebind_pointer<__node_const_pointer, const value_type>::type pointer;
|
||||
typedef typename __rebind_pointer<__node_pointer, const value_type>::type
|
||||
pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
|
||||
@ -302,14 +402,15 @@ public:
|
||||
: __ptr_(__p.__ptr_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __ptr_->__value_;}
|
||||
reference operator*() const {return __get_unsafe_node_pointer()->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(
|
||||
__get_unsafe_node_pointer()->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_const_iterator& operator++()
|
||||
{
|
||||
__ptr_ = __ptr_->__next_;
|
||||
__ptr_ = __traits::__as_iter_node(__ptr_->__next_);
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -343,21 +444,21 @@ protected:
|
||||
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
|
||||
typedef allocator_traits<__node_allocator> __node_traits;
|
||||
typedef typename __node_traits::pointer __node_pointer;
|
||||
typedef typename __node_traits::pointer __node_const_pointer;
|
||||
|
||||
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __begin_node>::type __begin_node_allocator;
|
||||
typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;
|
||||
typedef typename __rebind_alloc_helper<
|
||||
allocator_traits<allocator_type>, __begin_node
|
||||
>::type __begin_node_allocator;
|
||||
typedef typename allocator_traits<__begin_node_allocator>::pointer
|
||||
__begin_node_pointer;
|
||||
|
||||
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_pointer __before_begin() _NOEXCEPT
|
||||
{return static_cast<__node_pointer>(pointer_traits<__begin_node_pointer>::
|
||||
pointer_to(__before_begin_.first()));}
|
||||
__begin_node_pointer __before_begin() _NOEXCEPT
|
||||
{return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_.first());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_const_pointer __before_begin() const _NOEXCEPT
|
||||
{return static_cast<__node_const_pointer>(pointer_traits<__begin_node_pointer>::
|
||||
pointer_to(const_cast<__begin_node&>(__before_begin_.first())));}
|
||||
__begin_node_pointer __before_begin() const _NOEXCEPT
|
||||
{return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_.first()));}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_allocator& __alloc() _NOEXCEPT
|
||||
@ -379,8 +480,10 @@ protected:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_base(__forward_list_base&& __x)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
@ -405,6 +508,7 @@ protected:
|
||||
__node_traits::propagate_on_container_move_assignment::value>());}
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(__forward_list_base& __x)
|
||||
#if _LIBCPP_STD_VER >= 14
|
||||
_NOEXCEPT;
|
||||
@ -438,7 +542,7 @@ private:
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
__forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
|
||||
: __before_begin_(_VSTD::move(__x.__before_begin_))
|
||||
@ -447,7 +551,7 @@ __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
__forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x,
|
||||
const allocator_type& __a)
|
||||
: __before_begin_(__begin_node(), __node_allocator(__a))
|
||||
@ -468,7 +572,7 @@ __forward_list_base<_Tp, _Alloc>::~__forward_list_base()
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
__forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
|
||||
#if _LIBCPP_STD_VER >= 14
|
||||
@ -505,9 +609,10 @@ class _LIBCPP_TYPE_VIS_ONLY forward_list
|
||||
{
|
||||
typedef __forward_list_base<_Tp, _Alloc> base;
|
||||
typedef typename base::__node_allocator __node_allocator;
|
||||
typedef typename base::__node __node;
|
||||
typedef typename base::__node_traits __node_traits;
|
||||
typedef typename base::__node_pointer __node_pointer;
|
||||
typedef typename base::__node __node;
|
||||
typedef typename base::__node_traits __node_traits;
|
||||
typedef typename base::__node_pointer __node_pointer;
|
||||
typedef typename base::__begin_node_pointer __begin_node_pointer;
|
||||
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
@ -530,6 +635,7 @@ public:
|
||||
forward_list()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
|
||||
{} // = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit forward_list(const allocator_type& __a);
|
||||
explicit forward_list(size_type __n);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
@ -566,12 +672,14 @@ public:
|
||||
|
||||
forward_list& operator=(const forward_list& __x);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
forward_list& operator=(forward_list&& __x)
|
||||
_NOEXCEPT_(
|
||||
__node_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value);
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
forward_list& operator=(initializer_list<value_type> __il);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
@ -584,6 +692,7 @@ public:
|
||||
assign(_InputIterator __f, _InputIterator __l);
|
||||
void assign(size_type __n, const value_type& __v);
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void assign(initializer_list<value_type> __il);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
@ -714,7 +823,7 @@ public:
|
||||
template <class _Compare> void merge(forward_list& __x, _Compare __comp);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void sort() {sort(__less<value_type>());}
|
||||
template <class _Compare> void sort(_Compare __comp);
|
||||
template <class _Compare> _LIBCPP_INLINE_VISIBILITY void sort(_Compare __comp);
|
||||
void reverse() _NOEXCEPT;
|
||||
|
||||
private:
|
||||
@ -737,7 +846,7 @@ private:
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a)
|
||||
: base(__a)
|
||||
{
|
||||
@ -751,8 +860,8 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n)
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
|
||||
for (__node_pointer __p = base::__before_begin(); __n > 0; --__n,
|
||||
__p = __p->__next_)
|
||||
for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n,
|
||||
__p = __p->__next_as_begin())
|
||||
{
|
||||
__h.reset(__node_traits::allocate(__a, 1));
|
||||
__node_traits::construct(__a, _VSTD::addressof(__h->__value_));
|
||||
@ -772,8 +881,8 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
|
||||
for (__node_pointer __p = base::__before_begin(); __n > 0; --__n,
|
||||
__p = __p->__next_)
|
||||
for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n,
|
||||
__p = __p->__next_as_begin())
|
||||
{
|
||||
__h.reset(__node_traits::allocate(__a, 1));
|
||||
__node_traits::construct(__a, _VSTD::addressof(__h->__value_));
|
||||
@ -911,7 +1020,7 @@ forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
forward_list<_Tp, _Alloc>&
|
||||
forward_list<_Tp, _Alloc>::operator=(forward_list&& __x)
|
||||
_NOEXCEPT_(
|
||||
@ -928,7 +1037,7 @@ forward_list<_Tp, _Alloc>::operator=(forward_list&& __x)
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
forward_list<_Tp, _Alloc>&
|
||||
forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
|
||||
{
|
||||
@ -976,7 +1085,7 @@ forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v)
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
|
||||
{
|
||||
@ -1049,7 +1158,7 @@ template <class... _Args>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args)
|
||||
{
|
||||
__node_pointer const __r = __p.__ptr_;
|
||||
__begin_node_pointer const __r = __p.__get_begin();
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
|
||||
@ -1066,7 +1175,7 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v)
|
||||
{
|
||||
__node_pointer const __r = __p.__ptr_;
|
||||
__begin_node_pointer const __r = __p.__get_begin();
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
|
||||
@ -1082,7 +1191,7 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v)
|
||||
{
|
||||
__node_pointer const __r = __p.__ptr_;
|
||||
__begin_node_pointer const __r = __p.__get_begin();
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
|
||||
@ -1097,7 +1206,7 @@ typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
|
||||
const value_type& __v)
|
||||
{
|
||||
__node_pointer __r = __p.__ptr_;
|
||||
__begin_node_pointer __r = __p.__get_begin();
|
||||
if (__n > 0)
|
||||
{
|
||||
__node_allocator& __a = base::__alloc();
|
||||
@ -1132,7 +1241,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__last->__next_ = __r->__next_;
|
||||
__r->__next_ = __first;
|
||||
__r = __last;
|
||||
__r = static_cast<__begin_node_pointer>(__last);
|
||||
}
|
||||
return iterator(__r);
|
||||
}
|
||||
@ -1147,7 +1256,7 @@ typename enable_if
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
|
||||
_InputIterator __f, _InputIterator __l)
|
||||
{
|
||||
__node_pointer __r = __p.__ptr_;
|
||||
__begin_node_pointer __r = __p.__get_begin();
|
||||
if (__f != __l)
|
||||
{
|
||||
__node_allocator& __a = base::__alloc();
|
||||
@ -1182,7 +1291,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__last->__next_ = __r->__next_;
|
||||
__r->__next_ = __first;
|
||||
__r = __last;
|
||||
__r = static_cast<__begin_node_pointer>(__last);
|
||||
}
|
||||
return iterator(__r);
|
||||
}
|
||||
@ -1191,7 +1300,7 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::erase_after(const_iterator __f)
|
||||
{
|
||||
__node_pointer __p = __f.__ptr_;
|
||||
__begin_node_pointer __p = __f.__get_begin();
|
||||
__node_pointer __n = __p->__next_;
|
||||
__p->__next_ = __n->__next_;
|
||||
__node_allocator& __a = base::__alloc();
|
||||
@ -1204,21 +1313,22 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l)
|
||||
{
|
||||
__node_pointer __e = __l.__ptr_;
|
||||
__node_pointer __e = __l.__get_unsafe_node_pointer();
|
||||
if (__f != __l)
|
||||
{
|
||||
__node_pointer __p = __f.__ptr_;
|
||||
__node_pointer __n = __p->__next_;
|
||||
__begin_node_pointer __bp = __f.__get_begin();
|
||||
|
||||
__node_pointer __n = __bp->__next_;
|
||||
if (__n != __e)
|
||||
{
|
||||
__p->__next_ = __e;
|
||||
__bp->__next_ = __e;
|
||||
__node_allocator& __a = base::__alloc();
|
||||
do
|
||||
{
|
||||
__p = __n->__next_;
|
||||
__node_pointer __tmp = __n->__next_;
|
||||
__node_traits::destroy(__a, _VSTD::addressof(__n->__value_));
|
||||
__node_traits::deallocate(__a, __n, 1);
|
||||
__n = __p;
|
||||
__n = __tmp;
|
||||
} while (__n != __e);
|
||||
}
|
||||
}
|
||||
@ -1245,8 +1355,8 @@ forward_list<_Tp, _Alloc>::resize(size_type __n)
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
|
||||
for (__node_pointer __ptr = __p.__ptr_; __n > 0; --__n,
|
||||
__ptr = __ptr->__next_)
|
||||
for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n,
|
||||
__ptr = __ptr->__next_as_begin())
|
||||
{
|
||||
__h.reset(__node_traits::allocate(__a, 1));
|
||||
__node_traits::construct(__a, _VSTD::addressof(__h->__value_));
|
||||
@ -1277,8 +1387,8 @@ forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v)
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
|
||||
for (__node_pointer __ptr = __p.__ptr_; __n > 0; --__n,
|
||||
__ptr = __ptr->__next_)
|
||||
for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n,
|
||||
__ptr = __ptr->__next_as_begin())
|
||||
{
|
||||
__h.reset(__node_traits::allocate(__a, 1));
|
||||
__node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
|
||||
@ -1296,14 +1406,14 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
|
||||
{
|
||||
if (!__x.empty())
|
||||
{
|
||||
if (__p.__ptr_->__next_ != nullptr)
|
||||
if (__p.__get_begin()->__next_ != nullptr)
|
||||
{
|
||||
const_iterator __lm1 = __x.before_begin();
|
||||
while (__lm1.__ptr_->__next_ != nullptr)
|
||||
while (__lm1.__get_begin()->__next_ != nullptr)
|
||||
++__lm1;
|
||||
__lm1.__ptr_->__next_ = __p.__ptr_->__next_;
|
||||
__lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
|
||||
}
|
||||
__p.__ptr_->__next_ = __x.__before_begin()->__next_;
|
||||
__p.__get_begin()->__next_ = __x.__before_begin()->__next_;
|
||||
__x.__before_begin()->__next_ = nullptr;
|
||||
}
|
||||
}
|
||||
@ -1317,9 +1427,9 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
|
||||
const_iterator __lm1 = _VSTD::next(__i);
|
||||
if (__p != __i && __p != __lm1)
|
||||
{
|
||||
__i.__ptr_->__next_ = __lm1.__ptr_->__next_;
|
||||
__lm1.__ptr_->__next_ = __p.__ptr_->__next_;
|
||||
__p.__ptr_->__next_ = __lm1.__ptr_;
|
||||
__i.__get_begin()->__next_ = __lm1.__get_begin()->__next_;
|
||||
__lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
|
||||
__p.__get_begin()->__next_ = __lm1.__get_unsafe_node_pointer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1332,13 +1442,13 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
|
||||
if (__f != __l && __p != __f)
|
||||
{
|
||||
const_iterator __lm1 = __f;
|
||||
while (__lm1.__ptr_->__next_ != __l.__ptr_)
|
||||
while (__lm1.__get_begin()->__next_ != __l.__get_begin())
|
||||
++__lm1;
|
||||
if (__f != __lm1)
|
||||
{
|
||||
__lm1.__ptr_->__next_ = __p.__ptr_->__next_;
|
||||
__p.__ptr_->__next_ = __f.__ptr_->__next_;
|
||||
__f.__ptr_->__next_ = __l.__ptr_;
|
||||
__lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;
|
||||
__p.__get_begin()->__next_ = __f.__get_begin()->__next_;
|
||||
__f.__get_begin()->__next_ = __l.__get_unsafe_node_pointer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1382,9 +1492,9 @@ 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;)
|
||||
for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
|
||||
{
|
||||
if (__i.__ptr_->__next_->__value_ == __v)
|
||||
if (__i.__get_begin()->__next_->__value_ == __v)
|
||||
{
|
||||
iterator __j = _VSTD::next(__i, 2);
|
||||
for (; __j != __e && *__j == __v; ++__j)
|
||||
@ -1405,9 +1515,9 @@ void
|
||||
forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
|
||||
{
|
||||
iterator __e = end();
|
||||
for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
|
||||
for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
|
||||
{
|
||||
if (__pred(__i.__ptr_->__next_->__value_))
|
||||
if (__pred(__i.__get_begin()->__next_->__value_))
|
||||
{
|
||||
iterator __j = _VSTD::next(__i, 2);
|
||||
for (; __j != __e && __pred(*__j); ++__j)
|
||||
@ -1432,7 +1542,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
|
||||
iterator __j = _VSTD::next(__i);
|
||||
for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
|
||||
;
|
||||
if (__i.__ptr_->__next_ != __j.__ptr_)
|
||||
if (__i.__get_begin()->__next_ != __j.__get_unsafe_node_pointer())
|
||||
erase_after(__i, __j);
|
||||
__i = __j;
|
||||
}
|
||||
@ -1499,7 +1609,7 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2,
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
template <class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
forward_list<_Tp, _Alloc>::sort(_Compare __comp)
|
||||
{
|
||||
@ -1530,7 +1640,7 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz,
|
||||
}
|
||||
difference_type __sz1 = __sz / 2;
|
||||
difference_type __sz2 = __sz - __sz1;
|
||||
__node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__ptr_;
|
||||
__node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__get_unsafe_node_pointer();
|
||||
__node_pointer __f2 = __t->__next_;
|
||||
__t->__next_ = nullptr;
|
||||
return __merge(__sort(__f1, __sz1, __comp),
|
||||
|
@ -200,14 +200,17 @@ public:
|
||||
|
||||
// 27.9.1.3 Assign/swap:
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf& operator=(basic_filebuf&& __rhs);
|
||||
#endif
|
||||
void swap(basic_filebuf& __rhs);
|
||||
|
||||
// 27.9.1.4 Members:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
basic_filebuf* open(const char* __s, ios_base::openmode __mode);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
|
||||
#endif
|
||||
basic_filebuf* close();
|
||||
@ -340,7 +343,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_filebuf<_CharT, _Traits>&
|
||||
basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
|
||||
{
|
||||
@ -458,7 +461,7 @@ swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
bool
|
||||
basic_filebuf<_CharT, _Traits>::is_open() const
|
||||
{
|
||||
@ -547,7 +550,7 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
{
|
||||
@ -603,7 +606,9 @@ basic_filebuf<_CharT, _Traits>::underflow()
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
|
||||
_LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
|
||||
if (__extbufend_ != __extbufnext_)
|
||||
memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
|
||||
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
|
||||
__extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
|
||||
size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
|
||||
@ -1008,26 +1013,35 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ifstream();
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ifstream(basic_ifstream&& __rhs);
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ifstream& operator=(basic_ifstream&& __rhs);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_ifstream& __rhs);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf<char_type, traits_type>* rdbuf() const;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::in);
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close();
|
||||
|
||||
private:
|
||||
@ -1035,7 +1049,7 @@ private:
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream()
|
||||
: basic_istream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1043,7 +1057,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream()
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
|
||||
: basic_istream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1052,7 +1066,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openm
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
|
||||
: basic_istream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1064,7 +1078,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::ope
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
|
||||
: basic_istream<char_type, traits_type>(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
@ -1073,7 +1087,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>&
|
||||
basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
|
||||
{
|
||||
@ -1085,7 +1099,7 @@ basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
basic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs)
|
||||
{
|
||||
@ -1102,7 +1116,7 @@ swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_ifstream<_CharT, _Traits>::rdbuf() const
|
||||
{
|
||||
@ -1110,7 +1124,7 @@ basic_ifstream<_CharT, _Traits>::rdbuf() const
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
bool
|
||||
basic_ifstream<_CharT, _Traits>::is_open() const
|
||||
{
|
||||
@ -1140,7 +1154,7 @@ basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
basic_ifstream<_CharT, _Traits>::close()
|
||||
{
|
||||
@ -1161,24 +1175,33 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ofstream();
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ofstream(basic_ofstream&& __rhs);
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ofstream& operator=(basic_ofstream&& __rhs);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_ofstream& __rhs);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf<char_type, traits_type>* rdbuf() const;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::out);
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close();
|
||||
|
||||
private:
|
||||
@ -1186,7 +1209,7 @@ private:
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream()
|
||||
: basic_ostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1194,7 +1217,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream()
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
|
||||
: basic_ostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1203,7 +1226,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openm
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
|
||||
: basic_ostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1215,7 +1238,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::ope
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
|
||||
: basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
@ -1224,7 +1247,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>&
|
||||
basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
|
||||
{
|
||||
@ -1236,7 +1259,7 @@ basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
basic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs)
|
||||
{
|
||||
@ -1253,7 +1276,7 @@ swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_ofstream<_CharT, _Traits>::rdbuf() const
|
||||
{
|
||||
@ -1261,7 +1284,7 @@ basic_ofstream<_CharT, _Traits>::rdbuf() const
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
bool
|
||||
basic_ofstream<_CharT, _Traits>::is_open() const
|
||||
{
|
||||
@ -1291,7 +1314,7 @@ basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
basic_ofstream<_CharT, _Traits>::close()
|
||||
{
|
||||
@ -1312,26 +1335,35 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_fstream();
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_fstream(basic_fstream&& __rhs);
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_fstream& operator=(basic_fstream&& __rhs);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_fstream& __rhs);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf<char_type, traits_type>* rdbuf() const;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close();
|
||||
|
||||
private:
|
||||
@ -1339,7 +1371,7 @@ private:
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream()
|
||||
: basic_iostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1347,7 +1379,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream()
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
|
||||
: basic_iostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1356,7 +1388,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmod
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
|
||||
: basic_iostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
@ -1368,7 +1400,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openm
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
|
||||
: basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
@ -1377,7 +1409,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>&
|
||||
basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
|
||||
{
|
||||
@ -1389,7 +1421,7 @@ basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
basic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs)
|
||||
{
|
||||
@ -1406,7 +1438,7 @@ swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_fstream<_CharT, _Traits>::rdbuf() const
|
||||
{
|
||||
@ -1414,7 +1446,7 @@ basic_fstream<_CharT, _Traits>::rdbuf() const
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
bool
|
||||
basic_fstream<_CharT, _Traits>::is_open() const
|
||||
{
|
||||
@ -1444,7 +1476,7 @@ basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
basic_fstream<_CharT, _Traits>::close()
|
||||
{
|
||||
|
@ -207,6 +207,8 @@ public:
|
||||
|
||||
template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
|
||||
|
||||
template <class F> unspecified not_fn(F&& f); // C++17
|
||||
|
||||
template<class T> struct is_bind_expression;
|
||||
template<class T> struct is_placeholder;
|
||||
|
||||
@ -407,7 +409,7 @@ public:
|
||||
// function modifiers:
|
||||
void swap(function&) noexcept;
|
||||
template<class F, class Alloc>
|
||||
void assign(F&&, const Alloc&);
|
||||
void assign(F&&, const Alloc&); // Removed in C++17
|
||||
|
||||
// function capacity:
|
||||
explicit operator bool() const noexcept;
|
||||
@ -1564,6 +1566,10 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
|
||||
typename aligned_storage<3*sizeof(void*)>::type __buf_;
|
||||
__base* __f_;
|
||||
|
||||
_LIBCPP_NO_CFI static __base *__as_base(void *p) {
|
||||
return reinterpret_cast<__base*>(p);
|
||||
}
|
||||
|
||||
template <class _Fp, bool = !is_same<_Fp, function>::value &&
|
||||
__invokable<_Fp&, _ArgTypes...>::value>
|
||||
struct __callable;
|
||||
@ -1626,10 +1632,13 @@ public:
|
||||
|
||||
// function modifiers:
|
||||
void swap(function&) _NOEXCEPT;
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14
|
||||
template<class _Fp, class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void assign(_Fp&& __f, const _Alloc& __a)
|
||||
{function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
|
||||
#endif
|
||||
|
||||
// function capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1657,9 +1666,9 @@ function<_Rp(_ArgTypes...)>::function(const function& __f)
|
||||
{
|
||||
if (__f.__f_ == 0)
|
||||
__f_ = 0;
|
||||
else if (__f.__f_ == (const __base*)&__f.__buf_)
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
__f_ = __as_base(&__buf_);
|
||||
__f.__f_->__clone(__f_);
|
||||
}
|
||||
else
|
||||
@ -1673,9 +1682,9 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
|
||||
{
|
||||
if (__f.__f_ == 0)
|
||||
__f_ = 0;
|
||||
else if (__f.__f_ == (const __base*)&__f.__buf_)
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
__f_ = __as_base(&__buf_);
|
||||
__f.__f_->__clone(__f_);
|
||||
}
|
||||
else
|
||||
@ -1687,9 +1696,9 @@ function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
|
||||
{
|
||||
if (__f.__f_ == 0)
|
||||
__f_ = 0;
|
||||
else if (__f.__f_ == (__base*)&__f.__buf_)
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
__f_ = __as_base(&__buf_);
|
||||
__f.__f_->__clone(__f_);
|
||||
}
|
||||
else
|
||||
@ -1706,9 +1715,9 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
|
||||
{
|
||||
if (__f.__f_ == 0)
|
||||
__f_ = 0;
|
||||
else if (__f.__f_ == (__base*)&__f.__buf_)
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
__f_ = __as_base(&__buf_);
|
||||
__f.__f_->__clone(__f_);
|
||||
}
|
||||
else
|
||||
@ -1733,8 +1742,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f,
|
||||
typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
|
||||
if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
::new (__f_) _FF(_VSTD::move(__f));
|
||||
__f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1763,8 +1771,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
|
||||
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), _Alloc(__a));
|
||||
__f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1788,16 +1795,16 @@ template<class _Rp, class ..._ArgTypes>
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
if ((void *)__f_ == &__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__f_ = 0;
|
||||
if (__f.__f_ == 0)
|
||||
__f_ = 0;
|
||||
else if (__f.__f_ == (__base*)&__f.__buf_)
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
__f_ = (__base*)&__buf_;
|
||||
__f_ = __as_base(&__buf_);
|
||||
__f.__f_->__clone(__f_);
|
||||
}
|
||||
else
|
||||
@ -1812,7 +1819,7 @@ template<class _Rp, class ..._ArgTypes>
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
if ((void *)__f_ == &__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
@ -1837,7 +1844,7 @@ function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
|
||||
template<class _Rp, class ..._ArgTypes>
|
||||
function<_Rp(_ArgTypes...)>::~function()
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
if ((void *)__f_ == &__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
@ -1847,34 +1854,34 @@ template<class _Rp, class ..._ArgTypes>
|
||||
void
|
||||
function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
|
||||
if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
|
||||
__base* __t = (__base*)&__tempbuf;
|
||||
__base* __t = __as_base(&__tempbuf);
|
||||
__f_->__clone(__t);
|
||||
__f_->destroy();
|
||||
__f_ = 0;
|
||||
__f.__f_->__clone((__base*)&__buf_);
|
||||
__f.__f_->__clone(__as_base(&__buf_));
|
||||
__f.__f_->destroy();
|
||||
__f.__f_ = 0;
|
||||
__f_ = (__base*)&__buf_;
|
||||
__t->__clone((__base*)&__f.__buf_);
|
||||
__f_ = __as_base(&__buf_);
|
||||
__t->__clone(__as_base(&__f.__buf_));
|
||||
__t->destroy();
|
||||
__f.__f_ = (__base*)&__f.__buf_;
|
||||
__f.__f_ = __as_base(&__f.__buf_);
|
||||
}
|
||||
else if (__f_ == (__base*)&__buf_)
|
||||
else if ((void *)__f_ == &__buf_)
|
||||
{
|
||||
__f_->__clone((__base*)&__f.__buf_);
|
||||
__f_->__clone(__as_base(&__f.__buf_));
|
||||
__f_->destroy();
|
||||
__f_ = __f.__f_;
|
||||
__f.__f_ = (__base*)&__f.__buf_;
|
||||
__f.__f_ = __as_base(&__f.__buf_);
|
||||
}
|
||||
else if (__f.__f_ == (__base*)&__f.__buf_)
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
{
|
||||
__f.__f_->__clone((__base*)&__buf_);
|
||||
__f.__f_->__clone(__as_base(&__buf_));
|
||||
__f.__f_->destroy();
|
||||
__f.__f_ = __f_;
|
||||
__f_ = (__base*)&__buf_;
|
||||
__f_ = __as_base(&__buf_);
|
||||
}
|
||||
else
|
||||
_VSTD::swap(__f_, __f.__f_);
|
||||
@ -1973,16 +1980,29 @@ namespace placeholders
|
||||
|
||||
template <int _Np> struct __ph {};
|
||||
|
||||
_LIBCPP_FUNC_VIS extern __ph<1> _1;
|
||||
_LIBCPP_FUNC_VIS extern __ph<2> _2;
|
||||
_LIBCPP_FUNC_VIS extern __ph<3> _3;
|
||||
_LIBCPP_FUNC_VIS extern __ph<4> _4;
|
||||
_LIBCPP_FUNC_VIS extern __ph<5> _5;
|
||||
_LIBCPP_FUNC_VIS extern __ph<6> _6;
|
||||
_LIBCPP_FUNC_VIS extern __ph<7> _7;
|
||||
_LIBCPP_FUNC_VIS extern __ph<8> _8;
|
||||
_LIBCPP_FUNC_VIS extern __ph<9> _9;
|
||||
_LIBCPP_FUNC_VIS extern __ph<10> _10;
|
||||
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
|
||||
_LIBCPP_FUNC_VIS extern const __ph<1> _1;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<2> _2;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<3> _3;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<4> _4;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<5> _5;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<6> _6;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<7> _7;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<8> _8;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<9> _9;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<10> _10;
|
||||
#else
|
||||
constexpr __ph<1> _1{};
|
||||
constexpr __ph<2> _2{};
|
||||
constexpr __ph<3> _3{};
|
||||
constexpr __ph<4> _4{};
|
||||
constexpr __ph<5> _5{};
|
||||
constexpr __ph<6> _6{};
|
||||
constexpr __ph<7> _7{};
|
||||
constexpr __ph<8> _8{};
|
||||
constexpr __ph<9> _9{};
|
||||
constexpr __ph<10> _10{};
|
||||
#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
|
||||
|
||||
} // placeholders
|
||||
|
||||
@ -2468,6 +2488,22 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
|
||||
{
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_INT128
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY hash<__int128_t>
|
||||
: public __scalar_hash<__int128_t>
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY hash<__uint128_t>
|
||||
: public __scalar_hash<__uint128_t>
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY hash<float>
|
||||
: public __scalar_hash<float>
|
||||
@ -2564,11 +2600,69 @@ struct _LIBCPP_TYPE_VIS_ONLY hash
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
template <class _Fn, class ..._Args>
|
||||
result_of_t<_Fn&&(_Args&&...)>
|
||||
invoke(_Fn&& __f, _Args&&... __args) {
|
||||
return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
|
||||
invoke(_Fn&& __f, _Args&&... __args)
|
||||
noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...)))
|
||||
{
|
||||
return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _DecayFunc>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __not_fn_imp {
|
||||
_DecayFunc __fd;
|
||||
|
||||
public:
|
||||
__not_fn_imp() = delete;
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_Args&& ...__args) &
|
||||
noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
|
||||
-> decltype(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
|
||||
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_Args&& ...__args) &&
|
||||
noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
|
||||
-> decltype(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
|
||||
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_Args&& ...__args) const&
|
||||
noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
|
||||
-> decltype(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
|
||||
{ return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
|
||||
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_Args&& ...__args) const&&
|
||||
noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
|
||||
-> decltype(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
|
||||
{ return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
|
||||
|
||||
private:
|
||||
template <class _RawFunc,
|
||||
class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __not_fn_imp(_RawFunc&& __rf)
|
||||
: __fd(_VSTD::forward<_RawFunc>(__rf)) {}
|
||||
|
||||
template <class _RawFunc>
|
||||
friend inline _LIBCPP_INLINE_VISIBILITY
|
||||
__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&);
|
||||
};
|
||||
|
||||
template <class _RawFunc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
|
||||
return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// struct hash<T*> in <memory>
|
||||
|
@ -322,7 +322,7 @@ template <class R, class... ArgTypes>
|
||||
class packaged_task<R(ArgTypes...)>
|
||||
{
|
||||
public:
|
||||
typedef R result_type;
|
||||
typedef R result_type; // extension
|
||||
|
||||
// construction and destruction
|
||||
packaged_task() noexcept;
|
||||
@ -1482,6 +1482,7 @@ template <class _Rp>
|
||||
void
|
||||
promise<_Rp>::set_exception(exception_ptr __p)
|
||||
{
|
||||
_LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" );
|
||||
if (__state_ == nullptr)
|
||||
__throw_future_error(future_errc::no_state);
|
||||
__state_->set_exception(__p);
|
||||
@ -1513,6 +1514,7 @@ template <class _Rp>
|
||||
void
|
||||
promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
|
||||
{
|
||||
_LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" );
|
||||
if (__state_ == nullptr)
|
||||
__throw_future_error(future_errc::no_state);
|
||||
__state_->set_exception_at_thread_exit(__p);
|
||||
@ -1629,6 +1631,7 @@ template <class _Rp>
|
||||
void
|
||||
promise<_Rp&>::set_exception(exception_ptr __p)
|
||||
{
|
||||
_LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" );
|
||||
if (__state_ == nullptr)
|
||||
__throw_future_error(future_errc::no_state);
|
||||
__state_->set_exception(__p);
|
||||
@ -1647,6 +1650,7 @@ template <class _Rp>
|
||||
void
|
||||
promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p)
|
||||
{
|
||||
_LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" );
|
||||
if (__state_ == nullptr)
|
||||
__throw_future_error(future_errc::no_state);
|
||||
__state_->set_exception_at_thread_exit(__p);
|
||||
@ -1994,7 +1998,7 @@ template<class _Rp, class ..._ArgTypes>
|
||||
class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)>
|
||||
{
|
||||
public:
|
||||
typedef _Rp result_type;
|
||||
typedef _Rp result_type; // extension
|
||||
|
||||
private:
|
||||
__packaged_task_function<result_type(_ArgTypes...)> __f_;
|
||||
@ -2123,7 +2127,7 @@ template<class ..._ArgTypes>
|
||||
class _LIBCPP_TYPE_VIS_ONLY packaged_task<void(_ArgTypes...)>
|
||||
{
|
||||
public:
|
||||
typedef void result_type;
|
||||
typedef void result_type; // extension
|
||||
|
||||
private:
|
||||
__packaged_task_function<result_type(_ArgTypes...)> __f_;
|
||||
|
@ -512,8 +512,6 @@ put_time(const tm* __tm, const _CharT* __fmt)
|
||||
return __iom_t10<_CharT>(__tm, __fmt);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
template <class _CharT, class _Traits, class _ForwardIterator>
|
||||
std::basic_ostream<_CharT, _Traits> &
|
||||
__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
|
||||
@ -569,7 +567,7 @@ __quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _Char
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Iter, class _Traits=char_traits<_CharT>>
|
||||
template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
|
||||
struct __quoted_output_proxy
|
||||
{
|
||||
_Iter __first;
|
||||
@ -631,21 +629,42 @@ quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_Char
|
||||
return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
__quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT,
|
||||
typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
( __s.cbegin(), __s.cend (), __delim, __escape );
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_proxy<_CharT, _Traits, _Allocator>
|
||||
__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
|
||||
}
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT,
|
||||
typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
( __s.cbegin(), __s.cend (), __delim, __escape );
|
||||
return __quoted(__s, __delim, __escape);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_proxy<_CharT, _Traits, _Allocator>
|
||||
quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
|
||||
return __quoted(__s, __delim, __escape);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -231,7 +231,7 @@ typedef ptrdiff_t streamsize;
|
||||
class _LIBCPP_TYPE_VIS ios_base
|
||||
{
|
||||
public:
|
||||
class _LIBCPP_TYPE_VIS failure;
|
||||
class _LIBCPP_EXCEPTION_ABI failure;
|
||||
|
||||
typedef unsigned int fmtflags;
|
||||
static const fmtflags boolalpha = 0x0001;
|
||||
|
@ -194,6 +194,11 @@ template <class _CharT, // for <stdexcept>
|
||||
typedef basic_string<char, char_traits<char>, allocator<char> > string;
|
||||
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
|
||||
|
||||
|
||||
// Include other forward declarations here
|
||||
template <class _Tp, class _Alloc = allocator<_Tp> >
|
||||
class _LIBCPP_TYPE_VIS_ONLY vector;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_IOSFWD
|
||||
|
@ -1251,18 +1251,35 @@ streamsize
|
||||
basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
|
||||
{
|
||||
__gc_ = 0;
|
||||
streamsize __c = this->rdbuf()->in_avail();
|
||||
switch (__c)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
case -1:
|
||||
this->setstate(ios_base::eofbit);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
read(__s, _VSTD::min(__c, __n));
|
||||
break;
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __sen(*this, true);
|
||||
if (__sen)
|
||||
{
|
||||
streamsize __c = this->rdbuf()->in_avail();
|
||||
switch (__c)
|
||||
{
|
||||
case -1:
|
||||
this->setstate(ios_base::eofbit);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
read(__s, _VSTD::min(__c, __n));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __gc_;
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,9 @@ bool
|
||||
operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
typename reverse_iterator<Iterator1>::difference_type
|
||||
operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
|
||||
auto
|
||||
operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y)
|
||||
-> decltype(__y.base() - __x.base());
|
||||
|
||||
template <class Iterator>
|
||||
reverse_iterator<Iterator>
|
||||
@ -149,7 +150,7 @@ public:
|
||||
typedef Container container_type;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef back_insert_iterator<Cont>& reference;
|
||||
typedef void reference;
|
||||
typedef void pointer;
|
||||
|
||||
explicit back_insert_iterator(Container& x);
|
||||
@ -170,7 +171,7 @@ public:
|
||||
typedef Container container_type;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef front_insert_iterator<Cont>& reference;
|
||||
typedef void reference;
|
||||
typedef void pointer;
|
||||
|
||||
explicit front_insert_iterator(Container& x);
|
||||
@ -192,7 +193,7 @@ public:
|
||||
typedef Container container_type;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef insert_iterator<Cont>& reference;
|
||||
typedef void reference;
|
||||
typedef void pointer;
|
||||
|
||||
insert_iterator(Container& x, typename Container::iterator i);
|
||||
@ -205,6 +206,73 @@ public:
|
||||
template <class Container, class Iterator>
|
||||
insert_iterator<Container> inserter(Container& x, Iterator i);
|
||||
|
||||
template <class Iterator>
|
||||
class move_iterator {
|
||||
public:
|
||||
typedef Iterator iterator_type;
|
||||
typedef typename iterator_traits<Iterator>::difference_type difference_type;
|
||||
typedef Iterator pointer;
|
||||
typedef typename iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
|
||||
typedef value_type&& reference;
|
||||
|
||||
move_iterator();
|
||||
explicit move_iterator(Iterator i);
|
||||
template <class U> move_iterator(const move_iterator<U>& u);
|
||||
template <class U> move_iterator& operator=(const move_iterator<U>& u);
|
||||
iterator_type base() const;
|
||||
reference operator*() const;
|
||||
pointer operator->() const;
|
||||
move_iterator& operator++();
|
||||
move_iterator operator++(int);
|
||||
move_iterator& operator--();
|
||||
move_iterator operator--(int);
|
||||
move_iterator operator+(difference_type n) const;
|
||||
move_iterator& operator+=(difference_type n);
|
||||
move_iterator operator-(difference_type n) const;
|
||||
move_iterator& operator-=(difference_type n);
|
||||
unspecified operator[](difference_type n) const;
|
||||
private:
|
||||
Iterator current; // exposition only
|
||||
};
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool
|
||||
operator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool
|
||||
operator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool
|
||||
operator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool
|
||||
operator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool
|
||||
operator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool
|
||||
operator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
auto
|
||||
operator-(const move_iterator<Iterator1>& x,
|
||||
const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
|
||||
|
||||
template <class Iterator>
|
||||
move_iterator<Iterator> operator+(typename move_iterator<Iterator>::difference_type n,
|
||||
const move_iterator<Iterator>& x);
|
||||
|
||||
template <class Iterator>
|
||||
move_iterator<Iterator> make_move_iterator(const Iterator& i);
|
||||
|
||||
|
||||
template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>
|
||||
class istream_iterator
|
||||
: public iterator<input_iterator_tag, T, Distance, const T*, const T&>
|
||||
@ -340,10 +408,10 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <iosfwd> // for forward declarations of vector and string.
|
||||
#include <__functional_base>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
#include <iosfwd>
|
||||
#include <initializer_list>
|
||||
#ifdef __APPLE__
|
||||
#include <Availability.h>
|
||||
@ -632,6 +700,16 @@ operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
|
||||
return __x.base() >= __y.base();
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
|
||||
-> decltype(__y.base() - __x.base())
|
||||
{
|
||||
return __y.base() - __x.base();
|
||||
}
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename reverse_iterator<_Iter1>::difference_type
|
||||
@ -639,6 +717,7 @@ operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
|
||||
{
|
||||
return __y.base() - __x.base();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Iter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -663,7 +742,7 @@ class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator
|
||||
void,
|
||||
void,
|
||||
void,
|
||||
back_insert_iterator<_Container>&>
|
||||
void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
@ -696,7 +775,7 @@ class _LIBCPP_TYPE_VIS_ONLY front_insert_iterator
|
||||
void,
|
||||
void,
|
||||
void,
|
||||
front_insert_iterator<_Container>&>
|
||||
void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
@ -729,7 +808,7 @@ class _LIBCPP_TYPE_VIS_ONLY insert_iterator
|
||||
void,
|
||||
void,
|
||||
void,
|
||||
insert_iterator<_Container>&>
|
||||
void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
@ -772,14 +851,14 @@ private:
|
||||
_Tp __value_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(&__s)
|
||||
_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
|
||||
{
|
||||
if (!(*__in_stream_ >> __value_))
|
||||
__in_stream_ = 0;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return &(operator*());}
|
||||
_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));}
|
||||
_LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
|
||||
{
|
||||
if (!(*__in_stream_ >> __value_))
|
||||
@ -811,9 +890,9 @@ private:
|
||||
const char_type* __delim_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
|
||||
: __out_stream_(&__s), __delim_(0) {}
|
||||
: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter)
|
||||
: __out_stream_(&__s), __delim_(__delimiter) {}
|
||||
: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
|
||||
_LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
|
||||
{
|
||||
*__out_stream_ << __value_;
|
||||
@ -949,9 +1028,14 @@ public:
|
||||
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
|
||||
typedef typename iterator_traits<iterator_type>::value_type value_type;
|
||||
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
|
||||
typedef typename iterator_traits<iterator_type>::pointer pointer;
|
||||
typedef iterator_type pointer;
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
typedef value_type&& reference;
|
||||
typedef typename iterator_traits<iterator_type>::reference __reference;
|
||||
typedef typename conditional<
|
||||
is_reference<__reference>::value,
|
||||
typename remove_reference<__reference>::type&&,
|
||||
__reference
|
||||
>::type reference;
|
||||
#else
|
||||
typedef typename iterator_traits<iterator_type>::reference reference;
|
||||
#endif
|
||||
@ -964,10 +1048,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const {
|
||||
return static_cast<reference>(*__i);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {
|
||||
typename iterator_traits<iterator_type>::reference __ref = *__i;
|
||||
return &__ref;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const { return __i;}
|
||||
_LIBCPP_INLINE_VISIBILITY move_iterator& operator++() {++__i; return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY move_iterator operator++(int)
|
||||
{move_iterator __tmp(*this); ++__i; return __tmp;}
|
||||
@ -1036,6 +1117,16 @@ operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
|
||||
return __x.base() <= __y.base();
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
|
||||
-> decltype(__x.base() - __y.base())
|
||||
{
|
||||
return __x.base() - __y.base();
|
||||
}
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename move_iterator<_Iter1>::difference_type
|
||||
@ -1043,6 +1134,7 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
|
||||
{
|
||||
return __x.base() - __y.base();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Iter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -1094,10 +1186,18 @@ _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
|
||||
-> decltype(__x.base() - __y.base());
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __wrap_iter<_Iter1>::difference_type
|
||||
operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
template <class _Iter>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1185,7 +1285,7 @@ public:
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
"Attempted to dereference a non-dereferenceable iterator");
|
||||
#endif
|
||||
return (pointer)&reinterpret_cast<const volatile char&>(*__i);
|
||||
return (pointer)_VSTD::addressof(*__i);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT
|
||||
{
|
||||
@ -1279,10 +1379,18 @@ private:
|
||||
bool
|
||||
operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
auto
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
|
||||
-> decltype(__x.base() - __y.base());
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
typename __wrap_iter<_Iter1>::difference_type
|
||||
operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
template <class _Iter1>
|
||||
friend
|
||||
@ -1388,6 +1496,20 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
|
||||
-> decltype(__x.base() - __y.base())
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
|
||||
"Attempted to subtract incompatible iterators");
|
||||
#endif
|
||||
return __x.base() - __y.base();
|
||||
}
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __wrap_iter<_Iter1>::difference_type
|
||||
@ -1399,6 +1521,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
|
||||
#endif
|
||||
return __x.base() - __y.base();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Iter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -1509,16 +1632,16 @@ reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
|
||||
|
||||
template <class _Cp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
auto cbegin(const _Cp& __c) -> decltype(begin(__c))
|
||||
auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
|
||||
{
|
||||
return begin(__c);
|
||||
return _VSTD::begin(__c);
|
||||
}
|
||||
|
||||
template <class _Cp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
auto cend(const _Cp& __c) -> decltype(end(__c))
|
||||
auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
|
||||
{
|
||||
return end(__c);
|
||||
return _VSTD::end(__c);
|
||||
}
|
||||
|
||||
template <class _Cp>
|
||||
@ -1551,16 +1674,16 @@ auto rend(const _Cp& __c) -> decltype(__c.rend())
|
||||
|
||||
template <class _Cp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto crbegin(const _Cp& __c) -> decltype(rbegin(__c))
|
||||
auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
|
||||
{
|
||||
return rbegin(__c);
|
||||
return _VSTD::rbegin(__c);
|
||||
}
|
||||
|
||||
template <class _Cp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto crend(const _Cp& __c) -> decltype(rend(__c))
|
||||
auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
|
||||
{
|
||||
return rend(__c);
|
||||
return _VSTD::rend(__c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -570,10 +570,13 @@ protected:
|
||||
const __node_allocator& __node_alloc() const _NOEXCEPT
|
||||
{return __size_alloc_.second();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_imp()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_imp(const allocator_type& __a);
|
||||
~__list_imp();
|
||||
void clear() _NOEXCEPT;
|
||||
@ -666,7 +669,7 @@ private:
|
||||
|
||||
// Unlink nodes [__f, __l]
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
__list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l)
|
||||
_NOEXCEPT
|
||||
@ -676,7 +679,7 @@ __list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
__list_imp<_Tp, _Alloc>::__list_imp()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
|
||||
: __size_alloc_(0)
|
||||
@ -684,7 +687,7 @@ __list_imp<_Tp, _Alloc>::__list_imp()
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
__list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
|
||||
: __size_alloc_(0, __node_allocator(__a))
|
||||
{
|
||||
@ -858,15 +861,19 @@ public:
|
||||
|
||||
list(const list& __c);
|
||||
list(const list& __c, const allocator_type& __a);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
list& operator=(const list& __c);
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
list(initializer_list<value_type> __il);
|
||||
list(initializer_list<value_type> __il, const allocator_type& __a);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
list(list&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
list(list&& __c, const allocator_type& __a);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
list& operator=(list&& __c)
|
||||
_NOEXCEPT_(
|
||||
__node_alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
@ -888,6 +895,7 @@ public:
|
||||
{assign(__il.begin(), __il.end());}
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1024,9 +1032,11 @@ public:
|
||||
|
||||
void remove(const value_type& __x);
|
||||
template <class _Pred> void remove_if(_Pred __pred);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void unique();
|
||||
template <class _BinaryPred>
|
||||
void unique(_BinaryPred __binary_pred);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void merge(list& __c);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1039,8 +1049,10 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void merge(list&& __c, _Comp __comp) {merge(__c, __comp);}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void sort();
|
||||
template <class _Comp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void sort(_Comp __comp);
|
||||
|
||||
void reverse() _NOEXCEPT;
|
||||
@ -1057,8 +1069,11 @@ public:
|
||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __link_nodes (__link_pointer __p, __link_pointer __f, __link_pointer __l);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __link_nodes_at_front(__link_pointer __f, __link_pointer __l);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __link_nodes_at_back (__link_pointer __f, __link_pointer __l);
|
||||
iterator __iterator(size_type __n);
|
||||
template <class _Comp>
|
||||
@ -1071,7 +1086,7 @@ private:
|
||||
|
||||
// Link in nodes [__f, __l] just prior to __p
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l)
|
||||
{
|
||||
@ -1083,7 +1098,7 @@ list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_p
|
||||
|
||||
// Link in nodes [__f, __l] at the front of the list
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l)
|
||||
{
|
||||
@ -1095,7 +1110,7 @@ list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l)
|
||||
|
||||
// Link in nodes [__f, __l] at the front of the list
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l)
|
||||
{
|
||||
@ -1107,7 +1122,7 @@ list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l)
|
||||
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
typename list<_Tp, _Alloc>::iterator
|
||||
list<_Tp, _Alloc>::__iterator(size_type __n)
|
||||
{
|
||||
@ -1243,7 +1258,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
list<_Tp, _Alloc>&
|
||||
list<_Tp, _Alloc>::operator=(const list& __c)
|
||||
{
|
||||
@ -1258,7 +1273,7 @@ list<_Tp, _Alloc>::operator=(const list& __c)
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
list<_Tp, _Alloc>::list(list&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
|
||||
: base(allocator_type(_VSTD::move(__c.__node_alloc())))
|
||||
@ -1270,7 +1285,7 @@ list<_Tp, _Alloc>::list(list&& __c)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
|
||||
: base(__a)
|
||||
{
|
||||
@ -1287,7 +1302,7 @@ list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
list<_Tp, _Alloc>&
|
||||
list<_Tp, _Alloc>::operator=(list&& __c)
|
||||
_NOEXCEPT_(
|
||||
@ -1355,7 +1370,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
_Alloc
|
||||
list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT
|
||||
{
|
||||
@ -2108,7 +2123,7 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::unique()
|
||||
{
|
||||
@ -2131,7 +2146,7 @@ list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::merge(list& __c)
|
||||
{
|
||||
@ -2193,7 +2208,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::sort()
|
||||
{
|
||||
@ -2202,7 +2217,7 @@ list<_Tp, _Alloc>::sort()
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
template <class _Comp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
list<_Tp, _Alloc>::sort(_Comp __comp)
|
||||
{
|
||||
|
@ -180,6 +180,7 @@ template <class charT> class messages_byname;
|
||||
|
||||
#include <__config>
|
||||
#include <__locale>
|
||||
#include <__debug>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <ios>
|
||||
@ -213,6 +214,12 @@ template <class charT> class messages_byname;
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
#include <__bsd_locale_defaults.h>
|
||||
#else
|
||||
#include <__bsd_locale_fallbacks.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
@ -228,189 +235,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
|
||||
typedef _VSTD::unique_ptr<__locale_struct, decltype(&freelocale)> __locale_unique_ptr;
|
||||
#ifndef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
|
||||
#endif
|
||||
|
||||
// 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) || \
|
||||
defined(_NEWLIB_VERSION) || defined(__GLIBC__)
|
||||
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__mb_cur_max_l(locale_t __l)
|
||||
{
|
||||
return MB_CUR_MAX_L(__l);
|
||||
}
|
||||
#else // _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l)
|
||||
{
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return MB_CUR_MAX;
|
||||
}
|
||||
#endif // _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
wint_t __btowc_l(int __c, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return btowc_l(__c, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return btowc(__c);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __wctob_l(wint_t __c, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return wctob_l(__c, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return wctob(__c);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return wcrtomb_l(__s, __wc, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return wcrtomb(__s, __wc, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbrtowc_l(__pwc, __s, __n, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbrtowc(__pwc, __s, __n, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbtowc_l(__pwc, __pmb, __max, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbtowc(__pwc, __pmb, __max);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbrlen_l(__s, __n, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbrlen(__s, __n, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
lconv *__localeconv_l(locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return localeconv_l(__l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return localeconv();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbsrtowcs_l(__dest, __src, __len, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbsrtowcs(__dest, __src, __len, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
int __snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vsnprintf_l(__s, __n, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vsnprintf(__s, __n, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vasprintf_l(__s, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vasprintf(__s, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vsscanf_l(__s, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vsscanf(__s, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
// __scan_keyword
|
||||
// Scans [__b, __e) until a match is found in the basic_strings range
|
||||
@ -932,6 +756,28 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Tp __do_strtod(const char* __a, char** __p2);
|
||||
|
||||
template <>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
float __do_strtod<float>(const char* __a, char** __p2) {
|
||||
return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
double __do_strtod<double>(const char* __a, char** __p2) {
|
||||
return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
long double __do_strtod<long double>(const char* __a, char** __p2) {
|
||||
return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_Tp
|
||||
__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
|
||||
@ -941,7 +787,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
|
||||
typename remove_reference<decltype(errno)>::type __save_errno = errno;
|
||||
errno = 0;
|
||||
char *__p2;
|
||||
long double __ld = strtold_l(__a, &__p2, _LIBCPP_GET_C_LOCALE);
|
||||
_Tp __ld = __do_strtod<_Tp>(__a, &__p2);
|
||||
typename remove_reference<decltype(errno)>::type __current_errno = errno;
|
||||
if (__current_errno == 0)
|
||||
errno = __save_errno;
|
||||
@ -952,7 +798,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
|
||||
}
|
||||
else if (__current_errno == ERANGE)
|
||||
__err = ios_base::failbit;
|
||||
return static_cast<_Tp>(__ld);
|
||||
return __ld;
|
||||
}
|
||||
__err = ios_base::failbit;
|
||||
return 0;
|
||||
@ -1188,11 +1034,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
|
||||
}
|
||||
// Stage 3
|
||||
__buf.resize(__a_end - __a);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
|
||||
#else
|
||||
if (__sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
|
||||
#endif
|
||||
if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
|
||||
__err = ios_base::failbit;
|
||||
// EOF checked
|
||||
if (__b == __e)
|
||||
@ -1556,13 +1398,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
this->__format_int(__fmt+1, __len, true, __iob.flags());
|
||||
const unsigned __nbuf = (numeric_limits<long>::digits / 3)
|
||||
+ ((numeric_limits<long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
+ 2;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1588,11 +1426,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<long long>::digits % 3) != 0)
|
||||
+ 2;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1618,11 +1452,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<unsigned long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1648,11 +1478,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<unsigned long long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1679,34 +1505,17 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
char* __nb = __nar;
|
||||
int __nc;
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
|
||||
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#endif
|
||||
else
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
unique_ptr<char, void(*)(void*)> __nbh(0, free);
|
||||
if (__nc > static_cast<int>(__nbuf-1))
|
||||
{
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
#endif
|
||||
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
else
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
#endif
|
||||
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
if (__nb == 0)
|
||||
__throw_bad_alloc();
|
||||
__nbh.reset(__nb);
|
||||
@ -1747,34 +1556,17 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
char* __nb = __nar;
|
||||
int __nc;
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
|
||||
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#endif
|
||||
else
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
__nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
unique_ptr<char, void(*)(void*)> __nbh(0, free);
|
||||
if (__nc > static_cast<int>(__nbuf-1))
|
||||
{
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
#endif
|
||||
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
|
||||
else
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
__nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
if (__nb == 0)
|
||||
__throw_bad_alloc();
|
||||
__nbh.reset(__nb);
|
||||
@ -1810,11 +1602,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
char __fmt[6] = "%p";
|
||||
const unsigned __nbuf = 20;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#endif
|
||||
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar
|
||||
@ -3526,11 +3314,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
|
||||
// secure memory for digit storage
|
||||
if (__n > __bs-1)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
__n = static_cast<size_t>(asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
|
||||
#else
|
||||
__n = __asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
|
||||
#endif
|
||||
__n = static_cast<size_t>(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
|
||||
if (__bb == 0)
|
||||
__throw_bad_alloc();
|
||||
__hn.reset(__bb);
|
||||
@ -3850,7 +3634,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
|
||||
: __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)),
|
||||
__wide_err_string_(_VSTD::move(__wc.__wide_err_string_)),
|
||||
__cvtptr_(__wc.__cvtptr_),
|
||||
__cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtstate_)
|
||||
__cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtcount_)
|
||||
{
|
||||
__wc.__cvtptr_ = nullptr;
|
||||
}
|
||||
@ -4140,7 +3924,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
|
||||
_LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
|
||||
if (__extbufend_ != __extbufnext_)
|
||||
memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
|
||||
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
|
||||
__extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
|
||||
streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
|
||||
void swap(map& m)
|
||||
noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
|
||||
__is_nothrow_swappable<key_compare>::value); // C++17
|
||||
is_nothrow_swappable<key_compare>::value); // C++17
|
||||
|
||||
// observers:
|
||||
allocator_type get_allocator() const noexcept;
|
||||
@ -357,7 +357,7 @@ public:
|
||||
|
||||
void swap(multimap& m)
|
||||
noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
|
||||
__is_nothrow_swappable<key_compare>::value); // C++17
|
||||
is_nothrow_swappable<key_compare>::value); // C++17
|
||||
|
||||
// observers:
|
||||
allocator_type get_allocator() const noexcept;
|
||||
@ -564,13 +564,11 @@ class __map_node_destructor
|
||||
{
|
||||
typedef _Allocator allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::value_type::value_type value_type;
|
||||
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
private:
|
||||
typedef typename value_type::value_type::first_type first_type;
|
||||
typedef typename value_type::value_type::second_type second_type;
|
||||
|
||||
private:
|
||||
allocator_type& __na_;
|
||||
|
||||
__map_node_destructor& operator=(const __map_node_destructor&);
|
||||
@ -615,7 +613,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
class multimap;
|
||||
template <class _TreeIterator> class __map_const_iterator;
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Key, class _Tp>
|
||||
union __value_type
|
||||
@ -628,33 +626,29 @@ union __value_type
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type(_Args&& ...__args)
|
||||
: __cc(std::forward<_Args>(__args)...) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type(const __value_type& __v)
|
||||
: __cc(__v.__cc) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type(__value_type& __v)
|
||||
: __cc(__v.__cc) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type(__value_type&& __v)
|
||||
: __nc(std::move(__v.__nc)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type& operator=(const __value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type& operator=(__value_type&& __v)
|
||||
{__nc = std::move(__v.__nc); return *this;}
|
||||
{__nc = _VSTD::move(__v.__nc); return *this;}
|
||||
|
||||
template <class _ValueTp,
|
||||
class = typename enable_if<
|
||||
__is_same_uncvref<_ValueTp, value_type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~__value_type() {__cc.~value_type();}
|
||||
__value_type& operator=(_ValueTp&& __v) {
|
||||
__nc = _VSTD::forward<_ValueTp>(__v); return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
__value_type() _LIBCPP_EQUAL_DELETE;
|
||||
~__value_type() _LIBCPP_EQUAL_DELETE;
|
||||
__value_type(const __value_type& __v) _LIBCPP_EQUAL_DELETE;
|
||||
__value_type(__value_type&& __v) _LIBCPP_EQUAL_DELETE;
|
||||
};
|
||||
|
||||
#else
|
||||
@ -668,18 +662,11 @@ struct __value_type
|
||||
|
||||
value_type __cc;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type() {}
|
||||
|
||||
template <class _A0>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type(const _A0& __a0)
|
||||
: __cc(__a0) {}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type(const _A0& __a0, const _A1& __a1)
|
||||
: __cc(__a0, __a1) {}
|
||||
private:
|
||||
__value_type();
|
||||
__value_type(__value_type const&);
|
||||
__value_type& operator=(__value_type const&);
|
||||
~__value_type();
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -697,19 +684,17 @@ struct __extract_key_value_types<__value_type<_Key, _Tp> >
|
||||
template <class _TreeIterator>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __map_iterator
|
||||
{
|
||||
typedef typename _TreeIterator::_NodeTypes _NodeTypes;
|
||||
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
|
||||
|
||||
_TreeIterator __i_;
|
||||
|
||||
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
|
||||
typedef typename _TreeIterator::value_type __value_type;
|
||||
typedef typename __extract_key_value_types<__value_type>::__key_type __key_type;
|
||||
typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type;
|
||||
public:
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<__key_type, __mapped_type> value_type;
|
||||
typedef typename _NodeTypes::__map_value_type value_type;
|
||||
typedef typename _TreeIterator::difference_type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef typename __rebind_pointer<typename __pointer_traits::pointer, value_type>::type
|
||||
pointer;
|
||||
typedef typename _NodeTypes::__map_value_type_pointer pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_iterator() _NOEXCEPT {}
|
||||
@ -758,19 +743,17 @@ public:
|
||||
template <class _TreeIterator>
|
||||
class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator
|
||||
{
|
||||
typedef typename _TreeIterator::_NodeTypes _NodeTypes;
|
||||
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
|
||||
|
||||
_TreeIterator __i_;
|
||||
|
||||
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
|
||||
typedef typename _TreeIterator::value_type __value_type;
|
||||
typedef typename __extract_key_value_types<__value_type>::__key_type __key_type;
|
||||
typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type;
|
||||
public:
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<__key_type, __mapped_type> value_type;
|
||||
typedef typename _NodeTypes::__map_value_type value_type;
|
||||
typedef typename _TreeIterator::difference_type difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename __rebind_pointer<typename __pointer_traits::pointer, const value_type>::type
|
||||
pointer;
|
||||
typedef typename _NodeTypes::__const_map_value_type_pointer pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_const_iterator() _NOEXCEPT {}
|
||||
@ -890,7 +873,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit map(const key_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__vc(__comp), __a) {}
|
||||
: __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
|
||||
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -905,7 +888,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
map(_InputIterator __f, _InputIterator __l,
|
||||
const key_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__vc(__comp), __a)
|
||||
: __tree_(__vc(__comp), typename __base::allocator_type(__a))
|
||||
{
|
||||
insert(__f, __l);
|
||||
}
|
||||
@ -927,7 +910,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
map& operator=(const map& __m)
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__tree_ = __m.__tree_;
|
||||
#else
|
||||
if (this != &__m) {
|
||||
@ -972,7 +955,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__vc(__comp), __a)
|
||||
: __tree_(__vc(__comp), typename __base::allocator_type(__a))
|
||||
{
|
||||
insert(__il.begin(), __il.end());
|
||||
}
|
||||
@ -994,13 +977,13 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit map(const allocator_type& __a)
|
||||
: __tree_(__a)
|
||||
: __tree_(typename __base::allocator_type(__a))
|
||||
{
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
map(const map& __m, const allocator_type& __a)
|
||||
: __tree_(__m.__tree_.value_comp(), __a)
|
||||
: __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
|
||||
{
|
||||
insert(__m.begin(), __m.end());
|
||||
}
|
||||
@ -1043,7 +1026,7 @@ public:
|
||||
size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
|
||||
|
||||
mapped_type& operator[](const key_type& __k);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
mapped_type& operator[](key_type&& __k);
|
||||
#endif
|
||||
|
||||
@ -1051,24 +1034,24 @@ public:
|
||||
const mapped_type& at(const key_type& __k) const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
|
||||
allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_compare key_comp() const {return __tree_.value_comp().key_comp();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> emplace(_Args&& ...__args) {
|
||||
return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
pair<iterator, bool>
|
||||
emplace(_Args&& ...__args);
|
||||
|
||||
template <class ..._Args>
|
||||
iterator
|
||||
emplace_hint(const_iterator __p, _Args&& ...__args);
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
|
||||
return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Pp,
|
||||
class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
|
||||
@ -1082,7 +1065,7 @@ public:
|
||||
iterator insert(const_iterator __pos, _Pp&& __p)
|
||||
{return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool>
|
||||
@ -1093,15 +1076,14 @@ public:
|
||||
insert(const_iterator __p, const value_type& __v)
|
||||
{return __tree_.__insert_unique(__p.__i_, __v);}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool>
|
||||
insert( value_type&& __v) {return __tree_.__insert_unique(_VSTD::forward<value_type>(__v));}
|
||||
insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator
|
||||
insert(const_iterator __p, value_type&& __v)
|
||||
{return __tree_.__insert_unique(__p.__i_, _VSTD::forward<value_type>(__v));}
|
||||
iterator insert(const_iterator __p, value_type&& __v)
|
||||
{return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));}
|
||||
#endif
|
||||
|
||||
template <class _InputIterator>
|
||||
@ -1121,62 +1103,45 @@ public:
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
|
||||
{
|
||||
iterator __p = lower_bound(__k);
|
||||
if ( __p != end() && !key_comp()(__k, __p->first))
|
||||
return _VSTD::make_pair(__p, false);
|
||||
else
|
||||
return _VSTD::make_pair(
|
||||
emplace_hint(__p,
|
||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
|
||||
true);
|
||||
return __tree_.__emplace_unique_key_args(__k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(__k),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||
}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
|
||||
{
|
||||
iterator __p = lower_bound(__k);
|
||||
if ( __p != end() && !key_comp()(__k, __p->first))
|
||||
return _VSTD::make_pair(__p, false);
|
||||
else
|
||||
return _VSTD::make_pair(
|
||||
emplace_hint(__p,
|
||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
|
||||
true);
|
||||
return __tree_.__emplace_unique_key_args(__k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||
}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
|
||||
{
|
||||
iterator __p = lower_bound(__k);
|
||||
if ( __p != end() && !key_comp()(__k, __p->first))
|
||||
return __p;
|
||||
else
|
||||
return emplace_hint(__p,
|
||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||
return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(__k),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||
}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
|
||||
{
|
||||
iterator __p = lower_bound(__k);
|
||||
if ( __p != end() && !key_comp()(__k, __p->first))
|
||||
return __p;
|
||||
else
|
||||
return emplace_hint(__p,
|
||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||
return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||
}
|
||||
|
||||
template <class _Vp>
|
||||
@ -1191,7 +1156,7 @@ public:
|
||||
}
|
||||
return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
|
||||
}
|
||||
|
||||
|
||||
template <class _Vp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
|
||||
@ -1230,8 +1195,7 @@ public:
|
||||
}
|
||||
return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1332,38 +1296,36 @@ private:
|
||||
typedef typename __base::__node __node;
|
||||
typedef typename __base::__node_allocator __node_allocator;
|
||||
typedef typename __base::__node_pointer __node_pointer;
|
||||
typedef typename __base::__node_const_pointer __node_const_pointer;
|
||||
typedef typename __base::__node_base_pointer __node_base_pointer;
|
||||
typedef typename __base::__node_base_const_pointer __node_base_const_pointer;
|
||||
|
||||
typedef __map_node_destructor<__node_allocator> _Dp;
|
||||
typedef unique_ptr<__node, _Dp> __node_holder;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node();
|
||||
template <class _A0>
|
||||
__node_holder __construct_node(_A0&& __a0);
|
||||
__node_holder __construct_node_with_key(key_type&& __k);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
__node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#endif
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
__node_holder __construct_node_with_key(const key_type& __k);
|
||||
#endif
|
||||
|
||||
__node_base_pointer const&
|
||||
__find_equal_key(__node_base_pointer& __parent, const key_type& __k) const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_base_pointer&
|
||||
__find_equal_key(__node_base_pointer& __parent, const key_type& __k);
|
||||
__node_base_const_pointer
|
||||
__find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const;
|
||||
__find_equal_key(__node_base_pointer& __parent, const key_type& __k) {
|
||||
map const* __const_this = this;
|
||||
return const_cast<__node_base_pointer&>(
|
||||
__const_this->__find_equal_key(__parent, __k));
|
||||
}
|
||||
};
|
||||
|
||||
// Find place to insert if __k doesn't exist
|
||||
// Set __parent to parent of null leaf
|
||||
// Return reference to null leaf
|
||||
|
||||
// Find __k
|
||||
// Set __parent to parent of null leaf and
|
||||
// return reference to null leaf iv __k does not exist.
|
||||
// If __k exists, set parent to node of __k and return reference to node of __k
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer&
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer const&
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
|
||||
const key_type& __k)
|
||||
const key_type& __k) const
|
||||
{
|
||||
__node_pointer __nd = __tree_.__root();
|
||||
if (__nd != nullptr)
|
||||
@ -1401,125 +1363,25 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __pa
|
||||
return __parent->__left_;
|
||||
}
|
||||
|
||||
// Find __k
|
||||
// Set __parent to parent of null leaf and
|
||||
// return reference to null leaf iv __k does not exist.
|
||||
// If __k exists, set parent to node of __k and return reference to node of __k
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_const_pointer
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer& __parent,
|
||||
const key_type& __k) const
|
||||
{
|
||||
__node_const_pointer __nd = __tree_.__root();
|
||||
if (__nd != nullptr)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
|
||||
{
|
||||
if (__nd->__left_ != nullptr)
|
||||
__nd = static_cast<__node_pointer>(__nd->__left_);
|
||||
else
|
||||
{
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return const_cast<const __node_base_const_pointer&>(__parent->__left_);
|
||||
}
|
||||
}
|
||||
else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
|
||||
{
|
||||
if (__nd->__right_ != nullptr)
|
||||
__nd = static_cast<__node_pointer>(__nd->__right_);
|
||||
else
|
||||
{
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return const_cast<const __node_base_const_pointer&>(__parent->__right_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
|
||||
return const_cast<const __node_base_const_pointer&>(__parent->__left_);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
|
||||
: __tree_(_VSTD::move(__m.__tree_), __a)
|
||||
: __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
|
||||
{
|
||||
if (__a != __m.get_allocator())
|
||||
{
|
||||
const_iterator __e = cend();
|
||||
while (!__m.empty())
|
||||
__tree_.__insert_unique(__e.__i_,
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__nc));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node()
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
#endif // !_LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_),
|
||||
_VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
|
||||
_VSTD::forward<_Args>(__args)...);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
@ -1550,25 +1412,29 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
|
||||
return __r->__value_.__cc.second;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#else
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
_Tp&
|
||||
map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
|
||||
{
|
||||
return __tree_.__emplace_unique_key_args(__k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(__k),
|
||||
_VSTD::forward_as_tuple()).first->__cc.second;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
_Tp&
|
||||
map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
|
||||
{
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_equal_key(__parent, __k);
|
||||
__node_pointer __r = static_cast<__node_pointer>(__child);
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__node_holder __h = __construct_node_with_key(_VSTD::move(__k));
|
||||
__tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
}
|
||||
return __r->__value_.__cc.second;
|
||||
return __tree_.__emplace_unique_key_args(__k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||
_VSTD::forward_as_tuple()).first->__cc.second;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // !_LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
_Tp&
|
||||
@ -1587,43 +1453,15 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
const _Tp&
|
||||
map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
|
||||
{
|
||||
__node_base_const_pointer __parent;
|
||||
__node_base_const_pointer __child = __find_equal_key(__parent, __k);
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer __child = __find_equal_key(__parent, __k);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (__child == nullptr)
|
||||
throw out_of_range("map::at: key not found");
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return static_cast<__node_const_pointer>(__child)->__value_.__cc.second;
|
||||
return static_cast<__node_pointer>(__child)->__value_.__cc.second;
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class ..._Args>
|
||||
pair<typename map<_Key, _Tp, _Compare, _Allocator>::iterator, bool>
|
||||
map<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
pair<iterator, bool> __r = __tree_.__node_insert_unique(__h.get());
|
||||
if (__r.second)
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class ..._Args>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::iterator
|
||||
map<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p,
|
||||
_Args&& ...__args)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
iterator __r = __tree_.__node_insert_unique(__p.__i_, __h.get());
|
||||
if (__r.__i_.__ptr_ == __h.get())
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -1761,7 +1599,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit multimap(const key_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__vc(__comp), __a) {}
|
||||
: __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
|
||||
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1776,7 +1614,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
multimap(_InputIterator __f, _InputIterator __l,
|
||||
const key_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__vc(__comp), __a)
|
||||
: __tree_(__vc(__comp), typename __base::allocator_type(__a))
|
||||
{
|
||||
insert(__f, __l);
|
||||
}
|
||||
@ -1799,7 +1637,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
multimap& operator=(const multimap& __m)
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__tree_ = __m.__tree_;
|
||||
#else
|
||||
if (this != &__m) {
|
||||
@ -1844,7 +1682,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
|
||||
: __tree_(__vc(__comp), __a)
|
||||
: __tree_(__vc(__comp), typename __base::allocator_type(__a))
|
||||
{
|
||||
insert(__il.begin(), __il.end());
|
||||
}
|
||||
@ -1866,13 +1704,13 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit multimap(const allocator_type& __a)
|
||||
: __tree_(__a)
|
||||
: __tree_(typename __base::allocator_type(__a))
|
||||
{
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
multimap(const multimap& __m, const allocator_type& __a)
|
||||
: __tree_(__m.__tree_.value_comp(), __a)
|
||||
: __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
|
||||
{
|
||||
insert(__m.begin(), __m.end());
|
||||
}
|
||||
@ -1914,25 +1752,26 @@ public:
|
||||
size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
|
||||
allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_compare key_comp() const {return __tree_.value_comp().key_comp();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_compare value_comp() const
|
||||
{return value_compare(__tree_.value_comp().key_comp());}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class ..._Args>
|
||||
iterator
|
||||
emplace(_Args&& ...__args);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator emplace(_Args&& ...__args) {
|
||||
return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
iterator
|
||||
emplace_hint(const_iterator __p, _Args&& ...__args);
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator emplace_hint(const_iterator __p, _Args&& ...__args) {
|
||||
return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Pp,
|
||||
class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
|
||||
@ -1946,7 +1785,15 @@ public:
|
||||
iterator insert(const_iterator __pos, _Pp&& __p)
|
||||
{return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(value_type&& __v)
|
||||
{return __tree_.__insert_multi(_VSTD::move(__v));}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator __p, value_type&& __v)
|
||||
{return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
|
||||
@ -1955,15 +1802,6 @@ public:
|
||||
iterator insert(const_iterator __p, const value_type& __v)
|
||||
{return __tree_.__insert_multi(__p.__i_, __v);}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert( value_type&& __v) {return __tree_.__insert_multi(_VSTD::forward<value_type>(__v));}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator __p, value_type&& __v)
|
||||
{return __tree_.__insert_multi(__p.__i_, _VSTD::forward<value_type>(__v));}
|
||||
#endif
|
||||
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
@ -2077,109 +1915,25 @@ private:
|
||||
typedef typename __base::__node __node;
|
||||
typedef typename __base::__node_allocator __node_allocator;
|
||||
typedef typename __base::__node_pointer __node_pointer;
|
||||
typedef typename __base::__node_const_pointer __node_const_pointer;
|
||||
|
||||
typedef __map_node_destructor<__node_allocator> _Dp;
|
||||
typedef unique_ptr<__node, _Dp> __node_holder;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node();
|
||||
template <class _A0>
|
||||
__node_holder
|
||||
__construct_node(_A0&& __a0);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
__node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
|
||||
: __tree_(_VSTD::move(__m.__tree_), __a)
|
||||
: __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
|
||||
{
|
||||
if (__a != __m.get_allocator())
|
||||
{
|
||||
const_iterator __e = cend();
|
||||
while (!__m.empty())
|
||||
__tree_.__insert_multi(__e.__i_,
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__nc));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node()
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0>
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_),
|
||||
_VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
|
||||
_VSTD::forward<_Args>(__args)...);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class ..._Args>
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::iterator
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
iterator __r = __tree_.__node_insert_multi(__h.get());
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class ..._Args>
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::iterator
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p,
|
||||
_Args&& ...__args)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
iterator __r = __tree_.__node_insert_multi(__p.__i_, __h.get());
|
||||
__h.release();
|
||||
return __r;
|
||||
}
|
||||
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
#endif
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -361,6 +361,7 @@ class shared_ptr
|
||||
{
|
||||
public:
|
||||
typedef T element_type;
|
||||
typedef weak_ptr<T> weak_type; // C++17
|
||||
|
||||
// constructors:
|
||||
constexpr shared_ptr() noexcept;
|
||||
@ -607,6 +608,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
||||
#include <__functional_base>
|
||||
#include <iosfwd>
|
||||
#include <tuple>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#if defined(_LIBCPP_NO_EXCEPTIONS)
|
||||
#include <cassert>
|
||||
@ -1726,7 +1728,12 @@ 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>(_VSTD::__allocate(__n * sizeof(_Tp)));}
|
||||
{
|
||||
if (__n > max_size())
|
||||
__libcpp_throw(length_error("allocator<T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size"));
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{_VSTD::__deallocate((void*)__p);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
@ -1817,7 +1824,12 @@ 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>(_VSTD::__allocate(__n * sizeof(_Tp)));}
|
||||
{
|
||||
if (__n > max_size())
|
||||
__libcpp_throw(length_error("allocator<const T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size"));
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{_VSTD::__deallocate((void*)__p);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
@ -2548,7 +2560,7 @@ public:
|
||||
typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT
|
||||
{
|
||||
static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
|
||||
static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
|
||||
static_assert(!is_void<_Tp>::value, "default_delete can not delete void type");
|
||||
delete [] __ptr;
|
||||
}
|
||||
};
|
||||
@ -2918,7 +2930,6 @@ public:
|
||||
return __t;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Pp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type
|
||||
@ -2929,29 +2940,13 @@ public:
|
||||
if (__tmp)
|
||||
__ptr_.second()(__tmp);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT
|
||||
_LIBCPP_INLINE_VISIBILITY void reset(nullptr_t = nullptr) _NOEXCEPT
|
||||
{
|
||||
pointer __tmp = __ptr_.first();
|
||||
__ptr_.first() = nullptr;
|
||||
if (__tmp)
|
||||
__ptr_.second()(__tmp);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT
|
||||
{
|
||||
pointer __tmp = __ptr_.first();
|
||||
__ptr_.first() = nullptr;
|
||||
if (__tmp)
|
||||
__ptr_.second()(__tmp);
|
||||
}
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer())
|
||||
{
|
||||
pointer __tmp = __ptr_.first();
|
||||
__ptr_.first() = __p;
|
||||
if (__tmp)
|
||||
__ptr_.second()(__tmp);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);}
|
||||
private:
|
||||
@ -2975,7 +2970,10 @@ private:
|
||||
|
||||
template <class _Tp, class _Dp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
typename enable_if<
|
||||
__is_swappable<_Dp>::value,
|
||||
void
|
||||
>::type
|
||||
swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
|
||||
|
||||
template <class _T1, class _D1, class _T2, class _D2>
|
||||
@ -3167,8 +3165,6 @@ template<class _Tp, class... _Args>
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
template <class _Tp> struct hash;
|
||||
|
||||
template <class _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Size
|
||||
@ -3868,6 +3864,9 @@ class _LIBCPP_TYPE_VIS_ONLY shared_ptr
|
||||
{
|
||||
public:
|
||||
typedef _Tp element_type;
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
typedef weak_ptr<_Tp> weak_type;
|
||||
#endif
|
||||
private:
|
||||
element_type* __ptr_;
|
||||
__shared_weak_count* __cntrl_;
|
||||
@ -3979,23 +3978,23 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator=(shared_ptr<_Yp>&& __r);
|
||||
template<class _Yp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<_Yp*, element_type*>::value,
|
||||
shared_ptr
|
||||
>::type&
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator=(auto_ptr<_Yp>&& __r);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template<class _Yp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<_Yp*, element_type*>::value,
|
||||
shared_ptr&
|
||||
>::type
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator=(auto_ptr<_Yp> __r);
|
||||
#endif
|
||||
template <class _Yp, class _Dp>
|
||||
@ -4120,21 +4119,22 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
template <class _Yp>
|
||||
template <class _Yp, class _OrigPtr>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
|
||||
__enable_weak_this(const enable_shared_from_this<_Yp>* __e,
|
||||
_OrigPtr* __ptr) _NOEXCEPT
|
||||
{
|
||||
if (__e)
|
||||
typedef typename remove_cv<_Yp>::type _RawYp;
|
||||
if (__e && __e->__weak_this_.expired())
|
||||
{
|
||||
__e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e));
|
||||
__e->__weak_this_.__cntrl_ = __cntrl_;
|
||||
__cntrl_->__add_weak();
|
||||
__e->__weak_this_ = shared_ptr<_RawYp>(*this,
|
||||
const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr)));
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __enable_weak_this(const volatile void*) _NOEXCEPT {}
|
||||
void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {}
|
||||
|
||||
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
|
||||
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
|
||||
@ -4168,7 +4168,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p,
|
||||
typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
|
||||
__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>());
|
||||
__hold.release();
|
||||
__enable_weak_this(__p);
|
||||
__enable_weak_this(__p, __p);
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
@ -4183,7 +4183,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
|
||||
__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>());
|
||||
__enable_weak_this(__p);
|
||||
__enable_weak_this(__p, __p);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
@ -4233,7 +4233,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
|
||||
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
|
||||
_CntrlBlk(__p, __d, __a);
|
||||
__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__enable_weak_this(__p);
|
||||
__enable_weak_this(__p, __p);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
@ -4344,7 +4344,7 @@ shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
|
||||
{
|
||||
typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
|
||||
__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>());
|
||||
__enable_weak_this(__r.get());
|
||||
__enable_weak_this(__r.get(), __r.get());
|
||||
__r.release();
|
||||
}
|
||||
|
||||
@ -4372,7 +4372,7 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
|
||||
{
|
||||
typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
|
||||
__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
|
||||
__enable_weak_this(__r.get());
|
||||
__enable_weak_this(__r.get(), __r.get());
|
||||
}
|
||||
__r.release();
|
||||
}
|
||||
@ -4403,7 +4403,7 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
|
||||
reference_wrapper<typename remove_reference<_Dp>::type>,
|
||||
allocator<_Yp> > _CntrlBlk;
|
||||
__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
|
||||
__enable_weak_this(__r.get());
|
||||
__enable_weak_this(__r.get(), __r.get());
|
||||
}
|
||||
__r.release();
|
||||
}
|
||||
@ -4424,7 +4424,7 @@ shared_ptr<_Tp>::make_shared(_Args&& ...__args)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4443,7 +4443,7 @@ shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4462,7 +4462,7 @@ shared_ptr<_Tp>::make_shared()
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4480,7 +4480,7 @@ shared_ptr<_Tp>::make_shared(_A0& __a0)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4498,7 +4498,7 @@ shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4516,7 +4516,7 @@ shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = __hold2.release();
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4535,7 +4535,7 @@ shared_ptr<_Tp>::allocate_shared(const _Alloc& __a)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4554,7 +4554,7 @@ shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4573,7 +4573,7 @@ shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -4592,7 +4592,7 @@ shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& _
|
||||
shared_ptr<_Tp> __r;
|
||||
__r.__ptr_ = __hold2.get()->get();
|
||||
__r.__cntrl_ = _VSTD::addressof(*__hold2.release());
|
||||
__r.__enable_weak_this(__r.__ptr_);
|
||||
__r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
|
||||
return __r;
|
||||
}
|
||||
|
||||
@ -5437,6 +5437,16 @@ public:
|
||||
shared_ptr<_Tp const> shared_from_this() const
|
||||
{return shared_ptr<const _Tp>(__weak_this_);}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
weak_ptr<_Tp> weak_from_this() _NOEXCEPT
|
||||
{ return __weak_this_; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT
|
||||
{ return __weak_this_; }
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
template <class _Up> friend class shared_ptr;
|
||||
};
|
||||
|
||||
@ -5457,9 +5467,8 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
|
||||
|
||||
// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
|
||||
// enabled with clang.
|
||||
#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
|
||||
class _LIBCPP_TYPE_VIS __sp_mut
|
||||
{
|
||||
@ -5546,14 +5555,17 @@ template <class _Tp>
|
||||
bool
|
||||
atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
|
||||
{
|
||||
shared_ptr<_Tp> __temp;
|
||||
__sp_mut& __m = __get_sp_mut(__p);
|
||||
__m.lock();
|
||||
if (__p->__owner_equivalent(*__v))
|
||||
{
|
||||
_VSTD::swap(__temp, *__p);
|
||||
*__p = __w;
|
||||
__m.unlock();
|
||||
return true;
|
||||
}
|
||||
_VSTD::swap(__temp, *__v);
|
||||
*__v = *__p;
|
||||
__m.unlock();
|
||||
return false;
|
||||
@ -5585,7 +5597,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v
|
||||
return atomic_compare_exchange_weak(__p, __v, __w);
|
||||
}
|
||||
|
||||
#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
|
||||
//enum class
|
||||
struct _LIBCPP_TYPE_VIS pointer_safety
|
||||
@ -5623,7 +5635,7 @@ _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t&
|
||||
|
||||
// --- Helper for container swap --
|
||||
template <typename _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
|
||||
#if _LIBCPP_STD_VER >= 14
|
||||
_NOEXCEPT
|
||||
@ -5649,7 +5661,7 @@ void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
|
||||
}
|
||||
|
||||
template <typename _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
|
||||
|
||||
template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
|
||||
@ -5662,6 +5674,26 @@ struct __noexcept_move_assign_container : public integral_constant<bool,
|
||||
#endif
|
||||
> {};
|
||||
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _Tp, class _Alloc>
|
||||
struct __temp_value {
|
||||
typedef allocator_traits<_Alloc> _Traits;
|
||||
|
||||
typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __v;
|
||||
_Alloc &__a;
|
||||
|
||||
_Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
|
||||
_Tp & get() { return *__addr(); }
|
||||
|
||||
template<class... _Args>
|
||||
__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
|
||||
{ _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
|
||||
|
||||
~__temp_value() { _Traits::destroy(__a, __addr()); }
|
||||
};
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_MEMORY
|
||||
|
@ -109,6 +109,19 @@ public:
|
||||
lock_guard& operator=(lock_guard const&) = delete;
|
||||
};
|
||||
|
||||
template <class... MutexTypes> // Variadic lock_guard only provided in ABI V2.
|
||||
class lock_guard
|
||||
{
|
||||
public:
|
||||
explicit lock_guard(MutexTypes&... m);
|
||||
lock_guard(MutexTypes&... m, adopt_lock_t);
|
||||
~lock_guard();
|
||||
lock_guard(lock_guard const&) = delete;
|
||||
lock_guard& operator=(lock_guard const&) = delete;
|
||||
private:
|
||||
tuple<MutexTypes&...> pm; // exposition only
|
||||
};
|
||||
|
||||
template <class Mutex>
|
||||
class unique_lock
|
||||
{
|
||||
@ -179,9 +192,7 @@ template<class Callable, class ...Args>
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#include <tuple>
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
#include <sched.h>
|
||||
#endif
|
||||
#include <__threading_support>
|
||||
|
||||
#include <__undef_min_max>
|
||||
|
||||
@ -195,7 +206,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TYPE_VIS recursive_mutex
|
||||
{
|
||||
pthread_mutex_t __m_;
|
||||
__libcpp_mutex_t __m_;
|
||||
|
||||
public:
|
||||
recursive_mutex();
|
||||
@ -210,7 +221,7 @@ public:
|
||||
bool try_lock() _NOEXCEPT;
|
||||
void unlock() _NOEXCEPT;
|
||||
|
||||
typedef pthread_mutex_t* native_handle_type;
|
||||
typedef __libcpp_mutex_t* native_handle_type;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
native_handle_type native_handle() {return &__m_;}
|
||||
};
|
||||
@ -262,7 +273,7 @@ class _LIBCPP_TYPE_VIS recursive_timed_mutex
|
||||
mutex __m_;
|
||||
condition_variable __cv_;
|
||||
size_t __count_;
|
||||
pthread_t __id_;
|
||||
__libcpp_thread_id __id_;
|
||||
public:
|
||||
recursive_timed_mutex();
|
||||
~recursive_timed_mutex();
|
||||
@ -288,9 +299,9 @@ bool
|
||||
recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
using namespace chrono;
|
||||
pthread_t __id = pthread_self();
|
||||
__libcpp_thread_id __id = __libcpp_thread_get_current_id();
|
||||
unique_lock<mutex> lk(__m_);
|
||||
if (pthread_equal(__id, __id_))
|
||||
if (__libcpp_thread_id_equal(__id, __id_))
|
||||
{
|
||||
if (__count_ == numeric_limits<size_t>::max())
|
||||
return false;
|
||||
@ -362,7 +373,7 @@ lock(_L0& __l0, _L1& __l1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
sched_yield();
|
||||
__libcpp_thread_yield();
|
||||
{
|
||||
unique_lock<_L1> __u1(__l1);
|
||||
if (__l0.try_lock())
|
||||
@ -371,7 +382,7 @@ lock(_L0& __l0, _L1& __l1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
sched_yield();
|
||||
__libcpp_thread_yield();
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +407,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
|
||||
}
|
||||
}
|
||||
++__i;
|
||||
sched_yield();
|
||||
__libcpp_thread_yield();
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
@ -412,7 +423,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
|
||||
__i = 0;
|
||||
else
|
||||
__i += 2;
|
||||
sched_yield();
|
||||
__libcpp_thread_yield();
|
||||
break;
|
||||
default:
|
||||
__lock_first(__i - 2, __l2, __l3..., __l0, __l1);
|
||||
@ -429,6 +440,27 @@ lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
|
||||
__lock_first(0, __l0, __l1, __l2, __l3...);
|
||||
}
|
||||
|
||||
template <class _L0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __unlock(_L0& __l0) {
|
||||
__l0.unlock();
|
||||
}
|
||||
|
||||
template <class _L0, class _L1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __unlock(_L0& __l0, _L1& __l1) {
|
||||
__l0.unlock();
|
||||
__l1.unlock();
|
||||
}
|
||||
|
||||
template <class _L0, class _L1, class _L2, class ..._L3>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
|
||||
__l0.unlock();
|
||||
__l1.unlock();
|
||||
_VSTD::__unlock(__l2, __l3...);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
@ -579,6 +611,63 @@ call_once(once_flag& __flag, const _Callable& __func)
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
|
||||
#if defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD) \
|
||||
&& !defined(_LIBCPP_CXX03_LANG)
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS_ONLY lock_guard<> {
|
||||
public:
|
||||
explicit lock_guard() {}
|
||||
~lock_guard() = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit lock_guard(adopt_lock_t) {}
|
||||
|
||||
lock_guard(lock_guard const&) = delete;
|
||||
lock_guard& operator=(lock_guard const&) = delete;
|
||||
};
|
||||
|
||||
template <class ..._MArgs>
|
||||
class _LIBCPP_TYPE_VIS_ONLY lock_guard
|
||||
{
|
||||
static_assert(sizeof...(_MArgs) >= 2, "At least 2 lock types required");
|
||||
typedef tuple<_MArgs&...> _MutexTuple;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit lock_guard(_MArgs&... __margs)
|
||||
: __t_(__margs...)
|
||||
{
|
||||
_VSTD::lock(__margs...);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
lock_guard(_MArgs&... __margs, adopt_lock_t)
|
||||
: __t_(__margs...)
|
||||
{
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~lock_guard() {
|
||||
typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices;
|
||||
__unlock_unpack(_Indices{}, __t_);
|
||||
}
|
||||
|
||||
lock_guard(lock_guard const&) = delete;
|
||||
lock_guard& operator=(lock_guard const&) = delete;
|
||||
|
||||
private:
|
||||
template <size_t ..._Indx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
|
||||
_VSTD::__unlock(_VSTD::get<_Indx>(__mt)...);
|
||||
}
|
||||
|
||||
_MutexTuple __t_;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_ABI_VARIADIC_LOCK_GUARD
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_MUTEX
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
template <class... Args> void emplace(Args&&... args);
|
||||
void pop();
|
||||
|
||||
void swap(queue& q) noexcept(noexcept(swap(c, q.c)));
|
||||
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
||||
};
|
||||
|
||||
template <class T, class Container>
|
||||
@ -153,7 +153,8 @@ public:
|
||||
void pop();
|
||||
|
||||
void swap(priority_queue& q)
|
||||
noexcept(noexcept(swap(c, q.c)) && noexcept(swap(comp.q.comp)));
|
||||
noexcept(is_nothrow_swappable_v<Container> &&
|
||||
is_nothrow_swappable_v<Comp>)
|
||||
};
|
||||
|
||||
template <class T, class Container, class Compare>
|
||||
@ -198,6 +199,7 @@ public:
|
||||
typedef typename container_type::reference reference;
|
||||
typedef typename container_type::const_reference const_reference;
|
||||
typedef typename container_type::size_type size_type;
|
||||
static_assert((is_same<_Tp, value_type>::value), "" );
|
||||
|
||||
protected:
|
||||
container_type c;
|
||||
@ -368,7 +370,10 @@ operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
typename enable_if<
|
||||
__is_swappable<_Container>::value,
|
||||
void
|
||||
>::type
|
||||
swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
{
|
||||
@ -392,6 +397,7 @@ public:
|
||||
typedef typename container_type::reference reference;
|
||||
typedef typename container_type::const_reference const_reference;
|
||||
typedef typename container_type::size_type size_type;
|
||||
static_assert((is_same<_Tp, value_type>::value), "" );
|
||||
|
||||
protected:
|
||||
container_type c;
|
||||
@ -430,45 +436,56 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit priority_queue(const value_compare& __comp)
|
||||
: c(), comp(__comp) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(const value_compare& __comp, const container_type& __c);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit priority_queue(const value_compare& __comp, container_type&& __c);
|
||||
#endif
|
||||
template <class _InputIter>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(_InputIter __f, _InputIter __l,
|
||||
const value_compare& __comp = value_compare());
|
||||
template <class _InputIter>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(_InputIter __f, _InputIter __l,
|
||||
const value_compare& __comp, const container_type& __c);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _InputIter>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(_InputIter __f, _InputIter __l,
|
||||
const value_compare& __comp, container_type&& __c);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit priority_queue(const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0);
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(const value_compare& __comp, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0);
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(const value_compare& __comp, const container_type& __c,
|
||||
const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0);
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(const priority_queue& __q, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(const value_compare& __comp, container_type&& __c,
|
||||
const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0);
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
priority_queue(priority_queue&& __q, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0);
|
||||
@ -481,22 +498,26 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference top() const {return c.front();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void push(const value_type& __v);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void push(value_type&& __v);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class... _Args> void emplace(_Args&&... __args);
|
||||
template <class... _Args> _LIBCPP_INLINE_VISIBILITY void emplace(_Args&&... __args);
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void pop();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(priority_queue& __q)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
|
||||
__is_nothrow_swappable<value_compare>::value);
|
||||
};
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
|
||||
const container_type& __c)
|
||||
: c(__c),
|
||||
@ -508,7 +529,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
|
||||
container_type&& __c)
|
||||
: c(_VSTD::move(__c)),
|
||||
@ -521,7 +542,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _InputIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
|
||||
const value_compare& __comp)
|
||||
: c(__f, __l),
|
||||
@ -532,7 +553,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _InputIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
|
||||
const value_compare& __comp,
|
||||
const container_type& __c)
|
||||
@ -547,7 +568,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _InputIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
|
||||
const value_compare& __comp,
|
||||
container_type&& __c)
|
||||
@ -562,7 +583,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type*)
|
||||
@ -572,7 +593,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
|
||||
const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
@ -584,7 +605,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
|
||||
const container_type& __c,
|
||||
const _Alloc& __a,
|
||||
@ -598,7 +619,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
|
||||
const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
@ -613,7 +634,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue&
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
|
||||
container_type&& __c,
|
||||
const _Alloc& __a,
|
||||
@ -627,7 +648,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
|
||||
const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
@ -641,7 +662,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
|
||||
{
|
||||
@ -652,7 +673,7 @@ priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
|
||||
{
|
||||
@ -664,7 +685,7 @@ priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
template <class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
|
||||
{
|
||||
@ -676,7 +697,7 @@ priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
priority_queue<_Tp, _Container, _Compare>::pop()
|
||||
{
|
||||
@ -685,7 +706,7 @@ priority_queue<_Tp, _Container, _Compare>::pop()
|
||||
}
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
|
||||
@ -698,7 +719,11 @@ priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
typename enable_if<
|
||||
__is_swappable<_Container>::value
|
||||
&& __is_swappable<_Compare>::value,
|
||||
void
|
||||
>::type
|
||||
swap(priority_queue<_Tp, _Container, _Compare>& __x,
|
||||
priority_queue<_Tp, _Container, _Compare>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
|
@ -319,25 +319,25 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit shared_lock(mutex_type& __m)
|
||||
: __m_(&__m),
|
||||
: __m_(_VSTD::addressof(__m)),
|
||||
__owns_(true)
|
||||
{__m_->lock_shared();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
|
||||
: __m_(&__m),
|
||||
: __m_(_VSTD::addressof(__m)),
|
||||
__owns_(false)
|
||||
{}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(mutex_type& __m, try_to_lock_t)
|
||||
: __m_(&__m),
|
||||
: __m_(_VSTD::addressof(__m)),
|
||||
__owns_(__m.try_lock_shared())
|
||||
{}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(mutex_type& __m, adopt_lock_t)
|
||||
: __m_(&__m),
|
||||
: __m_(_VSTD::addressof(__m)),
|
||||
__owns_(true)
|
||||
{}
|
||||
|
||||
@ -345,7 +345,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(mutex_type& __m,
|
||||
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
||||
: __m_(&__m),
|
||||
: __m_(_VSTD::addressof(__m)),
|
||||
__owns_(__m.try_lock_shared_until(__abs_time))
|
||||
{}
|
||||
|
||||
@ -353,7 +353,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
shared_lock(mutex_type& __m,
|
||||
const chrono::duration<_Rep, _Period>& __rel_time)
|
||||
: __m_(&__m),
|
||||
: __m_(_VSTD::addressof(__m)),
|
||||
__owns_(__m.try_lock_shared_for(__rel_time))
|
||||
{}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
template <class... Args> void emplace(Args&&... args);
|
||||
void pop();
|
||||
|
||||
void swap(stack& c) noexcept(noexcept(swap(c, q.c)));
|
||||
void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
|
||||
};
|
||||
|
||||
template <class T, class Container>
|
||||
@ -112,7 +112,8 @@ public:
|
||||
typedef typename container_type::reference reference;
|
||||
typedef typename container_type::const_reference const_reference;
|
||||
typedef typename container_type::size_type size_type;
|
||||
|
||||
static_assert((is_same<_Tp, value_type>::value), "" );
|
||||
|
||||
protected:
|
||||
container_type c;
|
||||
|
||||
@ -274,7 +275,10 @@ operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
typename enable_if<
|
||||
__is_swappable<_Container>::value,
|
||||
void
|
||||
>::type
|
||||
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
{
|
||||
|
39
contrib/libc++/include/stdbool.h
Normal file
39
contrib/libc++/include/stdbool.h
Normal file
@ -0,0 +1,39 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- stdbool.h --------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifndef _LIBCPP_STDBOOL_H
|
||||
#define _LIBCPP_STDBOOL_H
|
||||
|
||||
|
||||
/*
|
||||
stdbool.h synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
__bool_true_false_are_defined
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include_next <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#undef bool
|
||||
#undef true
|
||||
#undef false
|
||||
#undef __bool_true_false_are_defined
|
||||
#define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_STDBOOL_H
|
@ -53,7 +53,11 @@ public:
|
||||
#ifndef _LIBCPP___REFSTRING
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
class _LIBCPP_HIDDEN __libcpp_refstring {
|
||||
const char *__imp_ _LIBCPP_UNUSED;
|
||||
#ifdef __clang__
|
||||
const char *__imp_ __attribute__((__unused__)); // only clang emits a warning
|
||||
#else
|
||||
const char *__imp_;
|
||||
#endif
|
||||
};
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
#endif
|
||||
|
@ -495,12 +495,22 @@ basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
|
||||
const int_type __eof = traits_type::eof();
|
||||
int_type __c;
|
||||
streamsize __i = 0;
|
||||
for (;__i < __n; ++__i, ++__s)
|
||||
while(__i < __n)
|
||||
{
|
||||
if (__ninp_ < __einp_)
|
||||
*__s = *__ninp_++;
|
||||
{
|
||||
const streamsize __len = _VSTD::min(__einp_ - __ninp_, __n - __i);
|
||||
traits_type::copy(__s, __ninp_, __len);
|
||||
__s += __len;
|
||||
__i += __len;
|
||||
this->gbump(__len);
|
||||
}
|
||||
else if ((__c = uflow()) != __eof)
|
||||
{
|
||||
*__s = traits_type::to_char_type(__c);
|
||||
++__s;
|
||||
++__i;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
@ -98,8 +98,10 @@ public:
|
||||
basic_string(const basic_string& str);
|
||||
basic_string(basic_string&& str)
|
||||
noexcept(is_nothrow_move_constructible<allocator_type>::value);
|
||||
basic_string(const basic_string& str, size_type pos, size_type n = npos,
|
||||
basic_string(const basic_string& str, size_type pos,
|
||||
const allocator_type& a = allocator_type());
|
||||
basic_string(const basic_string& str, size_type pos, size_type n,
|
||||
const Allocator& a = Allocator());
|
||||
basic_string(const value_type* s, const allocator_type& a = allocator_type());
|
||||
basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());
|
||||
basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());
|
||||
@ -225,6 +227,7 @@ public:
|
||||
|
||||
const value_type* c_str() const noexcept;
|
||||
const value_type* data() const noexcept;
|
||||
value_type* data() noexcept; // C++17
|
||||
|
||||
allocator_type get_allocator() const noexcept;
|
||||
|
||||
@ -958,7 +961,7 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
|
||||
|
||||
// __str_find
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
@ -971,7 +974,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
|
||||
}
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
@ -982,7 +985,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __r =
|
||||
_VSTD::__search(__p + __pos, __p + __sz,
|
||||
__s, __s + __n, _Traits::eq,
|
||||
random_access_iterator_tag(), random_access_iterator_tag());
|
||||
random_access_iterator_tag(), random_access_iterator_tag()).first;
|
||||
if (__r == __p + __sz)
|
||||
return __npos;
|
||||
return static_cast<_SizeT>(__r - __p);
|
||||
@ -992,7 +995,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
|
||||
// __str_rfind
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_rfind(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
@ -1011,7 +1014,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
|
||||
}
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_rfind(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
@ -1030,7 +1033,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
|
||||
|
||||
// __str_find_first_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_first_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
@ -1046,7 +1049,7 @@ __str_find_first_of(const _CharT *__p, _SizeT __sz,
|
||||
|
||||
// __str_find_last_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_last_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
@ -1069,7 +1072,7 @@ __str_find_last_of(const _CharT *__p, _SizeT __sz,
|
||||
|
||||
// __str_find_first_not_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
@ -1085,7 +1088,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
|
||||
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
@ -1102,7 +1105,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
|
||||
|
||||
// __str_find_last_not_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
@ -1118,7 +1121,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
|
||||
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
@ -1396,7 +1399,10 @@ public:
|
||||
basic_string(size_type __n, value_type __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(size_type __n, value_type __c, const allocator_type& __a);
|
||||
basic_string(const basic_string& __str, size_type __pos, size_type __n = npos,
|
||||
basic_string(const basic_string& __str, size_type __pos, size_type __n,
|
||||
const allocator_type& __a = allocator_type());
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(const basic_string& __str, size_type __pos,
|
||||
const allocator_type& __a = allocator_type());
|
||||
template<class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1546,7 +1552,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY const_reference back() const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& assign(const basic_string& __str);
|
||||
basic_string& assign(const basic_string& __str) { return *this = __str; }
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& assign(basic_string&& str)
|
||||
@ -1659,6 +1665,10 @@ public:
|
||||
const value_type* c_str() const _NOEXCEPT {return data();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
|
||||
@ -2217,6 +2227,21 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
|
||||
const allocator_type& __a)
|
||||
: __r_(__a)
|
||||
{
|
||||
size_type __str_sz = __str.size();
|
||||
if (__pos > __str_sz)
|
||||
this->__throw_out_of_range();
|
||||
__init(__str.data() + __pos, __str_sz - __pos);
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
template <class _InputIterator>
|
||||
typename enable_if
|
||||
@ -2466,7 +2491,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
|
||||
if (this != &__str)
|
||||
{
|
||||
__copy_assign_alloc(__str);
|
||||
assign(__str);
|
||||
assign(__str.data(), __str.size());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -2557,14 +2582,6 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str)
|
||||
{
|
||||
return assign(__str.data(), __str.size());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
|
||||
|
110
contrib/libc++/include/string.h
Normal file
110
contrib/libc++/include/string.h
Normal file
@ -0,0 +1,110 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- string.h ---------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_STRING_H
|
||||
#define _LIBCPP_STRING_H
|
||||
|
||||
/*
|
||||
string.h synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
NULL
|
||||
|
||||
Types:
|
||||
|
||||
size_t
|
||||
|
||||
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
|
||||
void* memmove(void* s1, const void* s2, size_t n);
|
||||
char* strcpy (char* restrict s1, const char* restrict s2);
|
||||
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
|
||||
char* strcat (char* restrict s1, const char* restrict s2);
|
||||
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
|
||||
int memcmp(const void* s1, const void* s2, size_t n);
|
||||
int strcmp (const char* s1, const char* s2);
|
||||
int strncmp(const char* s1, const char* s2, size_t n);
|
||||
int strcoll(const char* s1, const char* s2);
|
||||
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
|
||||
const void* memchr(const void* s, int c, size_t n);
|
||||
void* memchr( void* s, int c, size_t n);
|
||||
const char* strchr(const char* s, int c);
|
||||
char* strchr( char* s, int c);
|
||||
size_t strcspn(const char* s1, const char* s2);
|
||||
const char* strpbrk(const char* s1, const char* s2);
|
||||
char* strpbrk( char* s1, const char* s2);
|
||||
const char* strrchr(const char* s, int c);
|
||||
char* strrchr( char* s, int c);
|
||||
size_t strspn(const char* s1, const char* s2);
|
||||
const char* strstr(const char* s1, const char* s2);
|
||||
char* strstr( char* s1, const char* s2);
|
||||
char* strtok(char* restrict s1, const char* restrict s2);
|
||||
void* memset(void* s, int c, size_t n);
|
||||
char* strerror(int errnum);
|
||||
size_t strlen(const char* s);
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include_next <string.h>
|
||||
|
||||
// MSVCRT, GNU libc and its derivates may already have the correct prototype in
|
||||
// <string.h>. This macro can be defined by users if their C library provides
|
||||
// the right signature.
|
||||
#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
|
||||
defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
|
||||
#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
|
||||
extern "C++" {
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_STRING_H
|
@ -98,8 +98,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
#include <tuple>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <__threading_support>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -137,7 +136,7 @@ public:
|
||||
template <class _Tp>
|
||||
class __thread_specific_ptr
|
||||
{
|
||||
pthread_key_t __key_;
|
||||
__libcpp_tl_key __key_;
|
||||
|
||||
// Only __thread_local_data() may construct a __thread_specific_ptr
|
||||
// and only with _Tp == __thread_struct.
|
||||
@ -155,7 +154,7 @@ public:
|
||||
~__thread_specific_ptr();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer get() const {return static_cast<_Tp*>(pthread_getspecific(__key_));}
|
||||
pointer get() const {return static_cast<_Tp*>(__libcpp_tl_get(__key_));}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator*() const {return *get();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -174,12 +173,12 @@ __thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
|
||||
template <class _Tp>
|
||||
__thread_specific_ptr<_Tp>::__thread_specific_ptr()
|
||||
{
|
||||
int __ec = pthread_key_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
int __ec = __libcpp_tl_create(
|
||||
&__key_,
|
||||
&__thread_specific_ptr::__at_thread_exit);
|
||||
if (__ec)
|
||||
throw system_error(error_code(__ec, system_category()),
|
||||
__throw_system_error(__ec,
|
||||
"__thread_specific_ptr construction failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
@ -196,7 +195,7 @@ typename __thread_specific_ptr<_Tp>::pointer
|
||||
__thread_specific_ptr<_Tp>::release()
|
||||
{
|
||||
pointer __p = get();
|
||||
pthread_setspecific(__key_, 0);
|
||||
__libcpp_tl_set(__key_, nullptr);
|
||||
return __p;
|
||||
}
|
||||
|
||||
@ -205,7 +204,7 @@ void
|
||||
__thread_specific_ptr<_Tp>::reset(pointer __p)
|
||||
{
|
||||
pointer __p_old = get();
|
||||
pthread_setspecific(__key_, __p);
|
||||
__libcpp_tl_set(__key_, __p);
|
||||
delete __p_old;
|
||||
}
|
||||
|
||||
@ -219,14 +218,14 @@ _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT;
|
||||
|
||||
} // this_thread
|
||||
|
||||
template<> struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>;
|
||||
template<> struct hash<__thread_id>;
|
||||
|
||||
class _LIBCPP_TYPE_VIS_ONLY __thread_id
|
||||
{
|
||||
// FIXME: pthread_t is a pointer on Darwin but a long on Linux.
|
||||
// NULL is the no-thread value on Darwin. Someone needs to check
|
||||
// on other platforms. We assume 0 works everywhere for now.
|
||||
pthread_t __id_;
|
||||
__libcpp_thread_id __id_;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -234,13 +233,13 @@ public:
|
||||
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT
|
||||
{return __x.__id_ == __y.__id_;}
|
||||
{return __libcpp_thread_id_equal(__x.__id_, __y.__id_);}
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT
|
||||
{return !(__x == __y);}
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator< (__thread_id __x, __thread_id __y) _NOEXCEPT
|
||||
{return __x.__id_ < __y.__id_;}
|
||||
{return __libcpp_thread_id_less(__x.__id_, __y.__id_);}
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT
|
||||
{return !(__y < __x);}
|
||||
@ -260,7 +259,7 @@ public:
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__thread_id(pthread_t __id) : __id_(__id) {}
|
||||
__thread_id(__libcpp_thread_id __id) : __id_(__id) {}
|
||||
|
||||
friend __thread_id this_thread::get_id() _NOEXCEPT;
|
||||
friend class _LIBCPP_TYPE_VIS thread;
|
||||
@ -274,7 +273,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(__thread_id __v) const
|
||||
{
|
||||
return hash<pthread_t>()(__v.__id_);
|
||||
return hash<__libcpp_thread_id>()(__v.__id_);
|
||||
}
|
||||
};
|
||||
|
||||
@ -285,20 +284,20 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
__thread_id
|
||||
get_id() _NOEXCEPT
|
||||
{
|
||||
return pthread_self();
|
||||
return __libcpp_thread_get_current_id();
|
||||
}
|
||||
|
||||
} // this_thread
|
||||
|
||||
class _LIBCPP_TYPE_VIS thread
|
||||
{
|
||||
pthread_t __t_;
|
||||
__libcpp_thread_t __t_;
|
||||
|
||||
thread(const thread&);
|
||||
thread& operator=(const thread&);
|
||||
public:
|
||||
typedef __thread_id id;
|
||||
typedef pthread_t native_handle_type;
|
||||
typedef __libcpp_thread_t native_handle_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
thread() _NOEXCEPT : __t_(0) {}
|
||||
@ -330,7 +329,7 @@ public:
|
||||
void join();
|
||||
void detach();
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
id get_id() const _NOEXCEPT {return __t_;}
|
||||
id get_id() const _NOEXCEPT {return __libcpp_thread_get_id(&__t_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
native_handle_type native_handle() _NOEXCEPT {return __t_;}
|
||||
|
||||
@ -339,21 +338,21 @@ public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Fp, class ..._Args, size_t ..._Indices>
|
||||
template <class _TSp, class _Fp, class ..._Args, size_t ..._Indices>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__thread_execute(tuple<_Fp, _Args...>& __t, __tuple_indices<_Indices...>)
|
||||
__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
|
||||
{
|
||||
__invoke(_VSTD::move(_VSTD::get<0>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
|
||||
__invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
|
||||
}
|
||||
|
||||
template <class _Fp>
|
||||
void*
|
||||
__thread_proxy(void* __vp)
|
||||
void* __thread_proxy(void* __vp)
|
||||
{
|
||||
__thread_local_data().reset(new __thread_struct);
|
||||
// _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
|
||||
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
|
||||
typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index;
|
||||
__thread_local_data().reset(_VSTD::get<0>(*__p).release());
|
||||
typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index;
|
||||
__thread_execute(*__p, _Index());
|
||||
return nullptr;
|
||||
}
|
||||
@ -363,10 +362,14 @@ template <class _Fp, class ..._Args,
|
||||
>
|
||||
thread::thread(_Fp&& __f, _Args&&... __args)
|
||||
{
|
||||
typedef tuple<typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
|
||||
_VSTD::unique_ptr<_Gp> __p(new _Gp(__decay_copy(_VSTD::forward<_Fp>(__f)),
|
||||
__decay_copy(_VSTD::forward<_Args>(__args))...));
|
||||
int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Gp>, __p.get());
|
||||
typedef unique_ptr<__thread_struct> _TSPtr;
|
||||
_TSPtr __tsp(new __thread_struct);
|
||||
typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp;
|
||||
_VSTD::unique_ptr<_Gp> __p(
|
||||
new _Gp(std::move(__tsp),
|
||||
__decay_copy(_VSTD::forward<_Fp>(__f)),
|
||||
__decay_copy(_VSTD::forward<_Args>(__args))...));
|
||||
int __ec = __libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
|
||||
if (__ec == 0)
|
||||
__p.release();
|
||||
else
|
||||
@ -376,22 +379,34 @@ thread::thread(_Fp&& __f, _Args&&... __args)
|
||||
#else // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Fp>
|
||||
void*
|
||||
__thread_proxy(void* __vp)
|
||||
struct __thread_invoke_pair {
|
||||
// This type is used to pass memory for thread local storage and a functor
|
||||
// to a newly created thread because std::pair doesn't work with
|
||||
// std::unique_ptr in C++03.
|
||||
__thread_invoke_pair(_Fp& __f) : __tsp_(new __thread_struct), __fn_(__f) {}
|
||||
unique_ptr<__thread_struct> __tsp_;
|
||||
_Fp __fn_;
|
||||
};
|
||||
|
||||
template <class _Fp>
|
||||
void* __thread_proxy_cxx03(void* __vp)
|
||||
{
|
||||
__thread_local_data().reset(new __thread_struct);
|
||||
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
|
||||
(*__p)();
|
||||
__thread_local_data().reset(__p->__tsp_.release());
|
||||
(__p->__fn_)();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class _Fp>
|
||||
thread::thread(_Fp __f)
|
||||
{
|
||||
std::unique_ptr<_Fp> __p(new _Fp(__f));
|
||||
int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Fp>, __p.get());
|
||||
|
||||
typedef __thread_invoke_pair<_Fp> _InvokePair;
|
||||
typedef std::unique_ptr<_InvokePair> _PairPtr;
|
||||
_PairPtr __pp(new _InvokePair(__f));
|
||||
int __ec = __libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
|
||||
if (__ec == 0)
|
||||
__p.release();
|
||||
__pp.release();
|
||||
else
|
||||
__throw_system_error(__ec, "thread constructor failed");
|
||||
}
|
||||
@ -464,7 +479,7 @@ sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void yield() _NOEXCEPT {sched_yield();}
|
||||
void yield() _NOEXCEPT {__libcpp_thread_yield();}
|
||||
|
||||
} // this_thread
|
||||
|
||||
|
@ -76,10 +76,18 @@ 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; // constexpr in C++14
|
||||
template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
|
||||
|
||||
|
||||
// [tuple.apply], calling a function with a tuple of arguments:
|
||||
template <class F, class Tuple>
|
||||
constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
|
||||
template <class T, class Tuple>
|
||||
constexpr T make_from_tuple(Tuple&& t); // C++17
|
||||
|
||||
// 20.4.1.4, tuple helper classes:
|
||||
template <class T> class tuple_size; // undefined
|
||||
template <class... T> class tuple_size<tuple<T...>>;
|
||||
template <class T>
|
||||
constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
|
||||
template <size_t I, class T> class tuple_element; // undefined
|
||||
template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
|
||||
template <size_t I, class T>
|
||||
@ -379,10 +387,8 @@ template <class ..._Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __swallow(_Tp&&...) _NOEXCEPT {}
|
||||
|
||||
template <bool ..._Pred>
|
||||
struct __all
|
||||
: is_same<__all<_Pred...>, __all<(_Pred, true)...>>
|
||||
{ };
|
||||
template <class ..._Tp>
|
||||
struct __lazy_all : __all<_Tp::value...> {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __all_default_constructible;
|
||||
@ -446,7 +452,7 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
|
||||
template <class _Alloc, class _Tuple,
|
||||
class = typename enable_if
|
||||
<
|
||||
__tuple_convertible<_Tuple, tuple<_Tp...> >::value
|
||||
__tuple_constructible<_Tuple, tuple<_Tp...> >::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -499,6 +505,28 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
|
||||
}
|
||||
};
|
||||
|
||||
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
|
||||
struct __tuple_like_with_size_imp : false_type {};
|
||||
|
||||
template <class _SizeTrait, size_t _Expected>
|
||||
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
|
||||
: integral_constant<bool, _SizeTrait::value == _Expected> {};
|
||||
|
||||
template <class _Tuple, size_t _ExpectedSize,
|
||||
class _RawTuple = typename __uncvref<_Tuple>::type>
|
||||
using __tuple_like_with_size = __tuple_like_with_size_imp<
|
||||
__tuple_like<_RawTuple>::value,
|
||||
tuple_size<_RawTuple>, _ExpectedSize
|
||||
>;
|
||||
|
||||
|
||||
struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
|
||||
template <class ...>
|
||||
static constexpr bool __enable_explicit() { return false; }
|
||||
template <class ...>
|
||||
static constexpr bool __enable_implicit() { return false; }
|
||||
};
|
||||
|
||||
template <class ..._Tp>
|
||||
class _LIBCPP_TYPE_VIS_ONLY tuple
|
||||
{
|
||||
@ -506,6 +534,118 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
|
||||
|
||||
base base_;
|
||||
|
||||
template <class ..._Args>
|
||||
struct _PackExpandsToThisTuple : false_type {};
|
||||
|
||||
template <class _Arg>
|
||||
struct _PackExpandsToThisTuple<_Arg>
|
||||
: is_same<typename __uncvref<_Arg>::type, tuple> {};
|
||||
|
||||
template <bool _MaybeEnable, class _Dummy = void>
|
||||
struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
|
||||
|
||||
template <class _Dummy>
|
||||
struct _CheckArgsConstructor<true, _Dummy>
|
||||
{
|
||||
template <class ..._Args>
|
||||
static constexpr bool __enable_explicit() {
|
||||
return
|
||||
__tuple_constructible<
|
||||
tuple<_Args...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
sizeof...(_Args) < sizeof...(_Tp) ?
|
||||
sizeof...(_Args) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
!__tuple_convertible<
|
||||
tuple<_Args...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
sizeof...(_Args) < sizeof...(_Tp) ?
|
||||
sizeof...(_Args) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
__all_default_constructible<
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
||||
sizeof...(_Args) < sizeof...(_Tp) ?
|
||||
sizeof...(_Args) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value;
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
static constexpr bool __enable_implicit() {
|
||||
return
|
||||
__tuple_convertible<
|
||||
tuple<_Args...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
sizeof...(_Args) < sizeof...(_Tp) ?
|
||||
sizeof...(_Args) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
__all_default_constructible<
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
||||
sizeof...(_Args) < sizeof...(_Tp) ?
|
||||
sizeof...(_Args) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool _MaybeEnable,
|
||||
bool = sizeof...(_Tp) == 1,
|
||||
class _Dummy = void>
|
||||
struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
|
||||
|
||||
template <class _Dummy>
|
||||
struct _CheckTupleLikeConstructor<true, false, _Dummy>
|
||||
{
|
||||
template <class _Tuple>
|
||||
static constexpr bool __enable_implicit() {
|
||||
return __tuple_convertible<_Tuple, tuple>::value;
|
||||
}
|
||||
|
||||
template <class _Tuple>
|
||||
static constexpr bool __enable_explicit() {
|
||||
return __tuple_constructible<_Tuple, tuple>::value
|
||||
&& !__tuple_convertible<_Tuple, tuple>::value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Dummy>
|
||||
struct _CheckTupleLikeConstructor<true, true, _Dummy>
|
||||
{
|
||||
// This trait is used to disable the tuple-like constructor when
|
||||
// the UTypes... constructor should be selected instead.
|
||||
// See LWG issue #2549.
|
||||
template <class _Tuple>
|
||||
using _PreferTupleLikeConstructor = __lazy_or<
|
||||
// Don't attempt the two checks below if the tuple we are given
|
||||
// has the same type as this tuple.
|
||||
is_same<typename __uncvref<_Tuple>::type, tuple>,
|
||||
__lazy_and<
|
||||
__lazy_not<is_constructible<_Tp..., _Tuple>>,
|
||||
__lazy_not<is_convertible<_Tuple, _Tp...>>
|
||||
>
|
||||
>;
|
||||
|
||||
template <class _Tuple>
|
||||
static constexpr bool __enable_implicit() {
|
||||
return __lazy_and<
|
||||
__tuple_convertible<_Tuple, tuple>,
|
||||
_PreferTupleLikeConstructor<_Tuple>
|
||||
>::value;
|
||||
}
|
||||
|
||||
template <class _Tuple>
|
||||
static constexpr bool __enable_explicit() {
|
||||
return __lazy_and<
|
||||
__tuple_constructible<_Tuple, tuple>,
|
||||
_PreferTupleLikeConstructor<_Tuple>,
|
||||
__lazy_not<__tuple_convertible<_Tuple, tuple>>
|
||||
>::value;
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
|
||||
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
@ -523,8 +663,30 @@ public:
|
||||
_LIBCPP_CONSTEXPR tuple()
|
||||
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
|
||||
|
||||
template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
|
||||
__lazy_and<
|
||||
is_same<allocator_arg_t, _AllocArgT>,
|
||||
__lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
|
||||
>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple(_AllocArgT, _Alloc const& __a)
|
||||
: base_(allocator_arg_t(), __a,
|
||||
__tuple_indices<>(), __tuple_types<>(),
|
||||
typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
|
||||
__tuple_types<_Tp...>()) {}
|
||||
|
||||
template <bool _Dummy = true,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckArgsConstructor<
|
||||
_Dummy
|
||||
>::template __enable_implicit<_Tp...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
|
||||
tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
|
||||
: base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
|
||||
typename __make_tuple_indices<0>::type(),
|
||||
@ -532,7 +694,33 @@ public:
|
||||
__t...
|
||||
) {}
|
||||
|
||||
template <class _Alloc>
|
||||
template <bool _Dummy = true,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckArgsConstructor<
|
||||
_Dummy
|
||||
>::template __enable_explicit<_Tp...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
|
||||
: base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
|
||||
typename __make_tuple_indices<0>::type(),
|
||||
typename __make_tuple_types<tuple, 0>::type(),
|
||||
__t...
|
||||
) {}
|
||||
|
||||
template <class _Alloc, bool _Dummy = true,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckArgsConstructor<
|
||||
_Dummy
|
||||
>::template __enable_implicit<_Tp...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
|
||||
: base_(allocator_arg_t(), __a,
|
||||
@ -543,24 +731,33 @@ public:
|
||||
__t...
|
||||
) {}
|
||||
|
||||
template <class _Alloc, bool _Dummy = true,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckArgsConstructor<
|
||||
_Dummy
|
||||
>::template __enable_explicit<_Tp...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit
|
||||
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
|
||||
: base_(allocator_arg_t(), __a,
|
||||
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
|
||||
typename __make_tuple_indices<0>::type(),
|
||||
typename __make_tuple_types<tuple, 0>::type(),
|
||||
__t...
|
||||
) {}
|
||||
|
||||
template <class ..._Up,
|
||||
typename enable_if
|
||||
<
|
||||
sizeof...(_Up) <= sizeof...(_Tp) &&
|
||||
__tuple_convertible
|
||||
<
|
||||
tuple<_Up...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
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,
|
||||
_CheckArgsConstructor<
|
||||
sizeof...(_Up) <= sizeof...(_Tp)
|
||||
&& !_PackExpandsToThisTuple<_Up...>::value
|
||||
>::template __enable_implicit<_Up...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
@ -584,31 +781,12 @@ public:
|
||||
template <class ..._Up,
|
||||
typename enable_if
|
||||
<
|
||||
sizeof...(_Up) <= sizeof...(_Tp) &&
|
||||
__tuple_constructible
|
||||
<
|
||||
tuple<_Up...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
sizeof...(_Up) < sizeof...(_Tp) ?
|
||||
sizeof...(_Up) :
|
||||
sizeof...(_Tp)>::type
|
||||
>::value &&
|
||||
!__tuple_convertible
|
||||
<
|
||||
tuple<_Up...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
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,
|
||||
_CheckArgsConstructor<
|
||||
sizeof...(_Up) <= sizeof...(_Tp)
|
||||
&& !_PackExpandsToThisTuple<_Up...>::value
|
||||
>::template __enable_explicit<_Up...>(),
|
||||
bool
|
||||
>::type =false
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit
|
||||
@ -629,24 +807,14 @@ public:
|
||||
_VSTD::forward<_Up>(__u)...) {}
|
||||
|
||||
template <class _Alloc, class ..._Up,
|
||||
class = typename enable_if
|
||||
typename enable_if
|
||||
<
|
||||
sizeof...(_Up) <= sizeof...(_Tp) &&
|
||||
__tuple_convertible
|
||||
<
|
||||
tuple<_Up...>,
|
||||
typename __make_tuple_types<tuple,
|
||||
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
|
||||
_CheckArgsConstructor<
|
||||
sizeof...(_Up) == sizeof...(_Tp) &&
|
||||
!_PackExpandsToThisTuple<_Up...>::value
|
||||
>::template __enable_implicit<_Up...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
|
||||
@ -657,10 +825,33 @@ public:
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
|
||||
_VSTD::forward<_Up>(__u)...) {}
|
||||
|
||||
template <class _Alloc, class ..._Up,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckArgsConstructor<
|
||||
sizeof...(_Up) == sizeof...(_Tp) &&
|
||||
!_PackExpandsToThisTuple<_Up...>::value
|
||||
>::template __enable_explicit<_Up...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit
|
||||
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
|
||||
: base_(allocator_arg_t(), __a,
|
||||
typename __make_tuple_indices<sizeof...(_Up)>::type(),
|
||||
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
|
||||
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
|
||||
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
|
||||
_VSTD::forward<_Up>(__u)...) {}
|
||||
|
||||
template <class _Tuple,
|
||||
typename enable_if
|
||||
<
|
||||
__tuple_convertible<_Tuple, tuple>::value,
|
||||
_CheckTupleLikeConstructor<
|
||||
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
|
||||
&& !_PackExpandsToThisTuple<_Tuple>::value
|
||||
>::template __enable_implicit<_Tuple>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
@ -671,8 +862,10 @@ public:
|
||||
template <class _Tuple,
|
||||
typename enable_if
|
||||
<
|
||||
__tuple_constructible<_Tuple, tuple>::value &&
|
||||
!__tuple_convertible<_Tuple, tuple>::value,
|
||||
_CheckTupleLikeConstructor<
|
||||
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
|
||||
&& !_PackExpandsToThisTuple<_Tuple>::value
|
||||
>::template __enable_explicit<_Tuple>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
@ -682,15 +875,32 @@ public:
|
||||
: base_(_VSTD::forward<_Tuple>(__t)) {}
|
||||
|
||||
template <class _Alloc, class _Tuple,
|
||||
class = typename enable_if
|
||||
typename enable_if
|
||||
<
|
||||
__tuple_convertible<_Tuple, tuple>::value
|
||||
>::type
|
||||
_CheckTupleLikeConstructor<
|
||||
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
|
||||
>::template __enable_implicit<_Tuple>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
|
||||
: base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
|
||||
|
||||
template <class _Alloc, class _Tuple,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckTupleLikeConstructor<
|
||||
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
|
||||
>::template __enable_explicit<_Tuple>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit
|
||||
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
|
||||
: base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
|
||||
|
||||
template <class _Tuple,
|
||||
class = typename enable_if
|
||||
<
|
||||
@ -784,39 +994,44 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
// get by type
|
||||
template <typename _T1, size_t _Idx, typename... _Args>
|
||||
struct __find_exactly_one_t_helper;
|
||||
|
||||
// -- find exactly one
|
||||
template <typename _T1, size_t _Idx, typename... _Args>
|
||||
struct __find_exactly_one_t_checker {
|
||||
static constexpr size_t value = _Idx;
|
||||
// Check the rest of the list to make sure there's only one
|
||||
static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
|
||||
};
|
||||
namespace __find_detail {
|
||||
|
||||
static constexpr size_t __not_found = -1;
|
||||
static constexpr size_t __ambiguous = __not_found - 1;
|
||||
|
||||
template <typename _T1, size_t _Idx>
|
||||
struct __find_exactly_one_t_helper <_T1, _Idx> {
|
||||
static constexpr size_t value = -1;
|
||||
};
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
|
||||
return !__matches ? __res :
|
||||
(__res == __not_found ? __curr_i : __ambiguous);
|
||||
}
|
||||
|
||||
template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
|
||||
struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
|
||||
static constexpr size_t value =
|
||||
std::conditional<
|
||||
std::is_same<_T1, _Head>::value,
|
||||
__find_exactly_one_t_checker<_T1, _Idx, _Args...>,
|
||||
__find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
|
||||
>::type::value;
|
||||
};
|
||||
template <size_t _Nx>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
|
||||
return __i == _Nx ? __not_found :
|
||||
__find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
|
||||
}
|
||||
|
||||
template <class _T1, class ..._Args>
|
||||
struct __find_exactly_one_checked {
|
||||
static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
|
||||
static constexpr size_t value = __find_detail::__find_idx(0, __matches);
|
||||
static_assert (value != __not_found, "type not found in type list" );
|
||||
static_assert(value != __ambiguous,"type occurs more than once in type list");
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
struct __find_exactly_one_checked<_T1> {
|
||||
static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
|
||||
};
|
||||
|
||||
} // namespace __find_detail;
|
||||
|
||||
template <typename _T1, typename... _Args>
|
||||
struct __find_exactly_one_t {
|
||||
static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
|
||||
static_assert ( value != -1, "type not found in type list" );
|
||||
};
|
||||
struct __find_exactly_one_t
|
||||
: public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
|
||||
};
|
||||
|
||||
template <class _T1, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -1154,6 +1369,50 @@ pair<_T1, _T2>::pair(piecewise_construct_t,
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
|
||||
|
||||
#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
|
||||
|
||||
template <class _Fn, class _Tuple, size_t ..._Id>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
|
||||
__tuple_indices<_Id...>)
|
||||
_LIBCPP_NOEXCEPT_RETURN(
|
||||
_VSTD::__invoke_constexpr(
|
||||
_VSTD::forward<_Fn>(__f),
|
||||
_VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
|
||||
)
|
||||
|
||||
template <class _Fn, class _Tuple>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
|
||||
_LIBCPP_NOEXCEPT_RETURN(
|
||||
_VSTD::__apply_tuple_impl(
|
||||
_VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
|
||||
typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
|
||||
)
|
||||
|
||||
template <class _Tp, class _Tuple, size_t... _Idx>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
|
||||
_LIBCPP_NOEXCEPT_RETURN(
|
||||
_Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
|
||||
)
|
||||
|
||||
template <class _Tp, class _Tuple>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _Tp make_from_tuple(_Tuple&& __t)
|
||||
_LIBCPP_NOEXCEPT_RETURN(
|
||||
_VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
|
||||
typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
|
||||
)
|
||||
|
||||
#undef _LIBCPP_NOEXCEPT_RETURN
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_TUPLE
|
||||
|
@ -105,6 +105,8 @@ namespace std
|
||||
template <class T, class U> struct is_assignable;
|
||||
template <class T> struct is_copy_assignable;
|
||||
template <class T> struct is_move_assignable;
|
||||
template <class T, class U> struct is_swappable_with; // C++17
|
||||
template <class T> struct is_swappable; // C++17
|
||||
template <class T> struct is_destructible;
|
||||
|
||||
template <class T, class... Args> struct is_trivially_constructible;
|
||||
@ -123,6 +125,8 @@ namespace std
|
||||
template <class T, class U> struct is_nothrow_assignable;
|
||||
template <class T> struct is_nothrow_copy_assignable;
|
||||
template <class T> struct is_nothrow_move_assignable;
|
||||
template <class T, class U> struct is_nothrow_swappable_with; // C++17
|
||||
template <class T> struct is_nothrow_swappable; // C++17
|
||||
template <class T> struct is_nothrow_destructible;
|
||||
|
||||
template <class T> struct has_virtual_destructor;
|
||||
@ -132,6 +136,14 @@ namespace std
|
||||
template <class Base, class Derived> struct is_base_of;
|
||||
template <class From, class To> struct is_convertible;
|
||||
|
||||
template <class, class R = void> struct is_callable; // not defined
|
||||
template <class Fn, class... ArgTypes, class R>
|
||||
struct is_callable<Fn(ArgTypes...), R>;
|
||||
|
||||
template <class, class R = void> struct is_nothrow_callable; // not defined
|
||||
template <class Fn, class... ArgTypes, class R>
|
||||
struct is_nothrow_callable<Fn(ArgTypes...), R>;
|
||||
|
||||
// Alignment properties and transformations:
|
||||
template <class T> struct alignment_of;
|
||||
template <size_t Len, size_t Align = most_stringent_alignment_requirement>
|
||||
@ -292,6 +304,10 @@ namespace std
|
||||
= is_copy_assignable<T>::value; // C++17
|
||||
template <class T> constexpr bool is_move_assignable_v
|
||||
= is_move_assignable<T>::value; // C++17
|
||||
template <class T, class U> constexpr bool is_swappable_with_v
|
||||
= is_swappable_with<T, U>::value; // C++17
|
||||
template <class T> constexpr bool is_swappable_v
|
||||
= is_swappable<T>::value; // C++17
|
||||
template <class T> constexpr bool is_destructible_v
|
||||
= is_destructible<T>::value; // C++17
|
||||
template <class T, class... Args> constexpr bool is_trivially_constructible_v
|
||||
@ -324,6 +340,10 @@ namespace std
|
||||
= is_nothrow_copy_assignable<T>::value; // C++17
|
||||
template <class T> constexpr bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<T>::value; // C++17
|
||||
template <class T, class U> constexpr bool is_nothrow_swappable_with_v
|
||||
= is_nothrow_swappable_with<T, U>::value; // C++17
|
||||
template <class T> constexpr bool is_nothrow_swappable_v
|
||||
= is_nothrow_swappable<T>::value; // C++17
|
||||
template <class T> constexpr bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<T>::value; // C++17
|
||||
template <class T> constexpr bool has_virtual_destructor_v
|
||||
@ -344,6 +364,10 @@ namespace std
|
||||
= is_base_of<Base, Derived>::value; // C++17
|
||||
template <class From, class To> constexpr bool is_convertible_v
|
||||
= is_convertible<From, To>::value; // C++17
|
||||
template <class T, class R = void> constexpr bool is_callable_v
|
||||
= is_callable<T, R>::value; // C++17
|
||||
template <class T, class R = void> constexpr bool is_nothrow_callable_v
|
||||
= is_nothrow_callable<T, R>::value; // C++17
|
||||
|
||||
// [meta.logical], logical operator traits:
|
||||
template<class... B> struct conjunction; // C++17
|
||||
@ -368,6 +392,10 @@ namespace std
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
|
||||
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
|
||||
|
||||
template <class>
|
||||
struct __void_t { typedef void type; };
|
||||
|
||||
@ -397,15 +425,29 @@ template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp
|
||||
#endif
|
||||
|
||||
// addressof
|
||||
#if __has_builtin(__builtin_addressof)
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp*
|
||||
addressof(_Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return __builtin_addressof(__x);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp*
|
||||
addressof(_Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
|
||||
}
|
||||
|
||||
#endif // __has_builtin(__builtin_addressof)
|
||||
|
||||
#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
|
||||
// Objective-C++ Automatic Reference Counting uses qualified pointers
|
||||
// that require special addressof() signatures. When
|
||||
@ -957,6 +999,19 @@ template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
|
||||
= is_compound<_Tp>::value;
|
||||
#endif
|
||||
|
||||
|
||||
// __is_referenceable [defns.referenceable]
|
||||
|
||||
struct __is_referenceable_impl {
|
||||
template <class _Tp> static _Tp& __test(int);
|
||||
template <class _Tp> static __two __test(...);
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_referenceable : integral_constant<bool,
|
||||
!is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
|
||||
|
||||
|
||||
// add_const
|
||||
|
||||
template <class _Tp, bool = is_reference<_Tp>::value ||
|
||||
@ -1014,12 +1069,11 @@ template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::
|
||||
|
||||
// add_lvalue_reference
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
|
||||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
|
||||
template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference
|
||||
{typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
|
||||
@ -1027,11 +1081,11 @@ template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_referenc
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
|
||||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
|
||||
template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference
|
||||
{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
|
||||
@ -1041,8 +1095,11 @@ template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_referenc
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp> _Tp&& __declval(int);
|
||||
template <class _Tp> _Tp __declval(long);
|
||||
|
||||
template <class _Tp>
|
||||
typename add_rvalue_reference<_Tp>::type
|
||||
decltype(_VSTD::__declval<_Tp>(0))
|
||||
declval() _NOEXCEPT;
|
||||
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -1053,6 +1110,24 @@ declval();
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
// __uncvref
|
||||
|
||||
template <class _Tp>
|
||||
struct __uncvref {
|
||||
typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __unconstref {
|
||||
typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
|
||||
};
|
||||
|
||||
// __is_same_uncvref
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
|
||||
typename __uncvref<_Up>::type> {};
|
||||
|
||||
struct __any
|
||||
{
|
||||
__any(...);
|
||||
@ -1072,8 +1147,16 @@ template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type
|
||||
|
||||
// add_pointer
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
|
||||
template <class _Tp,
|
||||
bool = __is_referenceable<_Tp>::value ||
|
||||
is_same<typename remove_cv<_Tp>::type, void>::value>
|
||||
struct __add_pointer_impl
|
||||
{typedef typename remove_reference<_Tp>::type* type;};
|
||||
template <class _Tp> struct __add_pointer_impl<_Tp, false>
|
||||
{typedef _Tp type;};
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
|
||||
{typedef typename __add_pointer_impl<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
|
||||
@ -1301,16 +1384,9 @@ struct __is_convertible_test : public false_type {};
|
||||
|
||||
template <class _From, class _To>
|
||||
struct __is_convertible_test<_From, _To,
|
||||
decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
|
||||
decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
|
||||
{};
|
||||
|
||||
template <class _Tp> __two __test(...);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _Tp> _Tp&& __source();
|
||||
#else
|
||||
template <class _Tp> typename remove_reference<_Tp>::type& __source();
|
||||
#endif
|
||||
|
||||
template <class _Tp, bool _IsArray = is_array<_Tp>::value,
|
||||
bool _IsFunction = is_function<_Tp>::value,
|
||||
bool _IsVoid = is_void<_Tp>::value>
|
||||
@ -1350,41 +1426,6 @@ struct __is_convertible
|
||||
>
|
||||
{};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
|
||||
|
||||
template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
|
||||
template <class _T1> struct __is_convertible<const _T1, const _T1&, 1, 0> : true_type {};
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
|
||||
: public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
|
||||
: public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
|
||||
: public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
|
||||
: public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0> : public false_type {};
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _T1> struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {};
|
||||
#endif
|
||||
template <class _T1> struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {};
|
||||
template <class _T1> struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
|
||||
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
|
||||
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
|
||||
@ -2136,7 +2177,7 @@ move(_Tp&& __t) _NOEXCEPT
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&&
|
||||
forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||
forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||
{
|
||||
return static_cast<_Tp&&>(__t);
|
||||
}
|
||||
@ -2144,9 +2185,9 @@ forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&&
|
||||
forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
|
||||
forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
|
||||
{
|
||||
static_assert(!std::is_lvalue_reference<_Tp>::value,
|
||||
static_assert(!is_lvalue_reference<_Tp>::value,
|
||||
"Can not forward an rvalue as an lvalue.");
|
||||
return static_cast<_Tp&&>(__t);
|
||||
}
|
||||
@ -2172,7 +2213,7 @@ move(const _Tp& __t)
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp&
|
||||
forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||
forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||
{
|
||||
return __t;
|
||||
}
|
||||
@ -2691,6 +2732,15 @@ struct __member_pointer_traits
|
||||
// typedef ... _FnType;
|
||||
};
|
||||
|
||||
|
||||
template <class _DecayedFp>
|
||||
struct __member_pointer_class_type {};
|
||||
|
||||
template <class _Ret, class _ClassType>
|
||||
struct __member_pointer_class_type<_Ret _ClassType::*> {
|
||||
typedef _ClassType type;
|
||||
};
|
||||
|
||||
// result_of
|
||||
|
||||
template <class _Callable> class result_of;
|
||||
@ -3918,7 +3968,12 @@ template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
|
||||
= is_trivial<_Tp>::value;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
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_impl<typename remove_cv<_Tp>::type> {};
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
// Check for complete types
|
||||
|
||||
@ -4006,8 +4061,6 @@ struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
|
||||
{
|
||||
};
|
||||
|
||||
#if __has_feature(cxx_reference_qualified_functions)
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) &>
|
||||
: private __check_complete<_Class>
|
||||
@ -4056,125 +4109,257 @@ struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <class _Rp, class _Class>
|
||||
struct __check_complete<_Rp _Class::*>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class _DecayFp = typename decay<_Fp>::type,
|
||||
class _DecayA0 = typename decay<_A0>::type,
|
||||
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
|
||||
using __enable_if_bullet1 = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<_DecayFp>::value
|
||||
&& is_base_of<_ClassT, _DecayA0>::value
|
||||
>::type;
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class _DecayFp = typename decay<_Fp>::type,
|
||||
class _DecayA0 = typename decay<_A0>::type>
|
||||
using __enable_if_bullet2 = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<_DecayFp>::value
|
||||
&& __is_reference_wrapper<_DecayA0>::value
|
||||
>::type;
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class _DecayFp = typename decay<_Fp>::type,
|
||||
class _DecayA0 = typename decay<_A0>::type,
|
||||
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
|
||||
using __enable_if_bullet3 = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<_DecayFp>::value
|
||||
&& !is_base_of<_ClassT, _DecayA0>::value
|
||||
&& !__is_reference_wrapper<_DecayA0>::value
|
||||
>::type;
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class _DecayFp = typename decay<_Fp>::type,
|
||||
class _DecayA0 = typename decay<_A0>::type,
|
||||
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
|
||||
using __enable_if_bullet4 = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<_DecayFp>::value
|
||||
&& is_base_of<_ClassT, _DecayA0>::value
|
||||
>::type;
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class _DecayFp = typename decay<_Fp>::type,
|
||||
class _DecayA0 = typename decay<_A0>::type>
|
||||
using __enable_if_bullet5 = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<_DecayFp>::value
|
||||
&& __is_reference_wrapper<_DecayA0>::value
|
||||
>::type;
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class _DecayFp = typename decay<_Fp>::type,
|
||||
class _DecayA0 = typename decay<_A0>::type,
|
||||
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
|
||||
using __enable_if_bullet6 = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<_DecayFp>::value
|
||||
&& !is_base_of<_ClassT, _DecayA0>::value
|
||||
&& !__is_reference_wrapper<_DecayA0>::value
|
||||
>::type;
|
||||
|
||||
// __invoke forward declarations
|
||||
|
||||
// fall back - none of the bullets
|
||||
|
||||
#define _LIBCPP_INVOKE_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
|
||||
{ return __VA_ARGS__; }
|
||||
|
||||
template <class ..._Args>
|
||||
auto
|
||||
__invoke(__any, _Args&& ...__args)
|
||||
-> __nat;
|
||||
auto __invoke(__any, _Args&& ...__args) -> __nat;
|
||||
|
||||
// bullets 1 and 2
|
||||
template <class ..._Args>
|
||||
auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
|
||||
|
||||
// bullets 1, 2 and 3
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
class = __enable_if_bullet1<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
-> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
|
||||
_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
!is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
class = __enable_if_bullet1<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = __enable_if_bullet2<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
-> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
|
||||
_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
// bullets 3 and 4
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = __enable_if_bullet2<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = __enable_if_bullet3<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = __enable_if_bullet3<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
// bullets 4, 5 and 6
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
class = __enable_if_bullet4<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
-> decltype(_VSTD::forward<_A0>(__a0).*__f);
|
||||
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
!is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
class = __enable_if_bullet4<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
|
||||
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class = __enable_if_bullet5<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
-> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
|
||||
_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
|
||||
|
||||
// bullet 5
|
||||
template <class _Fp, class _A0,
|
||||
class = __enable_if_bullet5<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
|
||||
_LIBCPP_INVOKE_RETURN(__a0.get().*__f)
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class = __enable_if_bullet6<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
|
||||
|
||||
template <class _Fp, class _A0,
|
||||
class = __enable_if_bullet6<_Fp, _A0>>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
|
||||
_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
|
||||
|
||||
// bullet 7
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _Args&& ...__args)
|
||||
-> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
|
||||
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR auto
|
||||
__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
|
||||
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
|
||||
|
||||
#undef _LIBCPP_INVOKE_RETURN
|
||||
|
||||
// __invokable
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
struct __invokable_imp
|
||||
template <class _Ret, class _Fp, class ..._Args>
|
||||
struct __invokable_r
|
||||
: private __check_complete<_Fp>
|
||||
{
|
||||
typedef decltype(
|
||||
__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
|
||||
) type;
|
||||
static const bool value = !is_same<type, __nat>::value;
|
||||
using _Result = decltype(
|
||||
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
|
||||
|
||||
static const bool value =
|
||||
conditional<
|
||||
!is_same<_Result, __nat>::value,
|
||||
typename conditional<
|
||||
is_void<_Ret>::value,
|
||||
true_type,
|
||||
is_convertible<_Result, _Ret>
|
||||
>::type,
|
||||
false_type
|
||||
>::type::value;
|
||||
};
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
struct __invokable
|
||||
: public integral_constant<bool,
|
||||
__invokable_imp<_Fp, _Args...>::value>
|
||||
{
|
||||
using __invokable = __invokable_r<void, _Fp, _Args...>;
|
||||
|
||||
template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
|
||||
struct __nothrow_invokable_r_imp {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
// __invoke_of
|
||||
|
||||
template <bool _Invokable, class _Fp, class ..._Args>
|
||||
struct __invoke_of_imp // false
|
||||
template <class _Ret, class _Fp, class ..._Args>
|
||||
struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
|
||||
{
|
||||
typedef __nothrow_invokable_r_imp _ThisT;
|
||||
|
||||
template <class _Tp>
|
||||
static void __test_noexcept(_Tp) noexcept;
|
||||
|
||||
static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
|
||||
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
|
||||
};
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
struct __invoke_of_imp<true, _Fp, _Args...>
|
||||
template <class _Ret, class _Fp, class ..._Args>
|
||||
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
|
||||
{
|
||||
typedef typename __invokable_imp<_Fp, _Args...>::type type;
|
||||
static const bool value = noexcept(
|
||||
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
|
||||
};
|
||||
|
||||
template <class _Ret, class _Fp, class ..._Args>
|
||||
using __nothrow_invokable_r =
|
||||
__nothrow_invokable_r_imp<
|
||||
__invokable_r<_Ret, _Fp, _Args...>::value,
|
||||
is_void<_Ret>::value,
|
||||
_Ret, _Fp, _Args...
|
||||
>;
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
struct __invoke_of
|
||||
: public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
|
||||
: public enable_if<
|
||||
__invokable<_Fp, _Args...>::value,
|
||||
typename __invokable_r<void, _Fp, _Args...>::_Result>
|
||||
{
|
||||
};
|
||||
|
||||
// result_of
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
|
||||
: public __invoke_of<_Fp, _Args...>
|
||||
@ -4185,7 +4370,39 @@ class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
|
||||
template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
// is_callable
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_callable;
|
||||
|
||||
template <class _Fn, class ..._Args, class _Ret>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_callable<_Fn(_Args...), _Ret>
|
||||
: integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
|
||||
|
||||
// is_nothrow_callable
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable;
|
||||
|
||||
template <class _Fn, class ..._Args, class _Ret>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable<_Fn(_Args...), _Ret>
|
||||
: integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
|
||||
{};
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
template <class _Tp> struct __is_swappable;
|
||||
template <class _Tp> struct __is_nothrow_swappable;
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -4206,6 +4423,13 @@ swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
|
||||
__y = _VSTD::move(__t);
|
||||
}
|
||||
|
||||
template<class _Tp, size_t _Np>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<
|
||||
__is_swappable<_Tp>::value
|
||||
>::type
|
||||
swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
@ -4221,55 +4445,108 @@ iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
|
||||
|
||||
namespace __detail
|
||||
{
|
||||
// ALL generic swap overloads MUST already have a declaration available at this point.
|
||||
|
||||
using _VSTD::swap;
|
||||
__nat swap(__any, __any);
|
||||
|
||||
template <class _Tp>
|
||||
struct __swappable
|
||||
template <class _Tp, class _Up = _Tp,
|
||||
bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
|
||||
struct __swappable_with
|
||||
{
|
||||
typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
|
||||
static const bool value = !is_same<type, __nat>::value;
|
||||
template <class _LHS, class _RHS>
|
||||
static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
|
||||
__test_swap(int);
|
||||
template <class, class>
|
||||
static __nat __test_swap(long);
|
||||
|
||||
// Extra parens are needed for the C++03 definition of decltype.
|
||||
typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
|
||||
typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
|
||||
|
||||
static const bool value = !is_same<__swap1, __nat>::value
|
||||
&& !is_same<__swap2, __nat>::value;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __swappable_with<_Tp, _Up, false> : false_type {};
|
||||
|
||||
template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
|
||||
struct __nothrow_swappable_with {
|
||||
static const bool value =
|
||||
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
|
||||
noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
|
||||
&& noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
|
||||
|
||||
} // __detail
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_swappable
|
||||
: public integral_constant<bool, __detail::__swappable<_Tp>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
|
||||
|
||||
template <bool, class _Tp>
|
||||
struct __is_nothrow_swappable_imp
|
||||
: public integral_constant<bool, noexcept(swap(_VSTD::declval<_Tp&>(),
|
||||
_VSTD::declval<_Tp&>()))>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_nothrow_swappable_imp<false, _Tp>
|
||||
: public false_type
|
||||
: public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_nothrow_swappable
|
||||
: public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
|
||||
: public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#else // __has_feature(cxx_noexcept)
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_swappable_with
|
||||
: public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_nothrow_swappable
|
||||
: public false_type
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_swappable
|
||||
: public conditional<
|
||||
__is_referenceable<_Tp>::value,
|
||||
is_swappable_with<
|
||||
typename add_lvalue_reference<_Tp>::type,
|
||||
typename add_lvalue_reference<_Tp>::type>,
|
||||
false_type
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
#endif // __has_feature(cxx_noexcept)
|
||||
template <class _Tp, class _Up>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable_with
|
||||
: public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable
|
||||
: public conditional<
|
||||
__is_referenceable<_Tp>::value,
|
||||
is_nothrow_swappable_with<
|
||||
typename add_lvalue_reference<_Tp>::type,
|
||||
typename add_lvalue_reference<_Tp>::type>,
|
||||
false_type
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp>
|
||||
constexpr bool is_swappable_v = is_swappable<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp>
|
||||
constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
#ifdef _LIBCPP_UNDERLYING_TYPE
|
||||
|
||||
@ -4296,7 +4573,7 @@ struct underlying_type
|
||||
#endif // _LIBCPP_UNDERLYING_TYPE
|
||||
|
||||
|
||||
template <class _Tp, bool = std::is_enum<_Tp>::value>
|
||||
template <class _Tp, bool = is_enum<_Tp>::value>
|
||||
struct __sfinae_underlying_type
|
||||
{
|
||||
typedef typename underlying_type<_Tp>::type type;
|
||||
@ -4389,6 +4666,39 @@ template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
|
||||
# endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
// These traits are used in __tree and __hash_table
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
struct __extract_key_fail_tag {};
|
||||
struct __extract_key_self_tag {};
|
||||
struct __extract_key_first_tag {};
|
||||
|
||||
template <class _ValTy, class _Key,
|
||||
class _RawValTy = typename __unconstref<_ValTy>::type>
|
||||
struct __can_extract_key
|
||||
: conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
|
||||
__extract_key_fail_tag>::type {};
|
||||
|
||||
template <class _Pair, class _Key, class _First, class _Second>
|
||||
struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
|
||||
: conditional<is_same<typename remove_const<_First>::type, _Key>::value,
|
||||
__extract_key_first_tag, __extract_key_fail_tag>::type {};
|
||||
|
||||
// __can_extract_map_key uses true_type/false_type instead of the tags.
|
||||
// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
|
||||
// and _ValTy == _Key.
|
||||
template <class _ValTy, class _Key, class _ContainerValueTy,
|
||||
class _RawValTy = typename __unconstref<_ValTy>::type>
|
||||
struct __can_extract_map_key
|
||||
: integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
|
||||
|
||||
// This specialization returns __extract_key_fail_tag for non-map containers
|
||||
// because _Key == _ContainerValueTy
|
||||
template <class _ValTy, class _Key, class _RawValTy>
|
||||
struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
|
||||
: false_type {};
|
||||
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_TYPE_TRAITS
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -404,10 +404,12 @@ public:
|
||||
size_type __n, const hasher& __hf, const allocator_type& __a)
|
||||
: unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit unordered_set(const allocator_type& __a);
|
||||
unordered_set(const unordered_set& __u);
|
||||
unordered_set(const unordered_set& __u, const allocator_type& __a);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_set(unordered_set&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
|
||||
unordered_set(unordered_set&& __u, const allocator_type& __a);
|
||||
@ -439,10 +441,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_set& operator=(unordered_set&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
|
||||
#endif
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_set& operator=(initializer_list<value_type> __il);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
@ -527,6 +531,7 @@ public:
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -678,7 +683,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
|
||||
const allocator_type& __a)
|
||||
: __table_(__a)
|
||||
@ -715,7 +720,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
|
||||
unordered_set&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
|
||||
@ -792,7 +797,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>&
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
|
||||
@ -806,7 +811,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>&
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
|
||||
initializer_list<value_type> __il)
|
||||
@ -819,7 +824,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
@ -940,10 +945,12 @@ public:
|
||||
size_type __n, const hasher& __hf, const allocator_type& __a)
|
||||
: unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit unordered_multiset(const allocator_type& __a);
|
||||
unordered_multiset(const unordered_multiset& __u);
|
||||
unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_multiset(unordered_multiset&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
|
||||
unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
|
||||
@ -973,6 +980,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_multiset& operator=(unordered_multiset&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
|
||||
#endif
|
||||
@ -1029,6 +1037,7 @@ public:
|
||||
{return __table_.__insert_multi(__p, _VSTD::move(__x));}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1181,7 +1190,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
|
||||
const allocator_type& __a)
|
||||
: __table_(__a)
|
||||
@ -1218,7 +1227,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
|
||||
unordered_multiset&& __u)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
|
||||
@ -1295,7 +1304,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
|
||||
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
|
||||
unordered_multiset&& __u)
|
||||
@ -1323,7 +1332,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
void
|
||||
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
|
@ -82,8 +82,8 @@ struct pair
|
||||
is_nothrow_move_assignable<T2>::value);
|
||||
template <class U, class V> pair& operator=(pair<U, V>&& p);
|
||||
|
||||
void swap(pair& p) noexcept(noexcept(swap(first, p.first)) &&
|
||||
noexcept(swap(second, p.second)));
|
||||
void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
|
||||
is_nothrow_swappable_v<T2>);
|
||||
};
|
||||
|
||||
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
|
||||
@ -169,7 +169,7 @@ template<size_t N>
|
||||
template<class... T>
|
||||
using index_sequence_for = make_index_sequence<sizeof...(T)>;
|
||||
|
||||
template<class T, class U=T>
|
||||
template<class T, class U=T>
|
||||
T exchange(T& obj, U&& new_value);
|
||||
} // std
|
||||
|
||||
@ -178,6 +178,7 @@ template<class T, class U=T>
|
||||
#include <__config>
|
||||
#include <__tuple>
|
||||
#include <type_traits>
|
||||
#include <initializer_list>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -224,10 +225,6 @@ operator>=(const _Tp& __x, const _Tp& __y)
|
||||
|
||||
// swap_ranges
|
||||
|
||||
// forward
|
||||
template<class _Tp, size_t _Np>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
|
||||
|
||||
template <class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -239,9 +236,12 @@ swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardItera
|
||||
return __first2;
|
||||
}
|
||||
|
||||
// forward declared in <type_traits>
|
||||
template<class _Tp, size_t _Np>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
typename enable_if<
|
||||
__is_swappable<_Tp>::value
|
||||
>::type
|
||||
swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
{
|
||||
_VSTD::swap_ranges(__a, __a + _Np, __b);
|
||||
@ -285,9 +285,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
||||
_T1 first;
|
||||
_T2 second;
|
||||
|
||||
// pair(const pair&) = default;
|
||||
// pair(pair&&) = default;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
|
||||
template <bool _Dummy = true, class = typename enable_if<
|
||||
__dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
|
||||
@ -310,10 +307,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
||||
)
|
||||
: first(__p.first), second(__p.second) {}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(const pair& __p) = default;
|
||||
#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
|
||||
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(const pair& __p)
|
||||
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
|
||||
@ -322,6 +316,21 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
||||
second(__p.second)
|
||||
{
|
||||
}
|
||||
|
||||
# ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
|
||||
is_nothrow_move_constructible<second_type>::value)
|
||||
: first(_VSTD::forward<first_type>(__p.first)),
|
||||
second(_VSTD::forward<second_type>(__p.second))
|
||||
{
|
||||
}
|
||||
# endif
|
||||
#elif !defined(_LIBCPP_CXX03_LANG)
|
||||
pair(pair const&) = default;
|
||||
pair(pair&&) = default;
|
||||
#else
|
||||
// Use the implicitly declared copy constructor in C++03
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -353,19 +362,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
|
||||
: first(_VSTD::forward<_U1>(__p.first)),
|
||||
second(_VSTD::forward<_U2>(__p.second)) {}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(pair&& __p) = default;
|
||||
#else
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
|
||||
is_nothrow_move_constructible<second_type>::value)
|
||||
: first(_VSTD::forward<first_type>(__p.first)),
|
||||
second(_VSTD::forward<second_type>(__p.second))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair&
|
||||
operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
|
||||
@ -501,7 +497,6 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
|
||||
|
||||
template <class _Tp>
|
||||
struct __make_pair_return_impl
|
||||
@ -742,63 +737,15 @@ template<size_t... _Ip>
|
||||
#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
|
||||
|
||||
template <class _Tp, _Tp _Ep>
|
||||
struct __make_integer_sequence
|
||||
{
|
||||
typedef __make_integer_seq<integer_sequence, _Tp, _Ep> type;
|
||||
};
|
||||
using __make_integer_sequence = __make_integer_seq<integer_sequence, _Tp, _Ep>;
|
||||
|
||||
#else
|
||||
|
||||
namespace __detail {
|
||||
|
||||
template<typename _Tp, size_t ..._Extra> struct __repeat;
|
||||
template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<integer_sequence<_Tp, _Np...>, _Extra...> {
|
||||
typedef integer_sequence<_Tp,
|
||||
_Np...,
|
||||
sizeof...(_Np) + _Np...,
|
||||
2 * sizeof...(_Np) + _Np...,
|
||||
3 * sizeof...(_Np) + _Np...,
|
||||
4 * sizeof...(_Np) + _Np...,
|
||||
5 * sizeof...(_Np) + _Np...,
|
||||
6 * sizeof...(_Np) + _Np...,
|
||||
7 * sizeof...(_Np) + _Np...,
|
||||
_Extra...> type;
|
||||
};
|
||||
|
||||
template<size_t _Np> struct __parity;
|
||||
template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
|
||||
|
||||
template<> struct __make<0> { typedef integer_sequence<size_t> type; };
|
||||
template<> struct __make<1> { typedef integer_sequence<size_t, 0> type; };
|
||||
template<> struct __make<2> { typedef integer_sequence<size_t, 0, 1> type; };
|
||||
template<> struct __make<3> { typedef integer_sequence<size_t, 0, 1, 2> type; };
|
||||
template<> struct __make<4> { typedef integer_sequence<size_t, 0, 1, 2, 3> type; };
|
||||
template<> struct __make<5> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
|
||||
template<> struct __make<6> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
|
||||
template<> struct __make<7> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
|
||||
|
||||
template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
|
||||
template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
|
||||
template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
|
||||
template<typename _Tp, typename _Up> struct __convert {
|
||||
template<typename> struct __result;
|
||||
template<_Tp ..._Np> struct __result<integer_sequence<_Tp, _Np...> > { typedef integer_sequence<_Up, _Np...> type; };
|
||||
};
|
||||
template<typename _Tp> struct __convert<_Tp, _Tp> { template<typename _Up> struct __result { typedef _Up type; }; };
|
||||
|
||||
}
|
||||
|
||||
template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked =
|
||||
typename __detail::__convert<size_t, _Tp>::template __result<typename __detail::__make<_Np>::type>::type;
|
||||
typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>;
|
||||
|
||||
template <class _Tp, _Tp _Ep>
|
||||
struct __make_integer_sequence
|
||||
struct __make_integer_sequence_checked
|
||||
{
|
||||
static_assert(is_integral<_Tp>::value,
|
||||
"std::make_integer_sequence can only be instantiated with an integral type" );
|
||||
@ -808,17 +755,20 @@ struct __make_integer_sequence
|
||||
typedef __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
|
||||
};
|
||||
|
||||
template <class _Tp, _Tp _Ep>
|
||||
using __make_integer_sequence = typename __make_integer_sequence_checked<_Tp, _Ep>::type;
|
||||
|
||||
#endif
|
||||
|
||||
template<class _Tp, _Tp _Np>
|
||||
using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;
|
||||
using make_integer_sequence = __make_integer_sequence<_Tp, _Np>;
|
||||
|
||||
template<size_t _Np>
|
||||
using make_index_sequence = make_integer_sequence<size_t, _Np>;
|
||||
|
||||
template<class... _Tp>
|
||||
using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
|
||||
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
@ -829,7 +779,7 @@ _T1 exchange(_T1& __obj, _T2 && __new_value)
|
||||
_T1 __old_value = _VSTD::move(__obj);
|
||||
__obj = _VSTD::forward<_T2>(__new_value);
|
||||
return __old_value;
|
||||
}
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -262,6 +262,7 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <iosfwd> // for forward declaration of vector
|
||||
#include <__bit_reference>
|
||||
#include <type_traits>
|
||||
#include <climits>
|
||||
@ -453,7 +454,7 @@ __vector_base<_Tp, _Allocator>::~__vector_base()
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator = allocator<_Tp> >
|
||||
template <class _Tp, class _Allocator /* = allocator<_Tp> */>
|
||||
class _LIBCPP_TYPE_VIS_ONLY vector
|
||||
: private __vector_base<_Tp, _Allocator>
|
||||
{
|
||||
@ -1811,9 +1812,9 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type __tmp(_VSTD::forward<_Args>(__args)...);
|
||||
__temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
|
||||
__move_range(__p, this->__end_, __p + 1);
|
||||
*__p = _VSTD::move(__tmp);
|
||||
*__p = _VSTD::move(__tmp.get());
|
||||
}
|
||||
__annotator.__done();
|
||||
}
|
||||
@ -2362,6 +2363,7 @@ public:
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value);
|
||||
#endif
|
||||
static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
|
||||
|
||||
void resize(size_type __sz, value_type __x = false);
|
||||
void flip() _NOEXCEPT;
|
||||
|
@ -118,7 +118,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
|
||||
|
||||
#include_next <wchar.h>
|
||||
|
||||
// Let <cwchar> know if we have const-correct overloads for wcschr and friends.
|
||||
// Determine whether we have const-correct overloads for wcschr and friends.
|
||||
#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
|
||||
# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
|
||||
#elif defined(__GLIBC_PREREQ)
|
||||
@ -127,6 +127,45 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
|
||||
extern "C++" {
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__))
|
||||
extern "C++" {
|
||||
#include <support/win32/support.h> // pull in *swprintf defines
|
||||
|
@ -48,14 +48,14 @@ 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;
|
||||
static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
unsigned __rs_default::__c_ = 0;
|
||||
|
||||
__rs_default::__rs_default()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
pthread_mutex_lock(&__rs_mut);
|
||||
__libcpp_mutex_lock(&__rs_mut);
|
||||
#endif
|
||||
__c_ = 1;
|
||||
}
|
||||
@ -69,7 +69,7 @@ __rs_default::~__rs_default()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
if (--__c_ == 0)
|
||||
pthread_mutex_unlock(&__rs_mut);
|
||||
__libcpp_mutex_unlock(&__rs_mut);
|
||||
#else
|
||||
--__c_;
|
||||
#endif
|
||||
|
@ -7,6 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define _LIBCPP_BUILDING_BIND
|
||||
#include "functional"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
@ -14,16 +15,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
namespace placeholders
|
||||
{
|
||||
|
||||
__ph<1> _1;
|
||||
__ph<2> _2;
|
||||
__ph<3> _3;
|
||||
__ph<4> _4;
|
||||
__ph<5> _5;
|
||||
__ph<6> _6;
|
||||
__ph<7> _7;
|
||||
__ph<8> _8;
|
||||
__ph<9> _9;
|
||||
__ph<10> _10;
|
||||
const __ph<1> _1{};
|
||||
const __ph<2> _2{};
|
||||
const __ph<3> _3{};
|
||||
const __ph<4> _4{};
|
||||
const __ph<5> _5{};
|
||||
const __ph<6> _6{};
|
||||
const __ph<7> _7{};
|
||||
const __ph<8> _8{};
|
||||
const __ph<9> _9{};
|
||||
const __ph<10> _10{};
|
||||
|
||||
} // placeholders
|
||||
|
||||
|
@ -20,19 +20,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
condition_variable::~condition_variable()
|
||||
{
|
||||
pthread_cond_destroy(&__cv_);
|
||||
__libcpp_condvar_destroy(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::notify_one() _NOEXCEPT
|
||||
{
|
||||
pthread_cond_signal(&__cv_);
|
||||
__libcpp_condvar_signal(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
condition_variable::notify_all() _NOEXCEPT
|
||||
{
|
||||
pthread_cond_broadcast(&__cv_);
|
||||
__libcpp_condvar_broadcast(&__cv_);
|
||||
}
|
||||
|
||||
void
|
||||
@ -41,7 +41,7 @@ condition_variable::wait(unique_lock<mutex>& lk) _NOEXCEPT
|
||||
if (!lk.owns_lock())
|
||||
__throw_system_error(EPERM,
|
||||
"condition_variable::wait: mutex not locked");
|
||||
int ec = pthread_cond_wait(&__cv_, lk.mutex()->native_handle());
|
||||
int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
|
||||
if (ec)
|
||||
__throw_system_error(ec, "condition_variable wait failed");
|
||||
}
|
||||
@ -71,7 +71,7 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
|
||||
ts.tv_sec = ts_sec_max;
|
||||
ts.tv_nsec = giga::num - 1;
|
||||
}
|
||||
int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
|
||||
int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
|
||||
if (ec != 0 && ec != ETIMEDOUT)
|
||||
__throw_system_error(ec, "condition_variable timed_wait failed");
|
||||
}
|
||||
|
@ -0,0 +1,256 @@
|
||||
#include "experimental/filesystem"
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
namespace { namespace detail {
|
||||
|
||||
inline error_code capture_errno() {
|
||||
_LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
|
||||
return error_code{errno, std::generic_category()};
|
||||
}
|
||||
|
||||
template <class ...Args>
|
||||
inline bool capture_error_or_throw(std::error_code* user_ec,
|
||||
const char* msg, Args&&... args)
|
||||
{
|
||||
std::error_code my_ec = capture_errno();
|
||||
if (user_ec) {
|
||||
*user_ec = my_ec;
|
||||
return true;
|
||||
}
|
||||
__libcpp_throw(filesystem_error(msg, std::forward<Args>(args)..., my_ec));
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class ...Args>
|
||||
inline bool set_or_throw(std::error_code& my_ec,
|
||||
std::error_code* user_ec,
|
||||
const char* msg, Args&&... args)
|
||||
{
|
||||
if (user_ec) {
|
||||
*user_ec = my_ec;
|
||||
return true;
|
||||
}
|
||||
__libcpp_throw(filesystem_error(msg, std::forward<Args>(args)..., my_ec));
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef path::string_type string_type;
|
||||
|
||||
|
||||
inline string_type posix_readdir(DIR *dir_stream, error_code& ec) {
|
||||
struct dirent* dir_entry_ptr = nullptr;
|
||||
errno = 0; // zero errno in order to detect errors
|
||||
if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {
|
||||
ec = capture_errno();
|
||||
return {};
|
||||
} else {
|
||||
ec.clear();
|
||||
return dir_entry_ptr->d_name;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail
|
||||
|
||||
using detail::set_or_throw;
|
||||
|
||||
class __dir_stream {
|
||||
public:
|
||||
__dir_stream() = delete;
|
||||
__dir_stream& operator=(const __dir_stream&) = delete;
|
||||
|
||||
__dir_stream(__dir_stream&& other) noexcept
|
||||
: __stream_(other.__stream_), __root_(std::move(other.__root_)),
|
||||
__entry_(std::move(other.__entry_))
|
||||
{
|
||||
other.__stream_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
__dir_stream(const path& root, directory_options opts, error_code& ec)
|
||||
: __stream_(nullptr),
|
||||
__root_(root)
|
||||
{
|
||||
if ((__stream_ = ::opendir(root.c_str())) == nullptr) {
|
||||
ec = detail::capture_errno();
|
||||
const bool allow_eacess =
|
||||
bool(opts & directory_options::skip_permission_denied);
|
||||
if (allow_eacess && ec.value() == EACCES)
|
||||
ec.clear();
|
||||
return;
|
||||
}
|
||||
advance(ec);
|
||||
}
|
||||
|
||||
~__dir_stream() noexcept
|
||||
{ if (__stream_) close(); }
|
||||
|
||||
bool good() const noexcept { return __stream_ != nullptr; }
|
||||
|
||||
bool advance(error_code &ec) {
|
||||
while (true) {
|
||||
auto str = detail::posix_readdir(__stream_, ec);
|
||||
if (str == "." || str == "..") {
|
||||
continue;
|
||||
} else if (ec || str.empty()) {
|
||||
close();
|
||||
return false;
|
||||
} else {
|
||||
__entry_.assign(__root_ / str);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::error_code close() noexcept {
|
||||
std::error_code m_ec;
|
||||
if (::closedir(__stream_) == -1)
|
||||
m_ec = detail::capture_errno();
|
||||
__stream_ = nullptr;
|
||||
return m_ec;
|
||||
}
|
||||
|
||||
DIR * __stream_{nullptr};
|
||||
public:
|
||||
path __root_;
|
||||
directory_entry __entry_;
|
||||
};
|
||||
|
||||
// directory_iterator
|
||||
|
||||
directory_iterator::directory_iterator(const path& p, error_code *ec,
|
||||
directory_options opts)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
__imp_ = make_shared<__dir_stream>(p, opts, m_ec);
|
||||
if (ec) *ec = m_ec;
|
||||
if (!__imp_->good()) {
|
||||
__imp_.reset();
|
||||
if (m_ec)
|
||||
set_or_throw(m_ec, ec,
|
||||
"directory_iterator::directory_iterator(...)", p);
|
||||
}
|
||||
}
|
||||
|
||||
directory_iterator& directory_iterator::__increment(error_code *ec)
|
||||
{
|
||||
_LIBCPP_ASSERT(__imp_, "Attempting to increment an invalid iterator");
|
||||
std::error_code m_ec;
|
||||
if (!__imp_->advance(m_ec)) {
|
||||
__imp_.reset();
|
||||
if (m_ec)
|
||||
set_or_throw(m_ec, ec, "directory_iterator::operator++()");
|
||||
} else {
|
||||
if (ec) ec->clear();
|
||||
}
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
directory_entry const& directory_iterator::__deref() const {
|
||||
_LIBCPP_ASSERT(__imp_, "Attempting to dereference an invalid iterator");
|
||||
return __imp_->__entry_;
|
||||
}
|
||||
|
||||
// recursive_directory_iterator
|
||||
|
||||
struct recursive_directory_iterator::__shared_imp {
|
||||
stack<__dir_stream> __stack_;
|
||||
directory_options __options_;
|
||||
};
|
||||
|
||||
recursive_directory_iterator::recursive_directory_iterator(const path& p,
|
||||
directory_options opt, error_code *ec)
|
||||
: __imp_(nullptr), __rec_(true)
|
||||
{
|
||||
if (ec) ec->clear();
|
||||
std::error_code m_ec;
|
||||
__dir_stream new_s(p, opt, m_ec);
|
||||
if (m_ec) set_or_throw(m_ec, ec, "recursive_directory_iterator", p);
|
||||
if (m_ec || !new_s.good()) return;
|
||||
|
||||
__imp_ = _VSTD::make_shared<__shared_imp>();
|
||||
__imp_->__options_ = opt;
|
||||
__imp_->__stack_.push(_VSTD::move(new_s));
|
||||
}
|
||||
|
||||
void recursive_directory_iterator::__pop(error_code* ec)
|
||||
{
|
||||
_LIBCPP_ASSERT(__imp_, "Popping the end iterator");
|
||||
if (ec) ec->clear();
|
||||
__imp_->__stack_.pop();
|
||||
if (__imp_->__stack_.size() == 0)
|
||||
__imp_.reset();
|
||||
else
|
||||
__advance(ec);
|
||||
}
|
||||
|
||||
directory_options recursive_directory_iterator::options() const {
|
||||
return __imp_->__options_;
|
||||
}
|
||||
|
||||
int recursive_directory_iterator::depth() const {
|
||||
return __imp_->__stack_.size() - 1;
|
||||
}
|
||||
|
||||
const directory_entry& recursive_directory_iterator::__deref() const {
|
||||
return __imp_->__stack_.top().__entry_;
|
||||
}
|
||||
|
||||
recursive_directory_iterator&
|
||||
recursive_directory_iterator::__increment(error_code *ec)
|
||||
{
|
||||
if (ec) ec->clear();
|
||||
if (recursion_pending()) {
|
||||
if (__try_recursion(ec) || (ec && *ec))
|
||||
return *this;
|
||||
}
|
||||
__rec_ = true;
|
||||
__advance(ec);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void recursive_directory_iterator::__advance(error_code* ec) {
|
||||
// REQUIRES: ec must be cleared before calling this function.
|
||||
const directory_iterator end_it;
|
||||
auto& stack = __imp_->__stack_;
|
||||
std::error_code m_ec;
|
||||
while (stack.size() > 0) {
|
||||
if (stack.top().advance(m_ec))
|
||||
return;
|
||||
if (m_ec) break;
|
||||
stack.pop();
|
||||
}
|
||||
__imp_.reset();
|
||||
if (m_ec)
|
||||
set_or_throw(m_ec, ec, "recursive_directory_iterator::operator++()");
|
||||
}
|
||||
|
||||
bool recursive_directory_iterator::__try_recursion(error_code *ec) {
|
||||
|
||||
bool rec_sym =
|
||||
bool(options() & directory_options::follow_directory_symlink);
|
||||
auto& curr_it = __imp_->__stack_.top();
|
||||
|
||||
if (is_directory(curr_it.__entry_.status()) &&
|
||||
(!is_symlink(curr_it.__entry_.symlink_status()) || rec_sym))
|
||||
{
|
||||
std::error_code m_ec;
|
||||
__dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
|
||||
if (new_it.good()) {
|
||||
__imp_->__stack_.push(_VSTD::move(new_it));
|
||||
return true;
|
||||
}
|
||||
if (m_ec) {
|
||||
__imp_.reset();
|
||||
set_or_throw(m_ec, ec,
|
||||
"recursive_directory_iterator::operator++()");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
794
contrib/libc++/src/experimental/filesystem/operations.cpp
Normal file
794
contrib/libc++/src/experimental/filesystem/operations.cpp
Normal file
@ -0,0 +1,794 @@
|
||||
//===--------------------- filesystem/ops.cpp -----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "experimental/filesystem"
|
||||
#include "iterator"
|
||||
#include "fstream"
|
||||
#include "type_traits"
|
||||
#include "random" /* for unique_path */
|
||||
#include "cstdlib"
|
||||
#include "climits"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <fcntl.h> /* values for fchmodat */
|
||||
#if !defined(UTIME_OMIT)
|
||||
#include <sys/time.h> // for ::utimes as used in __last_write_time
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
filesystem_error::~filesystem_error() {}
|
||||
|
||||
|
||||
// POSIX HELPERS
|
||||
|
||||
namespace detail { namespace {
|
||||
|
||||
using value_type = path::value_type;
|
||||
using string_type = path::string_type;
|
||||
|
||||
|
||||
|
||||
inline std::error_code capture_errno() {
|
||||
_LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
|
||||
std::error_code m_ec(errno, std::generic_category());
|
||||
return m_ec;
|
||||
}
|
||||
|
||||
void set_or_throw(std::error_code const& m_ec, std::error_code* ec,
|
||||
const char* msg, path const& p = {}, path const& p2 = {})
|
||||
{
|
||||
if (ec) {
|
||||
*ec = m_ec;
|
||||
} else {
|
||||
string msg_s("std::experimental::filesystem::");
|
||||
msg_s += msg;
|
||||
__libcpp_throw(filesystem_error(msg_s, p, p2, m_ec));
|
||||
}
|
||||
}
|
||||
|
||||
void set_or_throw(std::error_code* ec, const char* msg,
|
||||
path const& p = {}, path const& p2 = {})
|
||||
{
|
||||
return set_or_throw(capture_errno(), ec, msg, p, p2);
|
||||
}
|
||||
|
||||
perms posix_get_perms(const struct ::stat & st) noexcept {
|
||||
return static_cast<perms>(st.st_mode) & perms::mask;
|
||||
}
|
||||
|
||||
::mode_t posix_convert_perms(perms prms) {
|
||||
return static_cast< ::mode_t>(prms & perms::mask);
|
||||
}
|
||||
|
||||
file_status create_file_status(std::error_code& m_ec, path const& p,
|
||||
struct ::stat& path_stat,
|
||||
std::error_code* ec)
|
||||
{
|
||||
if (ec) *ec = m_ec;
|
||||
if (m_ec && (m_ec.value() == ENOENT || m_ec.value() == ENOTDIR)) {
|
||||
return file_status(file_type::not_found);
|
||||
}
|
||||
else if (m_ec) {
|
||||
set_or_throw(m_ec, ec, "posix_stat", p);
|
||||
return file_status(file_type::none);
|
||||
}
|
||||
// else
|
||||
|
||||
file_status fs_tmp;
|
||||
auto const mode = path_stat.st_mode;
|
||||
if (S_ISLNK(mode)) fs_tmp.type(file_type::symlink);
|
||||
else if (S_ISREG(mode)) fs_tmp.type(file_type::regular);
|
||||
else if (S_ISDIR(mode)) fs_tmp.type(file_type::directory);
|
||||
else if (S_ISBLK(mode)) fs_tmp.type(file_type::block);
|
||||
else if (S_ISCHR(mode)) fs_tmp.type(file_type::character);
|
||||
else if (S_ISFIFO(mode)) fs_tmp.type(file_type::fifo);
|
||||
else if (S_ISSOCK(mode)) fs_tmp.type(file_type::socket);
|
||||
else fs_tmp.type(file_type::unknown);
|
||||
|
||||
fs_tmp.permissions(detail::posix_get_perms(path_stat));
|
||||
return fs_tmp;
|
||||
}
|
||||
|
||||
file_status posix_stat(path const & p, struct ::stat& path_stat,
|
||||
std::error_code* ec)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
if (::stat(p.c_str(), &path_stat) == -1)
|
||||
m_ec = detail::capture_errno();
|
||||
return create_file_status(m_ec, p, path_stat, ec);
|
||||
}
|
||||
|
||||
file_status posix_stat(path const & p, std::error_code* ec) {
|
||||
struct ::stat path_stat;
|
||||
return posix_stat(p, path_stat, ec);
|
||||
}
|
||||
|
||||
file_status posix_lstat(path const & p, struct ::stat & path_stat,
|
||||
std::error_code* ec)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
if (::lstat(p.c_str(), &path_stat) == -1)
|
||||
m_ec = detail::capture_errno();
|
||||
return create_file_status(m_ec, p, path_stat, ec);
|
||||
}
|
||||
|
||||
file_status posix_lstat(path const & p, std::error_code* ec) {
|
||||
struct ::stat path_stat;
|
||||
return posix_lstat(p, path_stat, ec);
|
||||
}
|
||||
|
||||
bool stat_equivalent(struct ::stat& st1, struct ::stat& st2) {
|
||||
return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
|
||||
}
|
||||
|
||||
// DETAIL::MISC
|
||||
|
||||
|
||||
bool copy_file_impl(const path& from, const path& to, perms from_perms,
|
||||
std::error_code *ec)
|
||||
{
|
||||
std::ifstream in(from.c_str(), std::ios::binary);
|
||||
std::ofstream out(to.c_str(), std::ios::binary);
|
||||
|
||||
if (in.good() && out.good()) {
|
||||
using InIt = std::istreambuf_iterator<char>;
|
||||
using OutIt = std::ostreambuf_iterator<char>;
|
||||
InIt bin(in);
|
||||
InIt ein;
|
||||
OutIt bout(out);
|
||||
std::copy(bin, ein, bout);
|
||||
}
|
||||
if (out.fail() || in.fail()) {
|
||||
set_or_throw(make_error_code(errc::operation_not_permitted),
|
||||
ec, "copy_file", from, to);
|
||||
return false;
|
||||
}
|
||||
__permissions(to, from_perms, ec);
|
||||
// TODO what if permissions fails?
|
||||
return true;
|
||||
}
|
||||
|
||||
}} // end namespace detail
|
||||
|
||||
using detail::set_or_throw;
|
||||
|
||||
path __canonical(path const & orig_p, const path& base, std::error_code *ec)
|
||||
{
|
||||
path p = absolute(orig_p, base);
|
||||
char buff[PATH_MAX + 1];
|
||||
char *ret;
|
||||
if ((ret = ::realpath(p.c_str(), buff)) == nullptr) {
|
||||
set_or_throw(ec, "canonical", orig_p, base);
|
||||
return {};
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
return {ret};
|
||||
}
|
||||
|
||||
void __copy(const path& from, const path& to, copy_options options,
|
||||
std::error_code *ec)
|
||||
{
|
||||
const bool sym_status = bool(options &
|
||||
(copy_options::create_symlinks | copy_options::skip_symlinks));
|
||||
|
||||
const bool sym_status2 = bool(options &
|
||||
copy_options::copy_symlinks);
|
||||
|
||||
std::error_code m_ec;
|
||||
struct ::stat f_st = {};
|
||||
const file_status f = sym_status || sym_status2
|
||||
? detail::posix_lstat(from, f_st, &m_ec)
|
||||
: detail::posix_stat(from, f_st, &m_ec);
|
||||
if (m_ec)
|
||||
return set_or_throw(m_ec, ec, "copy", from, to);
|
||||
|
||||
struct ::stat t_st = {};
|
||||
const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec)
|
||||
: detail::posix_stat(to, t_st, &m_ec);
|
||||
|
||||
if (not status_known(t))
|
||||
return set_or_throw(m_ec, ec, "copy", from, to);
|
||||
|
||||
if (!exists(f) || is_other(f) || is_other(t)
|
||||
|| (is_directory(f) && is_regular_file(t))
|
||||
|| detail::stat_equivalent(f_st, t_st))
|
||||
{
|
||||
return set_or_throw(make_error_code(errc::function_not_supported),
|
||||
ec, "copy", from, to);
|
||||
}
|
||||
|
||||
if (ec) ec->clear();
|
||||
|
||||
if (is_symlink(f)) {
|
||||
if (bool(copy_options::skip_symlinks & options)) {
|
||||
// do nothing
|
||||
} else if (not exists(t)) {
|
||||
__copy_symlink(from, to, ec);
|
||||
} else {
|
||||
set_or_throw(make_error_code(errc::file_exists),
|
||||
ec, "copy", from, to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (is_regular_file(f)) {
|
||||
if (bool(copy_options::directories_only & options)) {
|
||||
// do nothing
|
||||
}
|
||||
else if (bool(copy_options::create_symlinks & options)) {
|
||||
__create_symlink(from, to, ec);
|
||||
}
|
||||
else if (bool(copy_options::create_hard_links & options)) {
|
||||
__create_hard_link(from, to, ec);
|
||||
}
|
||||
else if (is_directory(t)) {
|
||||
__copy_file(from, to / from.filename(), options, ec);
|
||||
} else {
|
||||
__copy_file(from, to, options, ec);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (is_directory(f)) {
|
||||
if (not bool(copy_options::recursive & options) &&
|
||||
bool(copy_options::__in_recursive_copy & options))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!exists(t)) {
|
||||
// create directory to with attributes from 'from'.
|
||||
__create_directory(to, from, ec);
|
||||
if (ec && *ec) { return; }
|
||||
}
|
||||
directory_iterator it = ec ? directory_iterator(from, *ec)
|
||||
: directory_iterator(from);
|
||||
if (ec && *ec) { return; }
|
||||
std::error_code m_ec;
|
||||
for (; it != directory_iterator(); it.increment(m_ec)) {
|
||||
if (m_ec) return set_or_throw(m_ec, ec, "copy", from, to);
|
||||
__copy(it->path(), to / it->path().filename(),
|
||||
options | copy_options::__in_recursive_copy, ec);
|
||||
if (ec && *ec) { return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool __copy_file(const path& from, const path& to, copy_options options,
|
||||
std::error_code *ec)
|
||||
{
|
||||
if (ec) ec->clear();
|
||||
|
||||
std::error_code m_ec;
|
||||
auto from_st = detail::posix_stat(from, &m_ec);
|
||||
if (not is_regular_file(from_st)) {
|
||||
if (not m_ec)
|
||||
m_ec = make_error_code(errc::not_supported);
|
||||
set_or_throw(m_ec, ec, "copy_file", from, to);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto to_st = detail::posix_stat(to, &m_ec);
|
||||
if (!status_known(to_st)) {
|
||||
set_or_throw(m_ec, ec, "copy_file", from, to);
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool to_exists = exists(to_st);
|
||||
if (to_exists && bool(copy_options::skip_existing & options)) {
|
||||
return false;
|
||||
}
|
||||
else if (to_exists && bool(copy_options::update_existing & options)) {
|
||||
auto from_time = __last_write_time(from, ec);
|
||||
if (ec && *ec) { return false; }
|
||||
auto to_time = __last_write_time(to, ec);
|
||||
if (ec && *ec) { return false; }
|
||||
if (from_time <= to_time) {
|
||||
return false;
|
||||
}
|
||||
return detail::copy_file_impl(from, to, from_st.permissions(), ec);
|
||||
}
|
||||
else if (!to_exists || bool(copy_options::overwrite_existing & options)) {
|
||||
return detail::copy_file_impl(from, to, from_st.permissions(), ec);
|
||||
}
|
||||
else {
|
||||
set_or_throw(make_error_code(errc::file_exists), ec, "copy", from, to);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void __copy_symlink(const path& existing_symlink, const path& new_symlink,
|
||||
std::error_code *ec)
|
||||
{
|
||||
const path real_path(__read_symlink(existing_symlink, ec));
|
||||
if (ec && *ec) { return; }
|
||||
// NOTE: proposal says you should detect if you should call
|
||||
// create_symlink or create_directory_symlink. I don't think this
|
||||
// is needed with POSIX
|
||||
__create_symlink(real_path, new_symlink, ec);
|
||||
}
|
||||
|
||||
|
||||
bool __create_directories(const path& p, std::error_code *ec)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
auto const st = detail::posix_stat(p, &m_ec);
|
||||
if (!status_known(st)) {
|
||||
set_or_throw(m_ec, ec, "create_directories", p);
|
||||
return false;
|
||||
}
|
||||
else if (is_directory(st)) {
|
||||
if (ec) ec->clear();
|
||||
return false;
|
||||
}
|
||||
else if (exists(st)) {
|
||||
set_or_throw(make_error_code(errc::file_exists),
|
||||
ec, "create_directories", p);
|
||||
return false;
|
||||
}
|
||||
|
||||
const path parent = p.parent_path();
|
||||
if (!parent.empty()) {
|
||||
const file_status parent_st = status(parent, m_ec);
|
||||
if (not status_known(parent_st)) {
|
||||
set_or_throw(m_ec, ec, "create_directories", p);
|
||||
return false;
|
||||
}
|
||||
if (not exists(parent_st)) {
|
||||
__create_directories(parent, ec);
|
||||
if (ec && *ec) { return false; }
|
||||
}
|
||||
}
|
||||
return __create_directory(p, ec);
|
||||
}
|
||||
|
||||
bool __create_directory(const path& p, std::error_code *ec)
|
||||
{
|
||||
if (ec) ec->clear();
|
||||
if (::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)
|
||||
return true;
|
||||
if (errno != EEXIST || !is_directory(p))
|
||||
set_or_throw(ec, "create_directory", p);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool __create_directory(path const & p, path const & attributes,
|
||||
std::error_code *ec)
|
||||
{
|
||||
struct ::stat attr_stat;
|
||||
std::error_code mec;
|
||||
auto st = detail::posix_stat(attributes, attr_stat, &mec);
|
||||
if (!status_known(st)) {
|
||||
set_or_throw(mec, ec, "create_directory", p, attributes);
|
||||
return false;
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
if (::mkdir(p.c_str(), attr_stat.st_mode) == 0)
|
||||
return true;
|
||||
if (errno != EEXIST || !is_directory(p))
|
||||
set_or_throw(ec, "create_directory", p, attributes);
|
||||
return false;
|
||||
}
|
||||
|
||||
void __create_directory_symlink(path const & from, path const & to,
|
||||
std::error_code *ec){
|
||||
if (::symlink(from.c_str(), to.c_str()) != 0)
|
||||
set_or_throw(ec, "create_directory_symlink", from, to);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
void __create_hard_link(const path& from, const path& to, std::error_code *ec){
|
||||
if (::link(from.c_str(), to.c_str()) == -1)
|
||||
set_or_throw(ec, "create_hard_link", from, to);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
void __create_symlink(path const & from, path const & to, std::error_code *ec) {
|
||||
|
||||
if (::symlink(from.c_str(), to.c_str()) == -1)
|
||||
set_or_throw(ec, "create_symlink", from, to);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
path __current_path(std::error_code *ec) {
|
||||
auto size = ::pathconf(".", _PC_PATH_MAX);
|
||||
_LIBCPP_ASSERT(size >= 0, "pathconf returned a 0 as max size");
|
||||
|
||||
auto buff = std::unique_ptr<char[]>(new char[size + 1]);
|
||||
char* ret;
|
||||
if ((ret = ::getcwd(buff.get(), static_cast<size_t>(size))) == nullptr) {
|
||||
set_or_throw(ec, "current_path");
|
||||
return {};
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
return {buff.get()};
|
||||
}
|
||||
|
||||
void __current_path(const path& p, std::error_code *ec) {
|
||||
if (::chdir(p.c_str()) == -1)
|
||||
set_or_throw(ec, "current_path", p);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
bool __equivalent(const path& p1, const path& p2, std::error_code *ec)
|
||||
{
|
||||
std::error_code ec1, ec2;
|
||||
struct ::stat st1 = {};
|
||||
struct ::stat st2 = {};
|
||||
auto s1 = detail::posix_stat(p1.native(), st1, &ec1);
|
||||
auto s2 = detail::posix_stat(p2.native(), st2, &ec2);
|
||||
|
||||
if ((!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))) {
|
||||
set_or_throw(make_error_code(errc::not_supported), ec,
|
||||
"equivalent", p1, p2);
|
||||
return false;
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
|
||||
}
|
||||
|
||||
|
||||
std::uintmax_t __file_size(const path& p, std::error_code *ec)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
struct ::stat st;
|
||||
file_status fst = detail::posix_stat(p, st, &m_ec);
|
||||
if (!exists(fst) || !is_regular_file(fst)) {
|
||||
if (!m_ec)
|
||||
m_ec = make_error_code(errc::not_supported);
|
||||
set_or_throw(m_ec, ec, "file_size", p);
|
||||
return static_cast<uintmax_t>(-1);
|
||||
}
|
||||
// is_regular_file(p) == true
|
||||
if (ec) ec->clear();
|
||||
return static_cast<std::uintmax_t>(st.st_size);
|
||||
}
|
||||
|
||||
std::uintmax_t __hard_link_count(const path& p, std::error_code *ec)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
struct ::stat st;
|
||||
detail::posix_stat(p, st, &m_ec);
|
||||
if (m_ec) {
|
||||
set_or_throw(m_ec, ec, "hard_link_count", p);
|
||||
return static_cast<std::uintmax_t>(-1);
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
return static_cast<std::uintmax_t>(st.st_nlink);
|
||||
}
|
||||
|
||||
|
||||
bool __fs_is_empty(const path& p, std::error_code *ec)
|
||||
{
|
||||
if (ec) ec->clear();
|
||||
std::error_code m_ec;
|
||||
struct ::stat pst;
|
||||
auto st = detail::posix_stat(p, pst, &m_ec);
|
||||
if (is_directory(st))
|
||||
return directory_iterator(p) == directory_iterator{};
|
||||
else if (is_regular_file(st))
|
||||
return static_cast<std::uintmax_t>(pst.st_size) == 0;
|
||||
// else
|
||||
set_or_throw(m_ec, ec, "is_empty", p);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
namespace detail { namespace {
|
||||
|
||||
template <class CType, class ChronoType>
|
||||
bool checked_set(CType* out, ChronoType time) {
|
||||
using Lim = numeric_limits<CType>;
|
||||
if (time > Lim::max() || time < Lim::min())
|
||||
return false;
|
||||
*out = static_cast<CType>(time);
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr long long min_seconds = file_time_type::duration::min().count()
|
||||
/ file_time_type::period::den;
|
||||
|
||||
template <class SubSecDurT, class SubSecT>
|
||||
bool set_times_checked(time_t* sec_out, SubSecT* subsec_out, file_time_type tp) {
|
||||
using namespace chrono;
|
||||
auto dur = tp.time_since_epoch();
|
||||
auto sec_dur = duration_cast<seconds>(dur);
|
||||
auto subsec_dur = duration_cast<SubSecDurT>(dur - sec_dur);
|
||||
// The tv_nsec and tv_usec fields must not be negative so adjust accordingly
|
||||
if (subsec_dur.count() < 0) {
|
||||
if (sec_dur.count() > min_seconds) {
|
||||
|
||||
sec_dur -= seconds(1);
|
||||
subsec_dur += seconds(1);
|
||||
} else {
|
||||
subsec_dur = SubSecDurT::zero();
|
||||
}
|
||||
}
|
||||
return checked_set(sec_out, sec_dur.count())
|
||||
&& checked_set(subsec_out, subsec_dur.count());
|
||||
}
|
||||
|
||||
}} // end namespace detail
|
||||
|
||||
|
||||
file_time_type __last_write_time(const path& p, std::error_code *ec)
|
||||
{
|
||||
std::error_code m_ec;
|
||||
struct ::stat st;
|
||||
detail::posix_stat(p, st, &m_ec);
|
||||
if (m_ec) {
|
||||
set_or_throw(m_ec, ec, "last_write_time", p);
|
||||
return file_time_type::min();
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
return file_time_type::clock::from_time_t(st.st_mtime);
|
||||
}
|
||||
|
||||
void __last_write_time(const path& p, file_time_type new_time,
|
||||
std::error_code *ec)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
std::error_code m_ec;
|
||||
|
||||
// We can use the presence of UTIME_OMIT to detect platforms that do not
|
||||
// provide utimensat.
|
||||
#if !defined(UTIME_OMIT)
|
||||
// This implementation has a race condition between determining the
|
||||
// last access time and attempting to set it to the same value using
|
||||
// ::utimes
|
||||
struct ::stat st;
|
||||
file_status fst = detail::posix_stat(p, st, &m_ec);
|
||||
if (m_ec && !status_known(fst)) {
|
||||
set_or_throw(m_ec, ec, "last_write_time", p);
|
||||
return;
|
||||
}
|
||||
struct ::timeval tbuf[2];
|
||||
tbuf[0].tv_sec = st.st_atime;
|
||||
tbuf[0].tv_usec = 0;
|
||||
const bool overflowed = !detail::set_times_checked<microseconds>(
|
||||
&tbuf[1].tv_sec, &tbuf[1].tv_usec, new_time);
|
||||
|
||||
if (overflowed) {
|
||||
set_or_throw(make_error_code(errc::invalid_argument), ec,
|
||||
"last_write_time", p);
|
||||
return;
|
||||
}
|
||||
if (::utimes(p.c_str(), tbuf) == -1) {
|
||||
m_ec = detail::capture_errno();
|
||||
}
|
||||
#else
|
||||
struct ::timespec tbuf[2];
|
||||
tbuf[0].tv_sec = 0;
|
||||
tbuf[0].tv_nsec = UTIME_OMIT;
|
||||
|
||||
const bool overflowed = !detail::set_times_checked<nanoseconds>(
|
||||
&tbuf[1].tv_sec, &tbuf[1].tv_nsec, new_time);
|
||||
if (overflowed) {
|
||||
set_or_throw(make_error_code(errc::invalid_argument),
|
||||
ec, "last_write_time", p);
|
||||
return;
|
||||
}
|
||||
if (::utimensat(AT_FDCWD, p.c_str(), tbuf, 0) == -1) {
|
||||
m_ec = detail::capture_errno();
|
||||
}
|
||||
#endif
|
||||
if (m_ec)
|
||||
set_or_throw(m_ec, ec, "last_write_time", p);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
|
||||
void __permissions(const path& p, perms prms, std::error_code *ec)
|
||||
{
|
||||
|
||||
const bool resolve_symlinks = !bool(perms::symlink_nofollow & prms);
|
||||
const bool add_perms = bool(perms::add_perms & prms);
|
||||
const bool remove_perms = bool(perms::remove_perms & prms);
|
||||
_LIBCPP_ASSERT(!(add_perms && remove_perms),
|
||||
"Both add_perms and remove_perms are set");
|
||||
|
||||
bool set_sym_perms = false;
|
||||
prms &= perms::mask;
|
||||
if (!resolve_symlinks || (add_perms || remove_perms)) {
|
||||
std::error_code m_ec;
|
||||
file_status st = resolve_symlinks ? detail::posix_stat(p, &m_ec)
|
||||
: detail::posix_lstat(p, &m_ec);
|
||||
set_sym_perms = is_symlink(st);
|
||||
if (m_ec) return set_or_throw(m_ec, ec, "permissions", p);
|
||||
_LIBCPP_ASSERT(st.permissions() != perms::unknown,
|
||||
"Permissions unexpectedly unknown");
|
||||
if (add_perms)
|
||||
prms |= st.permissions();
|
||||
else if (remove_perms)
|
||||
prms = st.permissions() & ~prms;
|
||||
}
|
||||
const auto real_perms = detail::posix_convert_perms(prms);
|
||||
|
||||
# if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
|
||||
const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0;
|
||||
if (::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) {
|
||||
return set_or_throw(ec, "permissions", p);
|
||||
}
|
||||
# else
|
||||
if (set_sym_perms)
|
||||
return set_or_throw(make_error_code(errc::operation_not_supported),
|
||||
ec, "permissions", p);
|
||||
if (::chmod(p.c_str(), real_perms) == -1) {
|
||||
return set_or_throw(ec, "permissions", p);
|
||||
}
|
||||
# endif
|
||||
if (ec) ec->clear();
|
||||
}
|
||||
|
||||
|
||||
path __read_symlink(const path& p, std::error_code *ec) {
|
||||
char buff[PATH_MAX + 1];
|
||||
std::error_code m_ec;
|
||||
::ssize_t ret;
|
||||
if ((ret = ::readlink(p.c_str(), buff, PATH_MAX)) == -1) {
|
||||
set_or_throw(ec, "read_symlink", p);
|
||||
return {};
|
||||
}
|
||||
_LIBCPP_ASSERT(ret <= PATH_MAX, "TODO");
|
||||
_LIBCPP_ASSERT(ret > 0, "TODO");
|
||||
if (ec) ec->clear();
|
||||
buff[ret] = 0;
|
||||
return {buff};
|
||||
}
|
||||
|
||||
|
||||
bool __remove(const path& p, std::error_code *ec) {
|
||||
if (ec) ec->clear();
|
||||
if (::remove(p.c_str()) == -1) {
|
||||
set_or_throw(ec, "remove", p);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::uintmax_t remove_all_impl(path const & p, std::error_code& ec)
|
||||
{
|
||||
const auto npos = static_cast<std::uintmax_t>(-1);
|
||||
const file_status st = __symlink_status(p, &ec);
|
||||
if (ec) return npos;
|
||||
std::uintmax_t count = 1;
|
||||
if (is_directory(st)) {
|
||||
for (directory_iterator it(p, ec); !ec && it != directory_iterator();
|
||||
it.increment(ec)) {
|
||||
auto other_count = remove_all_impl(it->path(), ec);
|
||||
if (ec) return npos;
|
||||
count += other_count;
|
||||
}
|
||||
if (ec) return npos;
|
||||
}
|
||||
if (!__remove(p, &ec)) return npos;
|
||||
return count;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
std::uintmax_t __remove_all(const path& p, std::error_code *ec) {
|
||||
std::error_code mec;
|
||||
auto count = remove_all_impl(p, mec);
|
||||
if (mec) {
|
||||
set_or_throw(mec, ec, "remove_all", p);
|
||||
return static_cast<std::uintmax_t>(-1);
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
return count;
|
||||
}
|
||||
|
||||
void __rename(const path& from, const path& to, std::error_code *ec) {
|
||||
if (::rename(from.c_str(), to.c_str()) == -1)
|
||||
set_or_throw(ec, "rename", from, to);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
void __resize_file(const path& p, std::uintmax_t size, std::error_code *ec) {
|
||||
if (::truncate(p.c_str(), static_cast<long>(size)) == -1)
|
||||
set_or_throw(ec, "resize_file", p);
|
||||
else if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
space_info __space(const path& p, std::error_code *ec) {
|
||||
space_info si;
|
||||
struct statvfs m_svfs = {};
|
||||
if (::statvfs(p.c_str(), &m_svfs) == -1) {
|
||||
set_or_throw(ec, "space", p);
|
||||
si.capacity = si.free = si.available =
|
||||
static_cast<std::uintmax_t>(-1);
|
||||
return si;
|
||||
}
|
||||
if (ec) ec->clear();
|
||||
// Multiply with overflow checking.
|
||||
auto do_mult = [&](std::uintmax_t& out, std::uintmax_t other) {
|
||||
out = other * m_svfs.f_frsize;
|
||||
if (out / other != m_svfs.f_frsize || other == 0)
|
||||
out = static_cast<std::uintmax_t>(-1);
|
||||
};
|
||||
do_mult(si.capacity, m_svfs.f_blocks);
|
||||
do_mult(si.free, m_svfs.f_bfree);
|
||||
do_mult(si.available, m_svfs.f_bavail);
|
||||
return si;
|
||||
}
|
||||
|
||||
file_status __status(const path& p, std::error_code *ec) {
|
||||
return detail::posix_stat(p, ec);
|
||||
}
|
||||
|
||||
file_status __symlink_status(const path& p, std::error_code *ec) {
|
||||
return detail::posix_lstat(p, ec);
|
||||
}
|
||||
|
||||
path __system_complete(const path& p, std::error_code *ec) {
|
||||
if (ec) ec->clear();
|
||||
return absolute(p, current_path());
|
||||
}
|
||||
|
||||
path __temp_directory_path(std::error_code *ec) {
|
||||
const char* env_paths[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
|
||||
const char* ret = nullptr;
|
||||
for (auto & ep : env_paths) {
|
||||
if ((ret = std::getenv(ep)))
|
||||
break;
|
||||
}
|
||||
path p(ret ? ret : "/tmp");
|
||||
std::error_code m_ec;
|
||||
if (is_directory(p, m_ec)) {
|
||||
if (ec) ec->clear();
|
||||
return p;
|
||||
}
|
||||
if (!m_ec || m_ec == make_error_code(errc::no_such_file_or_directory))
|
||||
m_ec = make_error_code(errc::not_a_directory);
|
||||
set_or_throw(m_ec, ec, "temp_directory_path");
|
||||
return {};
|
||||
}
|
||||
|
||||
// An absolute path is composed according to the table in [fs.op.absolute].
|
||||
path absolute(const path& p, const path& base) {
|
||||
auto root_name = p.root_name();
|
||||
auto root_dir = p.root_directory();
|
||||
|
||||
if (!root_name.empty() && !root_dir.empty())
|
||||
return p;
|
||||
|
||||
auto abs_base = base.is_absolute() ? base : absolute(base);
|
||||
|
||||
/* !has_root_name && !has_root_dir */
|
||||
if (root_name.empty() && root_dir.empty())
|
||||
{
|
||||
return abs_base / p;
|
||||
}
|
||||
else if (!root_name.empty()) /* has_root_name && !has_root_dir */
|
||||
{
|
||||
return root_name / abs_base.root_directory()
|
||||
/
|
||||
abs_base.relative_path() / p.relative_path();
|
||||
}
|
||||
else /* !has_root_name && has_root_dir */
|
||||
{
|
||||
if (abs_base.has_root_name())
|
||||
return abs_base.root_name() / p;
|
||||
// else p is absolute, return outside of block
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
391
contrib/libc++/src/experimental/filesystem/path.cpp
Normal file
391
contrib/libc++/src/experimental/filesystem/path.cpp
Normal file
@ -0,0 +1,391 @@
|
||||
//===--------------------- filesystem/path.cpp ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#include "experimental/filesystem"
|
||||
#include "experimental/string_view"
|
||||
#include "utility"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
_LIBCPP_CONSTEXPR path::value_type path::preferred_separator;
|
||||
|
||||
namespace { namespace parser
|
||||
{
|
||||
|
||||
using string_type = string_view;
|
||||
using value_type = path::value_type;
|
||||
|
||||
using string_view_pair = pair<string_view, string_view>;
|
||||
|
||||
// status reporting
|
||||
constexpr size_t npos = static_cast<size_t>(-1);
|
||||
|
||||
inline bool good(size_t pos) { return pos != npos; }
|
||||
|
||||
// lexical elements
|
||||
constexpr value_type preferred_separator = path::preferred_separator;
|
||||
constexpr value_type const * preferred_separator_str = "/";
|
||||
constexpr value_type const * dot = ".";
|
||||
|
||||
// forward //
|
||||
bool is_separator(string_type const &, size_t);
|
||||
bool is_root_name(const string_type&, size_t);
|
||||
bool is_root_directory(string_type const &, size_t);
|
||||
bool is_trailing_separator(string_type const &, size_t);
|
||||
|
||||
size_t start_of(string_type const &, size_t);
|
||||
size_t end_of(string_type const &, size_t);
|
||||
|
||||
size_t root_name_start(const string_type& s);
|
||||
size_t root_name_end(const string_type&);
|
||||
|
||||
size_t root_directory_start(string_type const &);
|
||||
size_t root_directory_end(string_type const &);
|
||||
|
||||
string_view_pair separate_filename(string_type const &);
|
||||
string_view extract_raw(string_type const &, size_t);
|
||||
string_view extract_preferred(string_type const &, size_t);
|
||||
|
||||
inline bool is_separator(const string_type& s, size_t pos) {
|
||||
return (pos < s.size() && s[pos] == preferred_separator);
|
||||
}
|
||||
|
||||
inline bool is_root_name(const string_type& s, size_t pos) {
|
||||
return good(pos) && pos == 0 ? root_name_start(s) == pos : false;
|
||||
}
|
||||
|
||||
inline bool is_root_directory(const string_type& s, size_t pos) {
|
||||
return good(pos) ? root_directory_start(s) == pos : false;
|
||||
}
|
||||
|
||||
inline bool is_trailing_separator(const string_type& s, size_t pos) {
|
||||
return (pos < s.size() && is_separator(s, pos) &&
|
||||
end_of(s, pos) == s.size()-1 &&
|
||||
!is_root_directory(s, pos) && !is_root_name(s, pos));
|
||||
}
|
||||
|
||||
size_t start_of(const string_type& s, size_t pos) {
|
||||
if (pos >= s.size()) return npos;
|
||||
bool in_sep = (s[pos] == preferred_separator);
|
||||
while (pos - 1 < s.size() &&
|
||||
(s[pos-1] == preferred_separator) == in_sep)
|
||||
{ --pos; }
|
||||
if (pos == 2 && !in_sep && s[0] == preferred_separator &&
|
||||
s[1] == preferred_separator)
|
||||
{ return 0; }
|
||||
return pos;
|
||||
}
|
||||
|
||||
size_t end_of(const string_type& s, size_t pos) {
|
||||
if (pos >= s.size()) return npos;
|
||||
// special case for root name
|
||||
if (pos == 0 && is_root_name(s, pos)) return root_name_end(s);
|
||||
bool in_sep = (s[pos] == preferred_separator);
|
||||
while (pos + 1 < s.size() && (s[pos+1] == preferred_separator) == in_sep)
|
||||
{ ++pos; }
|
||||
return pos;
|
||||
}
|
||||
|
||||
inline size_t root_name_start(const string_type& s) {
|
||||
return good(root_name_end(s)) ? 0 : npos;
|
||||
}
|
||||
|
||||
size_t root_name_end(const string_type& s) {
|
||||
if (s.size() < 2 || s[0] != preferred_separator
|
||||
|| s[1] != preferred_separator) {
|
||||
return npos;
|
||||
}
|
||||
if (s.size() == 2) {
|
||||
return 1;
|
||||
}
|
||||
size_t index = 2; // current position
|
||||
if (s[index] == preferred_separator) {
|
||||
return npos;
|
||||
}
|
||||
while (index + 1 < s.size() && s[index+1] != preferred_separator) {
|
||||
++index;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
size_t root_directory_start(const string_type& s) {
|
||||
size_t e = root_name_end(s);
|
||||
if (!good(e))
|
||||
return is_separator(s, 0) ? 0 : npos;
|
||||
return is_separator(s, e + 1) ? e + 1 : npos;
|
||||
}
|
||||
|
||||
size_t root_directory_end(const string_type& s) {
|
||||
size_t st = root_directory_start(s);
|
||||
if (!good(st)) return npos;
|
||||
size_t index = st;
|
||||
while (index + 1 < s.size() && s[index + 1] == preferred_separator)
|
||||
{ ++index; }
|
||||
return index;
|
||||
}
|
||||
|
||||
string_view_pair separate_filename(string_type const & s) {
|
||||
if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""};
|
||||
auto pos = s.find_last_of('.');
|
||||
if (pos == string_type::npos) return string_view_pair{s, string_view{}};
|
||||
return string_view_pair{s.substr(0, pos), s.substr(pos)};
|
||||
}
|
||||
|
||||
inline string_view extract_raw(const string_type& s, size_t pos) {
|
||||
size_t end_i = end_of(s, pos);
|
||||
if (!good(end_i)) return string_view{};
|
||||
return string_view(s).substr(pos, end_i - pos + 1);
|
||||
}
|
||||
|
||||
string_view extract_preferred(const string_type& s, size_t pos) {
|
||||
string_view raw = extract_raw(s, pos);
|
||||
if (raw.empty())
|
||||
return raw;
|
||||
if (is_trailing_separator(s, pos))
|
||||
return string_view{dot};
|
||||
if (is_separator(s, pos) && !is_root_name(s, pos))
|
||||
return string_view(preferred_separator_str);
|
||||
return raw;
|
||||
}
|
||||
|
||||
}} // namespace parser
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// path_view_iterator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
namespace {
|
||||
|
||||
struct path_view_iterator {
|
||||
const string_view __s_;
|
||||
size_t __pos_;
|
||||
|
||||
explicit path_view_iterator(string_view const& __s) : __s_(__s), __pos_(__s_.empty() ? parser::npos : 0) {}
|
||||
explicit path_view_iterator(string_view const& __s, size_t __p) : __s_(__s), __pos_(__p) {}
|
||||
|
||||
string_view operator*() const {
|
||||
return parser::extract_preferred(__s_, __pos_);
|
||||
}
|
||||
|
||||
path_view_iterator& operator++() {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
path_view_iterator& operator--() {
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void increment() {
|
||||
if (__pos_ == parser::npos) return;
|
||||
while (! set_position(parser::end_of(__s_, __pos_)+1))
|
||||
;
|
||||
return;
|
||||
}
|
||||
|
||||
void decrement() {
|
||||
if (__pos_ == 0) {
|
||||
set_position(0);
|
||||
}
|
||||
else if (__pos_ == parser::npos) {
|
||||
auto const str_size = __s_.size();
|
||||
set_position(parser::start_of(
|
||||
__s_, str_size != 0 ? str_size - 1 : str_size));
|
||||
} else {
|
||||
while (!set_position(parser::start_of(__s_, __pos_-1)))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
bool set_position(size_t pos) {
|
||||
if (pos >= __s_.size()) {
|
||||
__pos_ = parser::npos;
|
||||
} else {
|
||||
__pos_ = pos;
|
||||
}
|
||||
return valid_iterator_position();
|
||||
}
|
||||
|
||||
bool valid_iterator_position() const {
|
||||
if (__pos_ == parser::npos) return true; // end position is valid
|
||||
return (!parser::is_separator (__s_, __pos_) ||
|
||||
parser::is_root_directory (__s_, __pos_) ||
|
||||
parser::is_trailing_separator(__s_, __pos_) ||
|
||||
parser::is_root_name (__s_, __pos_));
|
||||
}
|
||||
|
||||
bool is_end() const { return __pos_ == parser::npos; }
|
||||
|
||||
inline bool operator==(path_view_iterator const& __p) {
|
||||
return __pos_ == __p.__pos_;
|
||||
}
|
||||
};
|
||||
|
||||
path_view_iterator pbegin(path const& p) {
|
||||
return path_view_iterator(p.native());
|
||||
}
|
||||
|
||||
path_view_iterator pend(path const& p) {
|
||||
path_view_iterator __p(p.native());
|
||||
__p.__pos_ = parser::npos;
|
||||
return __p;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// path definitions
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
path & path::replace_extension(path const & replacement)
|
||||
{
|
||||
path p = extension();
|
||||
if (not p.empty()) {
|
||||
__pn_.erase(__pn_.size() - p.native().size());
|
||||
}
|
||||
if (!replacement.empty()) {
|
||||
if (replacement.native()[0] != '.') {
|
||||
__pn_ += ".";
|
||||
}
|
||||
__pn_.append(replacement.__pn_);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// path.decompose
|
||||
|
||||
string_view path::__root_name() const
|
||||
{
|
||||
return parser::is_root_name(__pn_, 0)
|
||||
? parser::extract_preferred(__pn_, 0)
|
||||
: string_view{};
|
||||
}
|
||||
|
||||
string_view path::__root_directory() const
|
||||
{
|
||||
auto start_i = parser::root_directory_start(__pn_);
|
||||
if(!parser::good(start_i)) {
|
||||
return {};
|
||||
}
|
||||
return parser::extract_preferred(__pn_, start_i);
|
||||
}
|
||||
|
||||
string_view path::__relative_path() const
|
||||
{
|
||||
if (empty()) {
|
||||
return {__pn_};
|
||||
}
|
||||
auto end_i = parser::root_directory_end(__pn_);
|
||||
if (not parser::good(end_i)) {
|
||||
end_i = parser::root_name_end(__pn_);
|
||||
}
|
||||
if (not parser::good(end_i)) {
|
||||
return {__pn_};
|
||||
}
|
||||
return string_view(__pn_).substr(end_i+1);
|
||||
}
|
||||
|
||||
string_view path::__parent_path() const
|
||||
{
|
||||
if (empty() || pbegin(*this) == --pend(*this)) {
|
||||
return {};
|
||||
}
|
||||
auto end_it = --(--pend(*this));
|
||||
auto end_i = parser::end_of(__pn_, end_it.__pos_);
|
||||
return string_view(__pn_).substr(0, end_i+1);
|
||||
}
|
||||
|
||||
string_view path::__filename() const
|
||||
{
|
||||
return empty() ? string_view{} : *--pend(*this);
|
||||
}
|
||||
|
||||
string_view path::__stem() const
|
||||
{
|
||||
return parser::separate_filename(__filename()).first;
|
||||
}
|
||||
|
||||
string_view path::__extension() const
|
||||
{
|
||||
return parser::separate_filename(__filename()).second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// path.comparisons
|
||||
int path::__compare(const value_type* __s) const {
|
||||
path_view_iterator thisIter(this->native());
|
||||
path_view_iterator sIter(__s);
|
||||
while (!thisIter.is_end() && !sIter.is_end()) {
|
||||
int res = (*thisIter).compare(*sIter);
|
||||
if (res != 0) return res;
|
||||
++thisIter; ++sIter;
|
||||
}
|
||||
if (thisIter.is_end() && sIter.is_end())
|
||||
return 0;
|
||||
if (thisIter.is_end())
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// path.nonmembers
|
||||
size_t hash_value(const path& __p) _NOEXCEPT {
|
||||
path_view_iterator thisIter(__p.native());
|
||||
struct HashPairT {
|
||||
size_t first;
|
||||
size_t second;
|
||||
};
|
||||
HashPairT hp = {0, 0};
|
||||
std::hash<string_view> hasher;
|
||||
std::__scalar_hash<decltype(hp)> pair_hasher;
|
||||
while (!thisIter.is_end()) {
|
||||
hp.second = hasher(*thisIter);
|
||||
hp.first = pair_hasher(hp);
|
||||
++thisIter;
|
||||
}
|
||||
return hp.first;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// path.itr
|
||||
path::iterator path::begin() const
|
||||
{
|
||||
path_view_iterator pit = pbegin(*this);
|
||||
iterator it;
|
||||
it.__path_ptr_ = this;
|
||||
it.__pos_ = pit.__pos_;
|
||||
it.__elem_.__assign_view(*pit);
|
||||
return it;
|
||||
}
|
||||
|
||||
path::iterator path::end() const
|
||||
{
|
||||
iterator it{};
|
||||
it.__path_ptr_ = this;
|
||||
it.__pos_ = parser::npos;
|
||||
return it;
|
||||
}
|
||||
|
||||
path::iterator& path::iterator::__increment() {
|
||||
path_view_iterator it(__path_ptr_->native(), __pos_);
|
||||
it.increment();
|
||||
__pos_ = it.__pos_;
|
||||
__elem_.__assign_view(*it);
|
||||
return *this;
|
||||
}
|
||||
|
||||
path::iterator& path::iterator::__decrement() {
|
||||
path_view_iterator it(__path_ptr_->native(), __pos_);
|
||||
it.decrement();
|
||||
__pos_ = it.__pos_;
|
||||
__elem_.__assign_view(*it);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
144
contrib/libc++/src/experimental/memory_resource.cpp
Normal file
144
contrib/libc++/src/experimental/memory_resource.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
//===------------------------ memory_resource.cpp -------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "experimental/memory_resource"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
|
||||
#include "atomic"
|
||||
#elif !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
#include "mutex"
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
// memory_resource
|
||||
|
||||
//memory_resource::~memory_resource() {}
|
||||
|
||||
// new_delete_resource()
|
||||
|
||||
class _LIBCPP_TYPE_VIS_ONLY __new_delete_memory_resource_imp
|
||||
: public memory_resource
|
||||
{
|
||||
public:
|
||||
~__new_delete_memory_resource_imp() = default;
|
||||
|
||||
protected:
|
||||
virtual void* do_allocate(size_t __size, size_t __align)
|
||||
{ return __allocate(__size); }
|
||||
|
||||
virtual void do_deallocate(void * __p, size_t, size_t)
|
||||
{ __deallocate(__p); }
|
||||
|
||||
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
|
||||
{ return &__other == this; }
|
||||
};
|
||||
|
||||
// null_memory_resource()
|
||||
|
||||
class _LIBCPP_TYPE_VIS_ONLY __null_memory_resource_imp
|
||||
: public memory_resource
|
||||
{
|
||||
public:
|
||||
~__null_memory_resource_imp() = default;
|
||||
|
||||
protected:
|
||||
virtual void* do_allocate(size_t, size_t) {
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw std::bad_alloc();
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
virtual void do_deallocate(void *, size_t, size_t) {}
|
||||
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
|
||||
{ return &__other == this; }
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
union ResourceInitHelper {
|
||||
struct {
|
||||
__new_delete_memory_resource_imp new_delete_res;
|
||||
__null_memory_resource_imp null_res;
|
||||
} resources;
|
||||
char dummy;
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}
|
||||
~ResourceInitHelper() {}
|
||||
};
|
||||
// When compiled in C++14 this initialization should be a constant expression.
|
||||
// Only in C++11 is "init_priority" needed to ensure initialization order.
|
||||
ResourceInitHelper res_init __attribute__((init_priority (101)));
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
||||
memory_resource * new_delete_resource() _NOEXCEPT {
|
||||
return &res_init.resources.new_delete_res;
|
||||
}
|
||||
|
||||
memory_resource * null_memory_resource() _NOEXCEPT {
|
||||
return &res_init.resources.null_res;
|
||||
}
|
||||
|
||||
// default_memory_resource()
|
||||
|
||||
static memory_resource *
|
||||
__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) _NOEXCEPT
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
|
||||
static atomic<memory_resource*> __res =
|
||||
ATOMIC_VAR_INIT(&res_init.resources.new_delete_res);
|
||||
if (set) {
|
||||
new_res = new_res ? new_res : new_delete_resource();
|
||||
// TODO: Can a weaker ordering be used?
|
||||
return _VSTD::atomic_exchange_explicit(
|
||||
&__res, new_res, memory_order::memory_order_acq_rel);
|
||||
}
|
||||
else {
|
||||
return _VSTD::atomic_load_explicit(
|
||||
&__res, memory_order::memory_order_acquire);
|
||||
}
|
||||
#elif !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
static memory_resource * res = &res_init.resources.new_delete_res;
|
||||
static mutex res_lock;
|
||||
if (set) {
|
||||
new_res = new_res ? new_res : new_delete_resource();
|
||||
lock_guard<mutex> guard(res_lock);
|
||||
memory_resource * old_res = res;
|
||||
res = new_res;
|
||||
return old_res;
|
||||
} else {
|
||||
lock_guard<mutex> guard(res_lock);
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
static memory_resource* res = &res_init.resources.new_delete_res;
|
||||
if (set) {
|
||||
new_res = new_res ? new_res : new_delete_resource();
|
||||
memory_resource * old_res = res;
|
||||
res = new_res;
|
||||
return old_res;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
memory_resource * get_default_resource() _NOEXCEPT
|
||||
{
|
||||
return __default_memory_resource();
|
||||
}
|
||||
|
||||
memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT
|
||||
{
|
||||
return __default_memory_resource(true, __new_res);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
@ -123,11 +123,6 @@ const locale::category locale::time;
|
||||
const locale::category locale::messages;
|
||||
const locale::category locale::all;
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
class _LIBCPP_HIDDEN locale::__imp
|
||||
: public facet
|
||||
{
|
||||
@ -163,10 +158,6 @@ class _LIBCPP_HIDDEN locale::__imp
|
||||
template <class F> void install_from(const __imp& other);
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
locale::__imp::__imp(size_t refs)
|
||||
: facet(refs),
|
||||
facets_(N),
|
||||
@ -1409,33 +1400,21 @@ ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
|
||||
wchar_t
|
||||
ctype_byname<wchar_t>::do_widen(char c) const
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return btowc_l(c, __l);
|
||||
#else
|
||||
return __btowc_l(c, __l);
|
||||
#endif
|
||||
return __libcpp_btowc_l(c, __l);
|
||||
}
|
||||
|
||||
const char*
|
||||
ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
|
||||
{
|
||||
for (; low != high; ++low, ++dest)
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
*dest = btowc_l(*low, __l);
|
||||
#else
|
||||
*dest = __btowc_l(*low, __l);
|
||||
#endif
|
||||
*dest = __libcpp_btowc_l(*low, __l);
|
||||
return low;
|
||||
}
|
||||
|
||||
char
|
||||
ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int r = wctob_l(c, __l);
|
||||
#else
|
||||
int r = __wctob_l(c, __l);
|
||||
#endif
|
||||
int r = __libcpp_wctob_l(c, __l);
|
||||
return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
|
||||
}
|
||||
|
||||
@ -1444,11 +1423,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
|
||||
{
|
||||
for (; low != high; ++low, ++dest)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int r = wctob_l(*low, __l);
|
||||
#else
|
||||
int r = __wctob_l(*low, __l);
|
||||
#endif
|
||||
int r = __libcpp_wctob_l(*low, __l);
|
||||
*dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
|
||||
}
|
||||
return low;
|
||||
@ -1558,22 +1533,14 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
|
||||
{
|
||||
// save state in case it is needed to recover to_nxt on error
|
||||
mbstate_t save_state = st;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t n = wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
|
||||
static_cast<size_t>(to_end-to), &st, __l);
|
||||
#else
|
||||
size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
|
||||
#endif
|
||||
size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
|
||||
static_cast<size_t>(to_end-to), &st, __l);
|
||||
if (n == size_t(-1))
|
||||
{
|
||||
// need to recover to_nxt
|
||||
for (to_nxt = to; frm != frm_nxt; ++frm)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
n = wcrtomb_l(to_nxt, *frm, &save_state, __l);
|
||||
#else
|
||||
n = __wcrtomb_l(to_nxt, *frm, &save_state, __l);
|
||||
#endif
|
||||
n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);
|
||||
if (n == size_t(-1))
|
||||
break;
|
||||
to_nxt += n;
|
||||
@ -1590,11 +1557,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
|
||||
{
|
||||
// Try to write the terminating null
|
||||
extern_type tmp[MB_LEN_MAX];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
n = wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
#else
|
||||
n = __wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
#endif
|
||||
n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
if (n == size_t(-1)) // on error
|
||||
return error;
|
||||
if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?
|
||||
@ -1627,23 +1590,15 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
|
||||
{
|
||||
// save state in case it is needed to recover to_nxt on error
|
||||
mbstate_t save_state = st;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t n = mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
|
||||
static_cast<size_t>(to_end-to), &st, __l);
|
||||
#else
|
||||
size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
|
||||
#endif
|
||||
size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
|
||||
static_cast<size_t>(to_end-to), &st, __l);
|
||||
if (n == size_t(-1))
|
||||
{
|
||||
// need to recover to_nxt
|
||||
for (to_nxt = to; frm != frm_nxt; ++to_nxt)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
n = mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
|
||||
&save_state, __l);
|
||||
#else
|
||||
n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l);
|
||||
#endif
|
||||
n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
|
||||
&save_state, __l);
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
@ -1671,11 +1626,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
|
||||
if (fend != frm_end) // set up next null terminated sequence
|
||||
{
|
||||
// Try to write the terminating null
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
n = mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
|
||||
#else
|
||||
n = __mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
|
||||
#endif
|
||||
n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
|
||||
if (n != 0) // on error
|
||||
return error;
|
||||
++to_nxt;
|
||||
@ -1695,11 +1646,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
|
||||
{
|
||||
to_nxt = to;
|
||||
extern_type tmp[MB_LEN_MAX];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t n = wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
#else
|
||||
size_t n = __wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
#endif
|
||||
size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
if (n == size_t(-1) || n == 0) // on error
|
||||
return error;
|
||||
--n;
|
||||
@ -1713,21 +1660,11 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
|
||||
int
|
||||
codecvt<wchar_t, char, mbstate_t>::do_encoding() const _NOEXCEPT
|
||||
{
|
||||
#ifndef __CloudABI__
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
|
||||
#else
|
||||
if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
|
||||
#endif
|
||||
if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
// stateless encoding
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
if (__l == 0 || MB_CUR_MAX_L(__l) == 1) // there are no known constant length encodings
|
||||
#else
|
||||
if (__l == 0 || __mb_cur_max_l(__l) == 1) // there are no known constant length encodings
|
||||
#endif
|
||||
if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1) // there are no known constant length encodings
|
||||
return 1; // which take more than 1 char to form a wchar_t
|
||||
return 0;
|
||||
}
|
||||
@ -1745,11 +1682,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
|
||||
int nbytes = 0;
|
||||
for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t n = mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
|
||||
#else
|
||||
size_t n = __mbrlen_l(frm, frm_end-frm, &st, __l);
|
||||
#endif
|
||||
size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
@ -1771,11 +1704,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
|
||||
int
|
||||
codecvt<wchar_t, char, mbstate_t>::do_max_length() const _NOEXCEPT
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return __l == 0 ? 1 : static_cast<int>( MB_CUR_MAX_L(__l));
|
||||
#else
|
||||
return __l == 0 ? 1 : static_cast<int>(__mb_cur_max_l(__l));
|
||||
#endif
|
||||
return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l));
|
||||
}
|
||||
|
||||
// Valid UTF ranges
|
||||
@ -2894,10 +2823,10 @@ ucs4_to_utf16le(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& f
|
||||
to_nxt = to;
|
||||
if (mode & generate_header)
|
||||
{
|
||||
if (to_end-to_nxt < 2)
|
||||
if (to_end - to_nxt < 2)
|
||||
return codecvt_base::partial;
|
||||
*to_nxt++ = static_cast<uint8_t>(0xFF);
|
||||
*to_nxt++ = static_cast<uint8_t>(0xFE);
|
||||
*to_nxt++ = static_cast<uint8_t>(0xFF);
|
||||
*to_nxt++ = static_cast<uint8_t>(0xFE);
|
||||
}
|
||||
for (; frm_nxt < frm_end; ++frm_nxt)
|
||||
{
|
||||
@ -4333,11 +4262,7 @@ numpunct_byname<char>::__init(const char* nm)
|
||||
throw runtime_error("numpunct_byname<char>::numpunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
lconv* lc = localeconv_l(loc.get());
|
||||
#else
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
#endif
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (*lc->decimal_point)
|
||||
__decimal_point_ = *lc->decimal_point;
|
||||
if (*lc->thousands_sep)
|
||||
@ -4376,11 +4301,7 @@ numpunct_byname<wchar_t>::__init(const char* nm)
|
||||
throw runtime_error("numpunct_byname<char>::numpunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
lconv* lc = localeconv_l(loc.get());
|
||||
#else
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
#endif
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (*lc->decimal_point)
|
||||
__decimal_point_ = *lc->decimal_point;
|
||||
if (*lc->thousands_sep)
|
||||
@ -4981,11 +4902,7 @@ __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
|
||||
wchar_t* wbb = wbuf;
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbb + j;
|
||||
@ -5165,11 +5082,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
strftime_l(buf, countof(buf), "%A", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
const char* bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5177,11 +5090,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
strftime_l(buf, countof(buf), "%a", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5194,11 +5103,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
strftime_l(buf, countof(buf), "%B", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
const char* bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5206,11 +5111,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
strftime_l(buf, countof(buf), "%b", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5221,11 +5122,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
strftime_l(buf, countof(buf), "%p", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
const char* bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5234,11 +5131,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
strftime_l(buf, countof(buf), "%p", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
bb = buf;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5513,11 +5406,7 @@ __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
|
||||
__do_put(__nar, __ne, __tm, __fmt, __mod);
|
||||
mbstate_t mb = {0};
|
||||
const char* __nb = __nar;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
__we = __wb + j;
|
||||
@ -5908,11 +5797,7 @@ moneypunct_byname<char, false>::init(const char* nm)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
lconv* lc = localeconv_l(loc.get());
|
||||
#else
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
#endif
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = *lc->mon_decimal_point;
|
||||
else
|
||||
@ -5956,11 +5841,7 @@ moneypunct_byname<char, true>::init(const char* nm)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
lconv* lc = localeconv_l(loc.get());
|
||||
#else
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
#endif
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = *lc->mon_decimal_point;
|
||||
else
|
||||
@ -6021,11 +5902,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
lconv* lc = localeconv_l(loc.get());
|
||||
#else
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
#endif
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
|
||||
else
|
||||
@ -6038,11 +5915,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
wchar_t wbuf[100];
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = lc->currency_symbol;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbuf + j;
|
||||
@ -6057,11 +5930,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->positive_sign;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -6073,11 +5942,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->negative_sign;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -6104,11 +5969,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
lconv* lc = localeconv_l(loc.get());
|
||||
#else
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
#endif
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
|
||||
else
|
||||
@ -6121,11 +5982,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
wchar_t wbuf[100];
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = lc->int_curr_symbol;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#else
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#endif
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbuf + j;
|
||||
@ -6144,11 +6001,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->positive_sign;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -6164,11 +6017,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->negative_sign;
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#else
|
||||
j = __mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
#endif
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
|
@ -124,15 +124,15 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
|
||||
|
||||
#endif // _LIBCPP_NO_RTTI
|
||||
|
||||
#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
|
||||
static const std::size_t __sp_mut_count = 16;
|
||||
static pthread_mutex_t mut_back_imp[__sp_mut_count] =
|
||||
static __libcpp_mutex_t mut_back_imp[__sp_mut_count] =
|
||||
{
|
||||
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
|
||||
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
|
||||
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
|
||||
PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
|
||||
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER
|
||||
};
|
||||
|
||||
static mutex* mut_back = reinterpret_cast<std::mutex*>(mut_back_imp);
|
||||
@ -177,7 +177,7 @@ __get_sp_mut(const void* p)
|
||||
return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
|
||||
}
|
||||
|
||||
#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
|
||||
void
|
||||
declare_reachable(void*)
|
||||
|
@ -23,13 +23,13 @@ const adopt_lock_t adopt_lock = {};
|
||||
|
||||
mutex::~mutex()
|
||||
{
|
||||
pthread_mutex_destroy(&__m_);
|
||||
__libcpp_mutex_destroy(&__m_);
|
||||
}
|
||||
|
||||
void
|
||||
mutex::lock()
|
||||
{
|
||||
int ec = pthread_mutex_lock(&__m_);
|
||||
int ec = __libcpp_mutex_lock(&__m_);
|
||||
if (ec)
|
||||
__throw_system_error(ec, "mutex lock failed");
|
||||
}
|
||||
@ -37,13 +37,13 @@ mutex::lock()
|
||||
bool
|
||||
mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
return pthread_mutex_trylock(&__m_) == 0;
|
||||
return __libcpp_mutex_trylock(&__m_) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
mutex::unlock() _NOEXCEPT
|
||||
{
|
||||
int ec = pthread_mutex_unlock(&__m_);
|
||||
int ec = __libcpp_mutex_unlock(&__m_);
|
||||
(void)ec;
|
||||
assert(ec == 0);
|
||||
}
|
||||
@ -52,36 +52,14 @@ mutex::unlock() _NOEXCEPT
|
||||
|
||||
recursive_mutex::recursive_mutex()
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int ec = pthread_mutexattr_init(&attr);
|
||||
int ec = __libcpp_recursive_mutex_init(&__m_);
|
||||
if (ec)
|
||||
goto fail;
|
||||
ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (ec)
|
||||
{
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
goto fail;
|
||||
}
|
||||
ec = pthread_mutex_init(&__m_, &attr);
|
||||
if (ec)
|
||||
{
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
goto fail;
|
||||
}
|
||||
ec = pthread_mutexattr_destroy(&attr);
|
||||
if (ec)
|
||||
{
|
||||
pthread_mutex_destroy(&__m_);
|
||||
goto fail;
|
||||
}
|
||||
return;
|
||||
fail:
|
||||
__throw_system_error(ec, "recursive_mutex constructor failed");
|
||||
__throw_system_error(ec, "recursive_mutex constructor failed");
|
||||
}
|
||||
|
||||
recursive_mutex::~recursive_mutex()
|
||||
{
|
||||
int e = pthread_mutex_destroy(&__m_);
|
||||
int e = __libcpp_mutex_destroy(&__m_);
|
||||
(void)e;
|
||||
assert(e == 0);
|
||||
}
|
||||
@ -89,7 +67,7 @@ recursive_mutex::~recursive_mutex()
|
||||
void
|
||||
recursive_mutex::lock()
|
||||
{
|
||||
int ec = pthread_mutex_lock(&__m_);
|
||||
int ec = __libcpp_mutex_lock(&__m_);
|
||||
if (ec)
|
||||
__throw_system_error(ec, "recursive_mutex lock failed");
|
||||
}
|
||||
@ -97,7 +75,7 @@ recursive_mutex::lock()
|
||||
void
|
||||
recursive_mutex::unlock() _NOEXCEPT
|
||||
{
|
||||
int e = pthread_mutex_unlock(&__m_);
|
||||
int e = __libcpp_mutex_unlock(&__m_);
|
||||
(void)e;
|
||||
assert(e == 0);
|
||||
}
|
||||
@ -105,7 +83,7 @@ recursive_mutex::unlock() _NOEXCEPT
|
||||
bool
|
||||
recursive_mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
return pthread_mutex_trylock(&__m_) == 0;
|
||||
return __libcpp_mutex_trylock(&__m_) == 0;
|
||||
}
|
||||
|
||||
// timed_mutex
|
||||
@ -165,9 +143,9 @@ recursive_timed_mutex::~recursive_timed_mutex()
|
||||
void
|
||||
recursive_timed_mutex::lock()
|
||||
{
|
||||
pthread_t id = pthread_self();
|
||||
__libcpp_thread_id id = __libcpp_thread_get_current_id();
|
||||
unique_lock<mutex> lk(__m_);
|
||||
if (pthread_equal(id, __id_))
|
||||
if (__libcpp_thread_id_equal(id, __id_))
|
||||
{
|
||||
if (__count_ == numeric_limits<size_t>::max())
|
||||
__throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
|
||||
@ -183,9 +161,9 @@ recursive_timed_mutex::lock()
|
||||
bool
|
||||
recursive_timed_mutex::try_lock() _NOEXCEPT
|
||||
{
|
||||
pthread_t id = pthread_self();
|
||||
__libcpp_thread_id id = __libcpp_thread_get_current_id();
|
||||
unique_lock<mutex> lk(__m_, try_to_lock);
|
||||
if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
|
||||
if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
|
||||
{
|
||||
if (__count_ == numeric_limits<size_t>::max())
|
||||
return false;
|
||||
@ -217,8 +195,8 @@ recursive_timed_mutex::unlock() _NOEXCEPT
|
||||
// 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;
|
||||
static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
|
||||
static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
|
||||
#endif
|
||||
|
||||
/// NOTE: Changes to flag are done via relaxed atomic stores
|
||||
@ -247,9 +225,9 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
#else // !_LIBCPP_HAS_NO_THREADS
|
||||
pthread_mutex_lock(&mut);
|
||||
__libcpp_mutex_lock(&mut);
|
||||
while (flag == 1)
|
||||
pthread_cond_wait(&cv, &mut);
|
||||
__libcpp_condvar_wait(&cv, &mut);
|
||||
if (flag == 0)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -257,26 +235,26 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__libcpp_relaxed_store(&flag, 1ul);
|
||||
pthread_mutex_unlock(&mut);
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
func(arg);
|
||||
pthread_mutex_lock(&mut);
|
||||
__libcpp_mutex_lock(&mut);
|
||||
__libcpp_relaxed_store(&flag, ~0ul);
|
||||
pthread_mutex_unlock(&mut);
|
||||
pthread_cond_broadcast(&cv);
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
__libcpp_condvar_broadcast(&cv);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pthread_mutex_lock(&mut);
|
||||
__libcpp_mutex_lock(&mut);
|
||||
__libcpp_relaxed_store(&flag, 0ul);
|
||||
pthread_mutex_unlock(&mut);
|
||||
pthread_cond_broadcast(&cv);
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
__libcpp_condvar_broadcast(&cv);
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
else
|
||||
pthread_mutex_unlock(&mut);
|
||||
__libcpp_mutex_unlock(&mut);
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
}
|
||||
|
@ -69,21 +69,12 @@ regex_error::~regex_error() throw() {}
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
struct collationnames
|
||||
{
|
||||
const char* elem_;
|
||||
char char_;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
const collationnames collatenames[] =
|
||||
{
|
||||
{"A", 0x41},
|
||||
@ -199,21 +190,12 @@ const collationnames collatenames[] =
|
||||
{"zero", 0x30}
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
struct classnames
|
||||
{
|
||||
const char* elem_;
|
||||
regex_traits<char>::char_class_type mask_;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
const classnames ClassNames[] =
|
||||
{
|
||||
{"alnum", ctype_base::alnum},
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "algorithm"
|
||||
#include "climits"
|
||||
#include "cstring"
|
||||
#include "__debug"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@ -167,11 +168,13 @@ strstreambuf::overflow(int_type __c)
|
||||
buf = new char[new_size];
|
||||
if (buf == nullptr)
|
||||
return int_type(EOF);
|
||||
memcpy(buf, eback(), static_cast<size_t>(old_size));
|
||||
if (old_size != 0) {
|
||||
_LIBCPP_ASSERT(eback(), "overflow copying from NULL");
|
||||
memcpy(buf, eback(), static_cast<size_t>(old_size));
|
||||
}
|
||||
ptrdiff_t ninp = gptr() - eback();
|
||||
ptrdiff_t einp = egptr() - eback();
|
||||
ptrdiff_t nout = pptr() - pbase();
|
||||
ptrdiff_t eout = epptr() - pbase();
|
||||
if (__strmode_ & __allocated)
|
||||
{
|
||||
if (__pfree_)
|
||||
@ -180,7 +183,7 @@ strstreambuf::overflow(int_type __c)
|
||||
delete [] eback();
|
||||
}
|
||||
setg(buf, buf + ninp, buf + einp);
|
||||
setp(buf + einp, buf + einp + eout);
|
||||
setp(buf + einp, buf + new_size);
|
||||
pbump(static_cast<int>(nout));
|
||||
__strmode_ |= __allocated;
|
||||
}
|
||||
|
@ -13,8 +13,17 @@
|
||||
#include "system_error"
|
||||
|
||||
#include "include/config_elast.h"
|
||||
#include "cerrno"
|
||||
#include "cstring"
|
||||
#include "cstdio"
|
||||
#include "cstdlib"
|
||||
#include "cassert"
|
||||
#include "string"
|
||||
#include "string.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#include <android/api-level.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@ -46,10 +55,56 @@ error_category::equivalent(const error_code& code, int condition) const _NOEXCEP
|
||||
return *this == code.category() && code.value() == condition;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// GLIBC also uses 1024 as the maximum buffer size internally.
|
||||
constexpr size_t strerror_buff_size = 1024;
|
||||
|
||||
string do_strerror_r(int ev);
|
||||
|
||||
#if defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) \
|
||||
&& (!defined(__ANDROID__) || __ANDROID_API__ >= 23)
|
||||
// GNU Extended version
|
||||
string do_strerror_r(int ev) {
|
||||
char buffer[strerror_buff_size];
|
||||
char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
|
||||
return string(ret);
|
||||
}
|
||||
#else
|
||||
// POSIX version
|
||||
string do_strerror_r(int ev) {
|
||||
char buffer[strerror_buff_size];
|
||||
const int old_errno = errno;
|
||||
int ret;
|
||||
if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) {
|
||||
// If `ret == -1` then the error is specified using `errno`, otherwise
|
||||
// `ret` represents the error.
|
||||
const int new_errno = ret == -1 ? errno : ret;
|
||||
errno = old_errno;
|
||||
if (new_errno == EINVAL) {
|
||||
std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
|
||||
return string(buffer);
|
||||
} else {
|
||||
assert(new_errno == ERANGE);
|
||||
// FIXME maybe? 'strerror_buff_size' is likely to exceed the
|
||||
// maximum error size so ERANGE shouldn't be returned.
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
return string(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end namespace
|
||||
|
||||
string
|
||||
__do_message::message(int ev) const
|
||||
{
|
||||
return string(strerror(ev));
|
||||
#if defined(_LIBCPP_HAS_NO_THREADS)
|
||||
return string(::strerror(ev));
|
||||
#else
|
||||
return do_strerror_r(ev);
|
||||
#endif
|
||||
}
|
||||
|
||||
class _LIBCPP_HIDDEN __generic_error_category
|
||||
|
@ -16,10 +16,15 @@
|
||||
#include "future"
|
||||
#include "limits"
|
||||
#include <sys/types.h>
|
||||
#if !defined(_WIN32)
|
||||
# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__)
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
# include <sys/param.h>
|
||||
# if defined(BSD)
|
||||
# include <sys/sysctl.h>
|
||||
# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__)
|
||||
# endif // defined(BSD)
|
||||
#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
|
||||
#if !defined(_WIN32)
|
||||
# include <unistd.h>
|
||||
#endif // !_WIN32
|
||||
|
||||
@ -41,14 +46,17 @@ thread::~thread()
|
||||
void
|
||||
thread::join()
|
||||
{
|
||||
int ec = pthread_join(__t_, 0);
|
||||
int ec = EINVAL;
|
||||
if (__t_ != 0)
|
||||
{
|
||||
ec = __libcpp_thread_join(&__t_);
|
||||
if (ec == 0)
|
||||
__t_ = 0;
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (ec)
|
||||
throw system_error(error_code(ec, system_category()), "thread::join failed");
|
||||
#else
|
||||
(void)ec;
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__t_ = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -57,7 +65,7 @@ thread::detach()
|
||||
int ec = EINVAL;
|
||||
if (__t_ != 0)
|
||||
{
|
||||
ec = pthread_detach(__t_);
|
||||
ec = __libcpp_thread_detach(&__t_);
|
||||
if (ec == 0)
|
||||
__t_ = 0;
|
||||
}
|
||||
|
@ -72,6 +72,8 @@ LIBADD+= cxxrt
|
||||
INCSGROUPS= STD EXP EXT
|
||||
|
||||
STD_HEADERS= __bit_reference\
|
||||
__bsd_locale_defaults.h\
|
||||
__bsd_locale_fallbacks.h\
|
||||
__config\
|
||||
__debug\
|
||||
__functional_03\
|
||||
@ -85,6 +87,7 @@ STD_HEADERS= __bit_reference\
|
||||
__split_buffer\
|
||||
__sso_allocator\
|
||||
__std_stream\
|
||||
__threading_support\
|
||||
__tree\
|
||||
__tuple\
|
||||
__undef___deallocate\
|
||||
@ -159,12 +162,14 @@ STD_HEADERS= __bit_reference\
|
||||
shared_mutex\
|
||||
sstream\
|
||||
stack\
|
||||
stdbool.h\
|
||||
stddef.h\
|
||||
stdexcept\
|
||||
stdio.h\
|
||||
stdlib.h\
|
||||
streambuf\
|
||||
string\
|
||||
string.h\
|
||||
strstream\
|
||||
system_error\
|
||||
tgmath.h\
|
||||
@ -195,18 +200,33 @@ STD+= ${_LIBCXXRTDIR}/${hdr}
|
||||
STDDIR= ${CXXINCLUDEDIR}
|
||||
|
||||
EXP_HEADERS= __config\
|
||||
__memory\
|
||||
algorithm\
|
||||
any\
|
||||
chrono\
|
||||
deque\
|
||||
dynarray\
|
||||
filesystem\
|
||||
forward_list\
|
||||
functional\
|
||||
iterator\
|
||||
list\
|
||||
map\
|
||||
memory_resource\
|
||||
optional\
|
||||
propagate_const\
|
||||
ratio\
|
||||
regex\
|
||||
set\
|
||||
string\
|
||||
string_view\
|
||||
system_error\
|
||||
tuple\
|
||||
type_traits\
|
||||
utility
|
||||
unordered_map\
|
||||
unordered_set\
|
||||
utility\
|
||||
vector
|
||||
|
||||
.for hdr in ${EXP_HEADERS}
|
||||
EXP+= ${HDRDIR}/experimental/${hdr}
|
||||
|
Loading…
Reference in New Issue
Block a user