Merge libc++ trunk r338150, and resolve conflicts.
This commit is contained in:
commit
390bec78fd
@ -24,28 +24,28 @@
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return MB_CUR_MAX;
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wint_t __libcpp_btowc_l(int __c, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return btowc(__c);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __libcpp_wctob_l(wint_t __c, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return wctob(__c);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
@ -53,14 +53,14 @@ size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
|
||||
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return wcrtomb(__s, __wc, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
@ -68,7 +68,7 @@ size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
|
||||
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
@ -76,28 +76,28 @@ size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
|
||||
return mbrtowc(__pwc, __s, __n, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbtowc(__pwc, __pmb, __max);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbrlen(__s, __n, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
lconv *__libcpp_localeconv_l(locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return localeconv();
|
||||
}
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
218
contrib/libc++/include/__errc
Normal file
218
contrib/libc++/include/__errc
Normal file
@ -0,0 +1,218 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- __errc ----------------------------------===//
|
||||
//
|
||||
// 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___ERRC
|
||||
#define _LIBCPP___ERRC
|
||||
|
||||
/*
|
||||
system_error synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
enum class errc
|
||||
{
|
||||
address_family_not_supported, // EAFNOSUPPORT
|
||||
address_in_use, // EADDRINUSE
|
||||
address_not_available, // EADDRNOTAVAIL
|
||||
already_connected, // EISCONN
|
||||
argument_list_too_long, // E2BIG
|
||||
argument_out_of_domain, // EDOM
|
||||
bad_address, // EFAULT
|
||||
bad_file_descriptor, // EBADF
|
||||
bad_message, // EBADMSG
|
||||
broken_pipe, // EPIPE
|
||||
connection_aborted, // ECONNABORTED
|
||||
connection_already_in_progress, // EALREADY
|
||||
connection_refused, // ECONNREFUSED
|
||||
connection_reset, // ECONNRESET
|
||||
cross_device_link, // EXDEV
|
||||
destination_address_required, // EDESTADDRREQ
|
||||
device_or_resource_busy, // EBUSY
|
||||
directory_not_empty, // ENOTEMPTY
|
||||
executable_format_error, // ENOEXEC
|
||||
file_exists, // EEXIST
|
||||
file_too_large, // EFBIG
|
||||
filename_too_long, // ENAMETOOLONG
|
||||
function_not_supported, // ENOSYS
|
||||
host_unreachable, // EHOSTUNREACH
|
||||
identifier_removed, // EIDRM
|
||||
illegal_byte_sequence, // EILSEQ
|
||||
inappropriate_io_control_operation, // ENOTTY
|
||||
interrupted, // EINTR
|
||||
invalid_argument, // EINVAL
|
||||
invalid_seek, // ESPIPE
|
||||
io_error, // EIO
|
||||
is_a_directory, // EISDIR
|
||||
message_size, // EMSGSIZE
|
||||
network_down, // ENETDOWN
|
||||
network_reset, // ENETRESET
|
||||
network_unreachable, // ENETUNREACH
|
||||
no_buffer_space, // ENOBUFS
|
||||
no_child_process, // ECHILD
|
||||
no_link, // ENOLINK
|
||||
no_lock_available, // ENOLCK
|
||||
no_message_available, // ENODATA
|
||||
no_message, // ENOMSG
|
||||
no_protocol_option, // ENOPROTOOPT
|
||||
no_space_on_device, // ENOSPC
|
||||
no_stream_resources, // ENOSR
|
||||
no_such_device_or_address, // ENXIO
|
||||
no_such_device, // ENODEV
|
||||
no_such_file_or_directory, // ENOENT
|
||||
no_such_process, // ESRCH
|
||||
not_a_directory, // ENOTDIR
|
||||
not_a_socket, // ENOTSOCK
|
||||
not_a_stream, // ENOSTR
|
||||
not_connected, // ENOTCONN
|
||||
not_enough_memory, // ENOMEM
|
||||
not_supported, // ENOTSUP
|
||||
operation_canceled, // ECANCELED
|
||||
operation_in_progress, // EINPROGRESS
|
||||
operation_not_permitted, // EPERM
|
||||
operation_not_supported, // EOPNOTSUPP
|
||||
operation_would_block, // EWOULDBLOCK
|
||||
owner_dead, // EOWNERDEAD
|
||||
permission_denied, // EACCES
|
||||
protocol_error, // EPROTO
|
||||
protocol_not_supported, // EPROTONOSUPPORT
|
||||
read_only_file_system, // EROFS
|
||||
resource_deadlock_would_occur, // EDEADLK
|
||||
resource_unavailable_try_again, // EAGAIN
|
||||
result_out_of_range, // ERANGE
|
||||
state_not_recoverable, // ENOTRECOVERABLE
|
||||
stream_timeout, // ETIME
|
||||
text_file_busy, // ETXTBSY
|
||||
timed_out, // ETIMEDOUT
|
||||
too_many_files_open_in_system, // ENFILE
|
||||
too_many_files_open, // EMFILE
|
||||
too_many_links, // EMLINK
|
||||
too_many_symbolic_link_levels, // ELOOP
|
||||
value_too_large, // EOVERFLOW
|
||||
wrong_protocol_type // EPROTOTYPE
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// Some error codes are not present on all platforms, so we provide equivalents
|
||||
// for them:
|
||||
|
||||
//enum class errc
|
||||
_LIBCPP_DECLARE_STRONG_ENUM(errc)
|
||||
{
|
||||
address_family_not_supported = EAFNOSUPPORT,
|
||||
address_in_use = EADDRINUSE,
|
||||
address_not_available = EADDRNOTAVAIL,
|
||||
already_connected = EISCONN,
|
||||
argument_list_too_long = E2BIG,
|
||||
argument_out_of_domain = EDOM,
|
||||
bad_address = EFAULT,
|
||||
bad_file_descriptor = EBADF,
|
||||
bad_message = EBADMSG,
|
||||
broken_pipe = EPIPE,
|
||||
connection_aborted = ECONNABORTED,
|
||||
connection_already_in_progress = EALREADY,
|
||||
connection_refused = ECONNREFUSED,
|
||||
connection_reset = ECONNRESET,
|
||||
cross_device_link = EXDEV,
|
||||
destination_address_required = EDESTADDRREQ,
|
||||
device_or_resource_busy = EBUSY,
|
||||
directory_not_empty = ENOTEMPTY,
|
||||
executable_format_error = ENOEXEC,
|
||||
file_exists = EEXIST,
|
||||
file_too_large = EFBIG,
|
||||
filename_too_long = ENAMETOOLONG,
|
||||
function_not_supported = ENOSYS,
|
||||
host_unreachable = EHOSTUNREACH,
|
||||
identifier_removed = EIDRM,
|
||||
illegal_byte_sequence = EILSEQ,
|
||||
inappropriate_io_control_operation = ENOTTY,
|
||||
interrupted = EINTR,
|
||||
invalid_argument = EINVAL,
|
||||
invalid_seek = ESPIPE,
|
||||
io_error = EIO,
|
||||
is_a_directory = EISDIR,
|
||||
message_size = EMSGSIZE,
|
||||
network_down = ENETDOWN,
|
||||
network_reset = ENETRESET,
|
||||
network_unreachable = ENETUNREACH,
|
||||
no_buffer_space = ENOBUFS,
|
||||
no_child_process = ECHILD,
|
||||
no_link = ENOLINK,
|
||||
no_lock_available = ENOLCK,
|
||||
#ifdef ENODATA
|
||||
no_message_available = ENODATA,
|
||||
#else
|
||||
no_message_available = ENOMSG,
|
||||
#endif
|
||||
no_message = ENOMSG,
|
||||
no_protocol_option = ENOPROTOOPT,
|
||||
no_space_on_device = ENOSPC,
|
||||
#ifdef ENOSR
|
||||
no_stream_resources = ENOSR,
|
||||
#else
|
||||
no_stream_resources = ENOMEM,
|
||||
#endif
|
||||
no_such_device_or_address = ENXIO,
|
||||
no_such_device = ENODEV,
|
||||
no_such_file_or_directory = ENOENT,
|
||||
no_such_process = ESRCH,
|
||||
not_a_directory = ENOTDIR,
|
||||
not_a_socket = ENOTSOCK,
|
||||
#ifdef ENOSTR
|
||||
not_a_stream = ENOSTR,
|
||||
#else
|
||||
not_a_stream = EINVAL,
|
||||
#endif
|
||||
not_connected = ENOTCONN,
|
||||
not_enough_memory = ENOMEM,
|
||||
not_supported = ENOTSUP,
|
||||
operation_canceled = ECANCELED,
|
||||
operation_in_progress = EINPROGRESS,
|
||||
operation_not_permitted = EPERM,
|
||||
operation_not_supported = EOPNOTSUPP,
|
||||
operation_would_block = EWOULDBLOCK,
|
||||
owner_dead = EOWNERDEAD,
|
||||
permission_denied = EACCES,
|
||||
protocol_error = EPROTO,
|
||||
protocol_not_supported = EPROTONOSUPPORT,
|
||||
read_only_file_system = EROFS,
|
||||
resource_deadlock_would_occur = EDEADLK,
|
||||
resource_unavailable_try_again = EAGAIN,
|
||||
result_out_of_range = ERANGE,
|
||||
state_not_recoverable = ENOTRECOVERABLE,
|
||||
#ifdef ETIME
|
||||
stream_timeout = ETIME,
|
||||
#else
|
||||
stream_timeout = ETIMEDOUT,
|
||||
#endif
|
||||
text_file_busy = ETXTBSY,
|
||||
timed_out = ETIMEDOUT,
|
||||
too_many_files_open_in_system = ENFILE,
|
||||
too_many_files_open = EMFILE,
|
||||
too_many_links = EMLINK,
|
||||
too_many_symbolic_link_levels = ELOOP,
|
||||
value_too_large = EOVERFLOW,
|
||||
wrong_protocol_type = EPROTOTYPE
|
||||
};
|
||||
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___ERRC
|
@ -600,7 +600,10 @@ template<class _Rp>
|
||||
function<_Rp()>&
|
||||
function<_Rp()>::operator=(const function& __f)
|
||||
{
|
||||
function(__f).swap(*this);
|
||||
if (__f)
|
||||
function(__f).swap(*this);
|
||||
else
|
||||
*this = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -608,11 +611,12 @@ template<class _Rp>
|
||||
function<_Rp()>&
|
||||
function<_Rp()>::operator=(nullptr_t)
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__base* __t = __f_;
|
||||
__f_ = 0;
|
||||
if (__t == (__base*)&__buf_)
|
||||
__t->destroy();
|
||||
else if (__t)
|
||||
__t->destroy_deallocate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -876,7 +880,10 @@ template<class _Rp, class _A0>
|
||||
function<_Rp(_A0)>&
|
||||
function<_Rp(_A0)>::operator=(const function& __f)
|
||||
{
|
||||
function(__f).swap(*this);
|
||||
if (__f)
|
||||
function(__f).swap(*this);
|
||||
else
|
||||
*this = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -884,11 +891,12 @@ template<class _Rp, class _A0>
|
||||
function<_Rp(_A0)>&
|
||||
function<_Rp(_A0)>::operator=(nullptr_t)
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__base* __t = __f_;
|
||||
__f_ = 0;
|
||||
if (__t == (__base*)&__buf_)
|
||||
__t->destroy();
|
||||
else if (__t)
|
||||
__t->destroy_deallocate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1152,7 +1160,10 @@ template<class _Rp, class _A0, class _A1>
|
||||
function<_Rp(_A0, _A1)>&
|
||||
function<_Rp(_A0, _A1)>::operator=(const function& __f)
|
||||
{
|
||||
function(__f).swap(*this);
|
||||
if (__f)
|
||||
function(__f).swap(*this);
|
||||
else
|
||||
*this = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1160,11 +1171,12 @@ template<class _Rp, class _A0, class _A1>
|
||||
function<_Rp(_A0, _A1)>&
|
||||
function<_Rp(_A0, _A1)>::operator=(nullptr_t)
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__base* __t = __f_;
|
||||
__f_ = 0;
|
||||
if (__t == (__base*)&__buf_)
|
||||
__t->destroy();
|
||||
else if (__t)
|
||||
__t->destroy_deallocate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1428,7 +1440,10 @@ template<class _Rp, class _A0, class _A1, class _A2>
|
||||
function<_Rp(_A0, _A1, _A2)>&
|
||||
function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
|
||||
{
|
||||
function(__f).swap(*this);
|
||||
if (__f)
|
||||
function(__f).swap(*this);
|
||||
else
|
||||
*this = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1436,11 +1451,12 @@ template<class _Rp, class _A0, class _A1, class _A2>
|
||||
function<_Rp(_A0, _A1, _A2)>&
|
||||
function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
|
||||
{
|
||||
if (__f_ == (__base*)&__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__base* __t = __f_;
|
||||
__f_ = 0;
|
||||
if (__t == (__base*)&__buf_)
|
||||
__t->destroy();
|
||||
else if (__t)
|
||||
__t->destroy_deallocate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -646,16 +646,6 @@ void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, con
|
||||
new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
|
||||
}
|
||||
|
||||
// FIXME: Theis should have a version which takes a non-const alloc.
|
||||
template <class _Tp, class _Allocator, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args)
|
||||
{
|
||||
__user_alloc_construct_impl(
|
||||
__uses_alloc_ctor<_Tp, _Allocator>(),
|
||||
__storage, __a, _VSTD::forward<_Args>(__args)...
|
||||
);
|
||||
}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -32,13 +32,8 @@ _LIBCPP_PUSH_MACROS
|
||||
|
||||
_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
|
||||
|
||||
template <class _Key, class _Cp, class _Hash,
|
||||
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
|
||||
@ -172,7 +167,7 @@ struct __hash_key_value_types {
|
||||
}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type&& __move(__node_value_type& __v) {
|
||||
static __container_value_type&& __move(__node_value_type& __v) {
|
||||
return _VSTD::move(__v);
|
||||
}
|
||||
#endif
|
||||
@ -184,7 +179,6 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
|
||||
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;
|
||||
|
||||
@ -198,7 +192,7 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
|
||||
static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
|
||||
__container_value_type const&>::type
|
||||
__get_value(_Up& __t) {
|
||||
return __t.__cc;
|
||||
return __t.__get_value();
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
@ -211,12 +205,12 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type* __get_ptr(__node_value_type& __n) {
|
||||
return _VSTD::addressof(__n.__cc);
|
||||
return _VSTD::addressof(__n.__get_value());
|
||||
}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __nc_value_type&& __move(__node_value_type& __v) {
|
||||
return _VSTD::move(__v.__nc);
|
||||
static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
|
||||
return __v.__move();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1 +1 @@
|
||||
6000
|
||||
7000
|
||||
|
@ -24,11 +24,7 @@
|
||||
#elif defined(_AIX)
|
||||
# include <support/ibm/xlocale.h>
|
||||
#elif defined(__ANDROID__)
|
||||
// Android gained the locale aware functions in L (API level 21)
|
||||
# include <android/api-level.h>
|
||||
# if __ANDROID_API__ <= 20
|
||||
# include <support/android/locale_bionic.h>
|
||||
# endif
|
||||
# include <support/android/locale_bionic.h>
|
||||
#elif defined(__sun__)
|
||||
# include <xlocale.h>
|
||||
# include <support/solaris/xlocale.h>
|
||||
@ -473,7 +469,7 @@ public:
|
||||
static const mask alnum = alpha | digit;
|
||||
static const mask graph = alnum | punct;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE ctype_base() {}
|
||||
_LIBCPP_INLINE_VISIBILITY ctype_base() {}
|
||||
};
|
||||
|
||||
template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
|
||||
@ -486,77 +482,77 @@ class _LIBCPP_TYPE_VIS ctype<wchar_t>
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit ctype(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is(mask __m, char_type __c) const
|
||||
{
|
||||
return do_is(__m, __c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
|
||||
{
|
||||
return do_is(__low, __high, __vec);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
|
||||
{
|
||||
return do_scan_is(__m, __low, __high);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
|
||||
{
|
||||
return do_scan_not(__m, __low, __high);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char_type toupper(char_type __c) const
|
||||
{
|
||||
return do_toupper(__c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* toupper(char_type* __low, const char_type* __high) const
|
||||
{
|
||||
return do_toupper(__low, __high);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char_type tolower(char_type __c) const
|
||||
{
|
||||
return do_tolower(__c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* tolower(char_type* __low, const char_type* __high) const
|
||||
{
|
||||
return do_tolower(__low, __high);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char_type widen(char __c) const
|
||||
{
|
||||
return do_widen(__c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char* widen(const char* __low, const char* __high, char_type* __to) const
|
||||
{
|
||||
return do_widen(__low, __high, __to);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char narrow(char_type __c, char __dfault) const
|
||||
{
|
||||
return do_narrow(__c, __dfault);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
|
||||
{
|
||||
return do_narrow(__low, __high, __dfault, __to);
|
||||
@ -591,13 +587,13 @@ public:
|
||||
|
||||
explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool is(mask __m, char_type __c) const
|
||||
{
|
||||
return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
|
||||
{
|
||||
for (; __low != __high; ++__low, ++__vec)
|
||||
@ -605,7 +601,7 @@ public:
|
||||
return __low;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
|
||||
{
|
||||
for (; __low != __high; ++__low)
|
||||
@ -614,7 +610,7 @@ public:
|
||||
return __low;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
|
||||
{
|
||||
for (; __low != __high; ++__low)
|
||||
@ -623,49 +619,49 @@ public:
|
||||
return __low;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char_type toupper(char_type __c) const
|
||||
{
|
||||
return do_toupper(__c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* toupper(char_type* __low, const char_type* __high) const
|
||||
{
|
||||
return do_toupper(__low, __high);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char_type tolower(char_type __c) const
|
||||
{
|
||||
return do_tolower(__c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char_type* tolower(char_type* __low, const char_type* __high) const
|
||||
{
|
||||
return do_tolower(__low, __high);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char_type widen(char __c) const
|
||||
{
|
||||
return do_widen(__c);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char* widen(const char* __low, const char* __high, char_type* __to) const
|
||||
{
|
||||
return do_widen(__low, __high, __to);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char narrow(char_type __c, char __dfault) const
|
||||
{
|
||||
return do_narrow(__c, __dfault);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
|
||||
{
|
||||
return do_narrow(__low, __high, __dfault, __to);
|
||||
@ -678,7 +674,7 @@ public:
|
||||
#else
|
||||
static const size_t table_size = 256; // FIXME: Don't hardcode this.
|
||||
#endif
|
||||
_LIBCPP_ALWAYS_INLINE const mask* table() const _NOEXCEPT {return __tab_;}
|
||||
_LIBCPP_INLINE_VISIBILITY const mask* table() const _NOEXCEPT {return __tab_;}
|
||||
static const mask* classic_table() _NOEXCEPT;
|
||||
#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
|
||||
static const int* __classic_upper_table() _NOEXCEPT;
|
||||
@ -858,7 +854,7 @@ tolower(_CharT __c, const locale& __loc)
|
||||
class _LIBCPP_TYPE_VIS codecvt_base
|
||||
{
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE codecvt_base() {}
|
||||
_LIBCPP_INLINE_VISIBILITY codecvt_base() {}
|
||||
enum result {ok, partial, error, noconv};
|
||||
};
|
||||
|
||||
@ -878,11 +874,11 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
@ -890,14 +886,14 @@ public:
|
||||
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
{
|
||||
return do_unshift(__st, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
||||
@ -905,25 +901,25 @@ public:
|
||||
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int encoding() const _NOEXCEPT
|
||||
{
|
||||
return do_encoding();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool always_noconv() const _NOEXCEPT
|
||||
{
|
||||
return do_always_noconv();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
||||
{
|
||||
return do_length(__st, __frm, __end, __mx);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int max_length() const _NOEXCEPT
|
||||
{
|
||||
return do_max_length();
|
||||
@ -932,7 +928,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt(const char*, size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
@ -967,7 +963,7 @@ public:
|
||||
|
||||
explicit codecvt(size_t __refs = 0);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
@ -975,14 +971,14 @@ public:
|
||||
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
{
|
||||
return do_unshift(__st, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
||||
@ -990,25 +986,25 @@ public:
|
||||
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int encoding() const _NOEXCEPT
|
||||
{
|
||||
return do_encoding();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool always_noconv() const _NOEXCEPT
|
||||
{
|
||||
return do_always_noconv();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
||||
{
|
||||
return do_length(__st, __frm, __end, __mx);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int max_length() const _NOEXCEPT
|
||||
{
|
||||
return do_max_length();
|
||||
@ -1047,11 +1043,11 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
@ -1059,14 +1055,14 @@ public:
|
||||
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
{
|
||||
return do_unshift(__st, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
||||
@ -1074,25 +1070,25 @@ public:
|
||||
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int encoding() const _NOEXCEPT
|
||||
{
|
||||
return do_encoding();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool always_noconv() const _NOEXCEPT
|
||||
{
|
||||
return do_always_noconv();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
||||
{
|
||||
return do_length(__st, __frm, __end, __mx);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int max_length() const _NOEXCEPT
|
||||
{
|
||||
return do_max_length();
|
||||
@ -1101,7 +1097,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt(const char*, size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
@ -1133,11 +1129,11 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
@ -1145,14 +1141,14 @@ public:
|
||||
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
||||
{
|
||||
return do_unshift(__st, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
||||
@ -1160,25 +1156,25 @@ public:
|
||||
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int encoding() const _NOEXCEPT
|
||||
{
|
||||
return do_encoding();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool always_noconv() const _NOEXCEPT
|
||||
{
|
||||
return do_always_noconv();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
||||
{
|
||||
return do_length(__st, __frm, __end, __mx);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int max_length() const _NOEXCEPT
|
||||
{
|
||||
return do_max_length();
|
||||
@ -1187,7 +1183,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt(const char*, size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
@ -1214,10 +1210,10 @@ class _LIBCPP_TEMPLATE_VIS codecvt_byname
|
||||
: public codecvt<_InternT, _ExternT, _StateT>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_byname(const char* __nm, size_t __refs = 0)
|
||||
: codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_byname(const string& __nm, size_t __refs = 0)
|
||||
: codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
|
||||
protected:
|
||||
@ -1248,7 +1244,7 @@ template <>
|
||||
struct __narrow_to_utf8<8>
|
||||
{
|
||||
template <class _OutputIterator, class _CharT>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
|
||||
{
|
||||
@ -1262,13 +1258,13 @@ template <>
|
||||
struct __narrow_to_utf8<16>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
|
||||
|
||||
~__narrow_to_utf8();
|
||||
|
||||
template <class _OutputIterator, class _CharT>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
|
||||
{
|
||||
@ -1296,13 +1292,13 @@ template <>
|
||||
struct __narrow_to_utf8<32>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
|
||||
|
||||
~__narrow_to_utf8();
|
||||
|
||||
template <class _OutputIterator, class _CharT>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
|
||||
{
|
||||
@ -1338,7 +1334,7 @@ template <>
|
||||
struct __widen_from_utf8<8>
|
||||
{
|
||||
template <class _OutputIterator>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
|
||||
{
|
||||
@ -1352,13 +1348,13 @@ template <>
|
||||
struct __widen_from_utf8<16>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
|
||||
|
||||
~__widen_from_utf8();
|
||||
|
||||
template <class _OutputIterator>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
|
||||
{
|
||||
@ -1386,13 +1382,13 @@ template <>
|
||||
struct __widen_from_utf8<32>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
|
||||
|
||||
~__widen_from_utf8();
|
||||
|
||||
template <class _OutputIterator>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
|
||||
{
|
||||
@ -1430,11 +1426,11 @@ public:
|
||||
|
||||
explicit numpunct(size_t __refs = 0);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
|
||||
_LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
|
||||
_LIBCPP_ALWAYS_INLINE string grouping() const {return do_grouping();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type truename() const {return do_truename();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type falsename() const {return do_falsename();}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
|
||||
_LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();}
|
||||
|
||||
static locale::id id;
|
||||
|
||||
@ -1461,11 +1457,11 @@ public:
|
||||
|
||||
explicit numpunct(size_t __refs = 0);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
|
||||
_LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
|
||||
_LIBCPP_ALWAYS_INLINE string grouping() const {return do_grouping();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type truename() const {return do_truename();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type falsename() const {return do_falsename();}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
|
||||
_LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();}
|
||||
|
||||
static locale::id id;
|
||||
|
||||
|
@ -27,24 +27,24 @@ struct _LIBCPP_TEMPLATE_VIS nullptr_t
|
||||
|
||||
struct __nat {int __for_bool_;};
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
operator _Tp* () const {return 0;}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator _Tp _Up::* () const {return 0;}
|
||||
|
||||
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
|
||||
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
|
||||
friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
|
||||
friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
|
||||
};
|
||||
|
||||
inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
|
||||
|
||||
#define nullptr _VSTD::__get_nullptr_t()
|
||||
|
||||
|
@ -55,14 +55,14 @@ public:
|
||||
__allocated_ = true;
|
||||
return (pointer)&buf_;
|
||||
}
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), __alignof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type)
|
||||
{
|
||||
if (__p == (pointer)&buf_)
|
||||
__allocated_ = false;
|
||||
else
|
||||
_VSTD::__libcpp_deallocate(__p);
|
||||
_VSTD::__libcpp_deallocate(__p, __alignof(_Tp));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
|
||||
|
||||
|
@ -266,7 +266,7 @@ const char*
|
||||
char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_char_memchr(__s, to_int_type(__a), __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
@ -278,7 +278,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -372,9 +372,9 @@ const wchar_t*
|
||||
char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_wmemchr(__s, __a, __n);
|
||||
return __builtin_wmemchr(__s, __a, __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return wmemchr(__s, __a, __n);
|
||||
#else
|
||||
@ -384,7 +384,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -26,18 +26,14 @@
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
# include <pthread.h>
|
||||
# include <sched.h>
|
||||
#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#include <fibersapi.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_HAS_THREAD_API_WIN32)
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
|
||||
#else
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -80,31 +76,37 @@ typedef pthread_key_t __libcpp_tls_key;
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC
|
||||
#else
|
||||
// Mutex
|
||||
typedef SRWLOCK __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
|
||||
typedef void* __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER 0
|
||||
|
||||
typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
|
||||
#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
|
||||
typedef void* __libcpp_recursive_mutex_t[6];
|
||||
#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
|
||||
typedef void* __libcpp_recursive_mutex_t[5];
|
||||
#else
|
||||
# error Unsupported architecture
|
||||
#endif
|
||||
|
||||
// Condition Variable
|
||||
typedef CONDITION_VARIABLE __libcpp_condvar_t;
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
|
||||
typedef void* __libcpp_condvar_t;
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER 0
|
||||
|
||||
// Execute Once
|
||||
typedef INIT_ONCE __libcpp_exec_once_flag;
|
||||
#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
|
||||
typedef void* __libcpp_exec_once_flag;
|
||||
#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
|
||||
|
||||
// Thread ID
|
||||
typedef DWORD __libcpp_thread_id;
|
||||
typedef long __libcpp_thread_id;
|
||||
|
||||
// Thread
|
||||
#define _LIBCPP_NULL_THREAD 0U
|
||||
|
||||
typedef HANDLE __libcpp_thread_t;
|
||||
typedef void* __libcpp_thread_t;
|
||||
|
||||
// Thread Local Storage
|
||||
typedef DWORD __libcpp_tls_key;
|
||||
typedef long __libcpp_tls_key;
|
||||
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
|
||||
#endif
|
||||
|
||||
// Mutex
|
||||
@ -201,10 +203,9 @@ void *__libcpp_tls_get(__libcpp_tls_key __key);
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
|
||||
|
||||
#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \
|
||||
defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
@ -390,244 +391,6 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
return pthread_setspecific(__key, __p);
|
||||
}
|
||||
|
||||
#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
|
||||
|
||||
// Mutex
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
InitializeCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
EnterCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return TryEnterCriticalSection(__m) != 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
LeaveCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
DeleteCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
AcquireSRWLockExclusive(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return TryAcquireSRWLockExclusive(__m) != 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
ReleaseSRWLockExclusive(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
|
||||
{
|
||||
static_cast<void>(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Condition Variable
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
WakeConditionVariable(__cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
WakeAllConditionVariable(__cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
|
||||
{
|
||||
SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
||||
timespec *__ts)
|
||||
{
|
||||
using namespace _VSTD::chrono;
|
||||
|
||||
auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
|
||||
auto abstime =
|
||||
system_clock::time_point(duration_cast<system_clock::duration>(duration));
|
||||
auto timeout_ms = duration_cast<milliseconds>(abstime - system_clock::now());
|
||||
|
||||
if (!SleepConditionVariableSRW(__cv, __m,
|
||||
timeout_ms.count() > 0 ? timeout_ms.count()
|
||||
: 0,
|
||||
0))
|
||||
{
|
||||
auto __ec = GetLastError();
|
||||
return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
static_cast<void>(__cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute Once
|
||||
static inline _LIBCPP_ALWAYS_INLINE BOOL CALLBACK
|
||||
__libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
|
||||
PVOID *__context)
|
||||
{
|
||||
static_cast<void>(__init_once);
|
||||
static_cast<void>(__context);
|
||||
|
||||
void (*init_routine)(void) = reinterpret_cast<void (*)(void)>(__parameter);
|
||||
init_routine();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
|
||||
void (*__init_routine)(void))
|
||||
{
|
||||
if (!InitOnceExecuteOnce(__flag, __libcpp_init_once_execute_once_thunk,
|
||||
reinterpret_cast<void *>(__init_routine), NULL))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Thread ID
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
|
||||
__libcpp_thread_id __rhs)
|
||||
{
|
||||
return __lhs == __rhs;
|
||||
}
|
||||
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
|
||||
{
|
||||
return __lhs < __rhs;
|
||||
}
|
||||
|
||||
// Thread
|
||||
struct __libcpp_beginthreadex_thunk_data
|
||||
{
|
||||
void *(*__func)(void *);
|
||||
void *__arg;
|
||||
};
|
||||
|
||||
static inline _LIBCPP_ALWAYS_INLINE unsigned WINAPI
|
||||
__libcpp_beginthreadex_thunk(void *__raw_data)
|
||||
{
|
||||
auto *__data =
|
||||
static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data);
|
||||
auto *__func = __data->__func;
|
||||
void *__arg = __data->__arg;
|
||||
delete __data;
|
||||
return static_cast<unsigned>(reinterpret_cast<uintptr_t>(__func(__arg)));
|
||||
}
|
||||
|
||||
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
|
||||
return *__t == 0;
|
||||
}
|
||||
|
||||
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
||||
void *__arg)
|
||||
{
|
||||
auto *__data = new __libcpp_beginthreadex_thunk_data;
|
||||
__data->__func = __func;
|
||||
__data->__arg = __arg;
|
||||
|
||||
*__t = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0,
|
||||
__libcpp_beginthreadex_thunk,
|
||||
__data, 0, nullptr));
|
||||
|
||||
if (*__t)
|
||||
return 0;
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id()
|
||||
{
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
|
||||
{
|
||||
return GetThreadId(*__t);
|
||||
}
|
||||
|
||||
int __libcpp_thread_join(__libcpp_thread_t *__t)
|
||||
{
|
||||
if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED)
|
||||
return GetLastError();
|
||||
if (!CloseHandle(*__t))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_thread_detach(__libcpp_thread_t *__t)
|
||||
{
|
||||
if (!CloseHandle(*__t))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __libcpp_thread_yield()
|
||||
{
|
||||
SwitchToThread();
|
||||
}
|
||||
|
||||
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
||||
{
|
||||
using namespace chrono;
|
||||
// round-up to the nearest milisecond
|
||||
milliseconds __ms =
|
||||
duration_cast<milliseconds>(__ns + chrono::nanoseconds(999999));
|
||||
// FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)
|
||||
Sleep(__ms.count());
|
||||
}
|
||||
|
||||
// Thread Local Storage
|
||||
int __libcpp_tls_create(__libcpp_tls_key* __key,
|
||||
void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
|
||||
{
|
||||
*__key = FlsAlloc(__at_exit);
|
||||
if (*__key == FLS_OUT_OF_INDEXES)
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *__libcpp_tls_get(__libcpp_tls_key __key)
|
||||
{
|
||||
return FlsGetValue(__key);
|
||||
}
|
||||
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
{
|
||||
if (!FlsSetValue(__key, __p))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
|
||||
#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -37,13 +37,8 @@ template <class _Pointer> class __tree_end_node;
|
||||
template <class _VoidPtr> class __tree_node_base;
|
||||
template <class _Tp, class _VoidPtr> class __tree_node;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Key, class _Value>
|
||||
union __value_type;
|
||||
#else
|
||||
template <class _Key, class _Value>
|
||||
struct __value_type;
|
||||
#endif
|
||||
|
||||
template <class _Key, class _CP, class _Compare,
|
||||
bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
|
||||
@ -569,10 +564,9 @@ struct __tree_key_value_types {
|
||||
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) {
|
||||
static __container_value_type&& __move(__node_value_type& __v) {
|
||||
return _VSTD::move(__v);
|
||||
}
|
||||
#endif
|
||||
@ -584,14 +578,13 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
|
||||
typedef _Tp mapped_type;
|
||||
typedef __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(__node_value_type const& __t) {
|
||||
return __t.__cc.first;
|
||||
return __t.__get_value().first;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
@ -605,7 +598,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type const&
|
||||
__get_value(__node_value_type const& __t) {
|
||||
return __t.__cc;
|
||||
return __t.__get_value();
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
@ -618,13 +611,13 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __container_value_type* __get_ptr(__node_value_type& __n) {
|
||||
return _VSTD::addressof(__n.__cc);
|
||||
return _VSTD::addressof(__n.__get_value());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static __nc_value_type&& __move(__node_value_type& __v) {
|
||||
return _VSTD::move(__v.__nc);
|
||||
static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
|
||||
return __v.__move();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -104,7 +104,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_bad_any_cast()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -304,7 +304,7 @@ private:
|
||||
__any_imp::_Buffer __buf;
|
||||
};
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr,
|
||||
const void* __fallback_info = nullptr) const
|
||||
@ -312,7 +312,7 @@ private:
|
||||
return __h(__a, this, __other, __info, __fallback_info);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr,
|
||||
const void* __fallback_info = nullptr)
|
||||
|
@ -72,6 +72,9 @@ struct array
|
||||
const T* data() const noexcept;
|
||||
};
|
||||
|
||||
template <class T, class... U>
|
||||
array(T, U...) -> array<T, 1 + sizeof...(U)>;
|
||||
|
||||
template <class T, size_t N>
|
||||
bool operator==(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
@ -86,7 +89,7 @@ template <class T, size_t N>
|
||||
bool operator>=(const array<T,N>& x, const array<T,N>& y);
|
||||
|
||||
template <class T, size_t N >
|
||||
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
|
||||
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
|
||||
|
||||
template <class T> class tuple_size;
|
||||
template <size_t I, class T> class tuple_element;
|
||||
@ -108,6 +111,8 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for _LIBCPP_UNREACHABLE
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -117,6 +122,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS array
|
||||
{
|
||||
@ -134,31 +140,27 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
value_type __elems_[_Size > 0 ? _Size : 1];
|
||||
_Tp __elems_[_Size];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
|
||||
{_VSTD::fill_n(__elems_, _Size, __u);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
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 fill(const value_type& __u) {
|
||||
_VSTD::fill_n(__elems_, _Size, __u);
|
||||
}
|
||||
|
||||
_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_);}
|
||||
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
|
||||
std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator begin() _NOEXCEPT {return iterator(__elems_);}
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
|
||||
iterator end() _NOEXCEPT {return iterator(data() + _Size);}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
@ -184,7 +186,7 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
@ -197,8 +199,8 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size - 1];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size - 1];}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
value_type* data() _NOEXCEPT {return __elems_;}
|
||||
@ -206,6 +208,7 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
const value_type* data() const _NOEXCEPT {return __elems_;}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
typename array<_Tp, _Size>::reference
|
||||
@ -227,12 +230,147 @@ array<_Tp, _Size>::at(size_type __n) const
|
||||
return __elems_[__n];
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
|
||||
{
|
||||
// types:
|
||||
typedef array __self;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
typedef typename conditional<is_const<_Tp>::value, const char,
|
||||
char>::type _CharType;
|
||||
|
||||
struct _ArrayInStructT { _Tp __data_[1]; };
|
||||
_ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot fill zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array&) _NOEXCEPT {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot swap zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT {return begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT {return end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
// capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator[](size_type) {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const_reference operator[](size_type) const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference at(size_type) {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type) const {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference front() {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference back() {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}
|
||||
};
|
||||
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _Tp, class... _Args,
|
||||
class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type
|
||||
>
|
||||
array(_Tp, _Args...)
|
||||
-> array<_Tp, 1 + sizeof...(_Args)>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
|
||||
return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
@ -248,7 +386,8 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
|
||||
return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
|
@ -555,6 +555,9 @@ void atomic_signal_fence(memory_order m) noexcept;
|
||||
#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
|
||||
#error <atomic> is not implemented
|
||||
#endif
|
||||
#ifdef kill_dependency
|
||||
#error C++ standard library is incompatible with <stdatomic.h>
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
# define __cpp_lib_atomic_is_always_lock_free 201603L
|
||||
@ -695,7 +698,7 @@ static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val,
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
|
||||
static inline _Tp __c11_atomic_load(const volatile _Atomic(_Tp)* __a,
|
||||
memory_order __order) {
|
||||
_Tp __ret;
|
||||
__atomic_load(&__a->__a_value, &__ret,
|
||||
@ -704,7 +707,7 @@ static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
|
||||
static inline _Tp __c11_atomic_load(const _Atomic(_Tp)* __a, memory_order __order) {
|
||||
_Tp __ret;
|
||||
__atomic_load(&__a->__a_value, &__ret,
|
||||
__gcc_atomic::__to_gcc_order(__order));
|
||||
@ -1741,7 +1744,7 @@ typedef struct atomic_flag
|
||||
atomic_flag() _NOEXCEPT : __a_() {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
@ -147,6 +147,11 @@ template <class Clock, class Duration1, class Duration2>
|
||||
|
||||
namespace chrono {
|
||||
|
||||
|
||||
template<class T> struct is_clock; // C++20
|
||||
template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // C++20
|
||||
|
||||
|
||||
// duration arithmetic
|
||||
template <class Rep1, class Period1, class Rep2, class Period2>
|
||||
constexpr
|
||||
@ -204,6 +209,8 @@ template <class ToDuration, class Rep, class Period>
|
||||
template <class ToDuration, class Rep, class Period>
|
||||
constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
|
||||
|
||||
// duration I/O is elsewhere
|
||||
|
||||
// time_point arithmetic (all constexpr in C++14)
|
||||
template <class Clock, class Duration1, class Rep2, class Period2>
|
||||
time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
|
||||
@ -251,6 +258,7 @@ template <class ToDuration, class Clock, class Duration>
|
||||
|
||||
template <class Rep, class Period>
|
||||
constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
|
||||
|
||||
// Clocks
|
||||
|
||||
class system_clock
|
||||
@ -267,6 +275,28 @@ public:
|
||||
static time_point from_time_t(time_t __t) noexcept;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
using sys_time = time_point<system_clock, Duration>; // C++20
|
||||
using sys_seconds = sys_time<seconds>; // C++20
|
||||
using sys_days = sys_time<days>; // C++20
|
||||
|
||||
class utc_clock; // C++20
|
||||
|
||||
template <class Duration>
|
||||
using utc_time = time_point<utc_clock, Duration>; // C++20
|
||||
using utc_seconds = utc_time<seconds>; // C++20
|
||||
|
||||
class tai_clock; // C++20
|
||||
|
||||
template <class Duration>
|
||||
using tai_time = time_point<tai_clock, Duration>; // C++20
|
||||
using tai_seconds = tai_time<seconds>; // C++20
|
||||
|
||||
class file_clock; // C++20
|
||||
|
||||
template<class Duration>
|
||||
using file_time = time_point<file_clock, Duration>; // C++20
|
||||
|
||||
class steady_clock
|
||||
{
|
||||
public:
|
||||
@ -281,8 +311,466 @@ public:
|
||||
|
||||
typedef steady_clock high_resolution_clock;
|
||||
|
||||
// 25.7.8, local time // C++20
|
||||
struct local_t {};
|
||||
template<class Duration>
|
||||
using local_time = time_point<local_t, Duration>;
|
||||
using local_seconds = local_time<seconds>;
|
||||
using local_days = local_time<days>;
|
||||
|
||||
// 25.7.9, time_point conversions template<class DestClock, class SourceClock> // C++20
|
||||
struct clock_time_conversion;
|
||||
|
||||
template<class DestClock, class SourceClock, class Duration>
|
||||
auto clock_cast(const time_point<SourceClock, Duration>& t);
|
||||
|
||||
// 25.8.2, class last_spec // C++20
|
||||
struct last_spec;
|
||||
|
||||
// 25.8.3, class day // C++20
|
||||
|
||||
class day;
|
||||
constexpr bool operator==(const day& x, const day& y) noexcept;
|
||||
constexpr bool operator!=(const day& x, const day& y) noexcept;
|
||||
constexpr bool operator< (const day& x, const day& y) noexcept;
|
||||
constexpr bool operator> (const day& x, const day& y) noexcept;
|
||||
constexpr bool operator<=(const day& x, const day& y) noexcept;
|
||||
constexpr bool operator>=(const day& x, const day& y) noexcept;
|
||||
constexpr day operator+(const day& x, const days& y) noexcept;
|
||||
constexpr day operator+(const days& x, const day& y) noexcept;
|
||||
constexpr day operator-(const day& x, const days& y) noexcept;
|
||||
constexpr days operator-(const day& x, const day& y) noexcept;
|
||||
|
||||
// 25.8.4, class month // C++20
|
||||
class month;
|
||||
constexpr bool operator==(const month& x, const month& y) noexcept;
|
||||
constexpr bool operator!=(const month& x, const month& y) noexcept;
|
||||
constexpr bool operator< (const month& x, const month& y) noexcept;
|
||||
constexpr bool operator> (const month& x, const month& y) noexcept;
|
||||
constexpr bool operator<=(const month& x, const month& y) noexcept;
|
||||
constexpr bool operator>=(const month& x, const month& y) noexcept;
|
||||
constexpr month operator+(const month& x, const months& y) noexcept;
|
||||
constexpr month operator+(const months& x, const month& y) noexcept;
|
||||
constexpr month operator-(const month& x, const months& y) noexcept;
|
||||
constexpr months operator-(const month& x, const month& y) noexcept;
|
||||
|
||||
// 25.8.5, class year // C++20
|
||||
class year;
|
||||
constexpr bool operator==(const year& x, const year& y) noexcept;
|
||||
constexpr bool operator!=(const year& x, const year& y) noexcept;
|
||||
constexpr bool operator< (const year& x, const year& y) noexcept;
|
||||
constexpr bool operator> (const year& x, const year& y) noexcept;
|
||||
constexpr bool operator<=(const year& x, const year& y) noexcept;
|
||||
constexpr bool operator>=(const year& x, const year& y) noexcept;
|
||||
constexpr year operator+(const year& x, const years& y) noexcept;
|
||||
constexpr year operator+(const years& x, const year& y) noexcept;
|
||||
constexpr year operator-(const year& x, const years& y) noexcept;
|
||||
constexpr years operator-(const year& x, const year& y) noexcept;
|
||||
|
||||
// 25.8.6, class weekday // C++20
|
||||
class weekday;
|
||||
|
||||
constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
|
||||
constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
|
||||
constexpr weekday operator+(const weekday& x, const days& y) noexcept;
|
||||
constexpr weekday operator+(const days& x, const weekday& y) noexcept;
|
||||
constexpr weekday operator-(const weekday& x, const days& y) noexcept;
|
||||
constexpr days operator-(const weekday& x, const weekday& y) noexcept;
|
||||
|
||||
// 25.8.7, class weekday_indexed // C++20
|
||||
|
||||
class weekday_indexed;
|
||||
constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
|
||||
constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
|
||||
|
||||
// 25.8.8, class weekday_last // C++20
|
||||
class weekday_last;
|
||||
|
||||
constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
|
||||
constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
|
||||
|
||||
// 25.8.9, class month_day // C++20
|
||||
class month_day;
|
||||
|
||||
constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
|
||||
|
||||
|
||||
// 25.8.10, class month_day_last // C++20
|
||||
class month_day_last;
|
||||
|
||||
constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
|
||||
// 25.8.11, class month_weekday // C++20
|
||||
class month_weekday;
|
||||
|
||||
constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
|
||||
constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
|
||||
|
||||
// 25.8.12, class month_weekday_last // C++20
|
||||
class month_weekday_last;
|
||||
|
||||
constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
|
||||
constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
|
||||
|
||||
|
||||
// 25.8.13, class year_month // C++20
|
||||
class year_month;
|
||||
|
||||
constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
|
||||
|
||||
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
|
||||
constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
|
||||
constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
|
||||
constexpr months operator-(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
|
||||
constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
|
||||
constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
|
||||
|
||||
// 25.8.14, class year_month_day class // C++20
|
||||
year_month_day;
|
||||
|
||||
constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
|
||||
constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
|
||||
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
|
||||
constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
|
||||
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
|
||||
constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
|
||||
constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
|
||||
|
||||
|
||||
// 25.8.15, class year_month_day_last // C++20
|
||||
class year_month_day_last;
|
||||
|
||||
constexpr bool operator==(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator!=(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator< (const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator> (const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator<=(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator>=(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
|
||||
constexpr year_month_day_last
|
||||
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
|
||||
|
||||
// 25.8.16, class year_month_weekday // C++20
|
||||
class year_month_weekday;
|
||||
|
||||
constexpr bool operator==(const year_month_weekday& x,
|
||||
const year_month_weekday& y) noexcept;
|
||||
constexpr bool operator!=(const year_month_weekday& x,
|
||||
const year_month_weekday& y) noexcept;
|
||||
|
||||
constexpr year_month_weekday
|
||||
operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
|
||||
|
||||
// 25.8.17, class year_month_weekday_last // C++20
|
||||
class year_month_weekday_last;
|
||||
|
||||
constexpr bool operator==(const year_month_weekday_last& x,
|
||||
const year_month_weekday_last& y) noexcept;
|
||||
constexpr bool operator!=(const year_month_weekday_last& x,
|
||||
const year_month_weekday_last& y) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
|
||||
|
||||
// 25.8.18, civil calendar conventional syntax operators // C++20
|
||||
constexpr year_month
|
||||
operator/(const year& y, const month& m) noexcept;
|
||||
constexpr year_month
|
||||
operator/(const year& y, int m) noexcept;
|
||||
constexpr month_day
|
||||
operator/(const month& m, const day& d) noexcept;
|
||||
constexpr month_day
|
||||
operator/(const month& m, int d) noexcept;
|
||||
constexpr month_day
|
||||
operator/(int m, const day& d) noexcept;
|
||||
constexpr month_day
|
||||
operator/(const day& d, const month& m) noexcept;
|
||||
constexpr month_day
|
||||
operator/(const day& d, int m) noexcept;
|
||||
constexpr month_day_last
|
||||
operator/(const month& m, last_spec) noexcept;
|
||||
constexpr month_day_last
|
||||
operator/(int m, last_spec) noexcept;
|
||||
constexpr month_day_last
|
||||
operator/(last_spec, const month& m) noexcept;
|
||||
constexpr month_day_last
|
||||
operator/(last_spec, int m) noexcept;
|
||||
constexpr month_weekday
|
||||
operator/(const month& m, const weekday_indexed& wdi) noexcept;
|
||||
constexpr month_weekday
|
||||
operator/(int m, const weekday_indexed& wdi) noexcept;
|
||||
constexpr month_weekday
|
||||
operator/(const weekday_indexed& wdi, const month& m) noexcept;
|
||||
constexpr month_weekday
|
||||
operator/(const weekday_indexed& wdi, int m) noexcept;
|
||||
constexpr month_weekday_last
|
||||
operator/(const month& m, const weekday_last& wdl) noexcept;
|
||||
constexpr month_weekday_last
|
||||
operator/(int m, const weekday_last& wdl) noexcept;
|
||||
constexpr month_weekday_last
|
||||
operator/(const weekday_last& wdl, const month& m) noexcept;
|
||||
constexpr month_weekday_last
|
||||
operator/(const weekday_last& wdl, int m) noexcept;
|
||||
constexpr year_month_day
|
||||
operator/(const year_month& ym, const day& d) noexcept;
|
||||
constexpr year_month_day
|
||||
operator/(const year_month& ym, int d) noexcept;
|
||||
constexpr year_month_day
|
||||
operator/(const year& y, const month_day& md) noexcept;
|
||||
constexpr year_month_day
|
||||
operator/(int y, const month_day& md) noexcept;
|
||||
constexpr year_month_day
|
||||
operator/(const month_day& md, const year& y) noexcept;
|
||||
constexpr year_month_day
|
||||
operator/(const month_day& md, int y) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator/(const year_month& ym, last_spec) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator/(const year& y, const month_day_last& mdl) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator/(int y, const month_day_last& mdl) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator/(const month_day_last& mdl, const year& y) noexcept;
|
||||
constexpr year_month_day_last
|
||||
operator/(const month_day_last& mdl, int y) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator/(const year& y, const month_weekday& mwd) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator/(int y, const month_weekday& mwd) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator/(const month_weekday& mwd, const year& y) noexcept;
|
||||
constexpr year_month_weekday
|
||||
operator/(const month_weekday& mwd, int y) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator/(const year_month& ym, const weekday_last& wdl) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator/(const year& y, const month_weekday_last& mwdl) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator/(int y, const month_weekday_last& mwdl) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator/(const month_weekday_last& mwdl, const year& y) noexcept;
|
||||
constexpr year_month_weekday_last
|
||||
operator/(const month_weekday_last& mwdl, int y) noexcept;
|
||||
|
||||
// 25.9, class template time_of_day // C++20
|
||||
template<class Duration> class time_of_day;
|
||||
|
||||
template<> class time_of_day<hours>;
|
||||
template<> class time_of_day<minutes>;
|
||||
template<> class time_of_day<seconds>;
|
||||
template<class Rep, class Period> class time_of_day<duration<Rep, Period>>;
|
||||
|
||||
// 25.10.2, time zone database // C++20
|
||||
struct tzdb;
|
||||
class tzdb_list;
|
||||
|
||||
// 25.10.2.3, time zone database access // C++20
|
||||
const tzdb& get_tzdb();
|
||||
tzdb_list& get_tzdb_list();
|
||||
const time_zone* locate_zone(string_view tz_name);
|
||||
const time_zone* current_zone();
|
||||
|
||||
// 25.10.2.4, remote time zone database support // C++20
|
||||
const tzdb& reload_tzdb();
|
||||
string remote_version();
|
||||
|
||||
// 25.10.3, exception classes // C++20
|
||||
class nonexistent_local_time;
|
||||
class ambiguous_local_time;
|
||||
|
||||
// 25.10.4, information classes // C++20
|
||||
struct sys_info;
|
||||
struct local_info;
|
||||
|
||||
// 25.10.5, class time_zone // C++20
|
||||
enum class choose {earliest, latest};
|
||||
class time_zone;
|
||||
bool operator==(const time_zone& x, const time_zone& y) noexcept;
|
||||
bool operator!=(const time_zone& x, const time_zone& y) noexcept;
|
||||
bool operator<(const time_zone& x, const time_zone& y) noexcept;
|
||||
bool operator>(const time_zone& x, const time_zone& y) noexcept;
|
||||
bool operator<=(const time_zone& x, const time_zone& y) noexcept;
|
||||
bool operator>=(const time_zone& x, const time_zone& y) noexcept;
|
||||
|
||||
// 25.10.6, class template zoned_traits // C++20
|
||||
template<class T> struct zoned_traits;
|
||||
|
||||
// 25.10.7, class template zoned_time // C++20
|
||||
template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time;
|
||||
using zoned_seconds = zoned_time<seconds>;
|
||||
|
||||
template<class Duration1, class Duration2, class TimeZonePtr>
|
||||
bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
|
||||
const zoned_time<Duration2, TimeZonePtr>& y);
|
||||
template<class Duration1, class Duration2, class TimeZonePtr>
|
||||
bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x,
|
||||
const zoned_time<Duration2, TimeZonePtr>& y);
|
||||
|
||||
// 25.10.8, leap second support // C++20
|
||||
class leap;
|
||||
|
||||
bool operator==(const leap& x, const leap& y);
|
||||
bool operator!=(const leap& x, const leap& y);
|
||||
bool operator< (const leap& x, const leap& y);
|
||||
bool operator> (const leap& x, const leap& y);
|
||||
bool operator<=(const leap& x, const leap& y);
|
||||
bool operator>=(const leap& x, const leap& y);
|
||||
template<class Duration>
|
||||
bool operator==(const leap& x, const sys_time<Duration>& y);
|
||||
template<class Duration>
|
||||
bool operator==(const sys_time<Duration>& x, const leap& y);
|
||||
template<class Duration>
|
||||
bool operator!=(const leap& x, const sys_time<Duration>& y);
|
||||
template<class Duration>
|
||||
bool operator!=(const sys_time<Duration>& x, const leap& y);
|
||||
template<class Duration>
|
||||
bool operator< (const leap& x, const sys_time<Duration>& y);
|
||||
template<class Duration>
|
||||
bool operator< (const sys_time<Duration>& x, const leap& y);
|
||||
template<class Duration>
|
||||
bool operator> (const leap& x, const sys_time<Duration>& y);
|
||||
template<class Duration>
|
||||
bool operator> (const sys_time<Duration>& x, const leap& y);
|
||||
template<class Duration>
|
||||
bool operator<=(const leap& x, const sys_time<Duration>& y);
|
||||
template<class Duration>
|
||||
bool operator<=(const sys_time<Duration>& x, const leap& y);
|
||||
template<class Duration>
|
||||
bool operator>=(const leap& x, const sys_time<Duration>& y);
|
||||
template<class Duration>
|
||||
bool operator>=(const sys_time<Duration>& x, const leap& y);
|
||||
|
||||
// 25.10.9, class link // C++20
|
||||
class link;
|
||||
bool operator==(const link& x, const link& y);
|
||||
bool operator!=(const link& x, const link& y);
|
||||
bool operator< (const link& x, const link& y);
|
||||
bool operator> (const link& x, const link& y);
|
||||
bool operator<=(const link& x, const link& y);
|
||||
bool operator>=(const link& x, const link& y);
|
||||
|
||||
// 25.11, formatting // C++20
|
||||
template<class charT, class Streamable>
|
||||
basic_string<charT>
|
||||
format(const charT* fmt, const Streamable& s);
|
||||
|
||||
template<class charT, class Streamable>
|
||||
basic_string<charT>
|
||||
format(const locale& loc, const charT* fmt, const Streamable& s);
|
||||
|
||||
template<class charT, class traits, class Alloc, class Streamable>
|
||||
basic_string<charT, traits, Alloc>
|
||||
format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s);
|
||||
|
||||
template<class charT, class traits, class Alloc, class Streamable>
|
||||
basic_string<charT, traits, Alloc>
|
||||
format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt,
|
||||
const Streamable& s);
|
||||
|
||||
// 25.12, parsing // C++20
|
||||
template<class charT, class traits, class Alloc, class Parsable>
|
||||
unspecified
|
||||
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp);
|
||||
|
||||
template<class charT, class traits, class Alloc, class Parsable>
|
||||
unspecified
|
||||
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
|
||||
basic_string<charT, traits, Alloc>& abbrev);
|
||||
|
||||
template<class charT, class traits, class Alloc, class Parsable>
|
||||
unspecified
|
||||
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
|
||||
minutes& offset);
|
||||
|
||||
template<class charT, class traits, class Alloc, class Parsable>
|
||||
unspecified
|
||||
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
|
||||
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
||||
|
||||
inline constexpr last_spec last{}; // C++20
|
||||
inline constexpr chrono::weekday Sunday{0}; // C++20
|
||||
inline constexpr chrono::weekday Monday{1}; // C++20
|
||||
inline constexpr chrono::weekday Tuesday{2}; // C++20
|
||||
inline constexpr chrono::weekday Wednesday{3}; // C++20
|
||||
inline constexpr chrono::weekday Thursday{4}; // C++20
|
||||
inline constexpr chrono::weekday Friday{5}; // C++20
|
||||
inline constexpr chrono::weekday Saturday{6}; // C++20
|
||||
|
||||
inline constexpr chrono::month January{1}; // C++20
|
||||
inline constexpr chrono::month February{2}; // C++20
|
||||
inline constexpr chrono::month March{3}; // C++20
|
||||
inline constexpr chrono::month April{4}; // C++20
|
||||
inline constexpr chrono::month May{5}; // C++20
|
||||
inline constexpr chrono::month June{6}; // C++20
|
||||
inline constexpr chrono::month July{7}; // C++20
|
||||
inline constexpr chrono::month August{8}; // C++20
|
||||
inline constexpr chrono::month September{9}; // C++20
|
||||
inline constexpr chrono::month October{10}; // C++20
|
||||
inline constexpr chrono::month November{11}; // C++20
|
||||
inline constexpr chrono::month December{12}; // C++20
|
||||
} // chrono
|
||||
|
||||
inline namespace literals {
|
||||
inline namespace chrono_literals {
|
||||
constexpr chrono::hours operator ""h(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
|
||||
constexpr chrono::minutes operator ""min(unsigned long long); // C++14
|
||||
@ -295,6 +783,10 @@ constexpr chrono::microseconds operator ""us(unsigned l
|
||||
constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
|
||||
constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
|
||||
constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20
|
||||
constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20
|
||||
} // chrono_literals
|
||||
} // literals
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
@ -547,7 +547,7 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
|
||||
#endif
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -559,7 +559,7 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -567,7 +567,7 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -579,7 +579,7 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -587,7 +587,7 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -599,7 +599,7 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -121,7 +121,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -156,7 +156,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -186,11 +186,11 @@ class _LIBCPP_TEMPLATE_VIS codecvt_utf8
|
||||
: public __codecvt_utf8<_Elem>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf8(size_t __refs = 0)
|
||||
: __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf8() {}
|
||||
};
|
||||
|
||||
@ -209,7 +209,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -244,7 +244,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -279,7 +279,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -314,7 +314,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -349,7 +349,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -384,7 +384,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -414,11 +414,11 @@ class _LIBCPP_TEMPLATE_VIS codecvt_utf16
|
||||
: public __codecvt_utf16<_Elem, _Mode & little_endian>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf16(size_t __refs = 0)
|
||||
: __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf16() {}
|
||||
};
|
||||
|
||||
@ -437,7 +437,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -472,7 +472,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -507,7 +507,7 @@ public:
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
@ -537,11 +537,11 @@ class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
|
||||
: public __codecvt_utf8_utf16<_Elem>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf8_utf16(size_t __refs = 0)
|
||||
: __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf8_utf16() {}
|
||||
};
|
||||
|
||||
|
679
contrib/libc++/include/compare
Normal file
679
contrib/libc++/include/compare
Normal file
@ -0,0 +1,679 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- compare -----------------------------------===//
|
||||
//
|
||||
// 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_COMPARE
|
||||
#define _LIBCPP_COMPARE
|
||||
|
||||
/*
|
||||
compare synopsis
|
||||
|
||||
namespace std {
|
||||
// [cmp.categories], comparison category types
|
||||
class weak_equality;
|
||||
class strong_equality;
|
||||
class partial_ordering;
|
||||
class weak_ordering;
|
||||
class strong_ordering;
|
||||
|
||||
// named comparison functions
|
||||
constexpr bool is_eq (weak_equality cmp) noexcept { return cmp == 0; }
|
||||
constexpr bool is_neq (weak_equality cmp) noexcept { return cmp != 0; }
|
||||
constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }
|
||||
constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
|
||||
constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }
|
||||
constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
|
||||
|
||||
// [cmp.common], common comparison category type
|
||||
template<class... Ts>
|
||||
struct common_comparison_category {
|
||||
using type = see below;
|
||||
};
|
||||
template<class... Ts>
|
||||
using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
|
||||
|
||||
// [cmp.alg], comparison algorithms
|
||||
template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
|
||||
template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
|
||||
template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
|
||||
template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
|
||||
template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
|
||||
}
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
#include <array>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
|
||||
// exposition only
|
||||
enum class _LIBCPP_ENUM_VIS _EqResult : unsigned char {
|
||||
__zero = 0,
|
||||
__equal = __zero,
|
||||
__equiv = __equal,
|
||||
__nonequal = 1,
|
||||
__nonequiv = __nonequal
|
||||
};
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS _OrdResult : signed char {
|
||||
__less = -1,
|
||||
__greater = 1
|
||||
};
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
|
||||
__unordered = -127
|
||||
};
|
||||
|
||||
struct _CmpUnspecifiedType;
|
||||
using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
|
||||
|
||||
class weak_equality {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr explicit weak_equality(_EqResult __val) noexcept : __value_(__val) {}
|
||||
|
||||
public:
|
||||
static const weak_equality equivalent;
|
||||
static const weak_equality nonequivalent;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_EqResult __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::nonequivalent(_EqResult::__nonequiv);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept {
|
||||
return __v;
|
||||
}
|
||||
#endif
|
||||
|
||||
class strong_equality {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr strong_equality(_EqResult __val) noexcept : __value_(__val) {}
|
||||
|
||||
public:
|
||||
static const strong_equality equal;
|
||||
static const strong_equality nonequal;
|
||||
static const strong_equality equivalent;
|
||||
static const strong_equality nonequivalent;
|
||||
|
||||
// conversion
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == _EqResult::__zero ? weak_equality::equivalent
|
||||
: weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept;
|
||||
#endif
|
||||
private:
|
||||
_EqResult __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equal(_EqResult::__equal);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequal(_EqResult::__nonequal);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequivalent(_EqResult::__nonequiv);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept {
|
||||
return __v;
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
class partial_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr partial_ordering(_EqResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr partial_ordering(_OrdResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr partial_ordering(_NCmpResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
constexpr bool __is_ordered() const noexcept {
|
||||
return __value_ != _ValueT(_NCmpResult::__unordered);
|
||||
}
|
||||
public:
|
||||
// valid values
|
||||
static const partial_ordering less;
|
||||
static const partial_ordering equivalent;
|
||||
static const partial_ordering greater;
|
||||
static const partial_ordering unordered;
|
||||
|
||||
// conversion
|
||||
constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == 0 ? weak_equality::equivalent : weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ == 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ < 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ <= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ > 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ >= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 == __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 < __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 <= __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 > __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return !__v.__is_ordered() || __v.__value_ != 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return !__v.__is_ordered() || __v.__value_ != 0;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
class weak_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
|
||||
public:
|
||||
static const weak_ordering less;
|
||||
static const weak_ordering equivalent;
|
||||
static const weak_ordering greater;
|
||||
|
||||
// conversions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == 0 ? weak_equality::equivalent
|
||||
: weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator partial_ordering() const noexcept {
|
||||
return __value_ == 0 ? partial_ordering::equivalent
|
||||
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
|
||||
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ < 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ <= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ > 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ >= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 == __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 != __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 < __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 <= __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 > __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
class strong_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
|
||||
public:
|
||||
static const strong_ordering less;
|
||||
static const strong_ordering equal;
|
||||
static const strong_ordering equivalent;
|
||||
static const strong_ordering greater;
|
||||
|
||||
// conversions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == 0 ? weak_equality::equivalent
|
||||
: weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator strong_equality() const noexcept {
|
||||
return __value_ == 0 ? strong_equality::equal
|
||||
: strong_equality::nonequal;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator partial_ordering() const noexcept {
|
||||
return __value_ == 0 ? partial_ordering::equivalent
|
||||
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator weak_ordering() const noexcept {
|
||||
return __value_ == 0 ? weak_ordering::equivalent
|
||||
: (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equal(_EqResult::__equal);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ < 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ <= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ > 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ >= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 == __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 != __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 < __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 <= __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 > __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
// named comparison functions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_eq(weak_equality __cmp) noexcept { return __cmp == 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_neq(weak_equality __cmp) noexcept { return __cmp != 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_lteq(partial_ordering __cmp) noexcept { return __cmp <= 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_gt(partial_ordering __cmp) noexcept { return __cmp > 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_gteq(partial_ordering __cmp) noexcept { return __cmp >= 0; }
|
||||
|
||||
namespace __comp_detail {
|
||||
|
||||
enum _ClassifyCompCategory : unsigned{
|
||||
_None,
|
||||
_WeakEq,
|
||||
_StrongEq,
|
||||
_PartialOrd,
|
||||
_WeakOrd,
|
||||
_StrongOrd,
|
||||
_CCC_Size
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _ClassifyCompCategory __type_to_enum() noexcept {
|
||||
if (is_same_v<_Tp, weak_equality>)
|
||||
return _WeakEq;
|
||||
if (is_same_v<_Tp, strong_equality>)
|
||||
return _StrongEq;
|
||||
if (is_same_v<_Tp, partial_ordering>)
|
||||
return _PartialOrd;
|
||||
if (is_same_v<_Tp, weak_ordering>)
|
||||
return _WeakOrd;
|
||||
if (is_same_v<_Tp, strong_ordering>)
|
||||
return _StrongOrd;
|
||||
return _None;
|
||||
}
|
||||
|
||||
template <size_t _Size>
|
||||
constexpr _ClassifyCompCategory
|
||||
__compute_comp_type(std::array<_ClassifyCompCategory, _Size> __types) {
|
||||
std::array<int, _CCC_Size> __seen = {};
|
||||
for (auto __type : __types)
|
||||
++__seen[__type];
|
||||
if (__seen[_None])
|
||||
return _None;
|
||||
if (__seen[_WeakEq])
|
||||
return _WeakEq;
|
||||
if (__seen[_StrongEq] && (__seen[_PartialOrd] || __seen[_WeakOrd]))
|
||||
return _WeakEq;
|
||||
if (__seen[_StrongEq])
|
||||
return _StrongEq;
|
||||
if (__seen[_PartialOrd])
|
||||
return _PartialOrd;
|
||||
if (__seen[_WeakOrd])
|
||||
return _WeakOrd;
|
||||
return _StrongOrd;
|
||||
}
|
||||
|
||||
template <class ..._Ts>
|
||||
constexpr auto __get_comp_type() {
|
||||
using _CCC = _ClassifyCompCategory;
|
||||
constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
|
||||
constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
|
||||
: __compute_comp_type(__type_kinds);
|
||||
if constexpr (_Cat == _None)
|
||||
return void();
|
||||
else if constexpr (_Cat == _WeakEq)
|
||||
return weak_equality::equivalent;
|
||||
else if constexpr (_Cat == _StrongEq)
|
||||
return strong_equality::equivalent;
|
||||
else if constexpr (_Cat == _PartialOrd)
|
||||
return partial_ordering::equivalent;
|
||||
else if constexpr (_Cat == _WeakOrd)
|
||||
return weak_ordering::equivalent;
|
||||
else if constexpr (_Cat == _StrongOrd)
|
||||
return strong_ordering::equivalent;
|
||||
else
|
||||
static_assert(_Cat != _Cat, "unhandled case");
|
||||
}
|
||||
} // namespace __comp_detail
|
||||
|
||||
// [cmp.common], common comparison category type
|
||||
template<class... _Ts>
|
||||
struct _LIBCPP_TEMPLATE_VIS common_comparison_category {
|
||||
using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
|
||||
};
|
||||
|
||||
template<class... _Ts>
|
||||
using common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
|
||||
|
||||
// [cmp.alg], comparison algorithms
|
||||
// TODO: unimplemented
|
||||
template<class _Tp> constexpr strong_ordering strong_order(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr strong_equality strong_equal(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr weak_equality weak_equal(const _Tp& __lhs, const _Tp& __rhs);
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_COMPARE
|
@ -203,7 +203,7 @@ template<class T> complex<T> proj(const complex<T>&);
|
||||
template<Integral T> complex<double> proj(T);
|
||||
complex<float> proj(float);
|
||||
|
||||
template<class T> complex<T> polar(const T&, const T& = 0);
|
||||
template<class T> complex<T> polar(const T&, const T& = T());
|
||||
|
||||
// 26.3.8 transcendentals:
|
||||
template<class T> complex<T> acos(const complex<T>&);
|
||||
@ -991,7 +991,7 @@ proj(_Tp __re)
|
||||
|
||||
template<class _Tp>
|
||||
complex<_Tp>
|
||||
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
|
||||
polar(const _Tp& __rho, const _Tp& __theta = _Tp())
|
||||
{
|
||||
if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
|
||||
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
|
||||
@ -1125,6 +1125,17 @@ pow(const _Tp& __x, const complex<_Up>& __y)
|
||||
return _VSTD::pow(result_type(__x), result_type(__y));
|
||||
}
|
||||
|
||||
// __sqr, computes pow(x, 2)
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
complex<_Tp>
|
||||
__sqr(const complex<_Tp>& __x)
|
||||
{
|
||||
return complex<_Tp>((__x.real() - __x.imag()) * (__x.real() + __x.imag()),
|
||||
_Tp(2) * __x.real() * __x.imag());
|
||||
}
|
||||
|
||||
// asinh
|
||||
|
||||
template<class _Tp>
|
||||
@ -1150,7 +1161,7 @@ asinh(const complex<_Tp>& __x)
|
||||
}
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
||||
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
|
||||
complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1)));
|
||||
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
|
||||
}
|
||||
|
||||
@ -1184,7 +1195,7 @@ acosh(const complex<_Tp>& __x)
|
||||
}
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
|
||||
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
|
||||
complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
|
||||
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
|
||||
}
|
||||
|
||||
@ -1318,7 +1329,7 @@ acos(const complex<_Tp>& __x)
|
||||
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
||||
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
|
||||
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
||||
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
|
||||
complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
|
||||
if (signbit(__x.imag()))
|
||||
return complex<_Tp>(abs(__z.imag()), abs(__z.real()));
|
||||
return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));
|
||||
|
@ -128,6 +128,10 @@ public:
|
||||
void clear() noexcept;
|
||||
};
|
||||
|
||||
template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
||||
deque(InputIterator, InputIterator, Allocator = Allocator())
|
||||
-> deque<typename iterator_traits<InputIterator>::value_type, Allocator>;
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator>
|
||||
@ -921,13 +925,14 @@ class __deque_base
|
||||
{
|
||||
__deque_base(const __deque_base& __c);
|
||||
__deque_base& operator=(const __deque_base& __c);
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
public:
|
||||
typedef _Allocator allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
@ -946,6 +951,7 @@ protected:
|
||||
typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
|
||||
difference_type> const_iterator;
|
||||
|
||||
protected:
|
||||
__map __map_;
|
||||
size_type __start_;
|
||||
__compressed_pair<size_type, allocator_type> __size_;
|
||||
@ -1461,6 +1467,23 @@ private:
|
||||
void __move_assign(deque& __c, false_type);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _InputIterator,
|
||||
class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
deque(_InputIterator, _InputIterator)
|
||||
-> deque<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
|
||||
template<class _InputIterator,
|
||||
class _Alloc,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
deque(_InputIterator, _InputIterator, _Alloc)
|
||||
-> deque<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
#endif
|
||||
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
deque<_Tp, _Allocator>::deque(size_type __n)
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ struct __throw_with_nested;
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __throw_with_nested<_Tp, _Up, true> {
|
||||
_LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
|
||||
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__do_throw(_Tp&& __t)
|
||||
#else
|
||||
@ -272,7 +272,7 @@ struct __throw_with_nested<_Tp, _Up, true> {
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __throw_with_nested<_Tp, _Up, false> {
|
||||
_LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
|
||||
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__do_throw(_Tp&& __t)
|
||||
#else
|
||||
|
@ -52,6 +52,16 @@
|
||||
|
||||
#define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1
|
||||
|
||||
#define _VSTD_FS ::std::experimental::filesystem::v1
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
|
||||
|
||||
#endif
|
||||
|
@ -23,11 +23,8 @@ inline namespace fundamentals_v1 {
|
||||
template <class ForwardIterator, class Searcher>
|
||||
ForwardIterator search(ForwardIterator first, ForwardIterator last,
|
||||
const Searcher &searcher);
|
||||
template <class PopulationIterator, class SampleIterator, class Distance,
|
||||
class UniformRandomNumberGenerator>
|
||||
SampleIterator sample(PopulationIterator first, PopulationIterator last,
|
||||
SampleIterator out, Distance n,
|
||||
UniformRandomNumberGenerator &&g);
|
||||
|
||||
// sample removed because it's now part of C++17
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
@ -56,16 +53,6 @@ _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
|
||||
{ return __s(__f, __l).first; }
|
||||
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
|
||||
_SampleIterator __output_iter, _Distance __n,
|
||||
_UniformRandomNumberGenerator &&__g) {
|
||||
return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
@ -8,585 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_ANY
|
||||
#define _LIBCPP_EXPERIMENTAL_ANY
|
||||
|
||||
/*
|
||||
experimental/any synopsis
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
class bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const noexcept;
|
||||
};
|
||||
|
||||
class any
|
||||
{
|
||||
public:
|
||||
|
||||
// 6.3.1 any construct/destruct
|
||||
any() noexcept;
|
||||
|
||||
any(const any& other);
|
||||
any(any&& other) noexcept;
|
||||
|
||||
template <class ValueType>
|
||||
any(ValueType&& value);
|
||||
|
||||
~any();
|
||||
|
||||
// 6.3.2 any assignments
|
||||
any& operator=(const any& rhs);
|
||||
any& operator=(any&& rhs) noexcept;
|
||||
|
||||
template <class ValueType>
|
||||
any& operator=(ValueType&& rhs);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
void clear() noexcept;
|
||||
void swap(any& rhs) noexcept;
|
||||
|
||||
// 6.3.4 any observers
|
||||
bool empty() const noexcept;
|
||||
const type_info& type() const noexcept;
|
||||
};
|
||||
|
||||
// 6.4 Non-member functions
|
||||
void swap(any& x, any& y) noexcept;
|
||||
|
||||
template<class ValueType>
|
||||
ValueType any_cast(const any& operand);
|
||||
template<class ValueType>
|
||||
ValueType any_cast(any& operand);
|
||||
template<class ValueType>
|
||||
ValueType any_cast(any&& operand);
|
||||
|
||||
template<class ValueType>
|
||||
const ValueType* any_cast(const any* operand) noexcept;
|
||||
template<class ValueType>
|
||||
ValueType* any_cast(any* operand) noexcept;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include <cstdlib>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11 // C++ > 11
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
void __throw_bad_any_cast()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_any_cast();
|
||||
#else
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Forward declarations
|
||||
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
|
||||
{
|
||||
typedef typename aligned_storage<3*sizeof(void*), alignment_of<void*>::value>::type
|
||||
_Buffer;
|
||||
|
||||
template <class _Tp>
|
||||
struct _IsSmallObject
|
||||
: public integral_constant<bool
|
||||
, sizeof(_Tp) <= sizeof(_Buffer)
|
||||
&& alignment_of<_Buffer>::value
|
||||
% alignment_of<_Tp>::value == 0
|
||||
&& is_nothrow_move_constructible<_Tp>::value
|
||||
>
|
||||
{};
|
||||
|
||||
enum class _Action
|
||||
{
|
||||
_Destroy,
|
||||
_Copy,
|
||||
_Move,
|
||||
_Get,
|
||||
_TypeInfo
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _SmallHandler;
|
||||
|
||||
template <class _Tp>
|
||||
struct _LargeHandler;
|
||||
|
||||
template <class _Tp>
|
||||
using _Handler = typename conditional<_IsSmallObject<_Tp>::value
|
||||
, _SmallHandler<_Tp>
|
||||
, _LargeHandler<_Tp>
|
||||
>::type;
|
||||
template <class _ValueType>
|
||||
using _EnableIfNotAny = typename
|
||||
enable_if<
|
||||
!is_same<typename decay<_ValueType>::type, any>::value
|
||||
>::type;
|
||||
|
||||
} // namespace __any_imp
|
||||
|
||||
class any
|
||||
{
|
||||
public:
|
||||
// 6.3.1 any construct/destruct
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any() _NOEXCEPT : __h(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(any const & __other) : __h(nullptr)
|
||||
{
|
||||
if (__other.__h) __other.__call(_Action::_Copy, this);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(any && __other) _NOEXCEPT : __h(nullptr)
|
||||
{
|
||||
if (__other.__h) __other.__call(_Action::_Move, this);
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class = __any_imp::_EnableIfNotAny<_ValueType>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(_ValueType && __value);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~any()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
// 6.3.2 any assignments
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any const & __rhs)
|
||||
{
|
||||
any(__rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any && __rhs) _NOEXCEPT
|
||||
{
|
||||
any(_VSTD::move(__rhs)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class = __any_imp::_EnableIfNotAny<_ValueType>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(_ValueType && __rhs);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
if (__h) this->__call(_Action::_Destroy);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __rhs) _NOEXCEPT;
|
||||
|
||||
// 6.3.4 any observers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT
|
||||
{
|
||||
return __h == nullptr;
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const type_info & type() const _NOEXCEPT
|
||||
{
|
||||
if (__h) {
|
||||
return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
|
||||
} else {
|
||||
return typeid(void);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef __any_imp::_Action _Action;
|
||||
|
||||
typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *);
|
||||
|
||||
union _Storage
|
||||
{
|
||||
void * __ptr;
|
||||
__any_imp::_Buffer __buf;
|
||||
};
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr) const
|
||||
{
|
||||
return __h(__a, this, __other, __info);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr)
|
||||
{
|
||||
return __h(__a, this, __other, __info);
|
||||
}
|
||||
|
||||
template <class>
|
||||
friend struct __any_imp::_SmallHandler;
|
||||
template <class>
|
||||
friend struct __any_imp::_LargeHandler;
|
||||
|
||||
template <class _ValueType>
|
||||
friend typename add_pointer<typename add_const<_ValueType>::type>::type
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
friend typename add_pointer<_ValueType>::type
|
||||
any_cast(any *) _NOEXCEPT;
|
||||
|
||||
_HandleFuncPtr __h;
|
||||
_Storage __s;
|
||||
};
|
||||
|
||||
namespace __any_imp
|
||||
{
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS _SmallHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this, any * __other,
|
||||
type_info const * __info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<any &>(*__this));
|
||||
return nullptr;
|
||||
case _Action::_Copy:
|
||||
__copy(*__this, *__other);
|
||||
return nullptr;
|
||||
case _Action::_Move:
|
||||
__move(const_cast<any &>(*__this), *__other);
|
||||
return nullptr;
|
||||
case _Action::_Get:
|
||||
return __get(const_cast<any &>(*__this), __info);
|
||||
case _Action::_TypeInfo:
|
||||
return __type_info();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __create(any & __dest, _Up && __v)
|
||||
{
|
||||
::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v));
|
||||
__dest.__h = &_SmallHandler::__handle;
|
||||
}
|
||||
|
||||
private:
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(any & __this)
|
||||
{
|
||||
_Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
|
||||
__value.~_Tp();
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void __copy(any const & __this, any & __dest)
|
||||
{
|
||||
_SmallHandler::__create(__dest, *static_cast<_Tp const *>(
|
||||
static_cast<void const *>(&__this.__s.__buf)));
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void __move(any & __this, any & __dest)
|
||||
{
|
||||
_SmallHandler::__create(__dest, _VSTD::move(
|
||||
*static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
|
||||
__destroy(__this);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void* __get(any & __this, type_info const * __info)
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
if (typeid(_Tp) == *__info) {
|
||||
return static_cast<void*>(&__this.__s.__buf);
|
||||
}
|
||||
return nullptr;
|
||||
#else
|
||||
return static_cast<void*>(&__this.__s.__buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void* __type_info()
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS _LargeHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this, any * __other,
|
||||
type_info const * __info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<any &>(*__this));
|
||||
return nullptr;
|
||||
case _Action::_Copy:
|
||||
__copy(*__this, *__other);
|
||||
return nullptr;
|
||||
case _Action::_Move:
|
||||
__move(const_cast<any &>(*__this), *__other);
|
||||
return nullptr;
|
||||
case _Action::_Get:
|
||||
return __get(const_cast<any &>(*__this), __info);
|
||||
case _Action::_TypeInfo:
|
||||
return __type_info();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __create(any & __dest, _Up && __v)
|
||||
{
|
||||
typedef allocator<_Tp> _Alloc;
|
||||
typedef __allocator_destructor<_Alloc> _Dp;
|
||||
_Alloc __a;
|
||||
unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
|
||||
::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v));
|
||||
__dest.__s.__ptr = __hold.release();
|
||||
__dest.__h = &_LargeHandler::__handle;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(any & __this)
|
||||
{
|
||||
delete static_cast<_Tp*>(__this.__s.__ptr);
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void __copy(any const & __this, any & __dest)
|
||||
{
|
||||
_LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void __move(any & __this, any & __dest)
|
||||
{
|
||||
__dest.__s.__ptr = __this.__s.__ptr;
|
||||
__dest.__h = &_LargeHandler::__handle;
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void* __get(any & __this, type_info const * __info)
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
if (typeid(_Tp) == *__info) {
|
||||
return static_cast<void*>(__this.__s.__ptr);
|
||||
}
|
||||
return nullptr;
|
||||
#else
|
||||
return static_cast<void*>(__this.__s.__ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
|
||||
static void* __type_info()
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace __any_imp
|
||||
|
||||
|
||||
template <class _ValueType, class>
|
||||
any::any(_ValueType && __v) : __h(nullptr)
|
||||
{
|
||||
typedef typename decay<_ValueType>::type _Tp;
|
||||
static_assert(is_copy_constructible<_Tp>::value,
|
||||
"_ValueType must be CopyConstructible.");
|
||||
typedef __any_imp::_Handler<_Tp> _HandlerType;
|
||||
_HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v));
|
||||
}
|
||||
|
||||
template <class _ValueType, class>
|
||||
any & any::operator=(_ValueType && __v)
|
||||
{
|
||||
typedef typename decay<_ValueType>::type _Tp;
|
||||
static_assert(is_copy_constructible<_Tp>::value,
|
||||
"_ValueType must be CopyConstructible.");
|
||||
any(_VSTD::forward<_ValueType>(__v)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void any::swap(any & __rhs) _NOEXCEPT
|
||||
{
|
||||
if (__h && __rhs.__h) {
|
||||
any __tmp;
|
||||
__rhs.__call(_Action::_Move, &__tmp);
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
__tmp.__call(_Action::_Move, this);
|
||||
}
|
||||
else if (__h) {
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
}
|
||||
else if (__rhs.__h) {
|
||||
__rhs.__call(_Action::_Move, this);
|
||||
}
|
||||
}
|
||||
|
||||
// 6.4 Non-member functions
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __lhs, any & __rhs) _NOEXCEPT
|
||||
{
|
||||
__lhs.swap(__rhs);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any const & __v)
|
||||
{
|
||||
static_assert(
|
||||
is_reference<_ValueType>::value
|
||||
|| is_copy_constructible<_ValueType>::value,
|
||||
"_ValueType is required to be a reference or a CopyConstructible type.");
|
||||
typedef typename add_const<typename remove_reference<_ValueType>::type>::type
|
||||
_Tp;
|
||||
_Tp * __tmp = any_cast<_Tp>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return *__tmp;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any & __v)
|
||||
{
|
||||
static_assert(
|
||||
is_reference<_ValueType>::value
|
||||
|| is_copy_constructible<_ValueType>::value,
|
||||
"_ValueType is required to be a reference or a CopyConstructible type.");
|
||||
typedef typename remove_reference<_ValueType>::type _Tp;
|
||||
_Tp * __tmp = any_cast<_Tp>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return *__tmp;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any && __v)
|
||||
{
|
||||
static_assert(
|
||||
is_reference<_ValueType>::value
|
||||
|| is_copy_constructible<_ValueType>::value,
|
||||
"_ValueType is required to be a reference or a CopyConstructible type.");
|
||||
typedef typename remove_reference<_ValueType>::type _Tp;
|
||||
_Tp * __tmp = any_cast<_Tp>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return *__tmp;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline
|
||||
typename add_pointer<typename add_const<_ValueType>::type>::type
|
||||
any_cast(any const * __any) _NOEXCEPT
|
||||
{
|
||||
static_assert(!is_reference<_ValueType>::value,
|
||||
"_ValueType may not be a reference.");
|
||||
return any_cast<_ValueType>(const_cast<any *>(__any));
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
typename add_pointer<_ValueType>::type
|
||||
any_cast(any * __any) _NOEXCEPT
|
||||
{
|
||||
using __any_imp::_Action;
|
||||
static_assert(!is_reference<_ValueType>::value,
|
||||
"_ValueType may not be a reference.");
|
||||
typedef typename add_pointer<_ValueType>::type _ReturnType;
|
||||
if (__any && __any->__h) {
|
||||
|
||||
return static_cast<_ReturnType>(
|
||||
__any->__call(_Action::_Get, nullptr,
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
&typeid(_ValueType)
|
||||
#else
|
||||
nullptr
|
||||
#endif
|
||||
));
|
||||
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_ANY
|
||||
#error "<experimental/any> has been removed. Use <any> instead."
|
||||
|
@ -8,52 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
|
||||
#define _LIBCPP_EXPERIMENTAL_CHRONO
|
||||
|
||||
/**
|
||||
experimental/chrono synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace std {
|
||||
namespace chrono {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.12.4, customization traits
|
||||
template <class Rep> constexpr bool treat_as_floating_point_v
|
||||
= treat_as_floating_point<Rep>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace chrono
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <chrono>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
|
||||
= treat_as_floating_point<_Rep>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
_LIBCPP_END_NAMESPACE_CHRONO_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */
|
||||
#error "<experimental/chrono> has been removed. Use <chrono> instead."
|
||||
|
@ -93,28 +93,28 @@ class _LIBCPP_TEMPLATE_VIS coroutine_handle;
|
||||
template <>
|
||||
class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR coroutine_handle() _NOEXCEPT : __handle_(nullptr) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR coroutine_handle(nullptr_t) _NOEXCEPT : __handle_(nullptr) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
|
||||
__handle_ = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR void* address() const _NOEXCEPT { return __handle_; }
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return __handle_; }
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void operator()() { resume(); }
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void resume() {
|
||||
_LIBCPP_ASSERT(__is_suspended(),
|
||||
"resume() can only be called on suspended coroutines");
|
||||
@ -123,14 +123,14 @@ public:
|
||||
__builtin_coro_resume(__handle_);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void destroy() {
|
||||
_LIBCPP_ASSERT(__is_suspended(),
|
||||
"destroy() can only be called on suspended coroutines");
|
||||
__builtin_coro_destroy(__handle_);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool done() const {
|
||||
_LIBCPP_ASSERT(__is_suspended(),
|
||||
"done() can only be called on suspended coroutines");
|
||||
@ -138,7 +138,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static coroutine_handle from_address(void* __addr) _NOEXCEPT {
|
||||
coroutine_handle __tmp;
|
||||
__tmp.__handle_ = __addr;
|
||||
@ -146,7 +146,7 @@ public:
|
||||
}
|
||||
|
||||
// FIXME: Should from_address(nullptr) be allowed?
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
|
||||
return coroutine_handle(nullptr);
|
||||
}
|
||||
@ -169,27 +169,27 @@ private:
|
||||
};
|
||||
|
||||
// 18.11.2.7 comparison operators:
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return __x.address() == __y.address();
|
||||
}
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return !(__x == __y);
|
||||
}
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return less<void*>()(__x.address(), __y.address());
|
||||
}
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return __y < __x;
|
||||
}
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return !(__x > __y);
|
||||
}
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return !(__x < __y);
|
||||
}
|
||||
@ -202,8 +202,8 @@ public:
|
||||
// 18.11.2.1 construct/reset
|
||||
using coroutine_handle<>::coroutine_handle;
|
||||
#else
|
||||
_LIBCPP_ALWAYS_INLINE coroutine_handle() _NOEXCEPT : _Base() {}
|
||||
_LIBCPP_ALWAYS_INLINE coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {}
|
||||
_LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT : _Base() {}
|
||||
_LIBCPP_INLINE_VISIBILITY coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
|
||||
@ -213,12 +213,12 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Promise& promise() const {
|
||||
return *reinterpret_cast<_Promise*>(
|
||||
return *static_cast<_Promise*>(
|
||||
__builtin_coro_promise(this->__handle_, __alignof(_Promise), false));
|
||||
}
|
||||
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static coroutine_handle from_address(void* __addr) _NOEXCEPT {
|
||||
coroutine_handle __tmp;
|
||||
__tmp.__handle_ = __addr;
|
||||
@ -229,7 +229,7 @@ public:
|
||||
// the deleted _Promise* overload doesn't make from_address(nullptr)
|
||||
// ambiguous.
|
||||
// FIXME: should from_address work with nullptr?
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
|
||||
return coroutine_handle(nullptr);
|
||||
}
|
||||
@ -248,7 +248,7 @@ public:
|
||||
"pointers to the coroutine's promise type; use 'from_promise' instead");
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
|
||||
typedef typename remove_cv<_Promise>::type _RawPromise;
|
||||
coroutine_handle __tmp;
|
||||
@ -259,21 +259,61 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#if __has_builtin(__builtin_coro_noop)
|
||||
struct noop_coroutine_promise {};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise>
|
||||
: public coroutine_handle<> {
|
||||
using _Base = coroutine_handle<>;
|
||||
using _Promise = noop_coroutine_promise;
|
||||
public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Promise& promise() const {
|
||||
return *static_cast<_Promise*>(
|
||||
__builtin_coro_promise(this->__handle_, __alignof(_Promise), false));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }
|
||||
_LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
friend coroutine_handle<noop_coroutine_promise> noop_coroutine() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT {
|
||||
this->__handle_ = __builtin_coro_noop();
|
||||
}
|
||||
};
|
||||
|
||||
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
noop_coroutine_handle noop_coroutine() _NOEXCEPT {
|
||||
return noop_coroutine_handle();
|
||||
}
|
||||
#endif // __has_builtin(__builtin_coro_noop)
|
||||
|
||||
struct _LIBCPP_TYPE_VIS suspend_never {
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool await_ready() const _NOEXCEPT { return true; }
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_resume() const _NOEXCEPT {}
|
||||
};
|
||||
|
||||
struct _LIBCPP_TYPE_VIS suspend_always {
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool await_ready() const _NOEXCEPT { return false; }
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_resume() const _NOEXCEPT {}
|
||||
};
|
||||
|
||||
|
@ -133,19 +133,20 @@ public:
|
||||
private:
|
||||
size_t __size_;
|
||||
value_type * __base_;
|
||||
_LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {}
|
||||
_LIBCPP_INLINE_VISIBILITY dynarray () noexcept : __size_(0), __base_(nullptr) {}
|
||||
|
||||
static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
|
||||
{
|
||||
if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
|
||||
static inline _LIBCPP_INLINE_VISIBILITY
|
||||
value_type* __allocate(size_t __count) {
|
||||
if (numeric_limits<size_t>::max() / sizeof (value_type) <= __count)
|
||||
__throw_bad_array_length();
|
||||
|
||||
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
|
||||
return static_cast<value_type *>(
|
||||
_VSTD::__libcpp_allocate(sizeof(value_type) * __count, __alignof(value_type)));
|
||||
}
|
||||
|
||||
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept
|
||||
{
|
||||
_VSTD::__libcpp_deallocate (static_cast<void *> (__ptr));
|
||||
static inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __deallocate_value(value_type* __ptr ) noexcept {
|
||||
_VSTD::__libcpp_deallocate(static_cast<void *>(__ptr), __alignof(value_type));
|
||||
}
|
||||
|
||||
public:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -241,8 +241,8 @@ public:
|
||||
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
|
||||
{
|
||||
static_assert ( std::is_same<
|
||||
typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
|
||||
typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
|
||||
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
|
||||
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
|
||||
>::value,
|
||||
"Corpus and Pattern iterators must point to the same type" );
|
||||
|
||||
@ -394,8 +394,8 @@ public:
|
||||
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
|
||||
{
|
||||
static_assert ( std::is_same<
|
||||
typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
|
||||
typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
|
||||
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
|
||||
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
|
||||
>::value,
|
||||
"Corpus and Pattern iterators must point to the same type" );
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace pmr {
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <__tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
@ -96,7 +96,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
|
||||
}
|
||||
|
||||
// 8.5, memory.resource
|
||||
class _LIBCPP_TEMPLATE_VIS memory_resource
|
||||
class _LIBCPP_TYPE_VIS memory_resource
|
||||
{
|
||||
static const size_t __max_align = alignof(max_align_t);
|
||||
|
||||
@ -206,7 +206,7 @@ public:
|
||||
void construct(_Tp* __p, _Ts &&... __args)
|
||||
{
|
||||
_VSTD_LFTS::__lfts_user_alloc_construct(
|
||||
__p, resource(), _VSTD::forward<_Ts>(__args)...
|
||||
__p, *this, _VSTD::forward<_Ts>(__args)...
|
||||
);
|
||||
}
|
||||
|
||||
@ -218,14 +218,14 @@ public:
|
||||
::new ((void*)__p) pair<_T1, _T2>(piecewise_construct
|
||||
, __transform_tuple(
|
||||
typename __lfts_uses_alloc_ctor<
|
||||
_T1, memory_resource*, _Args1...
|
||||
_T1, polymorphic_allocator&, _Args1...
|
||||
>::type()
|
||||
, _VSTD::move(__x)
|
||||
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
|
||||
)
|
||||
, __transform_tuple(
|
||||
typename __lfts_uses_alloc_ctor<
|
||||
_T2, memory_resource*, _Args2...
|
||||
_T2, polymorphic_allocator&, _Args2...
|
||||
>::type()
|
||||
, _VSTD::move(__y)
|
||||
, typename __make_tuple_indices<sizeof...(_Args2)>::type{}
|
||||
@ -289,23 +289,23 @@ private:
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<allocator_arg_t const&, memory_resource*, _Args&&...>
|
||||
tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>
|
||||
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>) const
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>;
|
||||
return _Tup(allocator_arg, resource(),
|
||||
using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>;
|
||||
return _Tup(allocator_arg, *this,
|
||||
_VSTD::get<_Idx>(_VSTD::move(__t))...);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<_Args&&..., memory_resource*>
|
||||
tuple<_Args&&..., polymorphic_allocator&>
|
||||
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>) const
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
using _Tup = tuple<_Args&&..., memory_resource*>;
|
||||
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
|
||||
using _Tup = tuple<_Args&&..., polymorphic_allocator&>;
|
||||
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., *this);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -8,112 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
|
||||
#define _LIBCPP_EXPERIMENTAL_NUMERIC
|
||||
/*
|
||||
experimental/numeric synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v2 {
|
||||
|
||||
// 13.1.2, Greatest common divisor
|
||||
template<class M, class N>
|
||||
constexpr common_type_t<M,N> gcd(M m, N n);
|
||||
|
||||
// 13.1.3, Least common multiple
|
||||
template<class M, class N>
|
||||
constexpr common_type_t<M,N> lcm(M m, N n);
|
||||
|
||||
} // namespace fundamentals_v2
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <numeric>
|
||||
#include <type_traits> // is_integral
|
||||
#include <limits> // numeric_limits
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
|
||||
|
||||
template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs;
|
||||
|
||||
template <typename _Result, typename _Source>
|
||||
struct __abs<_Result, _Source, true> {
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
_Result operator()(_Source __t) const noexcept
|
||||
{
|
||||
if (__t >= 0) return __t;
|
||||
if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
|
||||
return -__t;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename _Result, typename _Source>
|
||||
struct __abs<_Result, _Source, false> {
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
_Result operator()(_Source __t) const noexcept { return __t; }
|
||||
};
|
||||
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
|
||||
inline _Tp __gcd(_Tp __m, _Tp __n)
|
||||
{
|
||||
static_assert((!is_signed<_Tp>::value), "" );
|
||||
return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
|
||||
}
|
||||
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
common_type_t<_Tp,_Up>
|
||||
gcd(_Tp __m, _Up __n)
|
||||
{
|
||||
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
|
||||
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
|
||||
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
|
||||
using _Rp = common_type_t<_Tp,_Up>;
|
||||
using _Wp = make_unsigned_t<_Rp>;
|
||||
return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd(
|
||||
static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
|
||||
static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
common_type_t<_Tp,_Up>
|
||||
lcm(_Tp __m, _Up __n)
|
||||
{
|
||||
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
|
||||
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
|
||||
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
|
||||
if (__m == 0 || __n == 0)
|
||||
return 0;
|
||||
|
||||
using _Rp = common_type_t<_Tp,_Up>;
|
||||
_Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
|
||||
_Rp __val2 = __abs<_Rp, _Up>()(__n);
|
||||
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
|
||||
return __val1 * __val2;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_V2
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */
|
||||
#error "<experimental/numeric> has been removed. Use <numeric> instead."
|
||||
|
@ -8,915 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
#define _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
|
||||
/*
|
||||
optional synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
namespace std { namespace experimental { inline namespace fundamentals_v1 {
|
||||
|
||||
// 5.3, optional for object types
|
||||
template <class T> class optional;
|
||||
|
||||
// 5.4, In-place construction
|
||||
struct in_place_t{};
|
||||
constexpr in_place_t in_place{};
|
||||
|
||||
// 5.5, No-value state indicator
|
||||
struct nullopt_t{see below};
|
||||
constexpr nullopt_t nullopt(unspecified);
|
||||
|
||||
// 5.6, Class bad_optional_access
|
||||
class bad_optional_access;
|
||||
|
||||
// 5.7, Relational operators
|
||||
template <class T>
|
||||
constexpr bool operator==(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator!=(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator<(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator>(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator<=(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator>=(const optional<T>&, const optional<T>&);
|
||||
|
||||
// 5.8, Comparison with nullopt
|
||||
template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
|
||||
|
||||
// 5.9, Comparison with T
|
||||
template <class T> constexpr bool operator==(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator==(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator!=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator!=(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<=(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator>(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator>(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator>=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator>=(const T&, const optional<T>&);
|
||||
|
||||
// 5.10, Specialized algorithms
|
||||
template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
|
||||
template <class T> constexpr optional<see below> make_optional(T&&);
|
||||
|
||||
template <class T>
|
||||
class optional
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
// 5.3.1, Constructors
|
||||
constexpr optional() noexcept;
|
||||
constexpr optional(nullopt_t) noexcept;
|
||||
optional(const optional&);
|
||||
optional(optional&&) noexcept(see below);
|
||||
constexpr optional(const T&);
|
||||
constexpr optional(T&&);
|
||||
template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
|
||||
template <class U, class... Args>
|
||||
constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
|
||||
|
||||
// 5.3.2, Destructor
|
||||
~optional();
|
||||
|
||||
// 5.3.3, Assignment
|
||||
optional& operator=(nullopt_t) noexcept;
|
||||
optional& operator=(const optional&);
|
||||
optional& operator=(optional&&) noexcept(see below);
|
||||
template <class U> optional& operator=(U&&);
|
||||
template <class... Args> void emplace(Args&&...);
|
||||
template <class U, class... Args>
|
||||
void emplace(initializer_list<U>, Args&&...);
|
||||
|
||||
// 5.3.4, Swap
|
||||
void swap(optional&) noexcept(see below);
|
||||
|
||||
// 5.3.5, Observers
|
||||
constexpr T const* operator ->() const;
|
||||
constexpr T* operator ->();
|
||||
constexpr T const& operator *() const &;
|
||||
constexpr T& operator *() &;
|
||||
constexpr T&& operator *() &&;
|
||||
constexpr const T&& operator *() const &&;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
constexpr T const& value() const &;
|
||||
constexpr T& value() &;
|
||||
constexpr T&& value() &&;
|
||||
constexpr const T&& value() const &&;
|
||||
template <class U> constexpr T value_or(U&&) const &;
|
||||
template <class U> constexpr T value_or(U&&) &&;
|
||||
|
||||
private:
|
||||
T* val; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
|
||||
// 5.11, Hash support
|
||||
template <class T> struct hash;
|
||||
template <class T> struct hash<experimental::optional<T>>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
#include <new>
|
||||
#include <__functional_base>
|
||||
#include <__debug>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
|
||||
: public std::logic_error
|
||||
{
|
||||
public:
|
||||
bad_optional_access() : std::logic_error("Bad optional Access") {}
|
||||
|
||||
// Get the key function ~bad_optional_access() into the dylib
|
||||
virtual ~bad_optional_access() _NOEXCEPT;
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
struct in_place_t {};
|
||||
constexpr in_place_t in_place{};
|
||||
|
||||
struct nullopt_t
|
||||
{
|
||||
explicit constexpr nullopt_t(int) noexcept {}
|
||||
};
|
||||
|
||||
constexpr nullopt_t nullopt{0};
|
||||
|
||||
template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
|
||||
class __optional_storage
|
||||
{
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
union
|
||||
{
|
||||
char __null_state_;
|
||||
value_type __val_;
|
||||
};
|
||||
bool __engaged_ = false;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~__optional_storage()
|
||||
{
|
||||
if (__engaged_)
|
||||
__val_.~value_type();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage() noexcept
|
||||
: __null_state_('\0') {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(const __optional_storage& __x)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(__optional_storage&& __x)
|
||||
noexcept(is_nothrow_move_constructible<value_type>::value)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(const value_type& __v)
|
||||
: __val_(__v),
|
||||
__engaged_(true) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(value_type&& __v)
|
||||
: __val_(_VSTD::move(__v)),
|
||||
__engaged_(true) {}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit __optional_storage(in_place_t, _Args&&... __args)
|
||||
: __val_(_VSTD::forward<_Args>(__args)...),
|
||||
__engaged_(true) {}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class __optional_storage<_Tp, true>
|
||||
{
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
union
|
||||
{
|
||||
char __null_state_;
|
||||
value_type __val_;
|
||||
};
|
||||
bool __engaged_ = false;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage() noexcept
|
||||
: __null_state_('\0') {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(const __optional_storage& __x)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(__optional_storage&& __x)
|
||||
noexcept(is_nothrow_move_constructible<value_type>::value)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(const value_type& __v)
|
||||
: __val_(__v),
|
||||
__engaged_(true) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(value_type&& __v)
|
||||
: __val_(_VSTD::move(__v)),
|
||||
__engaged_(true) {}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit __optional_storage(in_place_t, _Args&&... __args)
|
||||
: __val_(_VSTD::forward<_Args>(__args)...),
|
||||
__engaged_(true) {}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class optional
|
||||
: private __optional_storage<_Tp>
|
||||
{
|
||||
typedef __optional_storage<_Tp> __base;
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
static_assert(!is_reference<value_type>::value,
|
||||
"Instantiation of optional with a reference type is ill-formed.");
|
||||
static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value,
|
||||
"Instantiation of optional with a in_place_t type is ill-formed.");
|
||||
static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value,
|
||||
"Instantiation of optional with a nullopt_t type is ill-formed.");
|
||||
static_assert(is_object<value_type>::value,
|
||||
"Instantiation of optional with a non-object type is undefined behavior.");
|
||||
static_assert(is_nothrow_destructible<value_type>::value,
|
||||
"Instantiation of optional with an object type that is not noexcept destructible is undefined behavior.");
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
|
||||
_LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY ~optional() = default;
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v)
|
||||
: __base(__v) {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v)
|
||||
: __base(_VSTD::move(__v)) {}
|
||||
|
||||
template <class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit optional(in_place_t, _Args&&... __args)
|
||||
: __base(in_place, _VSTD::forward<_Args>(__args)...) {}
|
||||
|
||||
template <class _Up, class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
|
||||
: __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional& operator=(nullopt_t) noexcept
|
||||
{
|
||||
if (this->__engaged_)
|
||||
{
|
||||
this->__val_.~value_type();
|
||||
this->__engaged_ = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
operator=(const optional& __opt)
|
||||
{
|
||||
if (this->__engaged_ == __opt.__engaged_)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_ = __opt.__val_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_.~value_type();
|
||||
else
|
||||
::new((void*)_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
|
||||
this->__engaged_ = __opt.__engaged_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
operator=(optional&& __opt)
|
||||
noexcept(is_nothrow_move_assignable<value_type>::value &&
|
||||
is_nothrow_move_constructible<value_type>::value)
|
||||
{
|
||||
if (this->__engaged_ == __opt.__engaged_)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_ = _VSTD::move(__opt.__val_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_.~value_type();
|
||||
else
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(_VSTD::move(__opt.__val_));
|
||||
this->__engaged_ = __opt.__engaged_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Up,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_same<typename remove_reference<_Up>::type, value_type>::value &&
|
||||
is_constructible<value_type, _Up>::value &&
|
||||
is_assignable<value_type&, _Up>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
operator=(_Up&& __v)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_ = _VSTD::forward<_Up>(__v);
|
||||
else
|
||||
{
|
||||
::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
|
||||
this->__engaged_ = true;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
emplace(_Args&&... __args)
|
||||
{
|
||||
*this = nullopt;
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(_VSTD::forward<_Args>(__args)...);
|
||||
this->__engaged_ = true;
|
||||
}
|
||||
|
||||
template <class _Up, class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
emplace(initializer_list<_Up> __il, _Args&&... __args)
|
||||
{
|
||||
*this = nullopt;
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(__il, _VSTD::forward<_Args>(__args)...);
|
||||
this->__engaged_ = true;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(optional& __opt)
|
||||
noexcept(is_nothrow_move_constructible<value_type>::value &&
|
||||
__is_nothrow_swappable<value_type>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
if (this->__engaged_ == __opt.__engaged_)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
swap(this->__val_, __opt.__val_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->__engaged_)
|
||||
{
|
||||
::new((void*)_VSTD::addressof(__opt.__val_))
|
||||
value_type(_VSTD::move(this->__val_));
|
||||
this->__val_.~value_type();
|
||||
}
|
||||
else
|
||||
{
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(_VSTD::move(__opt.__val_));
|
||||
__opt.__val_.~value_type();
|
||||
}
|
||||
swap(this->__engaged_, __opt.__engaged_);
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
value_type const*
|
||||
operator->() const
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
|
||||
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
|
||||
return __builtin_addressof(this->__val_);
|
||||
#else
|
||||
return __operator_arrow(__has_operator_addressof<value_type>{});
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type*
|
||||
operator->()
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
|
||||
return _VSTD::addressof(this->__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
const value_type&
|
||||
operator*() const
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type&
|
||||
operator*()
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr explicit operator bool() const noexcept {return this->__engaged_;}
|
||||
|
||||
_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
#endif
|
||||
constexpr void __throw_bad_optional_access() const
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_optional_access();
|
||||
#else
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
constexpr value_type const& value() const
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
__throw_bad_optional_access();
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
value_type& value()
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
__throw_bad_optional_access();
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr value_type value_or(_Up&& __v) const&
|
||||
{
|
||||
static_assert(is_copy_constructible<value_type>::value,
|
||||
"optional<T>::value_or: T must be copy constructible");
|
||||
static_assert(is_convertible<_Up, value_type>::value,
|
||||
"optional<T>::value_or: U must be convertible to T");
|
||||
return this->__engaged_ ? this->__val_ :
|
||||
static_cast<value_type>(_VSTD::forward<_Up>(__v));
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type value_or(_Up&& __v) &&
|
||||
{
|
||||
static_assert(is_move_constructible<value_type>::value,
|
||||
"optional<T>::value_or: T must be move constructible");
|
||||
static_assert(is_convertible<_Up, value_type>::value,
|
||||
"optional<T>::value_or: U must be convertible to T");
|
||||
return this->__engaged_ ? _VSTD::move(this->__val_) :
|
||||
static_cast<value_type>(_VSTD::forward<_Up>(__v));
|
||||
}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type const*
|
||||
__operator_arrow(true_type) const
|
||||
{
|
||||
return _VSTD::addressof(this->__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
value_type const*
|
||||
__operator_arrow(false_type) const
|
||||
{
|
||||
return &this->__val_;
|
||||
}
|
||||
};
|
||||
|
||||
// Comparisons between optionals
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
if (static_cast<bool>(__x) != static_cast<bool>(__y))
|
||||
return false;
|
||||
if (!static_cast<bool>(__x))
|
||||
return true;
|
||||
return *__x == *__y;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
if (!static_cast<bool>(__y))
|
||||
return false;
|
||||
if (!static_cast<bool>(__x))
|
||||
return true;
|
||||
return *__x < *__y;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
|
||||
// Comparisons with nullopt
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const optional<_Tp>&, nullopt_t) noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(nullopt_t, const optional<_Tp>&) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(nullopt_t, const optional<_Tp>&) noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>&, nullopt_t) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
// Comparisons with T
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? *__x == __v : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? *__x == __v : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? !(*__x == __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? !(*__x == __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return !(__x > __v);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return !(__v > __x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? __v < __x : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? __x < __v : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return !(__x < __v);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return !(__v < __x);
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
optional<typename decay<_Tp>::type>
|
||||
make_optional(_Tp&& __v)
|
||||
{
|
||||
return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::optional<_Tp> >
|
||||
{
|
||||
typedef std::experimental::optional<_Tp> argument_type;
|
||||
typedef size_t result_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result_type operator()(const argument_type& __opt) const _NOEXCEPT
|
||||
{
|
||||
return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
|
||||
}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
#error "<experimental/optional> has been removed. Use <optional> instead."
|
||||
|
@ -463,8 +463,7 @@ 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));
|
||||
__pc1.swap(__pc2);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
|
@ -8,70 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_RATIO
|
||||
#define _LIBCPP_EXPERIMENTAL_RATIO
|
||||
|
||||
/**
|
||||
experimental/ratio synopsis
|
||||
C++1y
|
||||
#include <ratio>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.11.5, ratio comparison
|
||||
template <class R1, class R2> constexpr bool ratio_equal_v
|
||||
= ratio_equal<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_not_equal_v
|
||||
= ratio_not_equal<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_less_v
|
||||
= ratio_less<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_less_equal_v
|
||||
= ratio_less_equal<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_greater_v
|
||||
= ratio_greater<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_greater_equal_v
|
||||
= ratio_greater_equal<R1, R2>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <ratio>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
|
||||
= ratio_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v
|
||||
= ratio_not_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v
|
||||
= ratio_less<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v
|
||||
= ratio_less_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
|
||||
= ratio_greater<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
|
||||
= ratio_greater_equal<_R1, _R2>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_RATIO
|
||||
#error "<experimental/ratio> has been removed. Use <ratio> instead."
|
||||
|
1285
contrib/libc++/include/experimental/simd
Normal file
1285
contrib/libc++/include/experimental/simd
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,811 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_LFTS_STRING_VIEW
|
||||
#define _LIBCPP_LFTS_STRING_VIEW
|
||||
|
||||
/*
|
||||
string_view synopsis
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace library_fundamentals_v1 {
|
||||
|
||||
// 7.2, Class template basic_string_view
|
||||
template<class charT, class traits = char_traits<charT>>
|
||||
class basic_string_view;
|
||||
|
||||
// 7.9, basic_string_view non-member comparison functions
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator==(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator!=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator< (basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator> (basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator<=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator>=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
// see below, sufficient additional overloads of comparison functions
|
||||
|
||||
// 7.10, Inserters and extractors
|
||||
template<class charT, class traits>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os,
|
||||
basic_string_view<charT, traits> str);
|
||||
|
||||
// basic_string_view typedef names
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
|
||||
template<class charT, class traits = char_traits<charT>>
|
||||
class basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef traits traits_type;
|
||||
typedef charT value_type;
|
||||
typedef charT* pointer;
|
||||
typedef const charT* const_pointer;
|
||||
typedef charT& reference;
|
||||
typedef const charT& const_reference;
|
||||
typedef implementation-defined const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static constexpr size_type npos = size_type(-1);
|
||||
|
||||
// 7.3, basic_string_view constructors and assignment operators
|
||||
constexpr basic_string_view() noexcept;
|
||||
constexpr basic_string_view(const basic_string_view&) noexcept = default;
|
||||
basic_string_view& operator=(const basic_string_view&) noexcept = default;
|
||||
template<class Allocator>
|
||||
basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept;
|
||||
constexpr basic_string_view(const charT* str);
|
||||
constexpr basic_string_view(const charT* str, size_type len);
|
||||
|
||||
// 7.4, basic_string_view iterator support
|
||||
constexpr const_iterator begin() const noexcept;
|
||||
constexpr const_iterator end() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
// 7.5, basic_string_view capacity
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type length() const noexcept;
|
||||
constexpr size_type max_size() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// 7.6, basic_string_view element access
|
||||
constexpr const_reference operator[](size_type pos) const;
|
||||
constexpr const_reference at(size_type pos) const;
|
||||
constexpr const_reference front() const;
|
||||
constexpr const_reference back() const;
|
||||
constexpr const_pointer data() const noexcept;
|
||||
|
||||
// 7.7, basic_string_view modifiers
|
||||
constexpr void clear() noexcept;
|
||||
constexpr void remove_prefix(size_type n);
|
||||
constexpr void remove_suffix(size_type n);
|
||||
constexpr void swap(basic_string_view& s) noexcept;
|
||||
|
||||
// 7.8, basic_string_view string operations
|
||||
template<class Allocator>
|
||||
explicit operator basic_string<charT, traits, Allocator>() const;
|
||||
template<class Allocator = allocator<charT>>
|
||||
basic_string<charT, traits, Allocator> to_string(
|
||||
const Allocator& a = Allocator()) const;
|
||||
|
||||
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
||||
|
||||
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
||||
constexpr int compare(basic_string_view s) const noexcept;
|
||||
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1,
|
||||
basic_string_view s, size_type pos2, size_type n2) const;
|
||||
constexpr int compare(const charT* s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1,
|
||||
const charT* s, size_type n2) const;
|
||||
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
|
||||
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
|
||||
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
||||
|
||||
private:
|
||||
const_pointer data_; // exposition only
|
||||
size_type size_; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
|
||||
// 7.11, Hash support
|
||||
template <class T> struct hash;
|
||||
template <> struct hash<experimental::string_view>;
|
||||
template <> struct hash<experimental::u16string_view>;
|
||||
template <> struct hash<experimental::u32string_view>;
|
||||
template <> struct hash<experimental::wstring_view>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <iomanip>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
|
||||
class _LIBCPP_TEMPLATE_VIS basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef _Traits traits_type;
|
||||
typedef _CharT value_type;
|
||||
typedef const _CharT* pointer;
|
||||
typedef const _CharT* const_pointer;
|
||||
typedef const _CharT& reference;
|
||||
typedef const _CharT& const_reference;
|
||||
typedef const_pointer const_iterator; // See [string.view.iterators]
|
||||
typedef const_iterator iterator;
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
|
||||
|
||||
// [string.view.cons], construct/copy
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
template<class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
|
||||
: __data (__str.data()), __size(__str.size()) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s, size_type __len)
|
||||
: __data(__s), __size(__len)
|
||||
{
|
||||
// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s)
|
||||
: __data(__s), __size(_Traits::length(__s)) {}
|
||||
|
||||
// [string.view.iterators], iterators
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT { return cbegin(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT { return cend(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT { return __data; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT { return __data + __size; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
// [string.view.capacity], capacity
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type length() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
|
||||
empty() const _NOEXCEPT { return __size == 0; }
|
||||
|
||||
// [string.view.access], element access
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference operator[](size_type __pos) const { return __data[__pos]; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type __pos) const
|
||||
{
|
||||
return __pos >= size()
|
||||
? (__throw_out_of_range("string_view::at"), __data[0])
|
||||
: __data[__pos];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer data() const _NOEXCEPT { return __data; }
|
||||
|
||||
// [string.view.modifiers], modifiers:
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
__data = nullptr;
|
||||
__size = 0;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_prefix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
|
||||
__data += __n;
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_suffix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_string_view& __other) _NOEXCEPT
|
||||
{
|
||||
const value_type *__p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
|
||||
size_type __sz = __size;
|
||||
__size = __other.__size;
|
||||
__other.__size = __sz;
|
||||
// _VSTD::swap( __data, __other.__data );
|
||||
// _VSTD::swap( __size, __other.__size );
|
||||
}
|
||||
|
||||
// [string.view.ops], string operations:
|
||||
template<class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
|
||||
{ return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
|
||||
|
||||
template<class _Allocator = allocator<_CharT> >
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
to_string( const _Allocator& __a = _Allocator()) const
|
||||
{ return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); }
|
||||
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{
|
||||
if ( __pos > size())
|
||||
__throw_out_of_range("string_view::copy");
|
||||
size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
_VSTD::copy_n(begin() + __pos, __rlen, __s );
|
||||
return __rlen;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR
|
||||
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
|
||||
{
|
||||
// if (__pos > size())
|
||||
// __throw_out_of_range("string_view::substr");
|
||||
// size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
// return basic_string_view(data() + __pos, __rlen);
|
||||
return __pos > size()
|
||||
? (__throw_out_of_range("string_view::substr"), basic_string_view())
|
||||
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
|
||||
{
|
||||
size_type __rlen = _VSTD::min( size(), __sv.size());
|
||||
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
|
||||
if ( __retval == 0 ) // first __rlen chars matched
|
||||
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
|
||||
return __retval;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare( size_type __pos1, size_type __n1,
|
||||
basic_string_view _sv, size_type __pos2, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(const _CharT* __s) const
|
||||
{
|
||||
return compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
|
||||
}
|
||||
|
||||
// find
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos = 0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// rfind
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{ return find(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{ return rfind(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
private:
|
||||
const value_type* __data;
|
||||
size_type __size;
|
||||
};
|
||||
|
||||
|
||||
// [string.view.comparison]
|
||||
// operator ==
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
|
||||
// operator !=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
|
||||
// operator <
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
|
||||
// operator >
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
|
||||
// operator <=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
|
||||
// operator >=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
// [string.view.io]
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
|
||||
{
|
||||
return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
|
||||
}
|
||||
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// [string.view.hash]
|
||||
// Shamelessly stolen from <string>
|
||||
template<class _CharT, class _Traits>
|
||||
struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::basic_string_view<_CharT, _Traits> >
|
||||
: public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
|
||||
{
|
||||
size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
|
||||
};
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
size_t
|
||||
hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
|
||||
const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
|
||||
{
|
||||
return __do_string_hash(__val.data(), __val.data() + __val.size());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _CharT, class _Traits>
|
||||
__quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
|
||||
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_LFTS_STRING_VIEW
|
||||
#error "<experimental/string_view> has been removed. Use <string_view> instead."
|
||||
|
@ -8,56 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
|
||||
#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
|
||||
|
||||
/**
|
||||
experimental/system_error synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 19.5, System error support
|
||||
template <class T> constexpr bool is_error_code_enum_v
|
||||
= is_error_code_enum<T>::value;
|
||||
template <class T> constexpr bool is_error_condition_enum_v
|
||||
= is_error_condition_enum<T>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <system_error>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_code_enum_v
|
||||
= is_error_code_enum<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_condition_enum_v
|
||||
= is_error_condition_enum<_Tp>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR */
|
||||
#error "<experimental/system_error> has been removed. Use <system_error> instead."
|
||||
|
@ -8,75 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
|
||||
#define _LIBCPP_EXPERIMENTAL_TUPLE
|
||||
|
||||
/*
|
||||
experimental/tuple synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.4.2.5, tuple helper classes
|
||||
template <class T> constexpr size_t tuple_size_v
|
||||
= tuple_size<T>::value;
|
||||
|
||||
// 3.2.2, Calling a function with a tuple of arguments
|
||||
template <class F, class Tuple>
|
||||
constexpr decltype(auto) apply(F&& f, Tuple&& t);
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
# include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
# include <tuple>
|
||||
# include <utility>
|
||||
# include <__functional_base>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
template <class _Tp>
|
||||
_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
|
||||
#endif
|
||||
|
||||
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_constexpr(
|
||||
_VSTD::forward<_Fn>(__f),
|
||||
_VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
|
||||
);
|
||||
}
|
||||
|
||||
template <class _Fn, class _Tuple>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
decltype(auto) apply(_Fn && __f, _Tuple && __t) {
|
||||
return _VSTD_LFTS::__apply_tuple_impl(
|
||||
_VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
|
||||
make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>()
|
||||
);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */
|
||||
#error "<experimental/tuple> has been removed. Use <tuple> instead."
|
||||
|
@ -21,146 +21,6 @@ namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.10.4.1, primary type categories
|
||||
template <class T> constexpr bool is_void_v
|
||||
= is_void<T>::value;
|
||||
template <class T> constexpr bool is_null_pointer_v
|
||||
= is_null_pointer<T>::value;
|
||||
template <class T> constexpr bool is_integral_v
|
||||
= is_integral<T>::value;
|
||||
template <class T> constexpr bool is_floating_point_v
|
||||
= is_floating_point<T>::value;
|
||||
template <class T> constexpr bool is_array_v
|
||||
= is_array<T>::value;
|
||||
template <class T> constexpr bool is_pointer_v
|
||||
= is_pointer<T>::value;
|
||||
template <class T> constexpr bool is_lvalue_reference_v
|
||||
= is_lvalue_reference<T>::value;
|
||||
template <class T> constexpr bool is_rvalue_reference_v
|
||||
= is_rvalue_reference<T>::value;
|
||||
template <class T> constexpr bool is_member_object_pointer_v
|
||||
= is_member_object_pointer<T>::value;
|
||||
template <class T> constexpr bool is_member_function_pointer_v
|
||||
= is_member_function_pointer<T>::value;
|
||||
template <class T> constexpr bool is_enum_v
|
||||
= is_enum<T>::value;
|
||||
template <class T> constexpr bool is_union_v
|
||||
= is_union<T>::value;
|
||||
template <class T> constexpr bool is_class_v
|
||||
= is_class<T>::value;
|
||||
template <class T> constexpr bool is_function_v
|
||||
= is_function<T>::value;
|
||||
|
||||
// See C++14 20.10.4.2, composite type categories
|
||||
template <class T> constexpr bool is_reference_v
|
||||
= is_reference<T>::value;
|
||||
template <class T> constexpr bool is_arithmetic_v
|
||||
= is_arithmetic<T>::value;
|
||||
template <class T> constexpr bool is_fundamental_v
|
||||
= is_fundamental<T>::value;
|
||||
template <class T> constexpr bool is_object_v
|
||||
= is_object<T>::value;
|
||||
template <class T> constexpr bool is_scalar_v
|
||||
= is_scalar<T>::value;
|
||||
template <class T> constexpr bool is_compound_v
|
||||
= is_compound<T>::value;
|
||||
template <class T> constexpr bool is_member_pointer_v
|
||||
= is_member_pointer<T>::value;
|
||||
|
||||
// See C++14 20.10.4.3, type properties
|
||||
template <class T> constexpr bool is_const_v
|
||||
= is_const<T>::value;
|
||||
template <class T> constexpr bool is_volatile_v
|
||||
= is_volatile<T>::value;
|
||||
template <class T> constexpr bool is_trivial_v
|
||||
= is_trivial<T>::value;
|
||||
template <class T> constexpr bool is_trivially_copyable_v
|
||||
= is_trivially_copyable<T>::value;
|
||||
template <class T> constexpr bool is_standard_layout_v
|
||||
= is_standard_layout<T>::value;
|
||||
template <class T> constexpr bool is_pod_v
|
||||
= is_pod<T>::value;
|
||||
template <class T> constexpr bool is_literal_type_v
|
||||
= is_literal_type<T>::value;
|
||||
template <class T> constexpr bool is_empty_v
|
||||
= is_empty<T>::value;
|
||||
template <class T> constexpr bool is_polymorphic_v
|
||||
= is_polymorphic<T>::value;
|
||||
template <class T> constexpr bool is_abstract_v
|
||||
= is_abstract<T>::value;
|
||||
template <class T> constexpr bool is_final_v
|
||||
= is_final<T>::value;
|
||||
template <class T> constexpr bool is_signed_v
|
||||
= is_signed<T>::value;
|
||||
template <class T> constexpr bool is_unsigned_v
|
||||
= is_unsigned<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_constructible_v
|
||||
= is_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_default_constructible_v
|
||||
= is_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_copy_constructible_v
|
||||
= is_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_move_constructible_v
|
||||
= is_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_assignable_v
|
||||
= is_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_copy_assignable_v
|
||||
= is_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_move_assignable_v
|
||||
= is_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_destructible_v
|
||||
= is_destructible<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_trivially_constructible_v
|
||||
= is_trivially_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_trivially_default_constructible_v
|
||||
= is_trivially_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_trivially_copy_constructible_v
|
||||
= is_trivially_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_trivially_move_constructible_v
|
||||
= is_trivially_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_trivially_assignable_v
|
||||
= is_trivially_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_trivially_copy_assignable_v
|
||||
= is_trivially_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_trivially_move_assignable_v
|
||||
= is_trivially_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_trivially_destructible_v
|
||||
= is_trivially_destructible<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_nothrow_constructible_v
|
||||
= is_nothrow_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_nothrow_default_constructible_v
|
||||
= is_nothrow_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_copy_constructible_v
|
||||
= is_nothrow_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_move_constructible_v
|
||||
= is_nothrow_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_nothrow_assignable_v
|
||||
= is_nothrow_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_nothrow_copy_assignable_v
|
||||
= is_nothrow_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<T>::value;
|
||||
template <class T> constexpr bool has_virtual_destructor_v
|
||||
= has_virtual_destructor<T>::value;
|
||||
|
||||
// See C++14 20.10.5, type property queries
|
||||
template <class T> constexpr size_t alignment_of_v
|
||||
= alignment_of<T>::value;
|
||||
template <class T> constexpr size_t rank_v
|
||||
= rank<T>::value;
|
||||
template <class T, unsigned I = 0> constexpr size_t extent_v
|
||||
= extent<T, I>::value;
|
||||
|
||||
// See C++14 20.10.6, type relations
|
||||
template <class T, class U> constexpr bool is_same_v
|
||||
= is_same<T, U>::value;
|
||||
template <class Base, class Derived> constexpr bool is_base_of_v
|
||||
= is_base_of<Base, Derived>::value;
|
||||
template <class From, class To> constexpr bool is_convertible_v
|
||||
= is_convertible<From, To>::value;
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
template <class> class invocation_type; // not defined
|
||||
template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
|
||||
@ -172,14 +32,6 @@ inline namespace fundamentals_v1 {
|
||||
template <class T>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<T>::type;
|
||||
|
||||
// 3.3.3, Logical operator traits
|
||||
template<class... B> struct conjunction;
|
||||
template<class... B> constexpr bool conjunction_v = conjunction<B...>::value;
|
||||
template<class... B> struct disjunction;
|
||||
template<class... B> constexpr bool disjunction_v = disjunction<B...>::value;
|
||||
template<class B> struct negation;
|
||||
template<class B> constexpr bool negation_v = negation<B>::value;
|
||||
|
||||
// 3.3.4, Detection idiom
|
||||
template <class...> using void_t = void;
|
||||
|
||||
@ -229,215 +81,6 @@ inline namespace fundamentals_v1 {
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
// C++14 20.10.4.1, primary type categories
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
|
||||
= is_void<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
|
||||
= is_null_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
|
||||
= is_integral<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
|
||||
= is_floating_point<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
|
||||
= is_array<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
|
||||
= is_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
|
||||
= is_lvalue_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
|
||||
= is_rvalue_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
|
||||
= is_member_object_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
|
||||
= is_member_function_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
|
||||
= is_enum<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
|
||||
= is_union<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
|
||||
= is_class<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
|
||||
= is_function<_Tp>::value;
|
||||
|
||||
// C++14 20.10.4.2, composite type categories
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
|
||||
= is_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
|
||||
= is_arithmetic<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
|
||||
= is_fundamental<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
|
||||
= is_object<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
|
||||
= is_scalar<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
|
||||
= is_compound<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
|
||||
= is_member_pointer<_Tp>::value;
|
||||
|
||||
// C++14 20.10.4.3, type properties
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
|
||||
= is_const<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
|
||||
= is_volatile<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
|
||||
= is_trivial<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
|
||||
= is_trivially_copyable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
|
||||
= is_standard_layout<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
|
||||
= is_pod<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
|
||||
= is_literal_type<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
|
||||
= is_empty<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
|
||||
= is_polymorphic<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
|
||||
= is_abstract<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
|
||||
= is_final<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
|
||||
= is_signed<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
|
||||
= is_unsigned<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
|
||||
= is_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
|
||||
= is_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
|
||||
= is_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
|
||||
= is_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
|
||||
= is_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
|
||||
= is_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
|
||||
= is_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
|
||||
= is_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
|
||||
= is_trivially_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
|
||||
= is_trivially_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
|
||||
= is_trivially_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
|
||||
= is_trivially_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
|
||||
= is_trivially_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
|
||||
= is_trivially_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
|
||||
= is_trivially_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
|
||||
= is_trivially_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
|
||||
= is_nothrow_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
|
||||
= is_nothrow_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
|
||||
= is_nothrow_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
|
||||
= is_nothrow_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
|
||||
= is_nothrow_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
|
||||
= is_nothrow_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
|
||||
= has_virtual_destructor<_Tp>::value;
|
||||
|
||||
// C++14 20.10.5, type properties queries
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
|
||||
= alignment_of<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
|
||||
= rank<_Tp>::value;
|
||||
|
||||
template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
|
||||
= extent<_Tp, _Id>::value;
|
||||
|
||||
// C++14 20.10.6, type relations
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
|
||||
= is_same<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
|
||||
= is_base_of<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
|
||||
= is_convertible<_Tp, _Up>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
/*
|
||||
template <class>
|
||||
@ -459,24 +102,6 @@ template <class _Tp>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
|
||||
*/
|
||||
|
||||
// 3.3.3, Logical operator traits
|
||||
template <class...> using void_t = void;
|
||||
|
||||
template <class... _Args>
|
||||
struct conjunction : _VSTD::__and_<_Args...> {};
|
||||
template <class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool conjunction_v = conjunction<_Args...>::value;
|
||||
|
||||
template <class... _Args>
|
||||
struct disjunction : _VSTD::__or_<_Args...> {};
|
||||
template <class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool disjunction_v = disjunction<_Args...>::value;
|
||||
|
||||
template <class _Tp>
|
||||
struct negation : _VSTD::__not_<_Tp> {};
|
||||
template<class _Tp>
|
||||
_LIBCPP_CONSTEXPR bool negation_v = negation<_Tp>::value;
|
||||
|
||||
// 3.3.4, Detection idiom
|
||||
template <class...> using void_t = void;
|
||||
|
||||
|
2682
contrib/libc++/include/filesystem
Normal file
2682
contrib/libc++/include/filesystem
Normal file
File diff suppressed because it is too large
Load Diff
@ -134,6 +134,11 @@ public:
|
||||
void reverse() noexcept;
|
||||
};
|
||||
|
||||
|
||||
template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
||||
forward_list(InputIterator, InputIterator, Allocator = Allocator())
|
||||
-> forward_list<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator==(const forward_list<T, Allocator>& x,
|
||||
const forward_list<T, Allocator>& y);
|
||||
@ -452,6 +457,10 @@ protected:
|
||||
typedef typename allocator_traits<__begin_node_allocator>::pointer
|
||||
__begin_node_pointer;
|
||||
|
||||
static_assert((!is_same<allocator_type, __node_allocator>::value),
|
||||
"internal allocator type must differ from user-specified "
|
||||
"type; otherwise overload resolution breaks");
|
||||
|
||||
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -476,9 +485,11 @@ protected:
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
|
||||
: __before_begin_(__begin_node()) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_base(const allocator_type& __a)
|
||||
explicit __forward_list_base(const allocator_type& __a)
|
||||
: __before_begin_(__begin_node(), __node_allocator(__a)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __forward_list_base(const __node_allocator& __a)
|
||||
: __before_begin_(__begin_node(), __a) {}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -845,6 +856,23 @@ private:
|
||||
__sort(__node_pointer __f, difference_type __sz, _Compare& __comp);
|
||||
};
|
||||
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _InputIterator,
|
||||
class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
forward_list(_InputIterator, _InputIterator)
|
||||
-> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
|
||||
template<class _InputIterator,
|
||||
class _Alloc,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
forward_list(_InputIterator, _InputIterator, _Alloc)
|
||||
-> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline
|
||||
forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a)
|
||||
@ -932,12 +960,9 @@ forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
|
||||
: base(allocator_type(
|
||||
__node_traits::select_on_container_copy_construction(__x.__alloc())
|
||||
)
|
||||
)
|
||||
{
|
||||
insert_after(cbefore_begin(), __x.begin(), __x.end());
|
||||
: base(
|
||||
__node_traits::select_on_container_copy_construction(__x.__alloc())) {
|
||||
insert_after(cbefore_begin(), __x.begin(), __x.end());
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
bool is_open() const;
|
||||
basic_filebuf* open(const char* s, ios_base::openmode mode);
|
||||
basic_filebuf* open(const string& s, ios_base::openmode mode);
|
||||
basic_filebuf* open(const filesystem::path& p, ios_base::openmode mode); // C++17
|
||||
basic_filebuf* close();
|
||||
|
||||
protected:
|
||||
@ -77,6 +78,8 @@ public:
|
||||
basic_ifstream();
|
||||
explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
|
||||
explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
|
||||
explicit basic_ifstream(const filesystem::path& p,
|
||||
ios_base::openmode mode = ios_base::in); // C++17
|
||||
basic_ifstream(basic_ifstream&& rhs);
|
||||
|
||||
basic_ifstream& operator=(basic_ifstream&& rhs);
|
||||
@ -86,6 +89,8 @@ public:
|
||||
bool is_open() const;
|
||||
void open(const char* s, ios_base::openmode mode = ios_base::in);
|
||||
void open(const string& s, ios_base::openmode mode = ios_base::in);
|
||||
void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in); // C++17
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
@ -110,6 +115,8 @@ public:
|
||||
basic_ofstream();
|
||||
explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
|
||||
explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
|
||||
explicit basic_ofstream(const filesystem::path& p,
|
||||
ios_base::openmode mode = ios_base::out); // C++17
|
||||
basic_ofstream(basic_ofstream&& rhs);
|
||||
|
||||
basic_ofstream& operator=(basic_ofstream&& rhs);
|
||||
@ -119,6 +126,9 @@ public:
|
||||
bool is_open() const;
|
||||
void open(const char* s, ios_base::openmode mode = ios_base::out);
|
||||
void open(const string& s, ios_base::openmode mode = ios_base::out);
|
||||
void open(const filesystem::path& p,
|
||||
ios_base::openmode mode = ios_base::out); // C++17
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
@ -143,6 +153,8 @@ public:
|
||||
basic_fstream();
|
||||
explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
|
||||
explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
|
||||
explicit basic_fstream(const filesystem::path& p,
|
||||
ios_base::openmode mode = ios_base::in|ios_base::out); C++17
|
||||
basic_fstream(basic_fstream&& rhs);
|
||||
|
||||
basic_fstream& operator=(basic_fstream&& rhs);
|
||||
@ -152,6 +164,9 @@ public:
|
||||
bool is_open() const;
|
||||
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);
|
||||
void open(const filesystem::path& s,
|
||||
ios_base::openmode mode = ios_base::in|ios_base::out); // C++17
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
@ -170,6 +185,8 @@ typedef basic_fstream<wchar_t> wfstream;
|
||||
#include <istream>
|
||||
#include <__locale>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@ -212,12 +229,28 @@ public:
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
basic_filebuf* open(const char* __s, ios_base::openmode __mode);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
|
||||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
|
||||
return open(__p.c_str(), __mode);
|
||||
}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf* __open(int __fd, ios_base::openmode __mode);
|
||||
#endif
|
||||
basic_filebuf* close();
|
||||
|
||||
protected:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline static const char*
|
||||
__make_mdstring(ios_base::openmode __mode) _NOEXCEPT;
|
||||
|
||||
protected:
|
||||
// 27.9.1.5 Overridden virtual functions:
|
||||
virtual int_type underflow();
|
||||
virtual int_type pbackfail(int_type __c = traits_type::eof());
|
||||
@ -231,25 +264,25 @@ protected:
|
||||
virtual void imbue(const locale& __loc);
|
||||
|
||||
private:
|
||||
char* __extbuf_;
|
||||
const char* __extbufnext_;
|
||||
const char* __extbufend_;
|
||||
char __extbuf_min_[8];
|
||||
size_t __ebs_;
|
||||
char_type* __intbuf_;
|
||||
size_t __ibs_;
|
||||
FILE* __file_;
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type __st_;
|
||||
state_type __st_last_;
|
||||
ios_base::openmode __om_;
|
||||
ios_base::openmode __cm_;
|
||||
bool __owns_eb_;
|
||||
bool __owns_ib_;
|
||||
bool __always_noconv_;
|
||||
char* __extbuf_;
|
||||
const char* __extbufnext_;
|
||||
const char* __extbufend_;
|
||||
char __extbuf_min_[8];
|
||||
size_t __ebs_;
|
||||
char_type* __intbuf_;
|
||||
size_t __ibs_;
|
||||
FILE* __file_;
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type __st_;
|
||||
state_type __st_last_;
|
||||
ios_base::openmode __om_;
|
||||
ios_base::openmode __cm_;
|
||||
bool __owns_eb_;
|
||||
bool __owns_ib_;
|
||||
bool __always_noconv_;
|
||||
|
||||
bool __read_mode();
|
||||
void __write_mode();
|
||||
bool __read_mode();
|
||||
void __write_mode();
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
@ -470,6 +503,46 @@ basic_filebuf<_CharT, _Traits>::is_open() const
|
||||
return __file_ != 0;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(
|
||||
ios_base::openmode __mode) _NOEXCEPT {
|
||||
switch (__mode & ~ios_base::ate) {
|
||||
case ios_base::out:
|
||||
case ios_base::out | ios_base::trunc:
|
||||
return "w";
|
||||
case ios_base::out | ios_base::app:
|
||||
case ios_base::app:
|
||||
return "a";
|
||||
case ios_base::in:
|
||||
return "r";
|
||||
case ios_base::in | ios_base::out:
|
||||
return "r+";
|
||||
case ios_base::in | ios_base::out | ios_base::trunc:
|
||||
return "w+";
|
||||
case ios_base::in | ios_base::out | ios_base::app:
|
||||
case ios_base::in | ios_base::app:
|
||||
return "a+";
|
||||
case ios_base::out | ios_base::binary:
|
||||
case ios_base::out | ios_base::trunc | ios_base::binary:
|
||||
return "wb";
|
||||
case ios_base::out | ios_base::app | ios_base::binary:
|
||||
case ios_base::app | ios_base::binary:
|
||||
return "ab";
|
||||
case ios_base::in | ios_base::binary:
|
||||
return "rb";
|
||||
case ios_base::in | ios_base::out | ios_base::binary:
|
||||
return "r+b";
|
||||
case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
|
||||
return "w+b";
|
||||
case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
|
||||
case ios_base::in | ios_base::app | ios_base::binary:
|
||||
return "a+b";
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
template <class _CharT, class _Traits>
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
@ -478,51 +551,104 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
basic_filebuf<_CharT, _Traits>* __rt = 0;
|
||||
if (__file_ == 0)
|
||||
{
|
||||
if (const char* __mdstr = __make_mdstring(__mode)) {
|
||||
__rt = this;
|
||||
const char* __mdstr;
|
||||
__file_ = fopen(__s, __mdstr);
|
||||
if (__file_) {
|
||||
__om_ = __mode;
|
||||
if (__mode & ios_base::ate) {
|
||||
if (fseek(__file_, 0, SEEK_END)) {
|
||||
fclose(__file_);
|
||||
__file_ = 0;
|
||||
__rt = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
__rt = 0;
|
||||
}
|
||||
}
|
||||
return __rt;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY basic_filebuf<_CharT, _Traits>*
|
||||
basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
|
||||
basic_filebuf<_CharT, _Traits>* __rt = 0;
|
||||
if (__file_ == 0) {
|
||||
if (const char* __mdstr = __make_mdstring(__mode)) {
|
||||
__rt = this;
|
||||
__file_ = fdopen(__fd, __mdstr);
|
||||
if (__file_) {
|
||||
__om_ = __mode;
|
||||
if (__mode & ios_base::ate) {
|
||||
if (fseek(__file_, 0, SEEK_END)) {
|
||||
fclose(__file_);
|
||||
__file_ = 0;
|
||||
__rt = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
__rt = 0;
|
||||
}
|
||||
}
|
||||
return __rt;
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
// This is basically the same as the char* overload except that it uses _wfopen
|
||||
// and long mode strings.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
basic_filebuf<_CharT, _Traits>* __rt = 0;
|
||||
if (__file_ == 0)
|
||||
{
|
||||
__rt = this;
|
||||
const wchar_t* __mdstr;
|
||||
switch (__mode & ~ios_base::ate)
|
||||
{
|
||||
case ios_base::out:
|
||||
case ios_base::out | ios_base::trunc:
|
||||
__mdstr = "w";
|
||||
__mdstr = L"w";
|
||||
break;
|
||||
case ios_base::out | ios_base::app:
|
||||
case ios_base::app:
|
||||
__mdstr = "a";
|
||||
__mdstr = L"a";
|
||||
break;
|
||||
case ios_base::in:
|
||||
__mdstr = "r";
|
||||
__mdstr = L"r";
|
||||
break;
|
||||
case ios_base::in | ios_base::out:
|
||||
__mdstr = "r+";
|
||||
__mdstr = L"r+";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::trunc:
|
||||
__mdstr = "w+";
|
||||
__mdstr = L"w+";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::app:
|
||||
case ios_base::in | ios_base::app:
|
||||
__mdstr = "a+";
|
||||
__mdstr = L"a+";
|
||||
break;
|
||||
case ios_base::out | ios_base::binary:
|
||||
case ios_base::out | ios_base::trunc | ios_base::binary:
|
||||
__mdstr = "wb";
|
||||
__mdstr = L"wb";
|
||||
break;
|
||||
case ios_base::out | ios_base::app | ios_base::binary:
|
||||
case ios_base::app | ios_base::binary:
|
||||
__mdstr = "ab";
|
||||
__mdstr = L"ab";
|
||||
break;
|
||||
case ios_base::in | ios_base::binary:
|
||||
__mdstr = "rb";
|
||||
__mdstr = L"rb";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::binary:
|
||||
__mdstr = "r+b";
|
||||
__mdstr = L"r+b";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
|
||||
__mdstr = "w+b";
|
||||
__mdstr = L"w+b";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
|
||||
case ios_base::in | ios_base::app | ios_base::binary:
|
||||
__mdstr = "a+b";
|
||||
__mdstr = L"a+b";
|
||||
break;
|
||||
default:
|
||||
__rt = 0;
|
||||
@ -530,7 +656,7 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
}
|
||||
if (__rt)
|
||||
{
|
||||
__file_ = fopen(__s, __mdstr);
|
||||
__file_ = _wfopen(__s, __mdstr);
|
||||
if (__file_)
|
||||
{
|
||||
__om_ = __mode;
|
||||
@ -550,6 +676,7 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
}
|
||||
return __rt;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
@ -1017,8 +1144,17 @@ public:
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
|
||||
: basic_ifstream(__p.c_str(), __mode) {}
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
#endif
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1036,7 +1172,20 @@ public:
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void open(const filesystem::path& __p,
|
||||
ios_base::openmode __mode = ios_base::in) {
|
||||
return open(__p.c_str(), __mode);
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __open(int __fd, ios_base::openmode __mode);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close();
|
||||
@ -1062,6 +1211,17 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openm
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
|
||||
: basic_istream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::in) == 0)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
|
||||
@ -1139,6 +1299,18 @@ basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::in))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
@ -1148,6 +1320,15 @@ basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_ifstream<_CharT, _Traits>::__open(int __fd,
|
||||
ios_base::openmode __mode) {
|
||||
if (__sb_.__open(__fd, __mode | ios_base::in))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
@ -1176,8 +1357,19 @@ public:
|
||||
basic_ofstream();
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
|
||||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
|
||||
: basic_ofstream(__p.c_str(), __mode) {}
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ofstream(basic_ofstream&& __rhs);
|
||||
@ -1194,7 +1386,19 @@ public:
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#endif
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
|
||||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
|
||||
{ return open(__p.c_str(), __mode); }
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __open(int __fd, ios_base::openmode __mode);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close();
|
||||
@ -1220,6 +1424,17 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openm
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
|
||||
: basic_ostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::out) == 0)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
|
||||
@ -1297,6 +1512,18 @@ basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::out))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
@ -1306,6 +1533,15 @@ basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_ofstream<_CharT, _Traits>::__open(int __fd,
|
||||
ios_base::openmode __mode) {
|
||||
if (__sb_.__open(__fd, __mode | ios_base::out))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
@ -1335,8 +1571,19 @@ public:
|
||||
#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);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
|
||||
: basic_fstream(__p.c_str(), __mode) {}
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
#endif
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1354,7 +1601,17 @@ public:
|
||||
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);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out)
|
||||
{ return open(__p.c_str(), __mode); }
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close();
|
||||
@ -1380,6 +1637,17 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmod
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
|
||||
: basic_iostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
if (__sb_.open(__s, __mode) == 0)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
|
||||
@ -1457,6 +1725,18 @@ basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
if (__sb_.open(__s, __mode))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
|
@ -1399,7 +1399,7 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_bad_function_call()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -1818,11 +1818,7 @@ template<class _Rp, class ..._ArgTypes>
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
|
||||
{
|
||||
if ((void *)__f_ == &__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__f_ = 0;
|
||||
*this = nullptr;
|
||||
if (__f.__f_ == 0)
|
||||
__f_ = 0;
|
||||
else if ((void *)__f.__f_ == &__f.__buf_)
|
||||
@ -1842,11 +1838,12 @@ template<class _Rp, class ..._ArgTypes>
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
|
||||
{
|
||||
if ((void *)__f_ == &__buf_)
|
||||
__f_->destroy();
|
||||
else if (__f_)
|
||||
__f_->destroy_deallocate();
|
||||
__base* __t = __f_;
|
||||
__f_ = 0;
|
||||
if ((void *)__t == &__buf_)
|
||||
__t->destroy();
|
||||
else if (__t)
|
||||
__t->destroy_deallocate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -2411,6 +2408,117 @@ __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
|
||||
|
||||
// struct hash<T*> in <memory>
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
pair<_ForwardIterator1, _ForwardIterator1> _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
|
||||
forward_iterator_tag, forward_iterator_tag)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
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 make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
// *__first1 matches *__first2, now match elements after here
|
||||
_ForwardIterator1 __m1 = __first1;
|
||||
_ForwardIterator2 __m2 = __first2;
|
||||
while (true)
|
||||
{
|
||||
if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
|
||||
return make_pair(__first1, __m1);
|
||||
if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
|
||||
return make_pair(__last1, __last1);
|
||||
if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
|
||||
{
|
||||
++__first1;
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_RandomAccessIterator1, _RandomAccessIterator1>
|
||||
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag)
|
||||
{
|
||||
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
|
||||
const _D2 __len2 = __last2 - __first2;
|
||||
if (__len2 == 0)
|
||||
return make_pair(__first1, __first1);
|
||||
const _D1 __len1 = __last1 - __first1;
|
||||
if (__len1 < __len2)
|
||||
return make_pair(__last1, __last1);
|
||||
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__first1 == __s)
|
||||
return make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
|
||||
_RandomAccessIterator1 __m1 = __first1;
|
||||
_RandomAccessIterator2 __m2 = __first2;
|
||||
while (true)
|
||||
{
|
||||
if (++__m2 == __last2)
|
||||
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))
|
||||
{
|
||||
++__first1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
// default searcher
|
||||
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
|
||||
class _LIBCPP_TYPE_VIS default_searcher {
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
|
||||
_BinaryPredicate __p = _BinaryPredicate())
|
||||
: __first_(__f), __last_(__l), __pred_(__p) {}
|
||||
|
||||
template <typename _ForwardIterator2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<_ForwardIterator2, _ForwardIterator2>
|
||||
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
|
||||
{
|
||||
return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
|
||||
typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
|
||||
typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
private:
|
||||
_ForwardIterator __first_;
|
||||
_ForwardIterator __last_;
|
||||
_BinaryPredicate __pred_;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_FUNCTIONAL
|
||||
|
@ -409,7 +409,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
|
||||
#ifdef _LIBCXX_UNDERLYING_TYPE
|
||||
#ifdef _LIBCPP_UNDERLYING_TYPE
|
||||
typedef underlying_type<launch>::type __launch_underlying_type;
|
||||
#else
|
||||
typedef int __launch_underlying_type;
|
||||
@ -514,7 +514,7 @@ public:
|
||||
virtual ~future_error() _NOEXCEPT;
|
||||
};
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
_LIBCPP_AVAILABILITY_FUTURE_ERROR
|
||||
#endif
|
||||
@ -2021,7 +2021,7 @@ public:
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_same<
|
||||
typename decay<_Fp>::type,
|
||||
typename __uncvref<_Fp>::type,
|
||||
packaged_task
|
||||
>::value
|
||||
>::type
|
||||
@ -2032,7 +2032,7 @@ public:
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_same<
|
||||
typename decay<_Fp>::type,
|
||||
typename __uncvref<_Fp>::type,
|
||||
packaged_task
|
||||
>::value
|
||||
>::type
|
||||
@ -2150,7 +2150,7 @@ public:
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_same<
|
||||
typename decay<_Fp>::type,
|
||||
typename __uncvref<_Fp>::type,
|
||||
packaged_task
|
||||
>::value
|
||||
>::type
|
||||
@ -2161,7 +2161,7 @@ public:
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_same<
|
||||
typename decay<_Fp>::type,
|
||||
typename __uncvref<_Fp>::type,
|
||||
packaged_task
|
||||
>::value
|
||||
>::type
|
||||
|
@ -61,7 +61,7 @@ class _LIBCPP_TEMPLATE_VIS initializer_list
|
||||
const _Ep* __begin_;
|
||||
size_t __size_;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
|
||||
: __begin_(__b),
|
||||
@ -76,19 +76,19 @@ public:
|
||||
typedef const _Ep* iterator;
|
||||
typedef const _Ep* const_iterator;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
size_t size() const _NOEXCEPT {return __size_;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Ep* begin() const _NOEXCEPT {return __begin_;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
|
||||
};
|
||||
|
@ -337,9 +337,9 @@ protected:
|
||||
}
|
||||
|
||||
void init(void* __sb);
|
||||
_LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;}
|
||||
_LIBCPP_INLINE_VISIBILITY void* rdbuf() const {return __rdbuf_;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void rdbuf(void* __sb)
|
||||
{
|
||||
__rdbuf_ = __sb;
|
||||
@ -351,7 +351,7 @@ protected:
|
||||
void move(ios_base&);
|
||||
void swap(ios_base&) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void set_rdbuf(void* __sb)
|
||||
{
|
||||
__rdbuf_ = __sb;
|
||||
@ -592,30 +592,33 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
// __true_value will generate undefined references when linking unless
|
||||
// we give it internal linkage.
|
||||
|
||||
#if defined(_LIBCPP_CXX03_LANG)
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator __cxx03_bool::__bool_type() const {
|
||||
return !fail() ? &__cxx03_bool::__true_value : nullptr;
|
||||
}
|
||||
#else
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
|
||||
#endif
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
|
||||
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
|
||||
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
|
||||
_LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);}
|
||||
_LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();}
|
||||
_LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();}
|
||||
_LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();}
|
||||
_LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();}
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();}
|
||||
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();}
|
||||
_LIBCPP_INLINE_VISIBILITY void clear(iostate __state = goodbit) {ios_base::clear(__state);}
|
||||
_LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);}
|
||||
_LIBCPP_INLINE_VISIBILITY bool good() const {return ios_base::good();}
|
||||
_LIBCPP_INLINE_VISIBILITY bool eof() const {return ios_base::eof();}
|
||||
_LIBCPP_INLINE_VISIBILITY bool fail() const {return ios_base::fail();}
|
||||
_LIBCPP_INLINE_VISIBILITY bool bad() const {return ios_base::bad();}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();}
|
||||
_LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);}
|
||||
_LIBCPP_INLINE_VISIBILITY iostate exceptions() const {return ios_base::exceptions();}
|
||||
_LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);}
|
||||
|
||||
// 27.5.4.1 Constructor/destructor:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -649,7 +652,7 @@ public:
|
||||
char_type widen(char __c) const;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ios() {// purposefully does no initialization
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -658,7 +661,7 @@ protected:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void move(basic_ios& __rhs);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void move(basic_ios&& __rhs) {move(__rhs);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -667,7 +670,7 @@ protected:
|
||||
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
|
||||
private:
|
||||
basic_ostream<char_type, traits_type>* __tie_;
|
||||
mutable int_type __fill_;
|
||||
mutable int_type __fill_;
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
|
@ -358,381 +358,162 @@ basic_istream<_CharT, _Traits>::~basic_istream()
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
|
||||
{
|
||||
__input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
typedef num_get<_CharT, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __err, __n);
|
||||
__is.setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
__is.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
|
||||
{
|
||||
return _VSTD::__input_arithmetic<unsigned short>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<unsigned int>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(long& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<long>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<unsigned long>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(long long& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<long long>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<unsigned long long>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(float& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<float>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(double& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<double>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(long double& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<long double>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(bool& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic<bool>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(void*& __n)
|
||||
{
|
||||
return _VSTD::__input_arithmetic<void*>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
__input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
typedef num_get<_CharT, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
|
||||
this->setstate(__err);
|
||||
long __temp;
|
||||
use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __err, __temp);
|
||||
if (__temp < numeric_limits<_Tp>::min())
|
||||
{
|
||||
__err |= ios_base::failbit;
|
||||
__n = numeric_limits<_Tp>::min();
|
||||
}
|
||||
else if (__temp > numeric_limits<_Tp>::max())
|
||||
{
|
||||
__err |= ios_base::failbit;
|
||||
__n = numeric_limits<_Tp>::max();
|
||||
}
|
||||
else
|
||||
__n = static_cast<_Tp>(__temp);
|
||||
__is.setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
__is.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(short& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
long __temp;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp);
|
||||
if (__temp < numeric_limits<short>::min())
|
||||
{
|
||||
__err |= ios_base::failbit;
|
||||
__n = numeric_limits<short>::min();
|
||||
}
|
||||
else if (__temp > numeric_limits<short>::max())
|
||||
{
|
||||
__err |= ios_base::failbit;
|
||||
__n = numeric_limits<short>::max();
|
||||
}
|
||||
else
|
||||
__n = static_cast<short>(__temp);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic_with_numeric_limits<short>(*this, __n);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
basic_istream<_CharT, _Traits>::operator>>(int& __n)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
sentry __s(*this);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<char_type, traits_type> _Ip;
|
||||
typedef num_get<char_type, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
long __temp;
|
||||
use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp);
|
||||
if (__temp < numeric_limits<int>::min())
|
||||
{
|
||||
__err |= ios_base::failbit;
|
||||
__n = numeric_limits<int>::min();
|
||||
}
|
||||
else if (__temp > numeric_limits<int>::max())
|
||||
{
|
||||
__err |= ios_base::failbit;
|
||||
__n = numeric_limits<int>::max();
|
||||
}
|
||||
else
|
||||
__n = static_cast<int>(__temp);
|
||||
this->setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return *this;
|
||||
return _VSTD::__input_arithmetic_with_numeric_limits<int>(*this, __n);
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
@ -960,7 +741,6 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
|
||||
++__gc_;
|
||||
this->rdbuf()->sbumpc();
|
||||
}
|
||||
*__s = char_type();
|
||||
if (__gc_ == 0)
|
||||
__err |= ios_base::failbit;
|
||||
this->setstate(__err);
|
||||
@ -968,10 +748,14 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
|
@ -1217,38 +1217,38 @@ make_move_iterator(_Iter __i)
|
||||
template <class _Iter> class __wrap_iter;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
auto
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
-> decltype(__x.base() - __y.base());
|
||||
@ -1260,7 +1260,7 @@ operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBU
|
||||
#endif
|
||||
|
||||
template <class _Iter>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
__wrap_iter<_Iter>
|
||||
operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT_DEBUG;
|
||||
|
||||
@ -1272,7 +1272,7 @@ template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1,
|
||||
#if _LIBCPP_DEBUG_LEVEL < 2
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
typename enable_if
|
||||
<
|
||||
is_trivially_copy_assignable<_Tp>::value,
|
||||
@ -1283,7 +1283,7 @@ __unwrap_iter(__wrap_iter<_Tp*>);
|
||||
#else
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
typename enable_if
|
||||
<
|
||||
is_trivially_copy_assignable<_Tp>::value,
|
||||
@ -1306,7 +1306,7 @@ public:
|
||||
private:
|
||||
iterator_type __i;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter() _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT_DEBUG
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
: __i{}
|
||||
#endif
|
||||
@ -1315,22 +1315,23 @@ public:
|
||||
__get_db()->__insert_i(this);
|
||||
#endif
|
||||
}
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY __wrap_iter(const __wrap_iter<_Up>& __u,
|
||||
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT_DEBUG
|
||||
: __i(__u.base())
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
__wrap_iter(const __wrap_iter<_Up>& __u,
|
||||
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT_DEBUG
|
||||
: __i(__u.base())
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__iterator_copy(this, &__u);
|
||||
#endif
|
||||
}
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
__wrap_iter(const __wrap_iter& __x)
|
||||
: __i(__x.base())
|
||||
{
|
||||
__get_db()->__iterator_copy(this, &__x);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
__wrap_iter& operator=(const __wrap_iter& __x)
|
||||
{
|
||||
if (this != &__x)
|
||||
@ -1340,13 +1341,13 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
~__wrap_iter()
|
||||
{
|
||||
__get_db()->__erase_i(this);
|
||||
}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT_DEBUG
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
@ -1354,7 +1355,7 @@ public:
|
||||
#endif
|
||||
return *__i;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT_DEBUG
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
@ -1362,7 +1363,7 @@ public:
|
||||
#endif
|
||||
return (pointer)_VSTD::addressof(*__i);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT_DEBUG
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
@ -1371,9 +1372,10 @@ public:
|
||||
++__i;
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter operator++(int) _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT_DEBUG
|
||||
{__wrap_iter __tmp(*this); ++(*this); return __tmp;}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator--() _NOEXCEPT_DEBUG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT_DEBUG
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
|
||||
@ -1382,11 +1384,11 @@ public:
|
||||
--__i;
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter operator--(int) _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT_DEBUG
|
||||
{__wrap_iter __tmp(*this); --(*this); return __tmp;}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter operator+ (difference_type __n) const _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT_DEBUG
|
||||
{__wrap_iter __w(*this); __w += __n; return __w;}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator+=(difference_type __n) _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT_DEBUG
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
|
||||
@ -1395,11 +1397,11 @@ public:
|
||||
__i += __n;
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter operator- (difference_type __n) const _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT_DEBUG
|
||||
{return *this + (-__n);}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator-=(difference_type __n) _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT_DEBUG
|
||||
{*this += -__n; return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const _NOEXCEPT_DEBUG
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT_DEBUG
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
|
||||
@ -1408,67 +1410,68 @@ public:
|
||||
return __i[__n];
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY iterator_type base() const _NOEXCEPT_DEBUG {return __i;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT_DEBUG {return __i;}
|
||||
|
||||
private:
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
|
||||
{
|
||||
__get_db()->__insert_ic(this, __p);
|
||||
}
|
||||
#else
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
|
||||
#endif
|
||||
|
||||
template <class _Up> friend class __wrap_iter;
|
||||
template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
|
||||
template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
|
||||
template <class _Tp, ptrdiff_t> friend class _LIBCPP_TEMPLATE_VIS span;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
bool
|
||||
operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
bool
|
||||
operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
bool
|
||||
operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
bool
|
||||
operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
bool
|
||||
operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
bool
|
||||
operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
auto
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
-> decltype(__x.base() - __y.base());
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
typename __wrap_iter<_Iter1>::difference_type
|
||||
operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
|
||||
#endif
|
||||
|
||||
template <class _Iter1>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
__wrap_iter<_Iter1>
|
||||
operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT_DEBUG;
|
||||
|
||||
@ -1479,7 +1482,7 @@ private:
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL < 2
|
||||
template <class _Tp>
|
||||
friend
|
||||
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
|
||||
typename enable_if
|
||||
<
|
||||
is_trivially_copy_assignable<_Tp>::value,
|
||||
@ -1488,7 +1491,7 @@ private:
|
||||
__unwrap_iter(__wrap_iter<_Tp*>);
|
||||
#else
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
typename enable_if
|
||||
<
|
||||
is_trivially_copy_assignable<_Tp>::value,
|
||||
@ -1499,7 +1502,7 @@ private:
|
||||
};
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1507,7 +1510,7 @@ operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
|
||||
}
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1519,7 +1522,7 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
|
||||
}
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1527,7 +1530,7 @@ operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
|
||||
}
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1535,7 +1538,7 @@ operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
|
||||
}
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1543,7 +1546,7 @@ operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
|
||||
}
|
||||
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1551,7 +1554,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
|
||||
}
|
||||
|
||||
template <class _Iter1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1559,7 +1562,7 @@ operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
|
||||
}
|
||||
|
||||
template <class _Iter1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1567,7 +1570,7 @@ operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXC
|
||||
}
|
||||
|
||||
template <class _Iter1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1575,7 +1578,7 @@ operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
|
||||
}
|
||||
|
||||
template <class _Iter1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
bool
|
||||
operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1584,7 +1587,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
auto
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
-> decltype(__x.base() - __y.base())
|
||||
@ -1597,7 +1600,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
|
||||
}
|
||||
#else
|
||||
template <class _Iter1, class _Iter2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
typename __wrap_iter<_Iter1>::difference_type
|
||||
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
|
||||
{
|
||||
@ -1610,7 +1613,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
|
||||
#endif
|
||||
|
||||
template <class _Iter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
|
||||
__wrap_iter<_Iter>
|
||||
operator+(typename __wrap_iter<_Iter>::difference_type __n,
|
||||
__wrap_iter<_Iter> __x) _NOEXCEPT_DEBUG
|
||||
|
@ -147,6 +147,11 @@ public:
|
||||
void reverse() noexcept;
|
||||
};
|
||||
|
||||
|
||||
template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
||||
list(InputIterator, InputIterator, Allocator = Allocator())
|
||||
-> list<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
|
||||
|
||||
template <class T, class Alloc>
|
||||
bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y);
|
||||
template <class T, class Alloc>
|
||||
@ -527,11 +532,12 @@ class __list_imp
|
||||
{
|
||||
__list_imp(const __list_imp&);
|
||||
__list_imp& operator=(const __list_imp&);
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
public:
|
||||
typedef _Alloc allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
typedef typename __alloc_traits::void_pointer __void_pointer;
|
||||
typedef __list_iterator<value_type, __void_pointer> iterator;
|
||||
typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
|
||||
@ -550,6 +556,9 @@ protected:
|
||||
|
||||
typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
|
||||
typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
|
||||
static_assert((!is_same<allocator_type, __node_allocator>::value),
|
||||
"internal allocator type must differ from user-specified "
|
||||
"type; otherwise overload resolution breaks");
|
||||
|
||||
__node_base __end_;
|
||||
__compressed_pair<size_type, __node_allocator> __size_alloc_;
|
||||
@ -584,6 +593,11 @@ protected:
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_imp(const allocator_type& __a);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_imp(const __node_allocator& __a);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__list_imp(__node_allocator&& __a) _NOEXCEPT;
|
||||
#endif
|
||||
~__list_imp();
|
||||
void clear() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -707,9 +721,18 @@ __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
__list_imp<_Tp, _Alloc>::~__list_imp()
|
||||
{
|
||||
clear();
|
||||
inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
|
||||
: __size_alloc_(0, __a) {}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Tp, class _Alloc>
|
||||
inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
|
||||
: __size_alloc_(0, std::move(__a)) {}
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
__list_imp<_Tp, _Alloc>::~__list_imp() {
|
||||
clear();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__erase_c(this);
|
||||
#endif
|
||||
@ -1106,6 +1129,22 @@ private:
|
||||
void __move_assign(list& __c, false_type);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _InputIterator,
|
||||
class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
list(_InputIterator, _InputIterator)
|
||||
-> list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
|
||||
template<class _InputIterator,
|
||||
class _Alloc,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
list(_InputIterator, _InputIterator, _Alloc)
|
||||
-> list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
#endif
|
||||
|
||||
// Link in nodes [__f, __l] just prior to __p
|
||||
template <class _Tp, class _Alloc>
|
||||
inline
|
||||
@ -1226,10 +1265,8 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
list<_Tp, _Alloc>::list(const list& __c)
|
||||
: base(allocator_type(
|
||||
__node_alloc_traits::select_on_container_copy_construction(
|
||||
__c.__node_alloc())))
|
||||
{
|
||||
: base(__node_alloc_traits::select_on_container_copy_construction(
|
||||
__c.__node_alloc())) {
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
@ -1274,11 +1311,9 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline
|
||||
list<_Tp, _Alloc>::list(list&& __c)
|
||||
inline list<_Tp, _Alloc>::list(list&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
|
||||
: base(allocator_type(_VSTD::move(__c.__node_alloc())))
|
||||
{
|
||||
: base(_VSTD::move(__c.__node_alloc())) {
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
|
@ -573,81 +573,81 @@ public:
|
||||
typedef _CharT char_type;
|
||||
typedef _InputIterator iter_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit num_get(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, bool& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, long& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, long long& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, unsigned short& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, unsigned int& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, unsigned long& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, unsigned long long& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, float& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, double& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, long double& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, void*& __v) const
|
||||
{
|
||||
@ -657,7 +657,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~num_get() {}
|
||||
|
||||
template <class _Fp>
|
||||
@ -768,10 +768,10 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
|
||||
{
|
||||
if (__a != __a_end)
|
||||
{
|
||||
if (*__a == '-')
|
||||
{
|
||||
__err = ios_base::failbit;
|
||||
return 0;
|
||||
const bool __negate = *__a == '-';
|
||||
if (__negate && ++__a == __a_end) {
|
||||
__err = ios_base::failbit;
|
||||
return 0;
|
||||
}
|
||||
typename remove_reference<decltype(errno)>::type __save_errno = errno;
|
||||
errno = 0;
|
||||
@ -785,13 +785,14 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
|
||||
__err = ios_base::failbit;
|
||||
return 0;
|
||||
}
|
||||
else if (__current_errno == ERANGE ||
|
||||
numeric_limits<_Tp>::max() < __ll)
|
||||
else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll)
|
||||
{
|
||||
__err = ios_base::failbit;
|
||||
return numeric_limits<_Tp>::max();
|
||||
}
|
||||
return static_cast<_Tp>(__ll);
|
||||
_Tp __res = static_cast<_Tp>(__ll);
|
||||
if (__negate) __res = -__res;
|
||||
return __res;
|
||||
}
|
||||
__err = ios_base::failbit;
|
||||
return 0;
|
||||
@ -1260,60 +1261,60 @@ public:
|
||||
typedef _CharT char_type;
|
||||
typedef _OutputIterator iter_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit num_put(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
bool __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
long __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
long long __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
unsigned long __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
unsigned long long __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
double __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
long double __v) const
|
||||
{
|
||||
return do_put(__s, __iob, __fl, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
const void* __v) const
|
||||
{
|
||||
@ -1323,7 +1324,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~num_put() {}
|
||||
|
||||
virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
@ -1737,7 +1738,7 @@ protected:
|
||||
virtual const string_type& __x() const;
|
||||
virtual const string_type& __X() const;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~__time_get_c_storage() {}
|
||||
};
|
||||
|
||||
@ -1769,52 +1770,52 @@ public:
|
||||
typedef time_base::dateorder dateorder;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit time_get(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
dateorder date_order() const
|
||||
{
|
||||
return this->do_date_order();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get_time(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, tm* __tm) const
|
||||
{
|
||||
return do_get_time(__b, __e, __iob, __err, __tm);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get_date(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, tm* __tm) const
|
||||
{
|
||||
return do_get_date(__b, __e, __iob, __err, __tm);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get_weekday(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, tm* __tm) const
|
||||
{
|
||||
return do_get_weekday(__b, __e, __iob, __err, __tm);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get_monthname(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, tm* __tm) const
|
||||
{
|
||||
return do_get_monthname(__b, __e, __iob, __err, __tm);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get_year(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, tm* __tm) const
|
||||
{
|
||||
return do_get_year(__b, __e, __iob, __err, __tm);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
|
||||
ios_base::iostate& __err, tm *__tm,
|
||||
char __fmt, char __mod = 0) const
|
||||
@ -1829,7 +1830,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~time_get() {}
|
||||
|
||||
virtual dateorder do_date_order() const;
|
||||
@ -2398,7 +2399,7 @@ protected:
|
||||
explicit __time_get_storage(const char* __nm);
|
||||
explicit __time_get_storage(const string& __nm);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE ~__time_get_storage() {}
|
||||
_LIBCPP_INLINE_VISIBILITY ~__time_get_storage() {}
|
||||
|
||||
time_base::dateorder __do_date_order() const;
|
||||
|
||||
@ -2457,7 +2458,7 @@ class _LIBCPP_TYPE_VIS __time_put
|
||||
{
|
||||
locale_t __loc_;
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
|
||||
_LIBCPP_INLINE_VISIBILITY __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
|
||||
__time_put(const char* __nm);
|
||||
__time_put(const string& __nm);
|
||||
~__time_put();
|
||||
@ -2476,14 +2477,14 @@ public:
|
||||
typedef _CharT char_type;
|
||||
typedef _OutputIterator iter_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit time_put(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm,
|
||||
const char_type* __pb, const char_type* __pe) const;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
|
||||
const tm* __tm, char __fmt, char __mod = 0) const
|
||||
{
|
||||
@ -2493,16 +2494,16 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~time_put() {}
|
||||
virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,
|
||||
char __fmt, char __mod) const;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit time_put(const char* __nm, size_t __refs)
|
||||
: locale::facet(__refs),
|
||||
__time_put(__nm) {}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit time_put(const string& __nm, size_t __refs)
|
||||
: locale::facet(__refs),
|
||||
__time_put(__nm) {}
|
||||
@ -2571,16 +2572,16 @@ class _LIBCPP_TEMPLATE_VIS time_put_byname
|
||||
: public time_put<_CharT, _OutputIterator>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit time_put_byname(const char* __nm, size_t __refs = 0)
|
||||
: time_put<_CharT, _OutputIterator>(__nm, __refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit time_put_byname(const string& __nm, size_t __refs = 0)
|
||||
: time_put<_CharT, _OutputIterator>(__nm, __refs) {}
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~time_put_byname() {}
|
||||
};
|
||||
|
||||
@ -2595,7 +2596,7 @@ public:
|
||||
enum part {none, space, symbol, sign, value};
|
||||
struct pattern {char field[4];};
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE money_base() {}
|
||||
_LIBCPP_INLINE_VISIBILITY money_base() {}
|
||||
};
|
||||
|
||||
// moneypunct
|
||||
@ -2609,25 +2610,25 @@ public:
|
||||
typedef _CharT char_type;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit moneypunct(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
|
||||
_LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
|
||||
_LIBCPP_ALWAYS_INLINE string grouping() const {return do_grouping();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type curr_symbol() const {return do_curr_symbol();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type positive_sign() const {return do_positive_sign();}
|
||||
_LIBCPP_ALWAYS_INLINE string_type negative_sign() const {return do_negative_sign();}
|
||||
_LIBCPP_ALWAYS_INLINE int frac_digits() const {return do_frac_digits();}
|
||||
_LIBCPP_ALWAYS_INLINE pattern pos_format() const {return do_pos_format();}
|
||||
_LIBCPP_ALWAYS_INLINE pattern neg_format() const {return do_neg_format();}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
|
||||
_LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type curr_symbol() const {return do_curr_symbol();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type positive_sign() const {return do_positive_sign();}
|
||||
_LIBCPP_INLINE_VISIBILITY string_type negative_sign() const {return do_negative_sign();}
|
||||
_LIBCPP_INLINE_VISIBILITY int frac_digits() const {return do_frac_digits();}
|
||||
_LIBCPP_INLINE_VISIBILITY pattern pos_format() const {return do_pos_format();}
|
||||
_LIBCPP_INLINE_VISIBILITY pattern neg_format() const {return do_neg_format();}
|
||||
|
||||
static locale::id id;
|
||||
static const bool intl = _International;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~moneypunct() {}
|
||||
|
||||
virtual char_type do_decimal_point() const {return numeric_limits<char_type>::max();}
|
||||
@ -2667,16 +2668,16 @@ public:
|
||||
typedef _CharT char_type;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit moneypunct_byname(const char* __nm, size_t __refs = 0)
|
||||
: moneypunct<_CharT, _International>(__refs) {init(__nm);}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit moneypunct_byname(const string& __nm, size_t __refs = 0)
|
||||
: moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());}
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~moneypunct_byname() {}
|
||||
|
||||
virtual char_type do_decimal_point() const {return __decimal_point_;}
|
||||
@ -2722,7 +2723,7 @@ protected:
|
||||
typedef _CharT char_type;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE __money_get() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __money_get() {}
|
||||
|
||||
static void __gather_info(bool __intl, const locale& __loc,
|
||||
money_base::pattern& __pat, char_type& __dp,
|
||||
@ -2780,18 +2781,18 @@ public:
|
||||
typedef _InputIterator iter_type;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit money_get(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob,
|
||||
ios_base::iostate& __err, long double& __v) const
|
||||
{
|
||||
return do_get(__b, __e, __intl, __iob, __err, __v);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob,
|
||||
ios_base::iostate& __err, string_type& __v) const
|
||||
{
|
||||
@ -2802,7 +2803,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~money_get() {}
|
||||
|
||||
virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
|
||||
@ -3162,7 +3163,7 @@ protected:
|
||||
typedef _CharT char_type;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE __money_put() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __money_put() {}
|
||||
|
||||
static void __gather_info(bool __intl, bool __neg, const locale& __loc,
|
||||
money_base::pattern& __pat, char_type& __dp,
|
||||
@ -3338,18 +3339,18 @@ public:
|
||||
typedef _OutputIterator iter_type;
|
||||
typedef basic_string<char_type> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit money_put(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl,
|
||||
long double __units) const
|
||||
{
|
||||
return do_put(__s, __intl, __iob, __fl, __units);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl,
|
||||
const string_type& __digits) const
|
||||
{
|
||||
@ -3359,7 +3360,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~money_put() {}
|
||||
|
||||
virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
|
||||
@ -3488,7 +3489,7 @@ class _LIBCPP_TYPE_VIS messages_base
|
||||
public:
|
||||
typedef ptrdiff_t catalog;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE messages_base() {}
|
||||
_LIBCPP_INLINE_VISIBILITY messages_base() {}
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
@ -3500,24 +3501,24 @@ public:
|
||||
typedef _CharT char_type;
|
||||
typedef basic_string<_CharT> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit messages(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
catalog open(const basic_string<char>& __nm, const locale& __loc) const
|
||||
{
|
||||
return do_open(__nm, __loc);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
string_type get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dflt) const
|
||||
{
|
||||
return do_get(__c, __set, __msgid, __dflt);
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void close(catalog __c) const
|
||||
{
|
||||
do_close(__c);
|
||||
@ -3526,7 +3527,7 @@ public:
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~messages() {}
|
||||
|
||||
virtual catalog do_open(const basic_string<char>&, const locale&) const;
|
||||
@ -3599,16 +3600,16 @@ public:
|
||||
typedef messages_base::catalog catalog;
|
||||
typedef basic_string<_CharT> string_type;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit messages_byname(const char*, size_t __refs = 0)
|
||||
: messages<_CharT>(__refs) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit messages_byname(const string&, size_t __refs = 0)
|
||||
: messages<_CharT>(__refs) {}
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~messages_byname() {}
|
||||
};
|
||||
|
||||
@ -3636,43 +3637,43 @@ private:
|
||||
wstring_convert(const wstring_convert& __wc);
|
||||
wstring_convert& operator=(const wstring_convert& __wc);
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wstring_convert(_Codecvt* __pcvt, state_type __state);
|
||||
_LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err,
|
||||
const wide_string& __wide_err = wide_string());
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wstring_convert(wstring_convert&& __wc);
|
||||
#endif
|
||||
~wstring_convert();
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wide_string from_bytes(char __byte)
|
||||
{return from_bytes(&__byte, &__byte+1);}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wide_string from_bytes(const char* __ptr)
|
||||
{return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wide_string from_bytes(const byte_string& __str)
|
||||
{return from_bytes(__str.data(), __str.data() + __str.size());}
|
||||
wide_string from_bytes(const char* __first, const char* __last);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
byte_string to_bytes(_Elem __wchar)
|
||||
{return to_bytes(&__wchar, &__wchar+1);}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
byte_string to_bytes(const _Elem* __wptr)
|
||||
{return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
byte_string to_bytes(const wide_string& __wstr)
|
||||
{return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());}
|
||||
byte_string to_bytes(const _Elem* __first, const _Elem* __last);
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t converted() const _NOEXCEPT {return __cvtcount_;}
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
state_type state() const {return __cvtstate_;}
|
||||
};
|
||||
|
||||
|
@ -470,13 +470,13 @@ public:
|
||||
const _Compare& key_comp() const _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _CP& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.__cc.first, __y.__cc.first);}
|
||||
{return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _Key& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.__cc.first, __y);}
|
||||
{return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _CP& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);}
|
||||
{return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
|
||||
void swap(__map_value_compare&__y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
|
||||
{
|
||||
@ -489,13 +489,13 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
||||
operator () ( const _K2& __x, const _CP& __y ) const
|
||||
{return static_cast<const _Compare&>(*this) (__x, __y.__cc.first);}
|
||||
{return static_cast<const _Compare&>(*this) (__x, __y.__get_value().first);}
|
||||
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
||||
operator () (const _CP& __x, const _K2& __y) const
|
||||
{return static_cast<const _Compare&>(*this) (__x.__cc.first, __y);}
|
||||
{return static_cast<const _Compare&>(*this) (__x.__get_value().first, __y);}
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -518,13 +518,13 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _CP& __y) const
|
||||
{return comp(__x.__cc.first, __y.__cc.first);}
|
||||
{return comp(__x.__get_value().first, __y.__get_value().first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _Key& __y) const
|
||||
{return comp(__x.__cc.first, __y);}
|
||||
{return comp(__x.__get_value().first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _CP& __y) const
|
||||
{return comp(__x, __y.__cc.first);}
|
||||
{return comp(__x, __y.__get_value().first);}
|
||||
void swap(__map_value_compare&__y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
|
||||
{
|
||||
@ -537,13 +537,13 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
||||
operator () ( const _K2& __x, const _CP& __y ) const
|
||||
{return comp (__x, __y.__cc.first);}
|
||||
{return comp (__x, __y.__get_value().first);}
|
||||
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
||||
operator () (const _CP& __x, const _K2& __y) const
|
||||
{return comp (__x.__cc.first, __y);}
|
||||
{return comp (__x.__get_value().first, __y);}
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -597,9 +597,9 @@ public:
|
||||
void operator()(pointer __p) _NOEXCEPT
|
||||
{
|
||||
if (__second_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
|
||||
if (__first_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
|
||||
if (__p)
|
||||
__alloc_traits::deallocate(__na_, __p, 1);
|
||||
}
|
||||
@ -614,23 +614,67 @@ template <class _TreeIterator> class __map_const_iterator;
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Key, class _Tp>
|
||||
union __value_type
|
||||
struct __value_type
|
||||
{
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
|
||||
typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
|
||||
|
||||
private:
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type& __get_value()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
return *_VSTD::launder(_VSTD::addressof(__cc));
|
||||
#else
|
||||
return __cc;
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type& __get_value() const
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
return *_VSTD::launder(_VSTD::addressof(__cc));
|
||||
#else
|
||||
return __cc;
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__nc_ref_pair_type __ref()
|
||||
{
|
||||
value_type& __v = __get_value();
|
||||
return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__nc_rref_pair_type __move()
|
||||
{
|
||||
value_type& __v = __get_value();
|
||||
return __nc_rref_pair_type(
|
||||
_VSTD::move(const_cast<key_type&>(__v.first)),
|
||||
_VSTD::move(__v.second));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type& operator=(const __value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
{
|
||||
__ref() = __v.__get_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type& operator=(__value_type&& __v)
|
||||
{__nc = _VSTD::move(__v.__nc); return *this;}
|
||||
{
|
||||
__ref() = __v.__move();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _ValueTp,
|
||||
class = typename enable_if<
|
||||
@ -638,8 +682,10 @@ union __value_type
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__value_type& operator=(_ValueTp&& __v) {
|
||||
__nc = _VSTD::forward<_ValueTp>(__v); return *this;
|
||||
__value_type& operator=(_ValueTp&& __v)
|
||||
{
|
||||
__ref() = _VSTD::forward<_ValueTp>(__v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -658,8 +704,15 @@ struct __value_type
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
|
||||
private:
|
||||
value_type __cc;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type& __get_value() { return __cc; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type& __get_value() const { return __cc; }
|
||||
|
||||
private:
|
||||
__value_type();
|
||||
__value_type(__value_type const&);
|
||||
@ -701,9 +754,9 @@ public:
|
||||
__map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
reference operator*() const {return __i_->__get_value();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_iterator& operator++() {++__i_; return *this;}
|
||||
@ -764,9 +817,9 @@ public:
|
||||
: __i_(__i.__i_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
reference operator*() const {return __i_->__get_value();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_const_iterator& operator++() {++__i_; return *this;}
|
||||
@ -809,7 +862,6 @@ public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Allocator allocator_type;
|
||||
typedef value_type& reference;
|
||||
@ -1228,7 +1280,7 @@ public:
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
|
||||
count(const _K2& __k) const {return __tree_.__count_unique(__k);}
|
||||
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
@ -1275,11 +1327,11 @@ public:
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
|
||||
equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);}
|
||||
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
|
||||
equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
|
||||
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
|
||||
#endif
|
||||
|
||||
private:
|
||||
@ -1308,7 +1360,7 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
|
||||
const_iterator __e = cend();
|
||||
while (!__m.empty())
|
||||
__tree_.__insert_unique(__e.__i_,
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__nc));
|
||||
__m.__tree_.remove(__m.begin().__i_)->__value_.__move());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1319,7 +1371,7 @@ 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;
|
||||
_VSTD::forward_as_tuple()).first->__get_value().second;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
@ -1329,7 +1381,7 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
|
||||
return __tree_.__emplace_unique_key_args(__k,
|
||||
_VSTD::piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||
_VSTD::forward_as_tuple()).first->__cc.second;
|
||||
_VSTD::forward_as_tuple()).first->__get_value().second;
|
||||
}
|
||||
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
@ -1340,9 +1392,9 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type&
|
||||
{
|
||||
__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), __k);
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
|
||||
}
|
||||
@ -1360,7 +1412,7 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
|
||||
__tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
}
|
||||
return __r->__value_.__cc.second;
|
||||
return __r->__value_.__get_value().second;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
@ -1375,7 +1427,7 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
|
||||
if (__child == nullptr)
|
||||
throw out_of_range("map::at: key not found");
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return static_cast<__node_pointer>(__child)->__value_.__cc.second;
|
||||
return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
@ -1388,7 +1440,7 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
|
||||
if (__child == nullptr)
|
||||
throw out_of_range("map::at: key not found");
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return static_cast<__node_pointer>(__child)->__value_.__cc.second;
|
||||
return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
|
||||
}
|
||||
|
||||
|
||||
@ -1465,7 +1517,6 @@ public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Allocator allocator_type;
|
||||
typedef value_type& reference;
|
||||
@ -1852,7 +1903,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca
|
||||
const_iterator __e = cend();
|
||||
while (!__m.empty())
|
||||
__tree_.__insert_multi(__e.__i_,
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__nc));
|
||||
_VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -314,7 +314,7 @@ extern "C++" {
|
||||
#ifdef signbit
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -376,7 +376,7 @@ signbit(_A1) _NOEXCEPT
|
||||
#ifdef fpclassify
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int
|
||||
__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -422,7 +422,7 @@ fpclassify(_A1 __lcpp_x) _NOEXCEPT
|
||||
#ifdef isfinite
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -456,7 +456,7 @@ isfinite(_A1) _NOEXCEPT
|
||||
#ifdef isinf
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -483,6 +483,20 @@ typename std::enable_if<
|
||||
isinf(_A1) _NOEXCEPT
|
||||
{ return false; }
|
||||
|
||||
#ifdef _LIBCPP_PREFERRED_OVERLOAD
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
bool
|
||||
isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
|
||||
#endif
|
||||
|
||||
#endif // isinf
|
||||
|
||||
// isnan
|
||||
@ -490,7 +504,7 @@ isinf(_A1) _NOEXCEPT
|
||||
#ifdef isnan
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -513,6 +527,20 @@ typename std::enable_if<std::is_integral<_A1>::value, bool>::type
|
||||
isnan(_A1) _NOEXCEPT
|
||||
{ return false; }
|
||||
|
||||
#ifdef _LIBCPP_PREFERRED_OVERLOAD
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
|
||||
bool
|
||||
isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
|
||||
#endif
|
||||
|
||||
#endif // isnan
|
||||
|
||||
// isnormal
|
||||
@ -520,7 +548,7 @@ isnan(_A1) _NOEXCEPT
|
||||
#ifdef isnormal
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
@ -550,7 +578,7 @@ isnormal(_A1 __lcpp_x) _NOEXCEPT
|
||||
#ifdef isgreater
|
||||
|
||||
template <class _A1, class _A2>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
{
|
||||
@ -580,7 +608,7 @@ isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
#ifdef isgreaterequal
|
||||
|
||||
template <class _A1, class _A2>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
{
|
||||
@ -610,7 +638,7 @@ isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
#ifdef isless
|
||||
|
||||
template <class _A1, class _A2>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
{
|
||||
@ -640,7 +668,7 @@ isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
#ifdef islessequal
|
||||
|
||||
template <class _A1, class _A2>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
{
|
||||
@ -670,7 +698,7 @@ islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
#ifdef islessgreater
|
||||
|
||||
template <class _A1, class _A2>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
{
|
||||
@ -700,7 +728,7 @@ islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
#ifdef isunordered
|
||||
|
||||
template <class _A1, class _A2>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
|
||||
{
|
||||
@ -1486,4 +1514,18 @@ trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#else // _LIBCPP_MATH_H
|
||||
|
||||
// This include lives outside the header guard in order to support an MSVC
|
||||
// extension which allows users to do:
|
||||
//
|
||||
// #define _USE_MATH_DEFINES
|
||||
// #include <math.h>
|
||||
//
|
||||
// and receive the definitions of mathematical constants, even if <math.h>
|
||||
// has previously been included.
|
||||
#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
|
||||
#include_next <math.h>
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_MATH_H
|
||||
|
@ -126,9 +126,10 @@ public:
|
||||
|
||||
template <class U> struct rebind {typedef allocator<U> other;};
|
||||
|
||||
allocator() noexcept;
|
||||
allocator(const allocator&) noexcept;
|
||||
template <class U> allocator(const allocator<U>&) noexcept;
|
||||
constexpr allocator() noexcept; // constexpr in C++20
|
||||
constexpr allocator(const allocator&) noexcept; // constexpr in C++20
|
||||
template <class U>
|
||||
constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
|
||||
~allocator();
|
||||
pointer address(reference x) const noexcept;
|
||||
const_pointer address(const_reference x) const noexcept;
|
||||
@ -678,7 +679,7 @@ _LIBCPP_PUSH_MACROS
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
|
||||
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
|
||||
defined(__ATOMIC_RELAXED) && \
|
||||
@ -690,7 +691,7 @@ _ValueType __libcpp_relaxed_load(_ValueType const* __value) {
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_ALWAYS_INLINE
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_acquire_load(_ValueType const* __value) {
|
||||
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
|
||||
defined(__ATOMIC_ACQUIRE) && \
|
||||
@ -1778,8 +1779,13 @@ public:
|
||||
|
||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator() _NOEXCEPT {}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
@ -1790,10 +1796,10 @@ public:
|
||||
if (__n > max_size())
|
||||
__throw_length_error("allocator<T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size");
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), __alignof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{_VSTD::__libcpp_deallocate((void*)__p);}
|
||||
{_VSTD::__libcpp_deallocate((void*)__p, __alignof(_Tp));}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
@ -1877,8 +1883,13 @@ public:
|
||||
|
||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator() _NOEXCEPT {}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||
|
||||
_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)
|
||||
@ -1886,10 +1897,10 @@ public:
|
||||
if (__n > max_size())
|
||||
__throw_length_error("allocator<const T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size");
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), __alignof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p));}
|
||||
{_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __alignof(_Tp));}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
@ -1992,6 +2003,7 @@ public:
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_NO_CFI
|
||||
pair<_Tp*, ptrdiff_t>
|
||||
get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
|
||||
{
|
||||
@ -2003,7 +2015,28 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
|
||||
__n = __m;
|
||||
while (__n > 0)
|
||||
{
|
||||
#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
|
||||
if (__is_overaligned_for_new(__alignof(_Tp)))
|
||||
{
|
||||
std::align_val_t __al =
|
||||
std::align_val_t(std::alignment_of<_Tp>::value);
|
||||
__r.first = static_cast<_Tp*>(::operator new(
|
||||
__n * sizeof(_Tp), __al, nothrow));
|
||||
} else {
|
||||
__r.first = static_cast<_Tp*>(::operator new(
|
||||
__n * sizeof(_Tp), nothrow));
|
||||
}
|
||||
#else
|
||||
if (__is_overaligned_for_new(__alignof(_Tp)))
|
||||
{
|
||||
// Since aligned operator new is unavailable, return an empty
|
||||
// buffer rather than one with invalid alignment.
|
||||
return __r;
|
||||
}
|
||||
|
||||
__r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
|
||||
#endif
|
||||
|
||||
if (__r.first)
|
||||
{
|
||||
__r.second = __n;
|
||||
@ -2016,7 +2049,10 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);}
|
||||
void return_temporary_buffer(_Tp* __p) _NOEXCEPT
|
||||
{
|
||||
_VSTD::__libcpp_deallocate((void*)__p, __alignof(_Tp));
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
|
||||
template <class _Tp>
|
||||
@ -3447,7 +3483,7 @@ public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_bad_weak_ptr()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -4757,8 +4793,13 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
typedef typename common_type<_Tp*, _Up*>::type _Vp;
|
||||
return less<_Vp>()(__x.get(), __y.get());
|
||||
#else
|
||||
return less<>()(__x.get(), __y.get());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
@ -5597,6 +5638,16 @@ struct __temp_value {
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename _Alloc, typename = void, typename = void>
|
||||
struct __is_allocator : false_type {};
|
||||
|
||||
template<typename _Alloc>
|
||||
struct __is_allocator<_Alloc,
|
||||
typename __void_t<typename _Alloc::value_type>::type,
|
||||
typename __void_t<decltype(_VSTD::declval<_Alloc&>().allocate(size_t(0)))>::type
|
||||
>
|
||||
: true_type {};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
@ -243,6 +243,10 @@ module std [system] {
|
||||
header "codecvt"
|
||||
export *
|
||||
}
|
||||
module compare {
|
||||
header "compare"
|
||||
export *
|
||||
}
|
||||
module complex {
|
||||
header "complex"
|
||||
export *
|
||||
@ -260,6 +264,10 @@ module std [system] {
|
||||
header "exception"
|
||||
export *
|
||||
}
|
||||
module filesystem {
|
||||
header "filesystem"
|
||||
export *
|
||||
}
|
||||
module forward_list {
|
||||
header "forward_list"
|
||||
export initializer_list
|
||||
@ -470,10 +478,15 @@ module std [system] {
|
||||
export initializer_list
|
||||
export *
|
||||
}
|
||||
module version {
|
||||
header "version"
|
||||
export *
|
||||
}
|
||||
|
||||
// FIXME: These should be private.
|
||||
module __bit_reference { header "__bit_reference" export * }
|
||||
module __debug { header "__debug" export * }
|
||||
module __errc { header "__errc" export * }
|
||||
module __functional_base { header "__functional_base" export * }
|
||||
module __hash_table { header "__hash_table" export * }
|
||||
module __locale { header "__locale" export * }
|
||||
@ -492,14 +505,6 @@ module std [system] {
|
||||
module algorithm {
|
||||
header "experimental/algorithm"
|
||||
export *
|
||||
}
|
||||
module any {
|
||||
header "experimental/any"
|
||||
export *
|
||||
}
|
||||
module chrono {
|
||||
header "experimental/chrono"
|
||||
export *
|
||||
}
|
||||
module coroutine {
|
||||
requires coroutines
|
||||
@ -542,46 +547,30 @@ module std [system] {
|
||||
header "experimental/memory_resource"
|
||||
export *
|
||||
}
|
||||
module numeric {
|
||||
header "experimental/numeric"
|
||||
export *
|
||||
}
|
||||
module optional {
|
||||
header "experimental/optional"
|
||||
export *
|
||||
}
|
||||
module propagate_const {
|
||||
header "experimental/propagate_const"
|
||||
export *
|
||||
}
|
||||
module ratio {
|
||||
header "experimental/ratio"
|
||||
export *
|
||||
}
|
||||
module regex {
|
||||
header "experimental/regex"
|
||||
export *
|
||||
}
|
||||
module simd {
|
||||
header "experimental/simd"
|
||||
export *
|
||||
}
|
||||
module set {
|
||||
header "experimental/set"
|
||||
export *
|
||||
}
|
||||
module span {
|
||||
header "span"
|
||||
export *
|
||||
}
|
||||
module string {
|
||||
header "experimental/string"
|
||||
export *
|
||||
}
|
||||
module string_view {
|
||||
header "experimental/string_view"
|
||||
export *
|
||||
}
|
||||
module system_error {
|
||||
header "experimental/system_error"
|
||||
export *
|
||||
}
|
||||
module tuple {
|
||||
header "experimental/tuple"
|
||||
export *
|
||||
}
|
||||
module type_traits {
|
||||
header "experimental/type_traits"
|
||||
export *
|
||||
|
@ -89,6 +89,7 @@ void operator delete[](void* ptr, void*) noexcept;
|
||||
|
||||
#include <__config>
|
||||
#include <exception>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
#ifdef _LIBCPP_NO_EXCEPTIONS
|
||||
#include <cstdlib>
|
||||
@ -113,6 +114,14 @@ void operator delete[](void* ptr, void*) noexcept;
|
||||
# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
#endif
|
||||
|
||||
|
||||
#if !__has_builtin(__builtin_operator_new) || \
|
||||
__has_builtin(__builtin_operator_new) < 201802L || \
|
||||
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
|
||||
!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606
|
||||
#define _LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE
|
||||
#endif
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
@ -160,6 +169,7 @@ public:
|
||||
|
||||
#endif // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || _LIBCPP_STD_VER > 14
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
|
||||
@ -167,6 +177,7 @@ enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
|
||||
enum align_val_t { __zero = 0, __max = (size_t)-1 };
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // std
|
||||
|
||||
@ -221,7 +232,27 @@ inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
|
||||
_LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
|
||||
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
|
||||
return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
|
||||
#else
|
||||
return __align > alignment_of<max_align_t>::value;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY void *__libcpp_allocate(size_t __size, size_t __align) {
|
||||
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
if (__is_overaligned_for_new(__align)) {
|
||||
const align_val_t __align_val = static_cast<align_val_t>(__align);
|
||||
# ifdef _LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE
|
||||
return ::operator new(__size, __align_val);
|
||||
# else
|
||||
return __builtin_operator_new(__size, __align_val);
|
||||
# endif
|
||||
}
|
||||
#else
|
||||
((void)__align);
|
||||
#endif
|
||||
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||
return ::operator new(__size);
|
||||
#else
|
||||
@ -229,16 +260,28 @@ inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void *__ptr) {
|
||||
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||
::operator delete(__ptr);
|
||||
inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void* __ptr, size_t __align) {
|
||||
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
if (__is_overaligned_for_new(__align)) {
|
||||
const align_val_t __align_val = static_cast<align_val_t>(__align);
|
||||
# ifdef _LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE
|
||||
return ::operator delete(__ptr, __align_val);
|
||||
# else
|
||||
return __builtin_operator_delete(__ptr, __align_val);
|
||||
# endif
|
||||
}
|
||||
#else
|
||||
__builtin_operator_delete(__ptr);
|
||||
((void)__align);
|
||||
#endif
|
||||
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||
return ::operator delete(__ptr);
|
||||
#else
|
||||
return __builtin_operator_delete(__ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
_LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
|
||||
#endif
|
||||
|
@ -51,7 +51,7 @@ template<class InputIterator1, class InputIterator2, class T>
|
||||
T
|
||||
transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init); // C++17
|
||||
|
||||
|
||||
template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
|
||||
T
|
||||
transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
@ -75,10 +75,10 @@ template<class InputIterator, class OutputIterator, class T>
|
||||
OutputIterator
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init); // C++17
|
||||
|
||||
|
||||
template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
|
||||
OutputIterator
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init, BinaryOperation binary_op); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
@ -108,7 +108,7 @@ template<class InputIterator, class OutputIterator,
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
|
||||
|
||||
|
||||
template<class InputIterator, class OutputIterator,
|
||||
class BinaryOperation, class UnaryOperation, class T>
|
||||
OutputIterator
|
||||
@ -196,7 +196,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename iterator_traits<_InputIterator>::value_type
|
||||
reduce(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
return _VSTD::reduce(__first, __last,
|
||||
return _VSTD::reduce(__first, __last,
|
||||
typename iterator_traits<_InputIterator>::value_type{});
|
||||
}
|
||||
#endif
|
||||
@ -226,7 +226,7 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2
|
||||
template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
transform_reduce(_InputIterator __first, _InputIterator __last,
|
||||
transform_reduce(_InputIterator __first, _InputIterator __last,
|
||||
_Tp __init, _BinaryOp __b, _UnaryOp __u)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
@ -234,7 +234,7 @@ transform_reduce(_InputIterator __first, _InputIterator __last,
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2,
|
||||
template <class _InputIterator1, class _InputIterator2,
|
||||
class _Tp, class _BinaryOp1, class _BinaryOp2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
@ -249,10 +249,10 @@ transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init)
|
||||
{
|
||||
return _VSTD::transform_reduce(__first1, __last1, __first2, __init,
|
||||
return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init),
|
||||
_VSTD::plus<>(), _VSTD::multiplies<>());
|
||||
}
|
||||
#endif
|
||||
@ -298,7 +298,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp __init, _BinaryOp __b)
|
||||
{
|
||||
if (__first != __last)
|
||||
@ -318,14 +318,14 @@ exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp __init)
|
||||
{
|
||||
return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b, _Tp __init)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result) {
|
||||
@ -336,7 +336,7 @@ _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOp>
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b)
|
||||
{
|
||||
if (__first != __last) {
|
||||
@ -350,17 +350,17 @@ _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result)
|
||||
{
|
||||
return _VSTD::inclusive_scan(__first, __last, __result, std::plus<>());
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOp, class _UnaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp __init,
|
||||
_BinaryOp __b, _UnaryOp __u)
|
||||
{
|
||||
@ -379,7 +379,7 @@ transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
|
||||
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result) {
|
||||
@ -391,7 +391,7 @@ _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
|
||||
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
|
||||
{
|
||||
if (__first != __last) {
|
||||
@ -400,7 +400,7 @@ _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator
|
||||
if (++__first != __last)
|
||||
return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
|
||||
}
|
||||
|
||||
|
||||
return __result;
|
||||
}
|
||||
#endif
|
||||
|
@ -139,6 +139,10 @@ namespace std {
|
||||
private:
|
||||
T *val; // exposition only
|
||||
};
|
||||
|
||||
template<class T>
|
||||
optional(T) -> optional<T>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
@ -612,8 +616,8 @@ private:
|
||||
};
|
||||
template <class _Up>
|
||||
using _CheckOptionalArgsCtor = conditional_t<
|
||||
!is_same_v<decay_t<_Up>, in_place_t> &&
|
||||
!is_same_v<decay_t<_Up>, optional>,
|
||||
!is_same_v<__uncvref_t<_Up>, in_place_t> &&
|
||||
!is_same_v<__uncvref_t<_Up>, optional>,
|
||||
_CheckOptionalArgsConstructor,
|
||||
__check_tuple_constructor_fail
|
||||
>;
|
||||
@ -761,7 +765,7 @@ public:
|
||||
class = enable_if_t
|
||||
<__lazy_and<
|
||||
integral_constant<bool,
|
||||
!is_same_v<decay_t<_Up>, optional> &&
|
||||
!is_same_v<__uncvref_t<_Up>, optional> &&
|
||||
!(is_same_v<_Up, value_type> && is_scalar_v<value_type>)
|
||||
>,
|
||||
is_constructible<value_type, _Up>,
|
||||
@ -1003,6 +1007,11 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class T>
|
||||
optional(T) -> optional<T>;
|
||||
#endif
|
||||
|
||||
// Comparisons between optionals
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr
|
||||
|
@ -232,7 +232,7 @@ public:
|
||||
basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
|
||||
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream() {} // extension, intentially does not initialize
|
||||
};
|
||||
|
||||
@ -249,7 +249,7 @@ public:
|
||||
explicit sentry(basic_ostream<_CharT, _Traits>& __os);
|
||||
~sentry();
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT
|
||||
operator bool() const {return __ok_;}
|
||||
};
|
||||
@ -1071,19 +1071,17 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
|
||||
return __os << __p.get();
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DECLTYPE
|
||||
template<class _CharT, class _Traits, class _Yp, class _Dp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_same<void, typename __void_t<decltype(declval<basic_ostream<_CharT, _Traits>&>() << declval<_Yp>())>::type>::value,
|
||||
is_same<void, typename __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))>::type>::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
|
||||
{
|
||||
return __os << __p.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits, size_t _Size>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
|
@ -69,6 +69,12 @@ public:
|
||||
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
|
||||
};
|
||||
|
||||
template<class Container>
|
||||
queue(Container) -> queue<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template<class Container, class Allocator>
|
||||
queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template <class T, class Container>
|
||||
bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
|
||||
|
||||
@ -157,6 +163,20 @@ public:
|
||||
is_nothrow_swappable_v<Comp>)
|
||||
};
|
||||
|
||||
template <class Compare, class Container>
|
||||
priority_queue(Compare, Container)
|
||||
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
|
||||
|
||||
template<class InputIterator,
|
||||
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
|
||||
class Container = vector<typename iterator_traits<InputIterator>::value_type>>
|
||||
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
|
||||
-> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
|
||||
|
||||
template<class Compare, class Container, class Allocator>
|
||||
priority_queue(Compare, Container, Allocator)
|
||||
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
|
||||
|
||||
template <class T, class Container, class Compare>
|
||||
void swap(priority_queue<T, Container, Compare>& x,
|
||||
priority_queue<T, Container, Compare>& y)
|
||||
@ -290,7 +310,7 @@ public:
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
reference emplace(_Args&&... __args)
|
||||
decltype(auto) emplace(_Args&&... __args)
|
||||
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#else
|
||||
void emplace(_Args&&... __args)
|
||||
@ -321,6 +341,22 @@ public:
|
||||
operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _Container,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
|
||||
>
|
||||
queue(_Container)
|
||||
-> queue<typename _Container::value_type, _Container>;
|
||||
|
||||
template<class _Container,
|
||||
class _Alloc,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
|
||||
class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
|
||||
>
|
||||
queue(_Container, _Alloc)
|
||||
-> queue<typename _Container::value_type, _Container>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
@ -515,6 +551,36 @@ public:
|
||||
__is_nothrow_swappable<value_compare>::value);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template <class _Compare,
|
||||
class _Container,
|
||||
class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
|
||||
>
|
||||
priority_queue(_Compare, _Container)
|
||||
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
|
||||
|
||||
template<class _InputIterator,
|
||||
class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
|
||||
class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
|
||||
class = typename enable_if< __is_input_iterator<_InputIterator>::value, nullptr_t>::type,
|
||||
class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
|
||||
>
|
||||
priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
|
||||
-> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
|
||||
|
||||
template<class _Compare,
|
||||
class _Container,
|
||||
class _Alloc,
|
||||
class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
|
||||
class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
|
||||
>
|
||||
priority_queue(_Compare, _Container, _Alloc)
|
||||
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Container, class _Compare>
|
||||
inline
|
||||
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
|
||||
|
@ -4673,7 +4673,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
|
||||
double __py;
|
||||
if (__x < 10)
|
||||
{
|
||||
const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
|
||||
const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
|
||||
40320, 362880};
|
||||
__px = -__pr.__mean_;
|
||||
__py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];
|
||||
|
@ -192,6 +192,11 @@ public:
|
||||
void swap(basic_regex&);
|
||||
};
|
||||
|
||||
template<class ForwardIterator>
|
||||
basic_regex(ForwardIterator, ForwardIterator,
|
||||
regex_constants::syntax_option_type = regex_constants::ECMAScript)
|
||||
-> basic_regex<typename iterator_traits<ForwardIterator>::value_type>; // C++17
|
||||
|
||||
typedef basic_regex<char> regex;
|
||||
typedef basic_regex<wchar_t> wregex;
|
||||
|
||||
@ -963,7 +968,7 @@ public:
|
||||
};
|
||||
|
||||
template <regex_constants::error_type _Ev>
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_regex_error()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2922,6 +2927,15 @@ private:
|
||||
template <class, class> friend class __lookahead;
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template <class _ForwardIterator,
|
||||
class = typename enable_if<__is_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
|
||||
>
|
||||
basic_regex(_ForwardIterator, _ForwardIterator,
|
||||
regex_constants::syntax_option_type = regex_constants::ECMAScript)
|
||||
-> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
|
||||
template <class _CharT, class _Traits>
|
||||
@ -4013,7 +4027,7 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
|
||||
char_class_type __class_type =
|
||||
__traits_.lookup_classname(__first, __temp, __flags_ & icase);
|
||||
if (__class_type == 0)
|
||||
__throw_regex_error<regex_constants::error_brack>();
|
||||
__throw_regex_error<regex_constants::error_ctype>();
|
||||
__ml->__add_class(__class_type);
|
||||
__first = _VSTD::next(__temp, 2);
|
||||
return __first;
|
||||
|
@ -668,7 +668,7 @@ public:
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
|
||||
count(const _K2& __k) const {return __tree_.__count_unique(__k);}
|
||||
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
@ -715,11 +715,11 @@ public:
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
|
||||
equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);}
|
||||
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
|
||||
equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
|
||||
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -1077,7 +1077,7 @@ public:
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
|
||||
count(const _K2& __k) {return __tree_.__count_multi(__k);}
|
||||
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
608
contrib/libc++/include/span
Normal file
608
contrib/libc++/include/span
Normal file
@ -0,0 +1,608 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------------ span ---------------------------------===//
|
||||
//
|
||||
// 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_SPAN
|
||||
#define _LIBCPP_SPAN
|
||||
|
||||
/*
|
||||
span synopsis
|
||||
|
||||
namespace std {
|
||||
|
||||
// constants
|
||||
inline constexpr ptrdiff_t dynamic_extent = -1;
|
||||
|
||||
// [views.span], class template span
|
||||
template <class ElementType, ptrdiff_t Extent = dynamic_extent>
|
||||
class span;
|
||||
|
||||
// [span.comparison], span comparison operators
|
||||
template <class T, ptrdiff_t X, class U, ptrdiff_t Y>
|
||||
constexpr bool operator==(span<T, X> l, span<U, Y> r);
|
||||
template <class T, ptrdiff_t X, class U, ptrdiff_t Y>
|
||||
constexpr bool operator!=(span<T, X> l, span<U, Y> r);
|
||||
template <class T, ptrdiff_t X, class U, ptrdiff_t Y>
|
||||
constexpr bool operator<(span<T, X> l, span<U, Y> r);
|
||||
template <class T, ptrdiff_t X, class U, ptrdiff_t Y>
|
||||
constexpr bool operator<=(span<T, X> l, span<U, Y> r);
|
||||
template <class T, ptrdiff_t X, class U, ptrdiff_t Y>
|
||||
constexpr bool operator>(span<T, X> l, span<U, Y> r);
|
||||
template <class T, ptrdiff_t X, class U, ptrdiff_t Y>
|
||||
constexpr bool operator>=(span<T, X> l, span<U, Y> r);
|
||||
|
||||
// [span.objectrep], views of object representation
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
span<const byte, ((Extent == dynamic_extent) ? dynamic_extent :
|
||||
(static_cast<ptrdiff_t>(sizeof(ElementType)) * Extent))> as_bytes(span<ElementType, Extent> s) noexcept;
|
||||
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
span< byte, ((Extent == dynamic_extent) ? dynamic_extent :
|
||||
(static_cast<ptrdiff_t>(sizeof(ElementType)) * Extent))> as_writable_bytes(span<ElementType, Extent> s) noexcept;
|
||||
|
||||
|
||||
namespace std {
|
||||
template <class ElementType, ptrdiff_t Extent = dynamic_extent>
|
||||
class span {
|
||||
public:
|
||||
// constants and types
|
||||
using element_type = ElementType;
|
||||
using value_type = remove_cv_t<ElementType>;
|
||||
using index_type = ptrdiff_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = element_type*;
|
||||
using reference = element_type&;
|
||||
using iterator = implementation-defined;
|
||||
using const_iterator = implementation-defined;
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
static constexpr index_type extent = Extent;
|
||||
|
||||
// [span.cons], span constructors, copy, assignment, and destructor
|
||||
constexpr span() noexcept;
|
||||
constexpr span(pointer ptr, index_type count);
|
||||
constexpr span(pointer firstElem, pointer lastElem);
|
||||
template <size_t N>
|
||||
constexpr span(element_type (&arr)[N]) noexcept;
|
||||
template <size_t N>
|
||||
constexpr span(array<value_type, N>& arr) noexcept;
|
||||
template <size_t N>
|
||||
constexpr span(const array<value_type, N>& arr) noexcept;
|
||||
template <class Container>
|
||||
constexpr span(Container& cont);
|
||||
template <class Container>
|
||||
constexpr span(const Container& cont);
|
||||
constexpr span(const span& other) noexcept = default;
|
||||
template <class OtherElementType, ptrdiff_t OtherExtent>
|
||||
constexpr span(const span<OtherElementType, OtherExtent>& s) noexcept;
|
||||
~span() noexcept = default;
|
||||
constexpr span& operator=(const span& other) noexcept = default;
|
||||
|
||||
// [span.sub], span subviews
|
||||
template <ptrdiff_t Count>
|
||||
constexpr span<element_type, Count> first() const;
|
||||
template <ptrdiff_t Count>
|
||||
constexpr span<element_type, Count> last() const;
|
||||
template <ptrdiff_t Offset, ptrdiff_t Count = dynamic_extent>
|
||||
constexpr span<element_type, see below> subspan() const;
|
||||
|
||||
constexpr span<element_type, dynamic_extent> first(index_type count) const;
|
||||
constexpr span<element_type, dynamic_extent> last(index_type count) const;
|
||||
constexpr span<element_type, dynamic_extent> subspan(index_type offset, index_type count = dynamic_extent) const;
|
||||
|
||||
// [span.obs], span observers
|
||||
constexpr index_type size() const noexcept;
|
||||
constexpr index_type size_bytes() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// [span.elem], span element access
|
||||
constexpr reference operator[](index_type idx) const;
|
||||
constexpr reference operator()(index_type idx) const;
|
||||
constexpr pointer data() const noexcept;
|
||||
|
||||
// [span.iterators], span iterator support
|
||||
constexpr iterator begin() const noexcept;
|
||||
constexpr iterator end() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
constexpr reverse_iterator rbegin() const noexcept;
|
||||
constexpr reverse_iterator rend() const noexcept;
|
||||
constexpr const_reverse_iterator crbegin() const noexcept;
|
||||
constexpr const_reverse_iterator crend() const noexcept;
|
||||
|
||||
private:
|
||||
pointer data_; // exposition only
|
||||
index_type size_; // exposition only
|
||||
};
|
||||
|
||||
template<class T, size_t N>
|
||||
span(T (&)[N]) -> span<T, N>;
|
||||
|
||||
template<class T, size_t N>
|
||||
span(array<T, N>&) -> span<T, N>;
|
||||
|
||||
template<class T, size_t N>
|
||||
span(const array<T, N>&) -> span<const T, N>;
|
||||
|
||||
template<class Container>
|
||||
span(Container&) -> span<typename Container::value_type>;
|
||||
|
||||
template<class Container>
|
||||
span(const Container&) -> span<const typename Container::value_type>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cstddef> // for ptrdiff_t
|
||||
#include <iterator> // for iterators
|
||||
#include <array> // for array
|
||||
#include <type_traits> // for remove_cv, etc
|
||||
#include <cstddef> // for byte
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
|
||||
inline constexpr ptrdiff_t dynamic_extent = -1;
|
||||
template <typename _Tp, ptrdiff_t _Extent = dynamic_extent> class span;
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_span_impl : public false_type {};
|
||||
|
||||
template <class _Tp, ptrdiff_t _Extent>
|
||||
struct __is_span_impl<span<_Tp, _Extent>> : public true_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_span : public __is_span_impl<remove_cv_t<_Tp>> {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_std_array_impl : public false_type {};
|
||||
|
||||
template <class _Tp, size_t _Sz>
|
||||
struct __is_std_array_impl<array<_Tp, _Sz>> : public true_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __is_std_array : public __is_std_array_impl<remove_cv_t<_Tp>> {};
|
||||
|
||||
template <class _Tp, class _ElementType, class = void>
|
||||
struct __is_span_compatible_container : public false_type {};
|
||||
|
||||
template <class _Tp, class _ElementType>
|
||||
struct __is_span_compatible_container<_Tp, _ElementType,
|
||||
void_t<
|
||||
// is not a specialization of span
|
||||
typename enable_if<!__is_span<_Tp>::value, nullptr_t>::type,
|
||||
// is not a specialization of array
|
||||
typename enable_if<!__is_std_array<_Tp>::value, nullptr_t>::type,
|
||||
// is_array_v<Container> is false,
|
||||
typename enable_if<!is_array_v<_Tp>, nullptr_t>::type,
|
||||
// data(cont) and size(cont) are well formed
|
||||
decltype(data(declval<_Tp>())),
|
||||
decltype(size(declval<_Tp>())),
|
||||
// remove_pointer_t<decltype(data(cont))>(*)[] is convertible to ElementType(*)[]
|
||||
typename enable_if<
|
||||
is_convertible_v<remove_pointer_t<decltype(data(declval<_Tp &>()))>(*)[],
|
||||
_ElementType(*)[]>,
|
||||
nullptr_t>::type
|
||||
>>
|
||||
: public true_type {};
|
||||
|
||||
|
||||
template <typename _Tp, ptrdiff_t _Extent>
|
||||
class _LIBCPP_TEMPLATE_VIS span {
|
||||
public:
|
||||
// constants and types
|
||||
using element_type = _Tp;
|
||||
using value_type = remove_cv_t<_Tp>;
|
||||
using index_type = ptrdiff_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = _Tp *;
|
||||
using const_pointer = const _Tp *; // not in standard
|
||||
using reference = _Tp &;
|
||||
using const_reference = const _Tp &; // not in standard
|
||||
using iterator = __wrap_iter<pointer>;
|
||||
using const_iterator = __wrap_iter<const_pointer>;
|
||||
using reverse_iterator = _VSTD::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
|
||||
|
||||
static constexpr index_type extent = _Extent;
|
||||
static_assert (_Extent >= 0, "Can't have a span with an extent < 0");
|
||||
|
||||
// [span.cons], span constructors, copy, assignment, and destructor
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}
|
||||
{ static_assert(_Extent == 0, "Can't default construct a statically sized span with size > 0"); }
|
||||
|
||||
constexpr span (const span&) noexcept = default;
|
||||
constexpr span& operator=(const span&) noexcept = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, index_type __count) : __data{__ptr}
|
||||
{ (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}
|
||||
{ (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __data{__arr} {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span( array<value_type, _Extent>& __arr) noexcept : __data{__arr.data()} {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span(const array<value_type, _Extent>& __arr) noexcept : __data{__arr.data()} {}
|
||||
|
||||
template <class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span( _Container& __c,
|
||||
enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr)
|
||||
: __data{_VSTD::data(__c)}
|
||||
{ _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (container))"); }
|
||||
|
||||
template <class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(const _Container& __c,
|
||||
enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr)
|
||||
: __data{_VSTD::data(__c)}
|
||||
{ _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (const container)"); }
|
||||
|
||||
template <class _OtherElementType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(const span<_OtherElementType, _Extent>& __other,
|
||||
enable_if_t<
|
||||
is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
|
||||
nullptr_t> = nullptr)
|
||||
: __data{__other.data()} {}
|
||||
|
||||
template <class _OtherElementType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(const span<_OtherElementType, dynamic_extent>& __other,
|
||||
enable_if_t<
|
||||
is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
|
||||
nullptr_t> = nullptr) noexcept
|
||||
: __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
|
||||
|
||||
|
||||
// ~span() noexcept = default;
|
||||
|
||||
template <ptrdiff_t _Count>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, _Count> first() const noexcept
|
||||
{
|
||||
static_assert(_Count >= 0, "Count must be >= 0 in span::first()");
|
||||
static_assert(_Count <= _Extent, "Count out of range in span::first()");
|
||||
return {data(), _Count};
|
||||
}
|
||||
|
||||
template <ptrdiff_t _Count>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, _Count> last() const noexcept
|
||||
{
|
||||
static_assert(_Count >= 0, "Count must be >= 0 in span::last()");
|
||||
static_assert(_Count <= _Extent, "Count out of range in span::last()");
|
||||
return {data() + size() - _Count, _Count};
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, dynamic_extent> first(index_type __count) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__count >= 0 && __count <= size(), "Count out of range in span::first(count)");
|
||||
return {data(), __count};
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, dynamic_extent> last(index_type __count) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__count >= 0 && __count <= size(), "Count out of range in span::last(count)");
|
||||
return {data() + size() - __count, __count};
|
||||
}
|
||||
|
||||
template <ptrdiff_t _Offset, ptrdiff_t _Count = dynamic_extent>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr auto subspan() const noexcept
|
||||
-> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
|
||||
{
|
||||
_LIBCPP_ASSERT(_Offset >= 0 && _Offset <= size(), "Offset out of range in span::subspan()");
|
||||
return {data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
|
||||
}
|
||||
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, dynamic_extent>
|
||||
subspan(index_type __offset, index_type __count = dynamic_extent) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT( __offset >= 0 && __offset <= size(), "Offset out of range in span::subspan(offset, count)");
|
||||
_LIBCPP_ASSERT((__count >= 0 && __count <= size()) || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)");
|
||||
if (__count == dynamic_extent)
|
||||
return {data() + __offset, size() - __offset};
|
||||
_LIBCPP_ASSERT(__offset + __count <= size(), "count + offset out of range in span::subspan(offset, count)");
|
||||
return {data() + __offset, __count};
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr index_type size() const noexcept { return _Extent; }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr index_type size_bytes() const noexcept { return _Extent * sizeof(element_type); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](index_type __idx) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T,N>[] index out of bounds");
|
||||
return __data[__idx];
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reference operator()(index_type __idx) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T,N>() index out of bounds");
|
||||
return __data[__idx];
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
|
||||
|
||||
// [span.iter], span iterator support
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_iterator cbegin() const noexcept { return const_iterator(data()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_iterator cend() const noexcept { return const_iterator(data() + size()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(cend()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr void swap(span &__other) noexcept
|
||||
{
|
||||
pointer __p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept
|
||||
{ return {reinterpret_cast<const byte *>(data()), size_bytes()}; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writeable_bytes() const noexcept
|
||||
{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
|
||||
|
||||
private:
|
||||
pointer __data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
|
||||
private:
|
||||
|
||||
public:
|
||||
// constants and types
|
||||
using element_type = _Tp;
|
||||
using value_type = remove_cv_t<_Tp>;
|
||||
using index_type = ptrdiff_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = _Tp *;
|
||||
using const_pointer = const _Tp *; // not in standard
|
||||
using reference = _Tp &;
|
||||
using const_reference = const _Tp &; // not in standard
|
||||
using iterator = __wrap_iter<pointer>;
|
||||
using const_iterator = __wrap_iter<const_pointer>;
|
||||
using reverse_iterator = _VSTD::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
|
||||
|
||||
static constexpr index_type extent = dynamic_extent;
|
||||
|
||||
// [span.cons], span constructors, copy, assignment, and destructor
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}, __size{0} {}
|
||||
|
||||
constexpr span (const span&) noexcept = default;
|
||||
constexpr span& operator=(const span&) noexcept = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, index_type __count) : __data{__ptr}, __size{__count} {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}, __size{distance(__f, __l)} {}
|
||||
|
||||
template <size_t _Sz>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
|
||||
|
||||
template <size_t _Sz>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(array<value_type, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
|
||||
|
||||
template <size_t _Sz>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(const array<value_type, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
|
||||
|
||||
template <class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span( _Container& __c,
|
||||
enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr)
|
||||
: __data{_VSTD::data(__c)}, __size{(index_type) _VSTD::size(__c)} {}
|
||||
|
||||
template <class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(const _Container& __c,
|
||||
enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr)
|
||||
: __data{_VSTD::data(__c)}, __size{(index_type) _VSTD::size(__c)} {}
|
||||
|
||||
|
||||
template <class _OtherElementType, ptrdiff_t _OtherExtent>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
|
||||
enable_if_t<
|
||||
is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
|
||||
nullptr_t> = nullptr) noexcept
|
||||
: __data{__other.data()}, __size{__other.size()} {}
|
||||
|
||||
// ~span() noexcept = default;
|
||||
|
||||
template <ptrdiff_t _Count>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, _Count> first() const noexcept
|
||||
{
|
||||
static_assert(_Count >= 0);
|
||||
_LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()");
|
||||
return {data(), _Count};
|
||||
}
|
||||
|
||||
template <ptrdiff_t _Count>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, _Count> last() const noexcept
|
||||
{
|
||||
static_assert(_Count >= 0);
|
||||
_LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()");
|
||||
return {data() + size() - _Count, _Count};
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, dynamic_extent> first(index_type __count) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__count >= 0 && __count <= size(), "Count out of range in span::first(count)");
|
||||
return {data(), __count};
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<element_type, dynamic_extent> last (index_type __count) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__count >= 0 && __count <= size(), "Count out of range in span::last(count)");
|
||||
return {data() + size() - __count, __count};
|
||||
}
|
||||
|
||||
template <ptrdiff_t _Offset, ptrdiff_t _Count = dynamic_extent>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr span<_Tp, dynamic_extent> subspan() const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(_Offset >= 0 && _Offset <= size(), "Offset out of range in span::subspan()");
|
||||
_LIBCPP_ASSERT(_Count == dynamic_extent || _Offset + _Count <= size(), "Count out of range in span::subspan()");
|
||||
return {data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count};
|
||||
}
|
||||
|
||||
constexpr span<element_type, dynamic_extent>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
subspan(index_type __offset, index_type __count = dynamic_extent) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT( __offset >= 0 && __offset <= size(), "Offset out of range in span::subspan(offset, count)");
|
||||
_LIBCPP_ASSERT((__count >= 0 && __count <= size()) || __count == dynamic_extent, "count out of range in span::subspan(offset, count)");
|
||||
if (__count == dynamic_extent)
|
||||
return {data() + __offset, size() - __offset};
|
||||
_LIBCPP_ASSERT(__offset + __count <= size(), "Offset + count out of range in span::subspan(offset, count)");
|
||||
return {data() + __offset, __count};
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr index_type size() const noexcept { return __size; }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr index_type size_bytes() const noexcept { return __size * sizeof(element_type); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](index_type __idx) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T>[] index out of bounds");
|
||||
return __data[__idx];
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reference operator()(index_type __idx) const noexcept
|
||||
{
|
||||
_LIBCPP_ASSERT(__idx >= 0 && __idx < size(), "span<T>() index out of bounds");
|
||||
return __data[__idx];
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
|
||||
|
||||
// [span.iter], span iterator support
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_iterator cbegin() const noexcept { return const_iterator(data()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_iterator cend() const noexcept { return const_iterator(data() + size()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(cend()); }
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr void swap(span &__other) noexcept
|
||||
{
|
||||
pointer __p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
|
||||
index_type __sz = __size;
|
||||
__size = __other.__size;
|
||||
__other.__size = __sz;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept
|
||||
{ return {reinterpret_cast<const byte *>(data()), size_bytes()}; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writeable_bytes() const noexcept
|
||||
{ return {reinterpret_cast<byte *>(data()), size_bytes()}; }
|
||||
|
||||
private:
|
||||
pointer __data;
|
||||
index_type __size;
|
||||
};
|
||||
|
||||
template <class _Tp1, ptrdiff_t _Extent1, class _Tp2, ptrdiff_t _Extent2>
|
||||
constexpr bool
|
||||
operator==(const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& __rhs)
|
||||
{ return equal(__lhs.begin(), __lhs.end(), __rhs.begin(), __rhs.end()); }
|
||||
|
||||
template <class _Tp1, ptrdiff_t _Extent1, class _Tp2, ptrdiff_t _Extent2>
|
||||
constexpr bool
|
||||
operator!=(const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& __rhs)
|
||||
{ return !(__rhs == __lhs); }
|
||||
|
||||
template <class _Tp1, ptrdiff_t _Extent1, class _Tp2, ptrdiff_t _Extent2>
|
||||
constexpr bool
|
||||
operator< (const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& __rhs)
|
||||
{ return lexicographical_compare (__lhs.begin(), __lhs.end(), __rhs.begin(), __rhs.end()); }
|
||||
|
||||
template <class _Tp1, ptrdiff_t _Extent1, class _Tp2, ptrdiff_t _Extent2>
|
||||
constexpr bool
|
||||
operator<=(const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& __rhs)
|
||||
{ return !(__rhs < __lhs); }
|
||||
|
||||
template <class _Tp1, ptrdiff_t _Extent1, class _Tp2, ptrdiff_t _Extent2>
|
||||
constexpr bool
|
||||
operator> (const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& __rhs)
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
template <class _Tp1, ptrdiff_t _Extent1, class _Tp2, ptrdiff_t _Extent2>
|
||||
constexpr bool
|
||||
operator>=(const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& __rhs)
|
||||
{ return !(__lhs < __rhs); }
|
||||
|
||||
// as_bytes & as_writeable_bytes
|
||||
template <class _Tp, ptrdiff_t _Extent>
|
||||
auto as_bytes(span<_Tp, _Extent> __s) noexcept
|
||||
-> decltype(__s.__as_bytes())
|
||||
{ return __s.__as_bytes(); }
|
||||
|
||||
template <class _Tp, ptrdiff_t _Extent>
|
||||
auto as_writeable_bytes(span<_Tp, _Extent> __s) noexcept
|
||||
-> typename enable_if<!is_const_v<_Tp>, decltype(__s.__as_writeable_bytes())>::type
|
||||
{ return __s.__as_writeable_bytes(); }
|
||||
|
||||
template <class _Tp, ptrdiff_t _Extent>
|
||||
constexpr void swap(span<_Tp, _Extent> &__lhs, span<_Tp, _Extent> &__rhs) noexcept
|
||||
{ __lhs.swap(__rhs); }
|
||||
|
||||
|
||||
// Deduction guides
|
||||
template<class _Tp, size_t _Sz>
|
||||
span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
|
||||
|
||||
template<class _Tp, size_t _Sz>
|
||||
span(array<_Tp, _Sz>&) -> span<_Tp, _Sz>;
|
||||
|
||||
template<class _Tp, size_t _Sz>
|
||||
span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
|
||||
|
||||
template<class _Container>
|
||||
span(_Container&) -> span<typename _Container::value_type>;
|
||||
|
||||
template<class _Container>
|
||||
span(const _Container&) -> span<const typename _Container::value_type>;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_SPAN
|
@ -61,6 +61,12 @@ public:
|
||||
void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
|
||||
};
|
||||
|
||||
template<class Container>
|
||||
stack(Container) -> stack<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template<class Container, class Allocator>
|
||||
stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template <class T, class Container>
|
||||
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
@ -199,7 +205,7 @@ public:
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
reference emplace(_Args&&... __args)
|
||||
decltype(auto) emplace(_Args&&... __args)
|
||||
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#else
|
||||
void emplace(_Args&&... __args)
|
||||
@ -229,6 +235,22 @@ public:
|
||||
operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _Container,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
|
||||
>
|
||||
stack(_Container)
|
||||
-> stack<typename _Container::value_type, _Container>;
|
||||
|
||||
template<class _Container,
|
||||
class _Alloc,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
|
||||
class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
|
||||
>
|
||||
stack(_Container, _Alloc)
|
||||
-> stack<typename _Container::value_type, _Container>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
|
@ -185,7 +185,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
// in the dylib
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_logic_error(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -196,7 +196,7 @@ void __throw_logic_error(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_domain_error(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -207,7 +207,7 @@ void __throw_domain_error(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_invalid_argument(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -218,7 +218,7 @@ void __throw_invalid_argument(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_length_error(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -229,7 +229,7 @@ void __throw_length_error(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_out_of_range(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -240,7 +240,7 @@ void __throw_out_of_range(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_range_error(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -251,7 +251,7 @@ void __throw_range_error(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_overflow_error(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
@ -262,7 +262,7 @@ void __throw_overflow_error(const char*__msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_underflow_error(const char*__msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
|
@ -109,13 +109,6 @@ void perror(const char* s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// snprintf
|
||||
#if defined(_LIBCPP_MSVCRT_LIKE)
|
||||
extern "C" {
|
||||
int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef getc
|
||||
#undef putc
|
||||
#undef clearerr
|
||||
|
@ -132,6 +132,9 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
virtual ~basic_streambuf();
|
||||
|
||||
// 27.6.2.2.1 locales:
|
||||
@ -233,9 +236,9 @@ protected:
|
||||
void swap(basic_streambuf& __rhs);
|
||||
|
||||
// 27.6.2.3.2 Get area:
|
||||
_LIBCPP_ALWAYS_INLINE char_type* eback() const {return __binp_;}
|
||||
_LIBCPP_ALWAYS_INLINE char_type* gptr() const {return __ninp_;}
|
||||
_LIBCPP_ALWAYS_INLINE char_type* egptr() const {return __einp_;}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type* eback() const {return __binp_;}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type* gptr() const {return __ninp_;}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type* egptr() const {return __einp_;}
|
||||
|
||||
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
||||
void gbump(int __n) { __ninp_ += __n; }
|
||||
@ -248,14 +251,14 @@ protected:
|
||||
}
|
||||
|
||||
// 27.6.2.3.3 Put area:
|
||||
_LIBCPP_ALWAYS_INLINE char_type* pbase() const {return __bout_;}
|
||||
_LIBCPP_ALWAYS_INLINE char_type* pptr() const {return __nout_;}
|
||||
_LIBCPP_ALWAYS_INLINE char_type* epptr() const {return __eout_;}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type* pbase() const {return __bout_;}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type* pptr() const {return __nout_;}
|
||||
_LIBCPP_INLINE_VISIBILITY char_type* epptr() const {return __eout_;}
|
||||
|
||||
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
||||
void pbump(int __n) { __nout_ += __n; }
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __pbump(streamsize __n) { __nout_ += __n; }
|
||||
|
||||
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
||||
|
@ -104,7 +104,8 @@ public:
|
||||
const Allocator& a = Allocator());
|
||||
template<class T>
|
||||
basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17
|
||||
explicit basic_string(const basic_string_view<charT, traits> sv, const Allocator& a = Allocator());
|
||||
template <class T>
|
||||
explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17
|
||||
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());
|
||||
@ -120,7 +121,8 @@ public:
|
||||
operator basic_string_view<charT, traits>() const noexcept;
|
||||
|
||||
basic_string& operator=(const basic_string& str);
|
||||
basic_string& operator=(basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& operator=(const T& t); // C++17
|
||||
basic_string& operator=(basic_string&& str)
|
||||
noexcept(
|
||||
allocator_type::propagate_on_container_move_assignment::value ||
|
||||
@ -164,13 +166,15 @@ public:
|
||||
reference at(size_type n);
|
||||
|
||||
basic_string& operator+=(const basic_string& str);
|
||||
basic_string& operator+=(basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& operator+=(const T& t); // C++17
|
||||
basic_string& operator+=(const value_type* s);
|
||||
basic_string& operator+=(value_type c);
|
||||
basic_string& operator+=(initializer_list<value_type>);
|
||||
|
||||
basic_string& append(const basic_string& str);
|
||||
basic_string& append(basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& append(const T& t); // C++17
|
||||
basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
|
||||
template <class T>
|
||||
basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
|
||||
@ -189,7 +193,8 @@ public:
|
||||
const_reference back() const;
|
||||
|
||||
basic_string& assign(const basic_string& str);
|
||||
basic_string& assign(basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& assign(const T& t); // C++17
|
||||
basic_string& assign(basic_string&& str);
|
||||
basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
|
||||
template <class T>
|
||||
@ -202,7 +207,8 @@ public:
|
||||
basic_string& assign(initializer_list<value_type>);
|
||||
|
||||
basic_string& insert(size_type pos1, const basic_string& str);
|
||||
basic_string& insert(size_type pos1, basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& insert(size_type pos1, const T& t);
|
||||
basic_string& insert(size_type pos1, const basic_string& str,
|
||||
size_type pos2, size_type n);
|
||||
template <class T>
|
||||
@ -221,7 +227,8 @@ public:
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
|
||||
basic_string& replace(size_type pos1, size_type n1, basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17
|
||||
basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2=npos); // C++14
|
||||
template <class T>
|
||||
@ -231,7 +238,8 @@ public:
|
||||
basic_string& replace(size_type pos, size_type n1, const value_type* s);
|
||||
basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
|
||||
basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
|
||||
basic_string& replace(const_iterator i1, const_iterator i2, basic_string_view<charT, traits> sv);
|
||||
template <class T>
|
||||
basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17
|
||||
basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);
|
||||
basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);
|
||||
basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
|
||||
@ -253,45 +261,53 @@ public:
|
||||
allocator_type get_allocator() const noexcept;
|
||||
|
||||
size_type find(const basic_string& str, size_type pos = 0) const noexcept;
|
||||
size_type find(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
||||
template <class T>
|
||||
size_type find(const T& t, size_type pos = 0) const; // C++17
|
||||
size_type find(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find(const value_type* s, size_type pos = 0) const noexcept;
|
||||
size_type find(value_type c, size_type pos = 0) const noexcept;
|
||||
|
||||
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
|
||||
size_type rfind(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
||||
template <class T>
|
||||
size_type rfind(const T& t, size_type pos = npos) const; // C++17
|
||||
size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
|
||||
size_type rfind(value_type c, size_type pos = npos) const noexcept;
|
||||
|
||||
size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
|
||||
size_type find_first_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
||||
template <class T>
|
||||
size_type find_first_of(const T& t, size_type pos = 0) const; // C++17
|
||||
size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;
|
||||
size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
|
||||
|
||||
size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
|
||||
size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
||||
template <class T>
|
||||
size_type find_last_of(const T& t, size_type pos = npos) const noexcept; // C++17
|
||||
size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
|
||||
size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
|
||||
|
||||
size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
|
||||
size_type find_first_not_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
||||
template <class T>
|
||||
size_type find_first_not_of(const T& t, size_type pos = 0) const; // C++17
|
||||
size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;
|
||||
size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
|
||||
|
||||
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
|
||||
size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
||||
template <class T>
|
||||
size_type find_last_not_of(const T& t, size_type pos = npos) const; // C++17
|
||||
size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
|
||||
size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
|
||||
|
||||
int compare(const basic_string& str) const noexcept;
|
||||
int compare(basic_string_view<charT, traits> sv) const noexcept;
|
||||
template <class T>
|
||||
int compare(const T& t) const noexcept; // C++17
|
||||
int compare(size_type pos1, size_type n1, const basic_string& str) const;
|
||||
int compare(size_type pos1, size_type n1, basic_string_view<charT, traits> sv) const;
|
||||
template <class T>
|
||||
int compare(size_type pos1, size_type n1, const T& t) const; // C++17
|
||||
int compare(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2=npos) const; // C++14
|
||||
template <class T>
|
||||
@ -311,6 +327,13 @@ public:
|
||||
bool __invariants() const;
|
||||
};
|
||||
|
||||
template<class InputIterator,
|
||||
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
||||
basic_string(InputIterator, InputIterator, Allocator = Allocator())
|
||||
-> basic_string<typename iterator_traits<InputIterator>::value_type,
|
||||
char_traits<typename iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>; // C++17
|
||||
|
||||
template<class charT, class traits, class Allocator>
|
||||
basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
@ -651,11 +674,14 @@ public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
|
||||
static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD");
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array");
|
||||
static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout");
|
||||
static_assert(( is_trivial<value_type>::value), "Character type of basic_string must be trivial");
|
||||
static_assert(( is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
|
||||
static_assert(( is_same<typename allocator_type::value_type, value_type>::value),
|
||||
"Allocator::value_type must be same type as value_type");
|
||||
|
||||
#if defined(_LIBCPP_RAW_ITERATORS)
|
||||
typedef pointer iterator;
|
||||
typedef const_pointer const_iterator;
|
||||
@ -779,31 +805,51 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(basic_string&& __str, const allocator_type& __a);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s);
|
||||
|
||||
template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(const _CharT* __s, const _Allocator& __a);
|
||||
basic_string(const _CharT* __s) {
|
||||
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
|
||||
__init(__s, traits_type::length(__s));
|
||||
# if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
# endif
|
||||
}
|
||||
|
||||
template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(const _CharT* __s, const _Allocator& __a);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(const _CharT* __s, size_type __n);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(size_type __n, _CharT __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(size_type __n, _CharT __c, const _Allocator& __a);
|
||||
|
||||
template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(size_type __n, _CharT __c, const _Allocator& __a);
|
||||
|
||||
basic_string(const basic_string& __str, size_type __pos, size_type __n,
|
||||
const _Allocator& __a = _Allocator());
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(const basic_string& __str, size_type __pos,
|
||||
const _Allocator& __a = _Allocator());
|
||||
template<class _Tp>
|
||||
|
||||
template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
basic_string(const _Tp& __t, size_type __pos, size_type __n,
|
||||
const allocator_type& __a = allocator_type(),
|
||||
typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0);
|
||||
_LIBCPP_INLINE_VISIBILITY explicit
|
||||
basic_string(__self_view __sv);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(__self_view __sv, const _Allocator& __a);
|
||||
const allocator_type& __a = allocator_type());
|
||||
|
||||
template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
explicit basic_string(const _Tp& __t);
|
||||
|
||||
template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
explicit basic_string(const _Tp& __t, const allocator_type& __a);
|
||||
|
||||
template<class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string(_InputIterator __first, _InputIterator __last);
|
||||
@ -824,11 +870,10 @@ public:
|
||||
|
||||
basic_string& operator=(const basic_string& __str);
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class = void>
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& operator=(__self_view __sv) {return assign(__sv);}
|
||||
template <class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
|
||||
basic_string& operator=(const _Tp& __t)
|
||||
{__self_view __sv = __t; return assign(__sv);}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& operator=(basic_string&& __str)
|
||||
@ -918,7 +963,15 @@ public:
|
||||
reference at(size_type __n);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);}
|
||||
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(__self_view __sv) {return append(__sv);}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string&
|
||||
>::type
|
||||
operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);}
|
||||
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);}
|
||||
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
@ -927,9 +980,17 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& append(const basic_string& __str);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& append(__self_view __sv) { return append(__sv.data(), __sv.size()); }
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string&
|
||||
>::type
|
||||
append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
|
||||
basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
@ -984,8 +1045,14 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY reference back();
|
||||
_LIBCPP_INLINE_VISIBILITY const_reference back() const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& assign(__self_view __sv) { return assign(__sv.data(), __sv.size()); }
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string&
|
||||
>::type
|
||||
assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& assign(const basic_string& __str) { return *this = __str; }
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
@ -1031,8 +1098,17 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& insert(size_type __pos1, const basic_string& __str);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& insert(size_type __pos1, __self_view __sv) { return insert(__pos1, __sv.data(), __sv.size()); }
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string&
|
||||
>::type
|
||||
insert(size_type __pos1, const _Tp& __t)
|
||||
{ __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
@ -1080,8 +1156,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& replace(size_type __pos1, size_type __n1, __self_view __sv) { return replace(__pos1, __n1, __sv.data(), __sv.size()); }
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string&
|
||||
>::type
|
||||
replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }
|
||||
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
@ -1096,8 +1179,16 @@ public:
|
||||
basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& replace(const_iterator __i1, const_iterator __i2, __self_view __sv) { return replace(__i1 - begin(), __i2 - __i1, __sv); }
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string&
|
||||
>::type
|
||||
replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1145,8 +1236,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
size_type
|
||||
>::type
|
||||
find(const _Tp& __t, size_type __pos = 0) const;
|
||||
size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
|
||||
@ -1154,8 +1252,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
size_type
|
||||
>::type
|
||||
rfind(const _Tp& __t, size_type __pos = npos) const;
|
||||
size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
|
||||
@ -1163,8 +1268,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
size_type
|
||||
>::type
|
||||
find_first_of(const _Tp& __t, size_type __pos = 0) const;
|
||||
size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
|
||||
@ -1173,8 +1285,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
size_type
|
||||
>::type
|
||||
find_last_of(const _Tp& __t, size_type __pos = npos) const;
|
||||
size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
|
||||
@ -1183,8 +1302,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
size_type
|
||||
>::type
|
||||
find_first_not_of(const _Tp &__t, size_type __pos = 0) const;
|
||||
size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
|
||||
@ -1193,8 +1319,15 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
size_type
|
||||
>::type
|
||||
find_last_not_of(const _Tp& __t, size_type __pos = npos) const;
|
||||
size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
|
||||
@ -1203,13 +1336,29 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int compare(const basic_string& __str) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int compare(__self_view __sv) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, __self_view __sv) const;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
int
|
||||
>::type
|
||||
compare(const _Tp &__t) const;
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
int
|
||||
>::type
|
||||
compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
|
||||
int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
@ -1250,6 +1399,8 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY bool __invariants() const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool __is_long() const _NOEXCEPT
|
||||
{return bool(__r_.first().__s.__size_ & __short_mask);}
|
||||
@ -1363,9 +1514,13 @@ private:
|
||||
enum {__alignment = 16};
|
||||
static _LIBCPP_INLINE_VISIBILITY
|
||||
size_type __recommend(size_type __s) _NOEXCEPT
|
||||
{return (__s < __min_cap ? static_cast<size_type>(__min_cap) :
|
||||
__align_it<sizeof(value_type) < __alignment ?
|
||||
__alignment/sizeof(value_type) : 1 > (__s+1)) - 1;}
|
||||
{
|
||||
if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1;
|
||||
size_type __guess = __align_it<sizeof(value_type) < __alignment ?
|
||||
__alignment/sizeof(value_type) : 1 > (__s+1) - 1;
|
||||
if (__guess == __min_cap) ++__guess;
|
||||
return __guess;
|
||||
}
|
||||
|
||||
inline
|
||||
void __init(const value_type* __s, size_type __sz, size_type __reserve);
|
||||
@ -1415,16 +1570,14 @@ private:
|
||||
{
|
||||
if (!__str.__is_long())
|
||||
{
|
||||
clear();
|
||||
shrink_to_fit();
|
||||
__clear_and_shrink();
|
||||
__alloc() = __str.__alloc();
|
||||
}
|
||||
else
|
||||
{
|
||||
allocator_type __a = __str.__alloc();
|
||||
pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap());
|
||||
clear();
|
||||
shrink_to_fit();
|
||||
__clear_and_shrink();
|
||||
__alloc() = _VSTD::move(__a);
|
||||
__set_long_pointer(__p);
|
||||
__set_long_cap(__str.__get_long_cap());
|
||||
@ -1481,6 +1634,35 @@ private:
|
||||
friend basic_string operator+<>(const basic_string&, value_type);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _InputIterator,
|
||||
class _CharT = typename iterator_traits<_InputIterator>::value_type,
|
||||
class _Allocator = allocator<_CharT>,
|
||||
class = typename enable_if<__is_input_iterator<_InputIterator>::value, void>::type,
|
||||
class = typename enable_if<__is_allocator<_Allocator>::value, void>::type
|
||||
>
|
||||
basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
|
||||
-> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
|
||||
|
||||
template<class _CharT,
|
||||
class _Traits,
|
||||
class _Allocator = allocator<_CharT>,
|
||||
class = typename enable_if<__is_allocator<_Allocator>::value, void>::type
|
||||
>
|
||||
explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
|
||||
-> basic_string<_CharT, _Traits, _Allocator>;
|
||||
|
||||
template<class _CharT,
|
||||
class _Traits,
|
||||
class _Allocator = allocator<_CharT>,
|
||||
class = typename enable_if<__is_allocator<_Allocator>::value, void>::type,
|
||||
class _Sz = typename allocator_traits<_Allocator>::size_type
|
||||
>
|
||||
basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())
|
||||
-> basic_string<_CharT, _Traits, _Allocator>;
|
||||
#endif
|
||||
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
@ -1598,18 +1780,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
|
||||
__init(__s, traits_type::length(__s));
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
template <class>
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
|
||||
: __r_(__second_tag(), __a)
|
||||
{
|
||||
@ -1746,7 +1917,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
template <class>
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
|
||||
: __r_(__second_tag(), __a)
|
||||
{
|
||||
@ -1787,13 +1958,13 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
template <class _Tp>
|
||||
template <class _Tp, class>
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(
|
||||
const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a,
|
||||
typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *)
|
||||
const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
|
||||
: __r_(__second_tag(), __a)
|
||||
{
|
||||
__self_view __sv = __self_view(__t).substr(__pos, __n);
|
||||
__self_view __sv0 = __t;
|
||||
__self_view __sv = __sv0.substr(__pos, __n);
|
||||
__init(__sv.data(), __sv.size());
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
@ -1801,9 +1972,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv)
|
||||
template <class _Tp, class>
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
__init(__sv.data(), __sv.size());
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
@ -1811,10 +1983,11 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv, const _Allocator& __a)
|
||||
template <class _Tp, class>
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
|
||||
: __r_(__second_tag(), __a)
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
__init(__sv.data(), __sv.size());
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
@ -2102,8 +2275,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
#endif
|
||||
{
|
||||
clear();
|
||||
shrink_to_fit();
|
||||
__clear_and_shrink();
|
||||
__r_.first() = __str.__r_.first();
|
||||
__move_assign_alloc(__str);
|
||||
__str.__zero();
|
||||
@ -3125,11 +3297,16 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find(__self_view __sv,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
|
||||
size_type __pos) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __sv.data(), __pos, __sv.size());
|
||||
}
|
||||
@ -3178,11 +3355,16 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::rfind(__self_view __sv,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
|
||||
size_type __pos) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __sv.data(), __pos, __sv.size());
|
||||
}
|
||||
@ -3231,11 +3413,16 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_of(__self_view __sv,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
|
||||
size_type __pos) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __sv.data(), __pos, __sv.size());
|
||||
}
|
||||
@ -3284,11 +3471,16 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_of(__self_view __sv,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
|
||||
size_type __pos) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __sv.data(), __pos, __sv.size());
|
||||
}
|
||||
@ -3337,11 +3529,16 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string&
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(__self_view __sv,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
|
||||
size_type __pos) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __sv.data(), __pos, __sv.size());
|
||||
}
|
||||
@ -3391,11 +3588,16 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string&
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(__self_view __sv,
|
||||
size_type __pos) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
|
||||
size_type __pos) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __sv.data(), __pos, __sv.size());
|
||||
}
|
||||
@ -3424,10 +3626,15 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
|
||||
// compare
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int
|
||||
basic_string<_CharT, _Traits, _Allocator>::compare(__self_view __sv) const _NOEXCEPT
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
int
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
size_t __lhs_sz = size();
|
||||
size_t __rhs_sz = __sv.size();
|
||||
int __result = traits_type::compare(data(), __sv.data(),
|
||||
@ -3473,12 +3680,17 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
int
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
|
||||
size_type __n1,
|
||||
__self_view __sv) const
|
||||
const _Tp& __t) const
|
||||
{
|
||||
__self_view __sv = __t;
|
||||
return compare(__pos1, __n1, __sv.data(), __sv.size());
|
||||
}
|
||||
|
||||
@ -3556,6 +3768,22 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
|
||||
return true;
|
||||
}
|
||||
|
||||
// __clear_and_shrink
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
|
||||
{
|
||||
clear();
|
||||
if(__is_long())
|
||||
{
|
||||
__alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
|
||||
__set_long_cap(0);
|
||||
__set_short_size(0);
|
||||
}
|
||||
}
|
||||
|
||||
// operator==
|
||||
|
||||
template<class _CharT, class _Traits, class _Allocator>
|
||||
|
@ -208,7 +208,9 @@ public:
|
||||
typedef ptrdiff_t difference_type;
|
||||
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
|
||||
|
||||
static_assert(is_pod<value_type>::value, "Character type of basic_string_view must be a POD");
|
||||
static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
|
||||
static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout");
|
||||
static_assert(( is_trivial<value_type>::value), "Character type of basic_string_view must be trivial");
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
|
@ -120,88 +120,6 @@ public:
|
||||
const char* what() const noexcept;
|
||||
};
|
||||
|
||||
enum class errc
|
||||
{
|
||||
address_family_not_supported, // EAFNOSUPPORT
|
||||
address_in_use, // EADDRINUSE
|
||||
address_not_available, // EADDRNOTAVAIL
|
||||
already_connected, // EISCONN
|
||||
argument_list_too_long, // E2BIG
|
||||
argument_out_of_domain, // EDOM
|
||||
bad_address, // EFAULT
|
||||
bad_file_descriptor, // EBADF
|
||||
bad_message, // EBADMSG
|
||||
broken_pipe, // EPIPE
|
||||
connection_aborted, // ECONNABORTED
|
||||
connection_already_in_progress, // EALREADY
|
||||
connection_refused, // ECONNREFUSED
|
||||
connection_reset, // ECONNRESET
|
||||
cross_device_link, // EXDEV
|
||||
destination_address_required, // EDESTADDRREQ
|
||||
device_or_resource_busy, // EBUSY
|
||||
directory_not_empty, // ENOTEMPTY
|
||||
executable_format_error, // ENOEXEC
|
||||
file_exists, // EEXIST
|
||||
file_too_large, // EFBIG
|
||||
filename_too_long, // ENAMETOOLONG
|
||||
function_not_supported, // ENOSYS
|
||||
host_unreachable, // EHOSTUNREACH
|
||||
identifier_removed, // EIDRM
|
||||
illegal_byte_sequence, // EILSEQ
|
||||
inappropriate_io_control_operation, // ENOTTY
|
||||
interrupted, // EINTR
|
||||
invalid_argument, // EINVAL
|
||||
invalid_seek, // ESPIPE
|
||||
io_error, // EIO
|
||||
is_a_directory, // EISDIR
|
||||
message_size, // EMSGSIZE
|
||||
network_down, // ENETDOWN
|
||||
network_reset, // ENETRESET
|
||||
network_unreachable, // ENETUNREACH
|
||||
no_buffer_space, // ENOBUFS
|
||||
no_child_process, // ECHILD
|
||||
no_link, // ENOLINK
|
||||
no_lock_available, // ENOLCK
|
||||
no_message_available, // ENODATA
|
||||
no_message, // ENOMSG
|
||||
no_protocol_option, // ENOPROTOOPT
|
||||
no_space_on_device, // ENOSPC
|
||||
no_stream_resources, // ENOSR
|
||||
no_such_device_or_address, // ENXIO
|
||||
no_such_device, // ENODEV
|
||||
no_such_file_or_directory, // ENOENT
|
||||
no_such_process, // ESRCH
|
||||
not_a_directory, // ENOTDIR
|
||||
not_a_socket, // ENOTSOCK
|
||||
not_a_stream, // ENOSTR
|
||||
not_connected, // ENOTCONN
|
||||
not_enough_memory, // ENOMEM
|
||||
not_supported, // ENOTSUP
|
||||
operation_canceled, // ECANCELED
|
||||
operation_in_progress, // EINPROGRESS
|
||||
operation_not_permitted, // EPERM
|
||||
operation_not_supported, // EOPNOTSUPP
|
||||
operation_would_block, // EWOULDBLOCK
|
||||
owner_dead, // EOWNERDEAD
|
||||
permission_denied, // EACCES
|
||||
protocol_error, // EPROTO
|
||||
protocol_not_supported, // EPROTONOSUPPORT
|
||||
read_only_file_system, // EROFS
|
||||
resource_deadlock_would_occur, // EDEADLK
|
||||
resource_unavailable_try_again, // EAGAIN
|
||||
result_out_of_range, // ERANGE
|
||||
state_not_recoverable, // ENOTRECOVERABLE
|
||||
stream_timeout, // ETIME
|
||||
text_file_busy, // ETXTBSY
|
||||
timed_out, // ETIMEDOUT
|
||||
too_many_files_open_in_system, // ENFILE
|
||||
too_many_files_open, // EMFILE
|
||||
too_many_links, // EMLINK
|
||||
too_many_symbolic_link_levels, // ELOOP
|
||||
value_too_large, // EOVERFLOW
|
||||
wrong_protocol_type // EPROTOTYPE
|
||||
};
|
||||
|
||||
template <> struct is_error_condition_enum<errc>
|
||||
: true_type { }
|
||||
|
||||
@ -225,8 +143,7 @@ template <> struct hash<std::error_condition>;
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cerrno>
|
||||
#include <__errc>
|
||||
#include <type_traits>
|
||||
#include <stdexcept>
|
||||
#include <__functional_base>
|
||||
@ -260,109 +177,6 @@ template <class _Tp>
|
||||
_LIBCPP_INLINE_VAR constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value;
|
||||
#endif
|
||||
|
||||
// Some error codes are not present on all platforms, so we provide equivalents
|
||||
// for them:
|
||||
|
||||
//enum class errc
|
||||
_LIBCPP_DECLARE_STRONG_ENUM(errc)
|
||||
{
|
||||
address_family_not_supported = EAFNOSUPPORT,
|
||||
address_in_use = EADDRINUSE,
|
||||
address_not_available = EADDRNOTAVAIL,
|
||||
already_connected = EISCONN,
|
||||
argument_list_too_long = E2BIG,
|
||||
argument_out_of_domain = EDOM,
|
||||
bad_address = EFAULT,
|
||||
bad_file_descriptor = EBADF,
|
||||
bad_message = EBADMSG,
|
||||
broken_pipe = EPIPE,
|
||||
connection_aborted = ECONNABORTED,
|
||||
connection_already_in_progress = EALREADY,
|
||||
connection_refused = ECONNREFUSED,
|
||||
connection_reset = ECONNRESET,
|
||||
cross_device_link = EXDEV,
|
||||
destination_address_required = EDESTADDRREQ,
|
||||
device_or_resource_busy = EBUSY,
|
||||
directory_not_empty = ENOTEMPTY,
|
||||
executable_format_error = ENOEXEC,
|
||||
file_exists = EEXIST,
|
||||
file_too_large = EFBIG,
|
||||
filename_too_long = ENAMETOOLONG,
|
||||
function_not_supported = ENOSYS,
|
||||
host_unreachable = EHOSTUNREACH,
|
||||
identifier_removed = EIDRM,
|
||||
illegal_byte_sequence = EILSEQ,
|
||||
inappropriate_io_control_operation = ENOTTY,
|
||||
interrupted = EINTR,
|
||||
invalid_argument = EINVAL,
|
||||
invalid_seek = ESPIPE,
|
||||
io_error = EIO,
|
||||
is_a_directory = EISDIR,
|
||||
message_size = EMSGSIZE,
|
||||
network_down = ENETDOWN,
|
||||
network_reset = ENETRESET,
|
||||
network_unreachable = ENETUNREACH,
|
||||
no_buffer_space = ENOBUFS,
|
||||
no_child_process = ECHILD,
|
||||
no_link = ENOLINK,
|
||||
no_lock_available = ENOLCK,
|
||||
#ifdef ENODATA
|
||||
no_message_available = ENODATA,
|
||||
#else
|
||||
no_message_available = ENOMSG,
|
||||
#endif
|
||||
no_message = ENOMSG,
|
||||
no_protocol_option = ENOPROTOOPT,
|
||||
no_space_on_device = ENOSPC,
|
||||
#ifdef ENOSR
|
||||
no_stream_resources = ENOSR,
|
||||
#else
|
||||
no_stream_resources = ENOMEM,
|
||||
#endif
|
||||
no_such_device_or_address = ENXIO,
|
||||
no_such_device = ENODEV,
|
||||
no_such_file_or_directory = ENOENT,
|
||||
no_such_process = ESRCH,
|
||||
not_a_directory = ENOTDIR,
|
||||
not_a_socket = ENOTSOCK,
|
||||
#ifdef ENOSTR
|
||||
not_a_stream = ENOSTR,
|
||||
#else
|
||||
not_a_stream = EINVAL,
|
||||
#endif
|
||||
not_connected = ENOTCONN,
|
||||
not_enough_memory = ENOMEM,
|
||||
not_supported = ENOTSUP,
|
||||
operation_canceled = ECANCELED,
|
||||
operation_in_progress = EINPROGRESS,
|
||||
operation_not_permitted = EPERM,
|
||||
operation_not_supported = EOPNOTSUPP,
|
||||
operation_would_block = EWOULDBLOCK,
|
||||
owner_dead = EOWNERDEAD,
|
||||
permission_denied = EACCES,
|
||||
protocol_error = EPROTO,
|
||||
protocol_not_supported = EPROTONOSUPPORT,
|
||||
read_only_file_system = EROFS,
|
||||
resource_deadlock_would_occur = EDEADLK,
|
||||
resource_unavailable_try_again = EAGAIN,
|
||||
result_out_of_range = ERANGE,
|
||||
state_not_recoverable = ENOTRECOVERABLE,
|
||||
#ifdef ETIME
|
||||
stream_timeout = ETIME,
|
||||
#else
|
||||
stream_timeout = ETIMEDOUT,
|
||||
#endif
|
||||
text_file_busy = ETXTBSY,
|
||||
timed_out = ETIMEDOUT,
|
||||
too_many_files_open_in_system = ENFILE,
|
||||
too_many_files_open = EMFILE,
|
||||
too_many_links = EMLINK,
|
||||
too_many_symbolic_link_levels = ELOOP,
|
||||
value_too_large = EOVERFLOW,
|
||||
wrong_protocol_type = EPROTOTYPE
|
||||
};
|
||||
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc>
|
||||
: true_type { };
|
||||
@ -389,7 +203,7 @@ public:
|
||||
defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
|
||||
error_category() _NOEXCEPT;
|
||||
#else
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
#endif
|
||||
private:
|
||||
@ -403,13 +217,13 @@ public:
|
||||
virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
|
||||
virtual string message(int __ev) const = 0;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
|
||||
|
||||
friend class _LIBCPP_HIDDEN __do_message;
|
||||
@ -430,21 +244,21 @@ class _LIBCPP_TYPE_VIS error_condition
|
||||
int __val_;
|
||||
const error_category* __cat_;
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_condition() _NOEXCEPT : __val_(0), __cat_(&generic_category()) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_condition(int __val, const error_category& __cat) _NOEXCEPT
|
||||
: __val_(__val), __cat_(&__cat) {}
|
||||
|
||||
template <class _Ep>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_condition(_Ep __e,
|
||||
typename enable_if<is_error_condition_enum<_Ep>::value>::type* = 0
|
||||
) _NOEXCEPT
|
||||
{*this = make_error_condition(__e);}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void assign(int __val, const error_category& __cat) _NOEXCEPT
|
||||
{
|
||||
__val_ = __val;
|
||||
@ -452,7 +266,7 @@ public:
|
||||
}
|
||||
|
||||
template <class _Ep>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_error_condition_enum<_Ep>::value,
|
||||
@ -461,21 +275,21 @@ public:
|
||||
operator=(_Ep __e) _NOEXCEPT
|
||||
{*this = make_error_condition(__e); return *this;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
__val_ = 0;
|
||||
__cat_ = &generic_category();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int value() const _NOEXCEPT {return __val_;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const error_category& category() const _NOEXCEPT {return *__cat_;}
|
||||
string message() const;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT
|
||||
operator bool() const _NOEXCEPT {return __val_ != 0;}
|
||||
};
|
||||
@ -502,21 +316,21 @@ class _LIBCPP_TYPE_VIS error_code
|
||||
int __val_;
|
||||
const error_category* __cat_;
|
||||
public:
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_code() _NOEXCEPT : __val_(0), __cat_(&system_category()) {}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_code(int __val, const error_category& __cat) _NOEXCEPT
|
||||
: __val_(__val), __cat_(&__cat) {}
|
||||
|
||||
template <class _Ep>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_code(_Ep __e,
|
||||
typename enable_if<is_error_code_enum<_Ep>::value>::type* = 0
|
||||
) _NOEXCEPT
|
||||
{*this = make_error_code(__e);}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void assign(int __val, const error_category& __cat) _NOEXCEPT
|
||||
{
|
||||
__val_ = __val;
|
||||
@ -524,7 +338,7 @@ public:
|
||||
}
|
||||
|
||||
template <class _Ep>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_error_code_enum<_Ep>::value,
|
||||
@ -533,26 +347,26 @@ public:
|
||||
operator=(_Ep __e) _NOEXCEPT
|
||||
{*this = make_error_code(__e); return *this;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
__val_ = 0;
|
||||
__cat_ = &system_category();
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int value() const _NOEXCEPT {return __val_;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const error_category& category() const _NOEXCEPT {return *__cat_;}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
error_condition default_error_condition() const _NOEXCEPT
|
||||
{return __cat_->default_error_condition(__val_);}
|
||||
|
||||
string message() const;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT
|
||||
operator bool() const _NOEXCEPT {return __val_ != 0;}
|
||||
};
|
||||
@ -658,7 +472,7 @@ public:
|
||||
system_error(int __ev, const error_category& __ecat);
|
||||
~system_error() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const error_code& code() const _NOEXCEPT {return __ec_;}
|
||||
|
||||
private:
|
||||
|
@ -14,16 +14,24 @@
|
||||
/*
|
||||
tgmath.h synopsis
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <ctgmath>
|
||||
|
||||
*/
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <ctgmath>
|
||||
|
||||
#else // __cplusplus
|
||||
|
||||
#include_next <tgmath.h>
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _LIBCPP_TGMATH_H
|
||||
|
@ -298,7 +298,7 @@ public:
|
||||
template <class _Fp, class ..._Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
!is_same<typename decay<_Fp>::type, thread>::value
|
||||
!is_same<typename __uncvref<_Fp>::type, thread>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
|
@ -173,16 +173,11 @@ class __tuple_leaf
|
||||
|
||||
template <class _Tp>
|
||||
static constexpr bool __can_bind_reference() {
|
||||
using _RawTp = typename remove_reference<_Tp>::type;
|
||||
using _RawHp = typename remove_reference<_Hp>::type;
|
||||
using _CheckLValueArg = integral_constant<bool,
|
||||
is_lvalue_reference<_Tp>::value
|
||||
|| is_same<_RawTp, reference_wrapper<_RawHp>>::value
|
||||
|| is_same<_RawTp, reference_wrapper<typename remove_const<_RawHp>::type>>::value
|
||||
>;
|
||||
return !is_reference<_Hp>::value
|
||||
|| (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
|
||||
|| (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
|
||||
#if __has_keyword(__reference_binds_to_temporary)
|
||||
return !__reference_binds_to_temporary(_Hp, _Tp);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
__tuple_leaf& operator=(const __tuple_leaf&);
|
||||
@ -216,7 +211,7 @@ public:
|
||||
template <class _Tp,
|
||||
class = typename enable_if<
|
||||
__lazy_and<
|
||||
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
||||
__lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
|
||||
, is_constructible<_Hp, _Tp>
|
||||
>::value
|
||||
>::type
|
||||
@ -224,15 +219,15 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
|
||||
: __value_(_VSTD::forward<_Tp>(__t))
|
||||
{static_assert(__can_bind_reference<_Tp>(),
|
||||
"Attempted to construct a reference element in a tuple with an rvalue");}
|
||||
{static_assert(__can_bind_reference<_Tp&&>(),
|
||||
"Attempted construction of reference element binds to a temporary whose lifetime has ended");}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
|
||||
: __value_(_VSTD::forward<_Tp>(__t))
|
||||
{static_assert(__can_bind_reference<_Tp>(),
|
||||
"Attempted to construct a reference element in a tuple with an rvalue");}
|
||||
{static_assert(__can_bind_reference<_Tp&&>(),
|
||||
"Attempted construction of reference element binds to a temporary whose lifetime has ended");}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -298,7 +293,7 @@ public:
|
||||
template <class _Tp,
|
||||
class = typename enable_if<
|
||||
__lazy_and<
|
||||
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
||||
__lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
|
||||
, is_constructible<_Hp, _Tp>
|
||||
>::value
|
||||
>::type
|
||||
@ -1388,7 +1383,7 @@ 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{})
|
||||
typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
|
||||
)
|
||||
|
||||
template <class _Tp, class _Tuple, size_t... _Idx>
|
||||
@ -1403,7 +1398,7 @@ 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{})
|
||||
typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
|
||||
)
|
||||
|
||||
#undef _LIBCPP_NOEXCEPT_RETURN
|
||||
|
@ -21,7 +21,7 @@ namespace std
|
||||
template <class T, T v> struct integral_constant;
|
||||
typedef integral_constant<bool, true> true_type; // C++11
|
||||
typedef integral_constant<bool, false> false_type; // C++11
|
||||
|
||||
|
||||
template <bool B> // C++14
|
||||
using bool_constant = integral_constant<bool, B>; // C++14
|
||||
typedef bool_constant<true> true_type; // C++14
|
||||
@ -172,7 +172,7 @@ namespace std
|
||||
using add_volatile_t = typename add_volatile<T>::type; // C++14
|
||||
template <class T>
|
||||
using add_cv_t = typename add_cv<T>::type; // C++14
|
||||
|
||||
|
||||
// reference modifications:
|
||||
template <class T>
|
||||
using remove_reference_t = typename remove_reference<T>::type; // C++14
|
||||
@ -180,13 +180,13 @@ namespace std
|
||||
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
|
||||
template <class T>
|
||||
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
|
||||
|
||||
|
||||
// sign modifications:
|
||||
template <class T>
|
||||
using make_signed_t = typename make_signed<T>::type; // C++14
|
||||
template <class T>
|
||||
using make_unsigned_t = typename make_unsigned<T>::type; // C++14
|
||||
|
||||
|
||||
// array modifications:
|
||||
template <class T>
|
||||
using remove_extent_t = typename remove_extent<T>::type; // C++14
|
||||
@ -223,7 +223,7 @@ namespace std
|
||||
|
||||
template <class...>
|
||||
using void_t = void; // C++17
|
||||
|
||||
|
||||
// See C++14 20.10.4.1, primary type categories
|
||||
template <class T> inline constexpr bool is_void_v
|
||||
= is_void<T>::value; // C++17
|
||||
@ -386,13 +386,13 @@ namespace std
|
||||
|
||||
// [meta.logical], logical operator traits:
|
||||
template<class... B> struct conjunction; // C++17
|
||||
template<class... B>
|
||||
template<class... B>
|
||||
inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17
|
||||
template<class... B> struct disjunction; // C++17
|
||||
template<class... B>
|
||||
inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17
|
||||
template<class B> struct negation; // C++17
|
||||
template<class B>
|
||||
template<class B>
|
||||
inline constexpr bool negation_v = negation<B>::value; // C++17
|
||||
|
||||
}
|
||||
@ -595,7 +595,7 @@ template<class _B0, class _B1>
|
||||
struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
|
||||
|
||||
template<class _B0, class _B1, class _B2, class... _Bn>
|
||||
struct __and_<_B0, _B1, _B2, _Bn...>
|
||||
struct __and_<_B0, _B1, _B2, _Bn...>
|
||||
: conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
|
||||
|
||||
// __or_
|
||||
@ -608,11 +608,11 @@ template<class _B0, class _B1>
|
||||
struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
|
||||
|
||||
template<class _B0, class _B1, class _B2, class... _Bn>
|
||||
struct __or_<_B0, _B1, _B2, _Bn...>
|
||||
struct __or_<_B0, _B1, _B2, _Bn...>
|
||||
: conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
|
||||
|
||||
// __not_
|
||||
template<class _Tp>
|
||||
template<class _Tp>
|
||||
struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
|
||||
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
@ -733,6 +733,12 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
|
||||
// is_floating_point
|
||||
|
||||
template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
|
||||
#ifdef __clang__
|
||||
template <> struct __libcpp_is_floating_point<__fp16> : public true_type {};
|
||||
#endif
|
||||
#ifdef __FLT16_MANT_DIG__
|
||||
template <> struct __libcpp_is_floating_point<_Float16> : public true_type {};
|
||||
#endif
|
||||
template <> struct __libcpp_is_floating_point<float> : public true_type {};
|
||||
template <> struct __libcpp_is_floating_point<double> : public true_type {};
|
||||
template <> struct __libcpp_is_floating_point<long double> : public true_type {};
|
||||
@ -897,7 +903,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v
|
||||
|
||||
// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
|
||||
// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
|
||||
//
|
||||
//
|
||||
|
||||
template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
|
||||
struct __member_pointer_traits_imp
|
||||
@ -1178,11 +1184,9 @@ struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
|
||||
typename __uncvref<_Up>::type> {};
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
// aligned_union - same as __uncvref
|
||||
// remove_cvref - same as __uncvref
|
||||
template <class _Tp>
|
||||
struct remove_cvref {
|
||||
using type = remove_cv_t<remove_reference_t<_Tp>>;
|
||||
};
|
||||
struct remove_cvref : public __uncvref<_Tp> {};
|
||||
|
||||
template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
|
||||
#endif
|
||||
@ -1207,12 +1211,12 @@ template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type
|
||||
|
||||
// add_pointer
|
||||
|
||||
template <class _Tp,
|
||||
bool = __is_referenceable<_Tp>::value ||
|
||||
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>
|
||||
template <class _Tp> struct __add_pointer_impl<_Tp, false>
|
||||
{typedef _Tp type;};
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
|
||||
@ -1626,7 +1630,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
|
||||
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
|
||||
: public integral_constant<bool,
|
||||
: public integral_constant<bool,
|
||||
__has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
@ -2237,7 +2241,7 @@ struct __is_destructor_wellformed {
|
||||
|
||||
template <typename _Tp1>
|
||||
static __two __test (...);
|
||||
|
||||
|
||||
static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
|
||||
};
|
||||
|
||||
@ -2245,8 +2249,8 @@ template <class _Tp, bool>
|
||||
struct __destructible_imp;
|
||||
|
||||
template <class _Tp>
|
||||
struct __destructible_imp<_Tp, false>
|
||||
: public _VSTD::integral_constant<bool,
|
||||
struct __destructible_imp<_Tp, false>
|
||||
: public _VSTD::integral_constant<bool,
|
||||
__is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
|
||||
|
||||
template <class _Tp>
|
||||
@ -3397,7 +3401,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
|
||||
: public is_constructible<_Tp,
|
||||
: public is_constructible<_Tp,
|
||||
typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
@ -4105,7 +4109,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
|
||||
is_reference<typename remove_all_extents<_Tp>::type>::value>
|
||||
#endif
|
||||
{};
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
|
||||
@ -4121,7 +4125,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
|
||||
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
|
||||
#endif
|
||||
{};
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v
|
||||
@ -4139,7 +4143,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
|
||||
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
|
||||
#endif
|
||||
{};
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
|
||||
@ -4170,147 +4174,6 @@ template <class _Tp> struct __is_reference_wrapper
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
// Check for complete types
|
||||
|
||||
template <class ..._Tp> struct __check_complete;
|
||||
|
||||
template <>
|
||||
struct __check_complete<>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Hp, class _T0, class ..._Tp>
|
||||
struct __check_complete<_Hp, _T0, _Tp...>
|
||||
: private __check_complete<_Hp>,
|
||||
private __check_complete<_T0, _Tp...>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Hp>
|
||||
struct __check_complete<_Hp, _Hp>
|
||||
: private __check_complete<_Hp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __check_complete<_Tp>
|
||||
{
|
||||
static_assert(sizeof(_Tp) > 0, "Type must be complete.");
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __check_complete<_Tp&>
|
||||
: private __check_complete<_Tp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __check_complete<_Tp&&>
|
||||
: private __check_complete<_Tp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class ..._Param>
|
||||
struct __check_complete<_Rp (*)(_Param...)>
|
||||
: private __check_complete<_Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class ..._Param>
|
||||
struct __check_complete<void (*)(_Param...)>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class ..._Param>
|
||||
struct __check_complete<_Rp (_Param...)>
|
||||
: private __check_complete<_Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class ..._Param>
|
||||
struct __check_complete<void (_Param...)>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...)>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) const>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) &>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) const&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) &&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class ..._Param>
|
||||
struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
|
||||
: private __check_complete<_Class>
|
||||
{
|
||||
};
|
||||
|
||||
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,
|
||||
@ -4493,8 +4356,9 @@ _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)
|
||||
|
||||
template <class _Ret, class _Fp, class ..._Args>
|
||||
struct __invokable_r
|
||||
: private __check_complete<_Fp>
|
||||
{
|
||||
// FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
|
||||
// or incomplete array types as required by the standard.
|
||||
using _Result = decltype(
|
||||
_VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
|
||||
|
||||
@ -4812,39 +4676,39 @@ struct __sfinae_underlying_type
|
||||
template <class _Tp>
|
||||
struct __sfinae_underlying_type<_Tp, false> {};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
int __convert_to_integral(int __val) { return __val; }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
unsigned __convert_to_integral(unsigned __val) { return __val; }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
long __convert_to_integral(long __val) { return __val; }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
unsigned long __convert_to_integral(unsigned long __val) { return __val; }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
long long __convert_to_integral(long long __val) { return __val; }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
|
||||
|
||||
template<typename _Fp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if<is_floating_point<_Fp>::value, long long>::type
|
||||
__convert_to_integral(_Fp __val) { return __val; }
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_INT128
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
__int128_t __convert_to_integral(__int128_t __val) { return __val; }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
|
||||
#endif
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename __sfinae_underlying_type<_Tp>::__promoted_type
|
||||
__convert_to_integral(_Tp __val) { return __val; }
|
||||
|
||||
@ -4941,6 +4805,21 @@ struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
|
||||
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
enum class endian
|
||||
{
|
||||
little = 0xDEAD,
|
||||
big = 0xFACE,
|
||||
#if defined(_LIBCPP_LITTLE_ENDIAN)
|
||||
native = little
|
||||
#elif defined(_LIBCPP_BIG_ENDIAN)
|
||||
native = big
|
||||
#else
|
||||
native = 0xCAFE
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
@ -4951,7 +4830,7 @@ template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
|
||||
operator<<=(byte& __lhs, _Integer __shift) noexcept
|
||||
{ return __lhs = __lhs << __shift; }
|
||||
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
|
||||
operator<< (byte __lhs, _Integer __shift) noexcept
|
||||
@ -4966,7 +4845,7 @@ template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
|
||||
operator>> (byte __lhs, _Integer __shift) noexcept
|
||||
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
|
||||
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
|
||||
to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
|
||||
|
@ -69,6 +69,10 @@ public:
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#include <vcruntime_typeinfo.h>
|
||||
#else
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
|
||||
#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
|
||||
@ -219,8 +223,10 @@ public:
|
||||
|
||||
} // std
|
||||
|
||||
#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_bad_cast()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
|
@ -396,7 +396,7 @@ public:
|
||||
const _Hash& hash_function() const _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Cp& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x.__cc.first);}
|
||||
{return static_cast<const _Hash&>(*this)(__x.__get_value().first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Key& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x);}
|
||||
@ -425,7 +425,7 @@ public:
|
||||
const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Cp& __x) const
|
||||
{return __hash_(__x.__cc.first);}
|
||||
{return __hash_(__x.__get_value().first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Key& __x) const
|
||||
{return __hash_(__x);}
|
||||
@ -464,13 +464,13 @@ public:
|
||||
const _Pred& key_eq() const _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Cp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
|
||||
{return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Key& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
|
||||
{return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
|
||||
void swap(__unordered_map_equal&__y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
|
||||
{
|
||||
@ -496,13 +496,13 @@ public:
|
||||
const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Cp& __y) const
|
||||
{return __pred_(__x.__cc.first, __y.__cc.first);}
|
||||
{return __pred_(__x.__get_value().first, __y.__get_value().first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Key& __y) const
|
||||
{return __pred_(__x.__cc.first, __y);}
|
||||
{return __pred_(__x.__get_value().first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||
{return __pred_(__x, __y.__cc.first);}
|
||||
{return __pred_(__x, __y.__get_value().first);}
|
||||
void swap(__unordered_map_equal&__y)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
|
||||
{
|
||||
@ -572,9 +572,9 @@ public:
|
||||
void operator()(pointer __p) _NOEXCEPT
|
||||
{
|
||||
if (__second_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
|
||||
if (__first_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
|
||||
if (__p)
|
||||
__alloc_traits::deallocate(__na_, __p, 1);
|
||||
}
|
||||
@ -582,23 +582,67 @@ public:
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Key, class _Tp>
|
||||
union __hash_value_type
|
||||
struct __hash_value_type
|
||||
{
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
|
||||
typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
|
||||
|
||||
private:
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type& __get_value()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
return *_VSTD::launder(_VSTD::addressof(__cc));
|
||||
#else
|
||||
return __cc;
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type& __get_value() const
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
return *_VSTD::launder(_VSTD::addressof(__cc));
|
||||
#else
|
||||
return __cc;
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__nc_ref_pair_type __ref()
|
||||
{
|
||||
value_type& __v = __get_value();
|
||||
return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__nc_rref_pair_type __move()
|
||||
{
|
||||
value_type& __v = __get_value();
|
||||
return __nc_rref_pair_type(
|
||||
_VSTD::move(const_cast<key_type&>(__v.first)),
|
||||
_VSTD::move(__v.second));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_value_type& operator=(const __hash_value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
{
|
||||
__ref() = __v.__get_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_value_type& operator=(__hash_value_type&& __v)
|
||||
{__nc = _VSTD::move(__v.__nc); return *this;}
|
||||
{
|
||||
__ref() = __v.__move();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _ValueTp,
|
||||
class = typename enable_if<
|
||||
@ -606,8 +650,10 @@ union __hash_value_type
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_value_type& operator=(_ValueTp&& __v) {
|
||||
__nc = _VSTD::forward<_ValueTp>(__v); return *this;
|
||||
__hash_value_type& operator=(_ValueTp&& __v)
|
||||
{
|
||||
__ref() = _VSTD::forward<_ValueTp>(__v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -628,8 +674,15 @@ struct __hash_value_type
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
|
||||
private:
|
||||
value_type __cc;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type& __get_value() { return __cc; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type& __get_value() const { return __cc; }
|
||||
|
||||
private:
|
||||
~__hash_value_type();
|
||||
};
|
||||
@ -657,9 +710,9 @@ public:
|
||||
__hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
reference operator*() const {return __i_->__get_value();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_iterator& operator++() {++__i_; return *this;}
|
||||
@ -711,9 +764,9 @@ public:
|
||||
: __i_(__i.__i_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
reference operator*() const {return __i_->__get_value();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_const_iterator& operator++() {++__i_; return *this;}
|
||||
@ -750,7 +803,6 @@ public:
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
|
||||
@ -1298,8 +1350,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
|
||||
{
|
||||
iterator __i = __u.begin();
|
||||
while (__u.size() != 0) {
|
||||
__table_.__emplace_unique(_VSTD::move(
|
||||
__u.__table_.remove((__i++).__i_)->__value_.__nc));
|
||||
__table_.__emplace_unique(
|
||||
__u.__table_.remove((__i++).__i_)->__value_.__move());
|
||||
}
|
||||
}
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1385,7 +1437,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
|
||||
{
|
||||
return __table_.__emplace_unique_key_args(__k,
|
||||
std::piecewise_construct, std::forward_as_tuple(__k),
|
||||
std::forward_as_tuple()).first->__cc.second;
|
||||
std::forward_as_tuple()).first->__get_value().second;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
@ -1394,7 +1446,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
|
||||
{
|
||||
return __table_.__emplace_unique_key_args(__k,
|
||||
std::piecewise_construct, std::forward_as_tuple(std::move(__k)),
|
||||
std::forward_as_tuple()).first->__cc.second;
|
||||
std::forward_as_tuple()).first->__get_value().second;
|
||||
}
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
|
||||
@ -1404,9 +1456,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
|
||||
}
|
||||
@ -1500,7 +1552,6 @@ public:
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
|
||||
@ -1915,8 +1966,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
|
||||
while (__u.size() != 0)
|
||||
{
|
||||
__table_.__insert_multi(
|
||||
_VSTD::move(__u.__table_.remove((__i++).__i_)->__value_.__nc)
|
||||
);
|
||||
__u.__table_.remove((__i++).__i_)->__value_.__move());
|
||||
}
|
||||
}
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
@ -14,6 +14,8 @@
|
||||
/*
|
||||
utility synopsis
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
@ -52,7 +54,7 @@ template <class T>
|
||||
>::type
|
||||
move_if_noexcept(T& x) noexcept; // constexpr in C++14
|
||||
|
||||
template <class T> constexpr add_const<T>_t& as_const(T& t) noexcept; // C++17
|
||||
template <class T> constexpr add_const_t<T>& as_const(T& t) noexcept; // C++17
|
||||
template <class T> void as_const(const T&&) = delete; // C++17
|
||||
|
||||
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
|
||||
@ -890,7 +892,7 @@ template<class... _Tp>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template<class _T1, class _T2 = _T1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_T1 exchange(_T1& __obj, _T2 && __new_value)
|
||||
{
|
||||
_T1 __old_value = _VSTD::move(__obj);
|
||||
|
@ -1053,6 +1053,9 @@ private:
|
||||
friend
|
||||
const _Up*
|
||||
end(const valarray<_Up>& __v);
|
||||
|
||||
void __clear();
|
||||
valarray& __assign_range(const value_type* __f, const value_type* __l);
|
||||
};
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
|
||||
@ -2735,7 +2738,8 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
|
||||
static_cast<result_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(result_type), __alignof(result_type)));
|
||||
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
|
||||
::new (__r.__end_) result_type(__expr_[__i]);
|
||||
}
|
||||
@ -2750,7 +2754,25 @@ valarray<_Tp>::valarray(size_t __n)
|
||||
: __begin_(0),
|
||||
__end_(0)
|
||||
{
|
||||
resize(__n);
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
for (; __n; --__n, ++__end_)
|
||||
::new (__end_) value_type();
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
@ -2769,7 +2791,8 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
|
||||
{
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2780,7 +2803,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2794,7 +2817,8 @@ valarray<_Tp>::valarray(const valarray& __v)
|
||||
{
|
||||
if (__v.size())
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__v.size() * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2805,7 +2829,7 @@ valarray<_Tp>::valarray(const valarray& __v)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2831,7 +2855,8 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
|
||||
size_t __n = __il.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2842,7 +2867,7 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2859,7 +2884,8 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
|
||||
size_t __n = __sa.__size_;
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2870,7 +2896,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2885,7 +2911,8 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
|
||||
size_t __n = __ga.__1d_.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2899,7 +2926,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2914,7 +2941,8 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
|
||||
size_t __n = __ma.__1d_.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2928,7 +2956,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2943,7 +2971,8 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
|
||||
size_t __n = __ia.__1d_.size();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -2957,7 +2986,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@ -2968,7 +2997,25 @@ template <class _Tp>
|
||||
inline
|
||||
valarray<_Tp>::~valarray()
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
valarray<_Tp>&
|
||||
valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
|
||||
{
|
||||
size_t __n = __l - __f;
|
||||
if (size() != __n)
|
||||
{
|
||||
__clear();
|
||||
__begin_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
__end_ = __begin_ + __n;
|
||||
_VSTD::uninitialized_copy(__f, __l, __begin_);
|
||||
} else {
|
||||
_VSTD::copy(__f, __l, __begin_);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
@ -2976,11 +3023,7 @@ valarray<_Tp>&
|
||||
valarray<_Tp>::operator=(const valarray& __v)
|
||||
{
|
||||
if (this != &__v)
|
||||
{
|
||||
if (size() != __v.size())
|
||||
resize(__v.size());
|
||||
_VSTD::copy(__v.__begin_, __v.__end_, __begin_);
|
||||
}
|
||||
return __assign_range(__v.__begin_, __v.__end_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -2991,7 +3034,7 @@ inline
|
||||
valarray<_Tp>&
|
||||
valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
__begin_ = __v.__begin_;
|
||||
__end_ = __v.__end_;
|
||||
__v.__begin_ = nullptr;
|
||||
@ -3004,10 +3047,7 @@ inline
|
||||
valarray<_Tp>&
|
||||
valarray<_Tp>::operator=(initializer_list<value_type> __il)
|
||||
{
|
||||
if (size() != __il.size())
|
||||
resize(__il.size());
|
||||
_VSTD::copy(__il.begin(), __il.end(), __begin_);
|
||||
return *this;
|
||||
return __assign_range(__il.begin(), __il.end());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
@ -3224,7 +3264,8 @@ valarray<_Tp>::operator+() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(+*__p);
|
||||
}
|
||||
@ -3241,7 +3282,8 @@ valarray<_Tp>::operator-() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(-*__p);
|
||||
}
|
||||
@ -3258,7 +3300,8 @@ valarray<_Tp>::operator~() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(~*__p);
|
||||
}
|
||||
@ -3275,7 +3318,7 @@ valarray<_Tp>::operator!() const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
|
||||
static_cast<bool*>(_VSTD::__libcpp_allocate(__n * sizeof(bool), __alignof(bool)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) bool(!*__p);
|
||||
}
|
||||
@ -3595,7 +3638,8 @@ valarray<_Tp>::shift(int __i) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
const value_type* __sb;
|
||||
value_type* __tb;
|
||||
value_type* __te;
|
||||
@ -3633,7 +3677,8 @@ valarray<_Tp>::cshift(int __i) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
__i %= static_cast<int>(__n);
|
||||
const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
|
||||
for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
|
||||
@ -3654,7 +3699,8 @@ valarray<_Tp>::apply(value_type __f(value_type)) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(__f(*__p));
|
||||
}
|
||||
@ -3671,7 +3717,8 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
|
||||
{
|
||||
__r.__begin_ =
|
||||
__r.__end_ =
|
||||
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
|
||||
::new (__r.__end_) value_type(__f(*__p));
|
||||
}
|
||||
@ -3680,18 +3727,26 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
|
||||
|
||||
template <class _Tp>
|
||||
void
|
||||
valarray<_Tp>::resize(size_t __n, value_type __x)
|
||||
valarray<_Tp>::__clear()
|
||||
{
|
||||
if (__begin_ != nullptr)
|
||||
{
|
||||
while (__end_ != __begin_)
|
||||
(--__end_)->~value_type();
|
||||
_VSTD::__libcpp_deallocate(__begin_);
|
||||
_VSTD::__libcpp_deallocate(__begin_, __alignof(value_type));
|
||||
__begin_ = __end_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
void
|
||||
valarray<_Tp>::resize(size_t __n, value_type __x)
|
||||
{
|
||||
__clear();
|
||||
if (__n)
|
||||
{
|
||||
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
|
||||
__begin_ = __end_ = static_cast<value_type*>(
|
||||
_VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
@ -3702,7 +3757,7 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
resize(0);
|
||||
__clear();
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
|
@ -476,8 +476,8 @@ private:
|
||||
template <class... _Fs>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
static constexpr auto __make_farray(_Fs&&... __fs) {
|
||||
__std_visit_visitor_return_type_check<decay_t<_Fs>...>();
|
||||
using __result = array<common_type_t<decay_t<_Fs>...>, sizeof...(_Fs)>;
|
||||
__std_visit_visitor_return_type_check<__uncvref_t<_Fs>...>();
|
||||
using __result = array<common_type_t<__uncvref_t<_Fs>...>, sizeof...(_Fs)>;
|
||||
return __result{{_VSTD::forward<_Fs>(__fs)...}};
|
||||
}
|
||||
|
||||
@ -514,8 +514,8 @@ private:
|
||||
template <class _Fp, class _Vp, class... _Vs>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
static constexpr auto __make_fdiagonal() {
|
||||
constexpr size_t _Np = decay_t<_Vp>::__size();
|
||||
static_assert(__all<(_Np == decay_t<_Vs>::__size())...>::value);
|
||||
constexpr size_t _Np = __uncvref_t<_Vp>::__size();
|
||||
static_assert(__all<(_Np == __uncvref_t<_Vs>::__size())...>::value);
|
||||
return __make_fdiagonal_impl<_Fp, _Vp, _Vs...>(make_index_sequence<_Np>{});
|
||||
}
|
||||
|
||||
@ -538,7 +538,7 @@ private:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
static constexpr auto __make_fmatrix() {
|
||||
return __make_fmatrix_impl<_Fp, _Vs...>(
|
||||
index_sequence<>{}, make_index_sequence<decay_t<_Vs>::__size()>{}...);
|
||||
index_sequence<>{}, make_index_sequence<__uncvref_t<_Vs>::__size()>{}...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -756,7 +756,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(
|
||||
if (!this->valueless_by_exception()) {
|
||||
__visitation::__base::__visit_alt(
|
||||
[](auto& __alt) noexcept {
|
||||
using __alt_type = decay_t<decltype(__alt)>;
|
||||
using __alt_type = __uncvref_t<decltype(__alt)>;
|
||||
__alt.~__alt_type();
|
||||
},
|
||||
*this);
|
||||
@ -1143,9 +1143,9 @@ public:
|
||||
|
||||
template <
|
||||
class _Arg,
|
||||
enable_if_t<!is_same_v<decay_t<_Arg>, variant>, int> = 0,
|
||||
enable_if_t<!__is_inplace_type<decay_t<_Arg>>::value, int> = 0,
|
||||
enable_if_t<!__is_inplace_index<decay_t<_Arg>>::value, int> = 0,
|
||||
enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
|
||||
enable_if_t<!__is_inplace_type<__uncvref_t<_Arg>>::value, int> = 0,
|
||||
enable_if_t<!__is_inplace_index<__uncvref_t<_Arg>>::value, int> = 0,
|
||||
class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
|
||||
size_t _Ip =
|
||||
__find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
|
||||
@ -1215,7 +1215,7 @@ public:
|
||||
|
||||
template <
|
||||
class _Arg,
|
||||
enable_if_t<!is_same_v<decay_t<_Arg>, variant>, int> = 0,
|
||||
enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
|
||||
class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
|
||||
size_t _Ip =
|
||||
__find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
|
||||
@ -1564,7 +1564,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<
|
||||
? 299792458 // Random value chosen by the universe upon creation
|
||||
: __variant::__visit_alt(
|
||||
[](const auto& __alt) {
|
||||
using __alt_type = decay_t<decltype(__alt)>;
|
||||
using __alt_type = __uncvref_t<decltype(__alt)>;
|
||||
using __value_type = remove_const_t<
|
||||
typename __alt_type::__value_type>;
|
||||
return hash<__value_type>{}(__alt.__value);
|
||||
|
@ -244,6 +244,10 @@ public:
|
||||
bool __invariants() const;
|
||||
};
|
||||
|
||||
template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
||||
vector(InputIterator, InputIterator, Allocator = Allocator())
|
||||
-> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
|
||||
|
||||
template <class Allocator> struct hash<std::vector<bool, Allocator>>;
|
||||
|
||||
template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
|
||||
@ -291,7 +295,7 @@ template <bool>
|
||||
class __vector_base_common
|
||||
{
|
||||
protected:
|
||||
_LIBCPP_ALWAYS_INLINE __vector_base_common() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __vector_base_common() {}
|
||||
_LIBCPP_NORETURN void __throw_length_error() const;
|
||||
_LIBCPP_NORETURN void __throw_out_of_range() const;
|
||||
};
|
||||
@ -316,13 +320,14 @@ template <class _Tp, class _Allocator>
|
||||
class __vector_base
|
||||
: protected __vector_base_common<true>
|
||||
{
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
public:
|
||||
typedef _Allocator allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
@ -350,6 +355,9 @@ protected:
|
||||
__vector_base()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
|
||||
_LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT;
|
||||
#endif
|
||||
~__vector_base();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -433,6 +441,15 @@ __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT
|
||||
: __begin_(nullptr),
|
||||
__end_(nullptr),
|
||||
__end_cap_(nullptr, std::move(__a)) {}
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__vector_base<_Tp, _Allocator>::~__vector_base()
|
||||
{
|
||||
@ -492,8 +509,8 @@ public:
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
explicit vector(size_type __n, const allocator_type& __a);
|
||||
#endif
|
||||
vector(size_type __n, const_reference __x);
|
||||
vector(size_type __n, const_reference __x, const allocator_type& __a);
|
||||
vector(size_type __n, const value_type& __x);
|
||||
vector(size_type __n, const value_type& __x, const allocator_type& __a);
|
||||
template <class _InputIterator>
|
||||
vector(_InputIterator __first,
|
||||
typename enable_if<__is_input_iterator <_InputIterator>::value &&
|
||||
@ -776,8 +793,8 @@ public:
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
|
||||
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
|
||||
void allocate(size_type __n);
|
||||
void deallocate() _NOEXCEPT;
|
||||
void __vallocate(size_type __n);
|
||||
void __vdeallocate() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
|
||||
void __construct_at_end(size_type __n);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -890,6 +907,22 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _InputIterator,
|
||||
class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
vector(_InputIterator, _InputIterator)
|
||||
-> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
|
||||
template<class _InputIterator,
|
||||
class _Alloc,
|
||||
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
|
||||
>
|
||||
vector(_InputIterator, _InputIterator, _Alloc)
|
||||
-> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
|
||||
@ -930,7 +963,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
|
||||
// Postcondition: size() == 0
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
vector<_Tp, _Allocator>::allocate(size_type __n)
|
||||
vector<_Tp, _Allocator>::__vallocate(size_type __n)
|
||||
{
|
||||
if (__n > max_size())
|
||||
this->__throw_length_error();
|
||||
@ -941,7 +974,7 @@ vector<_Tp, _Allocator>::allocate(size_type __n)
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
vector<_Tp, _Allocator>::deallocate() _NOEXCEPT
|
||||
vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
|
||||
{
|
||||
if (this->__begin_ != nullptr)
|
||||
{
|
||||
@ -1077,7 +1110,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)
|
||||
#endif
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n);
|
||||
}
|
||||
}
|
||||
@ -1092,27 +1125,27 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
|
||||
#endif
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x)
|
||||
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n, __x);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a)
|
||||
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
|
||||
: __base(__a)
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1120,7 +1153,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const alloca
|
||||
#endif
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n, __x);
|
||||
}
|
||||
}
|
||||
@ -1174,7 +1207,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
|
||||
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__first, __last, __n);
|
||||
}
|
||||
}
|
||||
@ -1194,7 +1227,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
|
||||
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__first, __last, __n);
|
||||
}
|
||||
}
|
||||
@ -1209,7 +1242,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
|
||||
size_type __n = __x.size();
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__x.__begin_, __x.__end_, __n);
|
||||
}
|
||||
}
|
||||
@ -1224,7 +1257,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
|
||||
size_type __n = __x.size();
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__x.__begin_, __x.__end_, __n);
|
||||
}
|
||||
}
|
||||
@ -1285,7 +1318,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
|
||||
#endif
|
||||
if (__il.size() > 0)
|
||||
{
|
||||
allocate(__il.size());
|
||||
__vallocate(__il.size());
|
||||
__construct_at_end(__il.begin(), __il.end(), __il.size());
|
||||
}
|
||||
}
|
||||
@ -1300,7 +1333,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
|
||||
#endif
|
||||
if (__il.size() > 0)
|
||||
{
|
||||
allocate(__il.size());
|
||||
__vallocate(__il.size());
|
||||
__construct_at_end(__il.begin(), __il.end(), __il.size());
|
||||
}
|
||||
}
|
||||
@ -1335,7 +1368,7 @@ void
|
||||
vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
{
|
||||
deallocate();
|
||||
__vdeallocate();
|
||||
__base::__move_assign_alloc(__c); // this can throw
|
||||
this->__begin_ = __c.__begin_;
|
||||
this->__end_ = __c.__end_;
|
||||
@ -1410,8 +1443,8 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
|
||||
}
|
||||
else
|
||||
{
|
||||
deallocate();
|
||||
allocate(__recommend(__new_size));
|
||||
__vdeallocate();
|
||||
__vallocate(__recommend(__new_size));
|
||||
__construct_at_end(__first, __last, __new_size);
|
||||
}
|
||||
__invalidate_all_iterators();
|
||||
@ -1432,8 +1465,8 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
|
||||
}
|
||||
else
|
||||
{
|
||||
deallocate();
|
||||
allocate(__recommend(static_cast<size_type>(__n)));
|
||||
__vdeallocate();
|
||||
__vallocate(__recommend(static_cast<size_type>(__n)));
|
||||
__construct_at_end(__n, __u);
|
||||
}
|
||||
__invalidate_all_iterators();
|
||||
@ -2416,8 +2449,8 @@ public:
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
|
||||
void allocate(size_type __n);
|
||||
void deallocate() _NOEXCEPT;
|
||||
void __vallocate(size_type __n);
|
||||
void __vdeallocate() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __align_it(size_type __new_size) _NOEXCEPT
|
||||
{return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);};
|
||||
@ -2455,7 +2488,7 @@ private:
|
||||
void __copy_assign_alloc(const vector& __c, true_type)
|
||||
{
|
||||
if (__alloc() != __c.__alloc())
|
||||
deallocate();
|
||||
__vdeallocate();
|
||||
__alloc() = __c.__alloc();
|
||||
}
|
||||
|
||||
@ -2511,7 +2544,7 @@ vector<bool, _Allocator>::__invalidate_all_iterators()
|
||||
// Postcondition: size() == 0
|
||||
template <class _Allocator>
|
||||
void
|
||||
vector<bool, _Allocator>::allocate(size_type __n)
|
||||
vector<bool, _Allocator>::__vallocate(size_type __n)
|
||||
{
|
||||
if (__n > max_size())
|
||||
this->__throw_length_error();
|
||||
@ -2523,7 +2556,7 @@ vector<bool, _Allocator>::allocate(size_type __n)
|
||||
|
||||
template <class _Allocator>
|
||||
void
|
||||
vector<bool, _Allocator>::deallocate() _NOEXCEPT
|
||||
vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
|
||||
{
|
||||
if (this->__begin_ != nullptr)
|
||||
{
|
||||
@ -2620,7 +2653,7 @@ vector<bool, _Allocator>::vector(size_type __n)
|
||||
{
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n, false);
|
||||
}
|
||||
}
|
||||
@ -2634,7 +2667,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
|
||||
{
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n, false);
|
||||
}
|
||||
}
|
||||
@ -2648,7 +2681,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
|
||||
{
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n, __x);
|
||||
}
|
||||
}
|
||||
@ -2661,7 +2694,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
|
||||
{
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__n, __x);
|
||||
}
|
||||
}
|
||||
@ -2731,7 +2764,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
|
||||
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__first, __last);
|
||||
}
|
||||
}
|
||||
@ -2747,7 +2780,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
|
||||
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__first, __last);
|
||||
}
|
||||
}
|
||||
@ -2763,7 +2796,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
|
||||
size_type __n = static_cast<size_type>(__il.size());
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__il.begin(), __il.end());
|
||||
}
|
||||
}
|
||||
@ -2777,7 +2810,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
|
||||
size_type __n = static_cast<size_type>(__il.size());
|
||||
if (__n > 0)
|
||||
{
|
||||
allocate(__n);
|
||||
__vallocate(__n);
|
||||
__construct_at_end(__il.begin(), __il.end());
|
||||
}
|
||||
}
|
||||
@ -2800,7 +2833,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
|
||||
{
|
||||
if (__v.size() > 0)
|
||||
{
|
||||
allocate(__v.size());
|
||||
__vallocate(__v.size());
|
||||
__construct_at_end(__v.begin(), __v.end());
|
||||
}
|
||||
}
|
||||
@ -2813,7 +2846,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
|
||||
{
|
||||
if (__v.size() > 0)
|
||||
{
|
||||
allocate(__v.size());
|
||||
__vallocate(__v.size());
|
||||
__construct_at_end(__v.begin(), __v.end());
|
||||
}
|
||||
}
|
||||
@ -2829,8 +2862,8 @@ vector<bool, _Allocator>::operator=(const vector& __v)
|
||||
{
|
||||
if (__v.__size_ > capacity())
|
||||
{
|
||||
deallocate();
|
||||
allocate(__v.__size_);
|
||||
__vdeallocate();
|
||||
__vallocate(__v.__size_);
|
||||
}
|
||||
_VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
|
||||
}
|
||||
@ -2842,17 +2875,15 @@ vector<bool, _Allocator>::operator=(const vector& __v)
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
vector<bool, _Allocator>::vector(vector&& __v)
|
||||
inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
_NOEXCEPT
|
||||
_NOEXCEPT
|
||||
#else
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
|
||||
#endif
|
||||
: __begin_(__v.__begin_),
|
||||
__size_(__v.__size_),
|
||||
__cap_alloc_(__v.__cap_alloc_)
|
||||
{
|
||||
__cap_alloc_(std::move(__v.__cap_alloc_)) {
|
||||
__v.__begin_ = nullptr;
|
||||
__v.__size_ = 0;
|
||||
__v.__cap() = 0;
|
||||
@ -2874,7 +2905,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a)
|
||||
}
|
||||
else if (__v.size() > 0)
|
||||
{
|
||||
allocate(__v.size());
|
||||
__vallocate(__v.size());
|
||||
__construct_at_end(__v.begin(), __v.end());
|
||||
}
|
||||
}
|
||||
@ -2905,7 +2936,7 @@ void
|
||||
vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
{
|
||||
deallocate();
|
||||
__vdeallocate();
|
||||
__move_assign_alloc(__c);
|
||||
this->__begin_ = __c.__begin_;
|
||||
this->__size_ = __c.__size_;
|
||||
@ -2970,8 +3001,8 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
|
||||
{
|
||||
if (__n > capacity())
|
||||
{
|
||||
deallocate();
|
||||
allocate(__n);
|
||||
__vdeallocate();
|
||||
__vallocate(__n);
|
||||
}
|
||||
__construct_at_end(__first, __last);
|
||||
}
|
||||
@ -2984,7 +3015,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
|
||||
if (__n > capacity())
|
||||
{
|
||||
vector __v(this->__alloc());
|
||||
__v.allocate(__n);
|
||||
__v.__vallocate(__n);
|
||||
__v.__construct_at_end(this->begin(), this->end());
|
||||
swap(__v);
|
||||
__invalidate_all_iterators();
|
||||
|
25
contrib/libc++/include/version
Normal file
25
contrib/libc++/include/version
Normal file
@ -0,0 +1,25 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- version ----------------------------------===//
|
||||
//
|
||||
// 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_VERSIONH
|
||||
#define _LIBCPP_VERSIONH
|
||||
|
||||
/*
|
||||
version synopsis
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_VERSIONH
|
@ -8,7 +8,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "any"
|
||||
#include "experimental/any"
|
||||
|
||||
namespace std {
|
||||
const char* bad_any_cast::what() const _NOEXCEPT {
|
||||
@ -16,8 +15,21 @@ const char* bad_any_cast::what() const _NOEXCEPT {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
// Preserve std::experimental::any_bad_cast for ABI compatibility
|
||||
// Even though it no longer exists in a header file
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
const char* bad_any_cast::what() const _NOEXCEPT {
|
||||
return "bad any cast";
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
@ -11,27 +11,10 @@
|
||||
#include "cerrno" // errno
|
||||
#include "system_error" // __throw_system_error
|
||||
#include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
|
||||
#include "include/apple_availability.h"
|
||||
|
||||
#if (__APPLE__)
|
||||
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
|
||||
#define _LIBCXX_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000
|
||||
#define _LIBCXX_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 100000
|
||||
#define _LIBCXX_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000
|
||||
#define _LIBCXX_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
|
||||
#else
|
||||
#define _LIBCXX_USE_CLOCK_GETTIME
|
||||
#if !defined(__APPLE__)
|
||||
#define _LIBCPP_USE_CLOCK_GETTIME
|
||||
#endif // __APPLE__
|
||||
|
||||
#if defined(_LIBCPP_WIN32API)
|
||||
@ -42,7 +25,7 @@
|
||||
#include <winapifamily.h>
|
||||
#endif
|
||||
#else
|
||||
#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME)
|
||||
#if !defined(CLOCK_REALTIME) || !defined(_LIBCPP_USE_CLOCK_GETTIME)
|
||||
#include <sys/time.h> // for gettimeofday and timeval
|
||||
#endif // !defined(CLOCK_REALTIME)
|
||||
#endif // defined(_LIBCPP_WIN32API)
|
||||
@ -92,16 +75,16 @@ system_clock::now() _NOEXCEPT
|
||||
static_cast<__int64>(ft.dwLowDateTime)};
|
||||
return time_point(duration_cast<duration>(d - nt_to_unix_epoch));
|
||||
#else
|
||||
#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
|
||||
struct timespec tp;
|
||||
if (0 != clock_gettime(CLOCK_REALTIME, &tp))
|
||||
__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
|
||||
return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
|
||||
#if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
|
||||
struct timespec tp;
|
||||
if (0 != clock_gettime(CLOCK_REALTIME, &tp))
|
||||
__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
|
||||
return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
|
||||
#else
|
||||
timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
|
||||
#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
|
||||
#endif // _LIBCPP_USE_CLOCK_GETTIME && CLOCK_REALTIME
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -129,7 +112,7 @@ const bool steady_clock::is_steady;
|
||||
#if defined(__APPLE__)
|
||||
|
||||
// Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
|
||||
#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
|
||||
#if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
|
||||
steady_clock::time_point
|
||||
steady_clock::now() _NOEXCEPT
|
||||
{
|
||||
@ -191,7 +174,7 @@ steady_clock::now() _NOEXCEPT
|
||||
static FP fp = init_steady_clock();
|
||||
return time_point(duration(fp()));
|
||||
}
|
||||
#endif // defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
|
||||
#endif // defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
|
||||
|
||||
#elif defined(_LIBCPP_WIN32API)
|
||||
|
||||
|
@ -1,342 +0,0 @@
|
||||
//===------------------ directory_iterator.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 "__config"
|
||||
#if defined(_LIBCPP_WIN32API)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
namespace { namespace detail {
|
||||
|
||||
#if !defined(_LIBCPP_WIN32API)
|
||||
inline error_code capture_errno() {
|
||||
_LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
|
||||
return error_code{errno, std::generic_category()};
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
__throw_filesystem_error(msg, std::forward<Args>(args)..., my_ec);
|
||||
return false;
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_WIN32API)
|
||||
inline path::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
|
||||
ec.clear();
|
||||
if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {
|
||||
if (errno)
|
||||
ec = capture_errno();
|
||||
return {};
|
||||
} else {
|
||||
return dir_entry_ptr->d_name;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}} // namespace detail
|
||||
|
||||
using detail::set_or_throw;
|
||||
|
||||
#if defined(_LIBCPP_WIN32API)
|
||||
class __dir_stream {
|
||||
public:
|
||||
__dir_stream() = delete;
|
||||
__dir_stream& operator=(const __dir_stream&) = delete;
|
||||
|
||||
__dir_stream(__dir_stream&& __ds) noexcept
|
||||
: __stream_(__ds.__stream_), __root_(std::move(__ds.__root_)),
|
||||
__entry_(std::move(__ds.__entry_)) {
|
||||
__ds.__stream_ = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
__dir_stream(const path& root, directory_options opts, error_code& ec)
|
||||
: __stream_(INVALID_HANDLE_VALUE), __root_(root) {
|
||||
__stream_ = ::FindFirstFile(root.c_str(), &__data_);
|
||||
if (__stream_ == INVALID_HANDLE_VALUE) {
|
||||
ec = error_code(::GetLastError(), std::generic_category());
|
||||
const bool ignore_permission_denied =
|
||||
bool(opts & directory_options::skip_permission_denied);
|
||||
if (ignore_permission_denied && ec.value() == ERROR_ACCESS_DENIED)
|
||||
ec.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
~__dir_stream() noexcept {
|
||||
if (__stream_ == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
close();
|
||||
}
|
||||
|
||||
bool good() const noexcept { return __stream_ != INVALID_HANDLE_VALUE; }
|
||||
|
||||
bool advance(error_code& ec) {
|
||||
while (::FindNextFile(__stream_, &__data_)) {
|
||||
if (!strcmp(__data_.cFileName, ".") || strcmp(__data_.cFileName, ".."))
|
||||
continue;
|
||||
__entry_.assign(__root_ / __data_.cFileName);
|
||||
return true;
|
||||
}
|
||||
ec = error_code(::GetLastError(), std::generic_category());
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::error_code close() noexcept {
|
||||
std::error_code ec;
|
||||
if (!::FindClose(__stream_))
|
||||
ec = error_code(::GetLastError(), std::generic_category());
|
||||
__stream_ = INVALID_HANDLE_VALUE;
|
||||
return ec;
|
||||
}
|
||||
|
||||
HANDLE __stream_{INVALID_HANDLE_VALUE};
|
||||
WIN32_FIND_DATA __data_;
|
||||
|
||||
public:
|
||||
path __root_;
|
||||
directory_entry __entry_;
|
||||
};
|
||||
#else
|
||||
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_;
|
||||
};
|
||||
#endif
|
||||
|
||||
// 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::__dereference() 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::__dereference() 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();
|
||||
|
||||
bool skip_rec = false;
|
||||
std::error_code m_ec;
|
||||
if (!rec_sym) {
|
||||
file_status st = curr_it.__entry_.symlink_status(m_ec);
|
||||
if (m_ec && status_known(st))
|
||||
m_ec.clear();
|
||||
if (m_ec || is_symlink(st) || !is_directory(st))
|
||||
skip_rec = true;
|
||||
} else {
|
||||
file_status st = curr_it.__entry_.status(m_ec);
|
||||
if (m_ec && status_known(st))
|
||||
m_ec.clear();
|
||||
if (m_ec || !is_directory(st))
|
||||
skip_rec = true;
|
||||
}
|
||||
|
||||
if (!skip_rec) {
|
||||
__dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
|
||||
if (new_it.good()) {
|
||||
__imp_->__stack_.push(_VSTD::move(new_it));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (m_ec) {
|
||||
const bool allow_eacess = bool(__imp_->__options_
|
||||
& directory_options::skip_permission_denied);
|
||||
if (m_ec.value() == EACCES && allow_eacess) {
|
||||
if (ec) ec->clear();
|
||||
} else {
|
||||
__imp_.reset();
|
||||
set_or_throw(m_ec, ec,
|
||||
"recursive_directory_iterator::operator++()");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
@ -1,173 +0,0 @@
|
||||
//===----------------------------------------------------------------------===////
|
||||
//
|
||||
// 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 FILESYSTEM_TIME_HELPER_H
|
||||
#define FILESYSTEM_TIME_HELPER_H
|
||||
|
||||
#include "experimental/__config"
|
||||
#include "chrono"
|
||||
#include "cstdlib"
|
||||
#include "climits"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#if !defined(UTIME_OMIT)
|
||||
#include <sys/time.h> // for ::utimes as used in __last_write_time
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
namespace time_detail { namespace {
|
||||
|
||||
using namespace chrono;
|
||||
|
||||
template <class FileTimeT,
|
||||
bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
|
||||
struct fs_time_util_base {
|
||||
static constexpr auto max_seconds =
|
||||
duration_cast<seconds>(FileTimeT::duration::max()).count();
|
||||
|
||||
static constexpr auto max_nsec =
|
||||
duration_cast<nanoseconds>(FileTimeT::duration::max() -
|
||||
seconds(max_seconds))
|
||||
.count();
|
||||
|
||||
static constexpr auto min_seconds =
|
||||
duration_cast<seconds>(FileTimeT::duration::min()).count();
|
||||
|
||||
static constexpr auto min_nsec_timespec =
|
||||
duration_cast<nanoseconds>(
|
||||
(FileTimeT::duration::min() - seconds(min_seconds)) + seconds(1))
|
||||
.count();
|
||||
|
||||
// Static assert that these values properly round trip.
|
||||
static_assert((seconds(min_seconds) +
|
||||
duration_cast<microseconds>(nanoseconds(min_nsec_timespec))) -
|
||||
duration_cast<microseconds>(seconds(1)) ==
|
||||
FileTimeT::duration::min(),
|
||||
"");
|
||||
};
|
||||
|
||||
template <class FileTimeT>
|
||||
struct fs_time_util_base<FileTimeT, true> {
|
||||
static const long long max_seconds;
|
||||
static const long long max_nsec;
|
||||
static const long long min_seconds;
|
||||
static const long long min_nsec_timespec;
|
||||
};
|
||||
|
||||
template <class FileTimeT>
|
||||
const long long fs_time_util_base<FileTimeT, true>::max_seconds =
|
||||
duration_cast<seconds>(FileTimeT::duration::max()).count();
|
||||
|
||||
template <class FileTimeT>
|
||||
const long long fs_time_util_base<FileTimeT, true>::max_nsec =
|
||||
duration_cast<nanoseconds>(FileTimeT::duration::max() -
|
||||
seconds(max_seconds))
|
||||
.count();
|
||||
|
||||
template <class FileTimeT>
|
||||
const long long fs_time_util_base<FileTimeT, true>::min_seconds =
|
||||
duration_cast<seconds>(FileTimeT::duration::min()).count();
|
||||
|
||||
template <class FileTimeT>
|
||||
const long long fs_time_util_base<FileTimeT, true>::min_nsec_timespec =
|
||||
duration_cast<nanoseconds>((FileTimeT::duration::min() -
|
||||
seconds(min_seconds)) +
|
||||
seconds(1))
|
||||
.count();
|
||||
|
||||
template <class FileTimeT, class TimeT, class TimeSpecT>
|
||||
struct fs_time_util : fs_time_util_base<FileTimeT> {
|
||||
using Base = fs_time_util_base<FileTimeT>;
|
||||
using Base::max_nsec;
|
||||
using Base::max_seconds;
|
||||
using Base::min_nsec_timespec;
|
||||
using Base::min_seconds;
|
||||
|
||||
public:
|
||||
template <class CType, class ChronoType>
|
||||
static 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;
|
||||
}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) {
|
||||
if (tm.tv_sec >= 0) {
|
||||
return (tm.tv_sec < max_seconds) ||
|
||||
(tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
|
||||
} else if (tm.tv_sec == (min_seconds - 1)) {
|
||||
return tm.tv_nsec >= min_nsec_timespec;
|
||||
} else {
|
||||
return (tm.tv_sec >= min_seconds);
|
||||
}
|
||||
}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) {
|
||||
auto secs = duration_cast<seconds>(tm.time_since_epoch());
|
||||
auto nsecs = duration_cast<nanoseconds>(tm.time_since_epoch() - secs);
|
||||
if (nsecs.count() < 0) {
|
||||
secs = secs + seconds(1);
|
||||
nsecs = nsecs + seconds(1);
|
||||
}
|
||||
using TLim = numeric_limits<TimeT>;
|
||||
if (secs.count() >= 0)
|
||||
return secs.count() <= TLim::max();
|
||||
return secs.count() >= TLim::min();
|
||||
}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT
|
||||
convert_timespec(TimeSpecT tm) {
|
||||
auto adj_msec = duration_cast<microseconds>(nanoseconds(tm.tv_nsec));
|
||||
if (tm.tv_sec >= 0) {
|
||||
auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec);
|
||||
return FileTimeT(Dur);
|
||||
} else if (duration_cast<microseconds>(nanoseconds(tm.tv_nsec)).count() ==
|
||||
0) {
|
||||
return FileTimeT(seconds(tm.tv_sec));
|
||||
} else { // tm.tv_sec < 0
|
||||
auto adj_subsec =
|
||||
duration_cast<microseconds>(seconds(1) - nanoseconds(tm.tv_nsec));
|
||||
auto Dur = seconds(tm.tv_sec + 1) - adj_subsec;
|
||||
return FileTimeT(Dur);
|
||||
}
|
||||
}
|
||||
|
||||
template <class SubSecDurT, class SubSecT>
|
||||
static bool set_times_checked(TimeT* sec_out, SubSecT* subsec_out,
|
||||
FileTimeT 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
|
||||
} // end namespace time_detail
|
||||
|
||||
using time_detail::fs_time_util;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
#endif // FILESYSTEM_TIME_HELPER_H
|
@ -1,808 +0,0 @@
|
||||
//===--------------------- 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 "filesystem_time_helper.h"
|
||||
|
||||
#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");
|
||||
return std::error_code(errno, std::generic_category());
|
||||
}
|
||||
|
||||
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;
|
||||
__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_ec1;
|
||||
struct ::stat f_st = {};
|
||||
const file_status f = sym_status || sym_status2
|
||||
? detail::posix_lstat(from, f_st, &m_ec1)
|
||||
: detail::posix_stat(from, f_st, &m_ec1);
|
||||
if (m_ec1)
|
||||
return set_or_throw(m_ec1, ec, "copy", from, to);
|
||||
|
||||
struct ::stat t_st = {};
|
||||
const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1)
|
||||
: detail::posix_stat(to, t_st, &m_ec1);
|
||||
|
||||
if (not status_known(t))
|
||||
return set_or_throw(m_ec1, ec, "copy", from, to);
|
||||
|
||||
if (!exists(f) || is_other(f) || is_other(t)
|
||||
|| (is_directory(f) && is_regular_file(t))
|
||||
|| 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) && bool(copy_options::create_symlinks & options)) {
|
||||
return set_or_throw(make_error_code(errc::is_a_directory), ec, "copy");
|
||||
}
|
||||
else if (is_directory(f) && (bool(copy_options::recursive & options) ||
|
||||
copy_options::none == options)) {
|
||||
|
||||
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_ec2;
|
||||
for (; it != directory_iterator(); it.increment(m_ec2)) {
|
||||
if (m_ec2) return set_or_throw(m_ec2, ec, "copy", from, to);
|
||||
__copy(it->path(), to / it->path().filename(),
|
||||
options | copy_options::__in_recursive_copy, ec);
|
||||
if (ec && *ec) { return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 && !is_regular_file(to_st)) {
|
||||
set_or_throw(make_error_code(errc::not_supported), ec, "copy_file", from, to);
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
auto make_unsupported_error = [&]() {
|
||||
set_or_throw(make_error_code(errc::not_supported), ec,
|
||||
"equivalent", p1, p2);
|
||||
return false;
|
||||
};
|
||||
std::error_code ec1, ec2;
|
||||
struct ::stat st1 = {};
|
||||
struct ::stat st2 = {};
|
||||
auto s1 = detail::posix_stat(p1.native(), st1, &ec1);
|
||||
if (!exists(s1))
|
||||
return make_unsupported_error();
|
||||
auto s2 = detail::posix_stat(p2.native(), st2, &ec2);
|
||||
if (!exists(s2))
|
||||
return make_unsupported_error();
|
||||
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 (m_ec) {
|
||||
set_or_throw(m_ec, ec, "is_empty", p);
|
||||
return false;
|
||||
}
|
||||
else if (!is_directory(st) && !is_regular_file(st)) {
|
||||
m_ec = make_error_code(errc::not_supported);
|
||||
set_or_throw(m_ec, ec, "is_empty");
|
||||
return false;
|
||||
}
|
||||
else if (is_directory(st)) {
|
||||
auto it = ec ? directory_iterator(p, *ec) : directory_iterator(p);
|
||||
if (ec && *ec)
|
||||
return false;
|
||||
return it == directory_iterator{};
|
||||
}
|
||||
else if (is_regular_file(st))
|
||||
return static_cast<std::uintmax_t>(pst.st_size) == 0;
|
||||
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
namespace detail { namespace {
|
||||
|
||||
using TimeSpec = struct timespec;
|
||||
using StatT = struct stat;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
|
||||
__attribute__((unused)) // Suppress warning
|
||||
TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
|
||||
#else
|
||||
TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
|
||||
__attribute__((unused)) // Suppress warning
|
||||
TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
|
||||
#endif
|
||||
|
||||
}} // end namespace detail
|
||||
|
||||
using FSTime = fs_time_util<file_time_type, time_t, struct timespec>;
|
||||
|
||||
file_time_type __last_write_time(const path& p, std::error_code *ec)
|
||||
{
|
||||
using namespace ::std::chrono;
|
||||
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();
|
||||
auto ts = detail::extract_mtime(st);
|
||||
if (!FSTime::is_representable(ts)) {
|
||||
set_or_throw(error_code(EOVERFLOW, generic_category()), ec,
|
||||
"last_write_time", p);
|
||||
return file_time_type::min();
|
||||
}
|
||||
return FSTime::convert_timespec(ts);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
auto atime = detail::extract_atime(st);
|
||||
struct ::timeval tbuf[2];
|
||||
tbuf[0].tv_sec = atime.tv_sec;
|
||||
tbuf[0].tv_usec = duration_cast<microseconds>(nanoseconds(atime.tv_nsec)).count();
|
||||
const bool overflowed = !FSTime::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 = !FSTime::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<::off_t>(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 (other == 0 || out / other != m_svfs.f_frsize)
|
||||
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;
|
||||
if (ret == nullptr)
|
||||
ret = "/tmp";
|
||||
|
||||
path p(ret);
|
||||
std::error_code m_ec;
|
||||
if (!exists(p, m_ec) || !is_directory(p, m_ec)) {
|
||||
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 {};
|
||||
}
|
||||
|
||||
if (ec)
|
||||
ec->clear();
|
||||
return p;
|
||||
}
|
||||
|
||||
// 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
|
@ -1,448 +0,0 @@
|
||||
//===--------------------- 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 "string_view"
|
||||
#include "utility"
|
||||
|
||||
namespace { namespace parser
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::experimental::filesystem;
|
||||
|
||||
using string_view_t = path::__string_view;
|
||||
using string_view_pair = pair<string_view_t, string_view_t>;
|
||||
using PosPtr = path::value_type const*;
|
||||
|
||||
struct PathParser {
|
||||
enum ParserState : unsigned char {
|
||||
// Zero is a special sentinel value used by default constructed iterators.
|
||||
PS_BeforeBegin = 1,
|
||||
PS_InRootName,
|
||||
PS_InRootDir,
|
||||
PS_InFilenames,
|
||||
PS_InTrailingSep,
|
||||
PS_AtEnd
|
||||
};
|
||||
|
||||
const string_view_t Path;
|
||||
string_view_t RawEntry;
|
||||
ParserState State;
|
||||
|
||||
private:
|
||||
PathParser(string_view_t P, ParserState State) noexcept
|
||||
: Path(P), State(State) {}
|
||||
|
||||
public:
|
||||
PathParser(string_view_t P, string_view_t E, unsigned char S)
|
||||
: Path(P), RawEntry(E), State(static_cast<ParserState>(S)) {
|
||||
// S cannot be '0' or PS_BeforeBegin.
|
||||
}
|
||||
|
||||
static PathParser CreateBegin(string_view_t P) noexcept {
|
||||
PathParser PP(P, PS_BeforeBegin);
|
||||
PP.increment();
|
||||
return PP;
|
||||
}
|
||||
|
||||
static PathParser CreateEnd(string_view_t P) noexcept {
|
||||
PathParser PP(P, PS_AtEnd);
|
||||
return PP;
|
||||
}
|
||||
|
||||
PosPtr peek() const noexcept {
|
||||
auto TkEnd = getNextTokenStartPos();
|
||||
auto End = getAfterBack();
|
||||
return TkEnd == End ? nullptr : TkEnd;
|
||||
}
|
||||
|
||||
void increment() noexcept {
|
||||
const PosPtr End = getAfterBack();
|
||||
const PosPtr Start = getNextTokenStartPos();
|
||||
if (Start == End)
|
||||
return makeState(PS_AtEnd);
|
||||
|
||||
switch (State) {
|
||||
case PS_BeforeBegin: {
|
||||
PosPtr TkEnd = consumeSeparator(Start, End);
|
||||
// If we consumed exactly two separators we have a root name.
|
||||
if (TkEnd && TkEnd == Start + 2) {
|
||||
// FIXME Do we need to consume a name or is '//' a root name on its own?
|
||||
// what about '//.', '//..', '//...'?
|
||||
auto NameEnd = consumeName(TkEnd, End);
|
||||
if (NameEnd)
|
||||
TkEnd = NameEnd;
|
||||
return makeState(PS_InRootName, Start, TkEnd);
|
||||
}
|
||||
else if (TkEnd)
|
||||
return makeState(PS_InRootDir, Start, TkEnd);
|
||||
else
|
||||
return makeState(PS_InFilenames, Start, consumeName(Start, End));
|
||||
}
|
||||
|
||||
case PS_InRootName:
|
||||
return makeState(PS_InRootDir, Start, consumeSeparator(Start, End));
|
||||
case PS_InRootDir:
|
||||
return makeState(PS_InFilenames, Start, consumeName(Start, End));
|
||||
|
||||
case PS_InFilenames: {
|
||||
PosPtr SepEnd = consumeSeparator(Start, End);
|
||||
if (SepEnd != End) {
|
||||
PosPtr TkEnd = consumeName(SepEnd, End);
|
||||
if (TkEnd)
|
||||
return makeState(PS_InFilenames, SepEnd, TkEnd);
|
||||
}
|
||||
return makeState(PS_InTrailingSep, Start, SepEnd);
|
||||
}
|
||||
|
||||
case PS_InTrailingSep:
|
||||
return makeState(PS_AtEnd);
|
||||
|
||||
case PS_AtEnd:
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void decrement() noexcept {
|
||||
const PosPtr REnd = getBeforeFront();
|
||||
const PosPtr RStart = getCurrentTokenStartPos() - 1;
|
||||
|
||||
switch (State) {
|
||||
case PS_AtEnd: {
|
||||
// Try to consume a trailing separator or root directory first.
|
||||
if (PosPtr SepEnd = consumeSeparator(RStart, REnd)) {
|
||||
if (SepEnd == REnd)
|
||||
return makeState((RStart == REnd + 2) ? PS_InRootName : PS_InRootDir,
|
||||
Path.data(), RStart + 1);
|
||||
// Check if we're seeing the root directory separator
|
||||
auto PP = CreateBegin(Path);
|
||||
bool InRootDir = PP.State == PS_InRootName &&
|
||||
&PP.RawEntry.back() == SepEnd;
|
||||
return makeState(InRootDir ? PS_InRootDir : PS_InTrailingSep,
|
||||
SepEnd + 1, RStart + 1);
|
||||
} else {
|
||||
PosPtr TkStart = consumeName(RStart, REnd);
|
||||
if (TkStart == REnd + 2 && consumeSeparator(TkStart, REnd) == REnd)
|
||||
return makeState(PS_InRootName, Path.data(), RStart + 1);
|
||||
else
|
||||
return makeState(PS_InFilenames, TkStart + 1, RStart + 1);
|
||||
}
|
||||
}
|
||||
case PS_InTrailingSep:
|
||||
return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1, RStart + 1);
|
||||
case PS_InFilenames: {
|
||||
PosPtr SepEnd = consumeSeparator(RStart, REnd);
|
||||
if (SepEnd == REnd)
|
||||
return makeState((RStart == REnd + 2) ? PS_InRootName : PS_InRootDir,
|
||||
Path.data(), RStart + 1);
|
||||
PosPtr TkEnd = consumeName(SepEnd, REnd);
|
||||
if (TkEnd == REnd + 2 && consumeSeparator(TkEnd, REnd) == REnd)
|
||||
return makeState(PS_InRootDir, SepEnd + 1, RStart + 1);
|
||||
return makeState(PS_InFilenames, TkEnd + 1, SepEnd + 1);
|
||||
}
|
||||
case PS_InRootDir:
|
||||
return makeState(PS_InRootName, Path.data(), RStart + 1);
|
||||
case PS_InRootName:
|
||||
case PS_BeforeBegin:
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Return a view with the "preferred representation" of the current
|
||||
/// element. For example trailing separators are represented as a '.'
|
||||
string_view_t operator*() const noexcept {
|
||||
switch (State) {
|
||||
case PS_BeforeBegin:
|
||||
case PS_AtEnd:
|
||||
return "";
|
||||
case PS_InRootDir:
|
||||
return "/";
|
||||
case PS_InTrailingSep:
|
||||
return ".";
|
||||
case PS_InRootName:
|
||||
case PS_InFilenames:
|
||||
return RawEntry;
|
||||
}
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
explicit operator bool() const noexcept {
|
||||
return State != PS_BeforeBegin && State != PS_AtEnd;
|
||||
}
|
||||
|
||||
PathParser& operator++() noexcept {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
PathParser& operator--() noexcept {
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
|
||||
State = NewState;
|
||||
RawEntry = string_view_t(Start, End - Start);
|
||||
}
|
||||
void makeState(ParserState NewState) noexcept {
|
||||
State = NewState;
|
||||
RawEntry = {};
|
||||
}
|
||||
|
||||
PosPtr getAfterBack() const noexcept {
|
||||
return Path.data() + Path.size();
|
||||
}
|
||||
|
||||
PosPtr getBeforeFront() const noexcept {
|
||||
return Path.data() - 1;
|
||||
}
|
||||
|
||||
/// \brief Return a pointer to the first character after the currently
|
||||
/// lexed element.
|
||||
PosPtr getNextTokenStartPos() const noexcept {
|
||||
switch (State) {
|
||||
case PS_BeforeBegin:
|
||||
return Path.data();
|
||||
case PS_InRootName:
|
||||
case PS_InRootDir:
|
||||
case PS_InFilenames:
|
||||
return &RawEntry.back() + 1;
|
||||
case PS_InTrailingSep:
|
||||
case PS_AtEnd:
|
||||
return getAfterBack();
|
||||
}
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
/// \brief Return a pointer to the first character in the currently lexed
|
||||
/// element.
|
||||
PosPtr getCurrentTokenStartPos() const noexcept {
|
||||
switch (State) {
|
||||
case PS_BeforeBegin:
|
||||
case PS_InRootName:
|
||||
return &Path.front();
|
||||
case PS_InRootDir:
|
||||
case PS_InFilenames:
|
||||
case PS_InTrailingSep:
|
||||
return &RawEntry.front();
|
||||
case PS_AtEnd:
|
||||
return &Path.back() + 1;
|
||||
}
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
PosPtr consumeSeparator(PosPtr P, PosPtr End) const noexcept {
|
||||
if (P == End || *P != '/')
|
||||
return nullptr;
|
||||
const int Inc = P < End ? 1 : -1;
|
||||
P += Inc;
|
||||
while (P != End && *P == '/')
|
||||
P += Inc;
|
||||
return P;
|
||||
}
|
||||
|
||||
PosPtr consumeName(PosPtr P, PosPtr End) const noexcept {
|
||||
if (P == End || *P == '/')
|
||||
return nullptr;
|
||||
const int Inc = P < End ? 1 : -1;
|
||||
P += Inc;
|
||||
while (P != End && *P != '/')
|
||||
P += Inc;
|
||||
return P;
|
||||
}
|
||||
};
|
||||
|
||||
string_view_pair separate_filename(string_view_t const & s) {
|
||||
if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""};
|
||||
auto pos = s.find_last_of('.');
|
||||
if (pos == string_view_t::npos)
|
||||
return string_view_pair{s, string_view_t{}};
|
||||
return string_view_pair{s.substr(0, pos), s.substr(pos)};
|
||||
}
|
||||
|
||||
string_view_t createView(PosPtr S, PosPtr E) noexcept {
|
||||
return {S, static_cast<size_t>(E - S) + 1};
|
||||
}
|
||||
|
||||
}} // namespace parser
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
using parser::string_view_t;
|
||||
using parser::string_view_pair;
|
||||
using parser::PathParser;
|
||||
using parser::createView;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// path definitions
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
constexpr path::value_type path::preferred_separator;
|
||||
|
||||
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_t path::__root_name() const
|
||||
{
|
||||
auto PP = PathParser::CreateBegin(__pn_);
|
||||
if (PP.State == PathParser::PS_InRootName)
|
||||
return *PP;
|
||||
return {};
|
||||
}
|
||||
|
||||
string_view_t path::__root_directory() const
|
||||
{
|
||||
auto PP = PathParser::CreateBegin(__pn_);
|
||||
if (PP.State == PathParser::PS_InRootName)
|
||||
++PP;
|
||||
if (PP.State == PathParser::PS_InRootDir)
|
||||
return *PP;
|
||||
return {};
|
||||
}
|
||||
|
||||
string_view_t path::__root_path_raw() const
|
||||
{
|
||||
auto PP = PathParser::CreateBegin(__pn_);
|
||||
if (PP.State == PathParser::PS_InRootName) {
|
||||
auto NextCh = PP.peek();
|
||||
if (NextCh && *NextCh == '/') {
|
||||
++PP;
|
||||
return createView(__pn_.data(), &PP.RawEntry.back());
|
||||
}
|
||||
return PP.RawEntry;
|
||||
}
|
||||
if (PP.State == PathParser::PS_InRootDir)
|
||||
return *PP;
|
||||
return {};
|
||||
}
|
||||
|
||||
string_view_t path::__relative_path() const
|
||||
{
|
||||
auto PP = PathParser::CreateBegin(__pn_);
|
||||
while (PP.State <= PathParser::PS_InRootDir)
|
||||
++PP;
|
||||
if (PP.State == PathParser::PS_AtEnd)
|
||||
return {};
|
||||
return createView(PP.RawEntry.data(), &__pn_.back());
|
||||
}
|
||||
|
||||
string_view_t path::__parent_path() const
|
||||
{
|
||||
if (empty())
|
||||
return {};
|
||||
auto PP = PathParser::CreateEnd(__pn_);
|
||||
--PP;
|
||||
if (PP.RawEntry.data() == __pn_.data())
|
||||
return {};
|
||||
--PP;
|
||||
return createView(__pn_.data(), &PP.RawEntry.back());
|
||||
}
|
||||
|
||||
string_view_t path::__filename() const
|
||||
{
|
||||
if (empty()) return {};
|
||||
return *(--PathParser::CreateEnd(__pn_));
|
||||
}
|
||||
|
||||
string_view_t path::__stem() const
|
||||
{
|
||||
return parser::separate_filename(__filename()).first;
|
||||
}
|
||||
|
||||
string_view_t path::__extension() const
|
||||
{
|
||||
return parser::separate_filename(__filename()).second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// path.comparisons
|
||||
int path::__compare(string_view_t __s) const {
|
||||
auto PP = PathParser::CreateBegin(__pn_);
|
||||
auto PP2 = PathParser::CreateBegin(__s);
|
||||
while (PP && PP2) {
|
||||
int res = (*PP).compare(*PP2);
|
||||
if (res != 0) return res;
|
||||
++PP; ++PP2;
|
||||
}
|
||||
if (PP.State == PP2.State && PP.State == PathParser::PS_AtEnd)
|
||||
return 0;
|
||||
if (PP.State == PathParser::PS_AtEnd)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// path.nonmembers
|
||||
size_t hash_value(const path& __p) noexcept {
|
||||
auto PP = PathParser::CreateBegin(__p.native());
|
||||
size_t hash_value = 0;
|
||||
std::hash<string_view_t> hasher;
|
||||
while (PP) {
|
||||
hash_value = __hash_combine(hash_value, hasher(*PP));
|
||||
++PP;
|
||||
}
|
||||
return hash_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// path.itr
|
||||
path::iterator path::begin() const
|
||||
{
|
||||
auto PP = PathParser::CreateBegin(__pn_);
|
||||
iterator it;
|
||||
it.__path_ptr_ = this;
|
||||
it.__state_ = PP.State;
|
||||
it.__entry_ = PP.RawEntry;
|
||||
it.__stashed_elem_.__assign_view(*PP);
|
||||
return it;
|
||||
}
|
||||
|
||||
path::iterator path::end() const
|
||||
{
|
||||
iterator it{};
|
||||
it.__state_ = PathParser::PS_AtEnd;
|
||||
it.__path_ptr_ = this;
|
||||
return it;
|
||||
}
|
||||
|
||||
path::iterator& path::iterator::__increment() {
|
||||
static_assert(__at_end == PathParser::PS_AtEnd, "");
|
||||
PathParser PP(__path_ptr_->native(), __entry_, __state_);
|
||||
++PP;
|
||||
__state_ = PP.State;
|
||||
__entry_ = PP.RawEntry;
|
||||
__stashed_elem_.__assign_view(*PP);
|
||||
return *this;
|
||||
}
|
||||
|
||||
path::iterator& path::iterator::__decrement() {
|
||||
PathParser PP(__path_ptr_->native(), __entry_, __state_);
|
||||
--PP;
|
||||
__state_ = PP.State;
|
||||
__entry_ = PP.RawEntry;
|
||||
__stashed_elem_.__assign_view(*PP);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
@ -31,10 +31,10 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void* do_allocate(size_t __size, size_t __align)
|
||||
{ return __allocate(__size); }
|
||||
{ return _VSTD::__libcpp_allocate(__size, __align); /* FIXME */}
|
||||
|
||||
virtual void do_deallocate(void * __p, size_t, size_t)
|
||||
{ _VSTD::__libcpp_deallocate(__p); }
|
||||
virtual void do_deallocate(void * __p, size_t, size_t __align)
|
||||
{ _VSTD::__libcpp_deallocate(__p, __align); /* FIXME */ }
|
||||
|
||||
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
|
||||
{ return &__other == this; }
|
||||
@ -68,12 +68,23 @@ union ResourceInitHelper {
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}
|
||||
~ResourceInitHelper() {}
|
||||
};
|
||||
|
||||
// Detect if the init_priority attribute is supported.
|
||||
#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
|
||||
|| defined(_LIBCPP_COMPILER_MSVC)
|
||||
// GCC on Apple doesn't support the init priority attribute,
|
||||
// and MSVC doesn't support any GCC attributes.
|
||||
# define _LIBCPP_INIT_PRIORITY_MAX
|
||||
#else
|
||||
# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
|
||||
#endif
|
||||
|
||||
// When compiled in C++14 this initialization should be a constant expression.
|
||||
// Only in C++11 is "init_priority" needed to ensure initialization order.
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
_LIBCPP_SAFE_STATIC
|
||||
#endif
|
||||
ResourceInitHelper res_init __attribute__((init_priority (101)));
|
||||
ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
396
contrib/libc++/src/filesystem/directory_iterator.cpp
Normal file
396
contrib/libc++/src/filesystem/directory_iterator.cpp
Normal file
@ -0,0 +1,396 @@
|
||||
//===------------------ directory_iterator.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 "filesystem"
|
||||
#include "__config"
|
||||
#if defined(_LIBCPP_WIN32API)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include "filesystem_common.h"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
|
||||
|
||||
namespace detail {
|
||||
namespace {
|
||||
|
||||
#if !defined(_LIBCPP_WIN32API)
|
||||
template <class DirEntT, class = decltype(DirEntT::d_type)>
|
||||
static file_type get_file_type(DirEntT* ent, int) {
|
||||
switch (ent->d_type) {
|
||||
case DT_BLK:
|
||||
return file_type::block;
|
||||
case DT_CHR:
|
||||
return file_type::character;
|
||||
case DT_DIR:
|
||||
return file_type::directory;
|
||||
case DT_FIFO:
|
||||
return file_type::fifo;
|
||||
case DT_LNK:
|
||||
return file_type::symlink;
|
||||
case DT_REG:
|
||||
return file_type::regular;
|
||||
case DT_SOCK:
|
||||
return file_type::socket;
|
||||
// Unlike in lstat, hitting "unknown" here simply means that the underlying
|
||||
// filesystem doesn't support d_type. Report is as 'none' so we correctly
|
||||
// set the cache to empty.
|
||||
case DT_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return file_type::none;
|
||||
}
|
||||
|
||||
template <class DirEntT>
|
||||
static file_type get_file_type(DirEntT* ent, long) {
|
||||
return file_type::none;
|
||||
}
|
||||
|
||||
static pair<string_view, file_type> posix_readdir(DIR* dir_stream,
|
||||
error_code& ec) {
|
||||
struct dirent* dir_entry_ptr = nullptr;
|
||||
errno = 0; // zero errno in order to detect errors
|
||||
ec.clear();
|
||||
if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {
|
||||
if (errno)
|
||||
ec = capture_errno();
|
||||
return {};
|
||||
} else {
|
||||
return {dir_entry_ptr->d_name, get_file_type(dir_entry_ptr, 0)};
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
static file_type get_file_type(const WIN32_FIND_DATA& data) {
|
||||
//auto attrs = data.dwFileAttributes;
|
||||
// FIXME(EricWF)
|
||||
return file_type::unknown;
|
||||
}
|
||||
static uintmax_t get_file_size(const WIN32_FIND_DATA& data) {
|
||||
return (data.nFileSizeHight * (MAXDWORD + 1)) + data.nFileSizeLow;
|
||||
}
|
||||
static file_time_type get_write_time(const WIN32_FIND_DATA& data) {
|
||||
ULARGE_INTEGER tmp;
|
||||
FILETIME& time = data.ftLastWriteTime;
|
||||
tmp.u.LowPart = time.dwLowDateTime;
|
||||
tmp.u.HighPart = time.dwHighDateTime;
|
||||
return file_time_type(file_time_type::duration(time.QuadPart));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
} // namespace detail
|
||||
|
||||
using detail::ErrorHandler;
|
||||
|
||||
#if defined(_LIBCPP_WIN32API)
|
||||
class __dir_stream {
|
||||
public:
|
||||
__dir_stream() = delete;
|
||||
__dir_stream& operator=(const __dir_stream&) = delete;
|
||||
|
||||
__dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_),
|
||||
__root_(move(__ds.__root_)),
|
||||
__entry_(move(__ds.__entry_)) {
|
||||
__ds.__stream_ = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
__dir_stream(const path& root, directory_options opts, error_code& ec)
|
||||
: __stream_(INVALID_HANDLE_VALUE), __root_(root) {
|
||||
__stream_ = ::FindFirstFileEx(root.c_str(), &__data_);
|
||||
if (__stream_ == INVALID_HANDLE_VALUE) {
|
||||
ec = error_code(::GetLastError(), generic_category());
|
||||
const bool ignore_permission_denied =
|
||||
bool(opts & directory_options::skip_permission_denied);
|
||||
if (ignore_permission_denied && ec.value() == ERROR_ACCESS_DENIED)
|
||||
ec.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
~__dir_stream() noexcept {
|
||||
if (__stream_ == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
close();
|
||||
}
|
||||
|
||||
bool good() const noexcept { return __stream_ != INVALID_HANDLE_VALUE; }
|
||||
|
||||
bool advance(error_code& ec) {
|
||||
while (::FindNextFile(__stream_, &__data_)) {
|
||||
if (!strcmp(__data_.cFileName, ".") || strcmp(__data_.cFileName, ".."))
|
||||
continue;
|
||||
// FIXME: Cache more of this
|
||||
//directory_entry::__cached_data cdata;
|
||||
//cdata.__type_ = get_file_type(__data_);
|
||||
//cdata.__size_ = get_file_size(__data_);
|
||||
//cdata.__write_time_ = get_write_time(__data_);
|
||||
__entry_.__assign_iter_entry(
|
||||
__root_ / __data_.cFileName,
|
||||
directory_entry::__create_iter_result(get_file_type(__data)));
|
||||
return true;
|
||||
}
|
||||
ec = error_code(::GetLastError(), generic_category());
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
error_code close() noexcept {
|
||||
error_code ec;
|
||||
if (!::FindClose(__stream_))
|
||||
ec = error_code(::GetLastError(), generic_category());
|
||||
__stream_ = INVALID_HANDLE_VALUE;
|
||||
return ec;
|
||||
}
|
||||
|
||||
HANDLE __stream_{INVALID_HANDLE_VALUE};
|
||||
WIN32_FIND_DATA __data_;
|
||||
|
||||
public:
|
||||
path __root_;
|
||||
directory_entry __entry_;
|
||||
};
|
||||
#else
|
||||
class __dir_stream {
|
||||
public:
|
||||
__dir_stream() = delete;
|
||||
__dir_stream& operator=(const __dir_stream&) = delete;
|
||||
|
||||
__dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_),
|
||||
__root_(move(other.__root_)),
|
||||
__entry_(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_type_pair = detail::posix_readdir(__stream_, ec);
|
||||
auto& str = str_type_pair.first;
|
||||
if (str == "." || str == "..") {
|
||||
continue;
|
||||
} else if (ec || str.empty()) {
|
||||
close();
|
||||
return false;
|
||||
} else {
|
||||
__entry_.__assign_iter_entry(
|
||||
__root_ / str,
|
||||
directory_entry::__create_iter_result(str_type_pair.second));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
error_code close() noexcept {
|
||||
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_;
|
||||
};
|
||||
#endif
|
||||
|
||||
// directory_iterator
|
||||
|
||||
directory_iterator::directory_iterator(const path& p, error_code* ec,
|
||||
directory_options opts) {
|
||||
ErrorHandler<void> err("directory_iterator::directory_iterator(...)", ec, &p);
|
||||
|
||||
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)
|
||||
err.report(m_ec);
|
||||
}
|
||||
}
|
||||
|
||||
directory_iterator& directory_iterator::__increment(error_code* ec) {
|
||||
_LIBCPP_ASSERT(__imp_, "Attempting to increment an invalid iterator");
|
||||
ErrorHandler<void> err("directory_iterator::operator++()", ec);
|
||||
|
||||
error_code m_ec;
|
||||
if (!__imp_->advance(m_ec)) {
|
||||
path root = move(__imp_->__root_);
|
||||
__imp_.reset();
|
||||
if (m_ec)
|
||||
err.report(m_ec, "at root \"%s\"", root);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
directory_entry const& directory_iterator::__dereference() 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) {
|
||||
ErrorHandler<void> err("recursive_directory_iterator", ec, &p);
|
||||
|
||||
error_code m_ec;
|
||||
__dir_stream new_s(p, opt, m_ec);
|
||||
if (m_ec)
|
||||
err.report(m_ec);
|
||||
if (m_ec || !new_s.good())
|
||||
return;
|
||||
|
||||
__imp_ = make_shared<__shared_imp>();
|
||||
__imp_->__options_ = opt;
|
||||
__imp_->__stack_.push(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::__dereference() 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) {
|
||||
ErrorHandler<void> err("recursive_directory_iterator::operator++()", ec);
|
||||
|
||||
const directory_iterator end_it;
|
||||
auto& stack = __imp_->__stack_;
|
||||
error_code m_ec;
|
||||
while (stack.size() > 0) {
|
||||
if (stack.top().advance(m_ec))
|
||||
return;
|
||||
if (m_ec)
|
||||
break;
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
if (m_ec) {
|
||||
path root = move(stack.top().__root_);
|
||||
__imp_.reset();
|
||||
err.report(m_ec, "at root \"%s\"", root);
|
||||
} else {
|
||||
__imp_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
bool recursive_directory_iterator::__try_recursion(error_code* ec) {
|
||||
ErrorHandler<void> err("recursive_directory_iterator::operator++()", ec);
|
||||
|
||||
bool rec_sym = bool(options() & directory_options::follow_directory_symlink);
|
||||
|
||||
auto& curr_it = __imp_->__stack_.top();
|
||||
|
||||
bool skip_rec = false;
|
||||
error_code m_ec;
|
||||
if (!rec_sym) {
|
||||
file_status st(curr_it.__entry_.__get_sym_ft(&m_ec));
|
||||
if (m_ec && status_known(st))
|
||||
m_ec.clear();
|
||||
if (m_ec || is_symlink(st) || !is_directory(st))
|
||||
skip_rec = true;
|
||||
} else {
|
||||
file_status st(curr_it.__entry_.__get_ft(&m_ec));
|
||||
if (m_ec && status_known(st))
|
||||
m_ec.clear();
|
||||
if (m_ec || !is_directory(st))
|
||||
skip_rec = true;
|
||||
}
|
||||
|
||||
if (!skip_rec) {
|
||||
__dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
|
||||
if (new_it.good()) {
|
||||
__imp_->__stack_.push(move(new_it));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (m_ec) {
|
||||
const bool allow_eacess =
|
||||
bool(__imp_->__options_ & directory_options::skip_permission_denied);
|
||||
if (m_ec.value() == EACCES && allow_eacess) {
|
||||
if (ec)
|
||||
ec->clear();
|
||||
} else {
|
||||
path at_ent = move(curr_it.__entry_.__p_);
|
||||
__imp_.reset();
|
||||
err.report(m_ec, "attempting recursion into \"%s\"", at_ent);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_FILESYSTEM
|
429
contrib/libc++/src/filesystem/filesystem_common.h
Normal file
429
contrib/libc++/src/filesystem/filesystem_common.h
Normal file
@ -0,0 +1,429 @@
|
||||
//===----------------------------------------------------------------------===////
|
||||
//
|
||||
// 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 FILESYSTEM_COMMON_H
|
||||
#define FILESYSTEM_COMMON_H
|
||||
|
||||
#include "__config"
|
||||
#include "filesystem"
|
||||
#include "array"
|
||||
#include "chrono"
|
||||
#include "cstdlib"
|
||||
#include "climits"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/time.h> // for ::utimes as used in __last_write_time
|
||||
#include <fcntl.h> /* values for fchmodat */
|
||||
|
||||
#include "../include/apple_availability.h"
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
// We can use the presence of UTIME_OMIT to detect platforms that provide
|
||||
// utimensat.
|
||||
#if defined(UTIME_OMIT)
|
||||
#define _LIBCPP_USE_UTIMENSAT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
|
||||
|
||||
namespace detail {
|
||||
namespace {
|
||||
|
||||
static string format_string_imp(const char* msg, ...) {
|
||||
// we might need a second shot at this, so pre-emptivly make a copy
|
||||
struct GuardVAList {
|
||||
va_list& target;
|
||||
bool active = true;
|
||||
GuardVAList(va_list& target) : target(target), active(true) {}
|
||||
void clear() {
|
||||
if (active)
|
||||
va_end(target);
|
||||
active = false;
|
||||
}
|
||||
~GuardVAList() {
|
||||
if (active)
|
||||
va_end(target);
|
||||
}
|
||||
};
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
GuardVAList args_guard(args);
|
||||
|
||||
va_list args_cp;
|
||||
va_copy(args_cp, args);
|
||||
GuardVAList args_copy_guard(args_cp);
|
||||
|
||||
array<char, 256> local_buff;
|
||||
size_t size = local_buff.size();
|
||||
auto ret = ::vsnprintf(local_buff.data(), size, msg, args_cp);
|
||||
|
||||
args_copy_guard.clear();
|
||||
|
||||
// handle empty expansion
|
||||
if (ret == 0)
|
||||
return string{};
|
||||
if (static_cast<size_t>(ret) < size)
|
||||
return string(local_buff.data());
|
||||
|
||||
// we did not provide a long enough buffer on our first attempt.
|
||||
// add 1 to size to account for null-byte in size cast to prevent overflow
|
||||
size = static_cast<size_t>(ret) + 1;
|
||||
auto buff_ptr = unique_ptr<char[]>(new char[size]);
|
||||
ret = ::vsnprintf(buff_ptr.get(), size, msg, args);
|
||||
return string(buff_ptr.get());
|
||||
}
|
||||
|
||||
const char* unwrap(string const& s) { return s.c_str(); }
|
||||
const char* unwrap(path const& p) { return p.native().c_str(); }
|
||||
template <class Arg>
|
||||
Arg const& unwrap(Arg const& a) {
|
||||
static_assert(!is_class<Arg>::value, "cannot pass class here");
|
||||
return a;
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
string format_string(const char* fmt, Args const&... args) {
|
||||
return format_string_imp(fmt, unwrap(args)...);
|
||||
}
|
||||
|
||||
error_code capture_errno() {
|
||||
_LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
|
||||
return error_code(errno, generic_category());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T error_value();
|
||||
template <>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value<void>() {}
|
||||
template <>
|
||||
bool error_value<bool>() {
|
||||
return false;
|
||||
}
|
||||
template <>
|
||||
uintmax_t error_value<uintmax_t>() {
|
||||
return uintmax_t(-1);
|
||||
}
|
||||
template <>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 file_time_type error_value<file_time_type>() {
|
||||
return file_time_type::min();
|
||||
}
|
||||
template <>
|
||||
path error_value<path>() {
|
||||
return {};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct ErrorHandler {
|
||||
const char* func_name;
|
||||
error_code* ec = nullptr;
|
||||
const path* p1 = nullptr;
|
||||
const path* p2 = nullptr;
|
||||
|
||||
ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,
|
||||
const path* p2 = nullptr)
|
||||
: func_name(fname), ec(ec), p1(p1), p2(p2) {
|
||||
if (ec)
|
||||
ec->clear();
|
||||
}
|
||||
|
||||
T report(const error_code& m_ec) const {
|
||||
if (ec) {
|
||||
*ec = m_ec;
|
||||
return error_value<T>();
|
||||
}
|
||||
string what = string("in ") + func_name;
|
||||
switch (bool(p1) + bool(p2)) {
|
||||
case 0:
|
||||
__throw_filesystem_error(what, m_ec);
|
||||
case 1:
|
||||
__throw_filesystem_error(what, *p1, m_ec);
|
||||
case 2:
|
||||
__throw_filesystem_error(what, *p1, *p2, m_ec);
|
||||
}
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
T report(const error_code& m_ec, const char* msg, Args const&... args) const {
|
||||
if (ec) {
|
||||
*ec = m_ec;
|
||||
return error_value<T>();
|
||||
}
|
||||
string what =
|
||||
string("in ") + func_name + ": " + format_string(msg, args...);
|
||||
switch (bool(p1) + bool(p2)) {
|
||||
case 0:
|
||||
__throw_filesystem_error(what, m_ec);
|
||||
case 1:
|
||||
__throw_filesystem_error(what, *p1, m_ec);
|
||||
case 2:
|
||||
__throw_filesystem_error(what, *p1, *p2, m_ec);
|
||||
}
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
T report(errc const& err) const { return report(make_error_code(err)); }
|
||||
|
||||
template <class... Args>
|
||||
T report(errc const& err, const char* msg, Args const&... args) const {
|
||||
return report(make_error_code(err), msg, args...);
|
||||
}
|
||||
|
||||
private:
|
||||
ErrorHandler(ErrorHandler const&) = delete;
|
||||
ErrorHandler& operator=(ErrorHandler const&) = delete;
|
||||
};
|
||||
|
||||
using chrono::duration;
|
||||
using chrono::duration_cast;
|
||||
|
||||
using TimeSpec = struct ::timespec;
|
||||
using StatT = struct ::stat;
|
||||
|
||||
template <class FileTimeT, class TimeT,
|
||||
bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
|
||||
struct time_util_base {
|
||||
using rep = typename FileTimeT::rep;
|
||||
using fs_duration = typename FileTimeT::duration;
|
||||
using fs_seconds = duration<rep>;
|
||||
using fs_nanoseconds = duration<rep, nano>;
|
||||
using fs_microseconds = duration<rep, micro>;
|
||||
|
||||
static constexpr rep max_seconds =
|
||||
duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
|
||||
|
||||
static constexpr rep max_nsec =
|
||||
duration_cast<fs_nanoseconds>(FileTimeT::duration::max() -
|
||||
fs_seconds(max_seconds))
|
||||
.count();
|
||||
|
||||
static constexpr rep min_seconds =
|
||||
duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
|
||||
|
||||
static constexpr rep min_nsec_timespec =
|
||||
duration_cast<fs_nanoseconds>(
|
||||
(FileTimeT::duration::min() - fs_seconds(min_seconds)) +
|
||||
fs_seconds(1))
|
||||
.count();
|
||||
|
||||
private:
|
||||
#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
|
||||
static constexpr fs_duration get_min_nsecs() {
|
||||
return duration_cast<fs_duration>(
|
||||
fs_nanoseconds(min_nsec_timespec) -
|
||||
duration_cast<fs_nanoseconds>(fs_seconds(1)));
|
||||
}
|
||||
// Static assert that these values properly round trip.
|
||||
static_assert(fs_seconds(min_seconds) + get_min_nsecs() ==
|
||||
FileTimeT::duration::min(),
|
||||
"value doesn't roundtrip");
|
||||
|
||||
static constexpr bool check_range() {
|
||||
// This kinda sucks, but it's what happens when we don't have __int128_t.
|
||||
if (sizeof(TimeT) == sizeof(rep)) {
|
||||
typedef duration<long long, ratio<3600 * 24 * 365> > Years;
|
||||
return duration_cast<Years>(fs_seconds(max_seconds)) > Years(250) &&
|
||||
duration_cast<Years>(fs_seconds(min_seconds)) < Years(-250);
|
||||
}
|
||||
return max_seconds >= numeric_limits<TimeT>::max() &&
|
||||
min_seconds <= numeric_limits<TimeT>::min();
|
||||
}
|
||||
static_assert(check_range(), "the representable range is unacceptable small");
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class FileTimeT, class TimeT>
|
||||
struct time_util_base<FileTimeT, TimeT, true> {
|
||||
using rep = typename FileTimeT::rep;
|
||||
using fs_duration = typename FileTimeT::duration;
|
||||
using fs_seconds = duration<rep>;
|
||||
using fs_nanoseconds = duration<rep, nano>;
|
||||
using fs_microseconds = duration<rep, micro>;
|
||||
|
||||
static const rep max_seconds;
|
||||
static const rep max_nsec;
|
||||
static const rep min_seconds;
|
||||
static const rep min_nsec_timespec;
|
||||
};
|
||||
|
||||
template <class FileTimeT, class TimeT>
|
||||
const typename FileTimeT::rep
|
||||
time_util_base<FileTimeT, TimeT, true>::max_seconds =
|
||||
duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
|
||||
|
||||
template <class FileTimeT, class TimeT>
|
||||
const typename FileTimeT::rep time_util_base<FileTimeT, TimeT, true>::max_nsec =
|
||||
duration_cast<fs_nanoseconds>(FileTimeT::duration::max() -
|
||||
fs_seconds(max_seconds))
|
||||
.count();
|
||||
|
||||
template <class FileTimeT, class TimeT>
|
||||
const typename FileTimeT::rep
|
||||
time_util_base<FileTimeT, TimeT, true>::min_seconds =
|
||||
duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
|
||||
|
||||
template <class FileTimeT, class TimeT>
|
||||
const typename FileTimeT::rep
|
||||
time_util_base<FileTimeT, TimeT, true>::min_nsec_timespec =
|
||||
duration_cast<fs_nanoseconds>((FileTimeT::duration::min() -
|
||||
fs_seconds(min_seconds)) +
|
||||
fs_seconds(1))
|
||||
.count();
|
||||
|
||||
template <class FileTimeT, class TimeT, class TimeSpecT>
|
||||
struct time_util : time_util_base<FileTimeT, TimeT> {
|
||||
using Base = time_util_base<FileTimeT, TimeT>;
|
||||
using Base::max_nsec;
|
||||
using Base::max_seconds;
|
||||
using Base::min_nsec_timespec;
|
||||
using Base::min_seconds;
|
||||
|
||||
using typename Base::fs_duration;
|
||||
using typename Base::fs_microseconds;
|
||||
using typename Base::fs_nanoseconds;
|
||||
using typename Base::fs_seconds;
|
||||
|
||||
public:
|
||||
template <class CType, class ChronoType>
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 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;
|
||||
}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) {
|
||||
if (tm.tv_sec >= 0) {
|
||||
return tm.tv_sec < max_seconds ||
|
||||
(tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
|
||||
} else if (tm.tv_sec == (min_seconds - 1)) {
|
||||
return tm.tv_nsec >= min_nsec_timespec;
|
||||
} else {
|
||||
return tm.tv_sec >= min_seconds;
|
||||
}
|
||||
}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) {
|
||||
auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());
|
||||
auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs);
|
||||
if (nsecs.count() < 0) {
|
||||
secs = secs + fs_seconds(1);
|
||||
nsecs = nsecs + fs_seconds(1);
|
||||
}
|
||||
using TLim = numeric_limits<TimeT>;
|
||||
if (secs.count() >= 0)
|
||||
return secs.count() <= TLim::max();
|
||||
return secs.count() >= TLim::min();
|
||||
}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT
|
||||
convert_from_timespec(TimeSpecT tm) {
|
||||
if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {
|
||||
return FileTimeT(fs_seconds(tm.tv_sec) +
|
||||
duration_cast<fs_duration>(fs_nanoseconds(tm.tv_nsec)));
|
||||
} else { // tm.tv_sec < 0
|
||||
auto adj_subsec = duration_cast<fs_duration>(fs_seconds(1) -
|
||||
fs_nanoseconds(tm.tv_nsec));
|
||||
auto Dur = fs_seconds(tm.tv_sec + 1) - adj_subsec;
|
||||
return FileTimeT(Dur);
|
||||
}
|
||||
}
|
||||
|
||||
template <class SubSecT>
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool
|
||||
set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {
|
||||
auto dur = tp.time_since_epoch();
|
||||
auto sec_dur = duration_cast<fs_seconds>(dur);
|
||||
auto subsec_dur = duration_cast<fs_nanoseconds>(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 = sec_dur - fs_seconds(1);
|
||||
subsec_dur = subsec_dur + fs_seconds(1);
|
||||
} else {
|
||||
subsec_dur = fs_nanoseconds::zero();
|
||||
}
|
||||
}
|
||||
return checked_set(sec_out, sec_dur.count()) &&
|
||||
checked_set(subsec_out, subsec_dur.count());
|
||||
}
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool convert_to_timespec(TimeSpecT& dest,
|
||||
FileTimeT tp) {
|
||||
if (!is_representable(tp))
|
||||
return false;
|
||||
return set_times_checked(&dest.tv_sec, &dest.tv_nsec, tp);
|
||||
}
|
||||
};
|
||||
|
||||
using fs_time = time_util<file_time_type, time_t, TimeSpec>;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
|
||||
TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
|
||||
#else
|
||||
TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
|
||||
TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
|
||||
#endif
|
||||
|
||||
// allow the utimes implementation to compile even it we're not going
|
||||
// to use it.
|
||||
|
||||
bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS,
|
||||
error_code& ec) {
|
||||
using namespace chrono;
|
||||
auto Convert = [](long nsec) {
|
||||
using int_type = decltype(std::declval< ::timeval>().tv_usec);
|
||||
auto dur = duration_cast<microseconds>(nanoseconds(nsec)).count();
|
||||
return static_cast<int_type>(dur);
|
||||
};
|
||||
struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},
|
||||
{TS[1].tv_sec, Convert(TS[1].tv_nsec)}};
|
||||
if (::utimes(p.c_str(), ConvertedTS) == -1) {
|
||||
ec = capture_errno();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_USE_UTIMENSAT)
|
||||
bool posix_utimensat(const path& p, std::array<TimeSpec, 2> const& TS,
|
||||
error_code& ec) {
|
||||
if (::utimensat(AT_FDCWD, p.c_str(), TS.data(), 0) == -1) {
|
||||
ec = capture_errno();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool set_file_times(const path& p, std::array<TimeSpec, 2> const& TS,
|
||||
error_code& ec) {
|
||||
#if !defined(_LIBCPP_USE_UTIMENSAT)
|
||||
return posix_utimes(p, TS, ec);
|
||||
#else
|
||||
return posix_utimensat(p, TS, ec);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // end namespace detail
|
||||
|
||||
_LIBCPP_END_NAMESPACE_FILESYSTEM
|
||||
|
||||
#endif // FILESYSTEM_COMMON_H
|
55
contrib/libc++/src/filesystem/int128_builtins.cpp
Normal file
55
contrib/libc++/src/filesystem/int128_builtins.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*===-- int128_builtins.cpp - Implement __muloti4 --------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __muloti4, and is stolen from the compiler_rt library.
|
||||
*
|
||||
* FIXME: we steal and re-compile it into filesystem, which uses __int128_t,
|
||||
* and requires this builtin when sanitized. See llvm.org/PR30643
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
#include "__config"
|
||||
#include "climits"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_INT128)
|
||||
|
||||
extern "C" __attribute__((no_sanitize("undefined")))
|
||||
__int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) {
|
||||
const int N = (int)(sizeof(__int128_t) * CHAR_BIT);
|
||||
const __int128_t MIN = (__int128_t)1 << (N - 1);
|
||||
const __int128_t MAX = ~MIN;
|
||||
*overflow = 0;
|
||||
__int128_t result = a * b;
|
||||
if (a == MIN) {
|
||||
if (b != 0 && b != 1)
|
||||
*overflow = 1;
|
||||
return result;
|
||||
}
|
||||
if (b == MIN) {
|
||||
if (a != 0 && a != 1)
|
||||
*overflow = 1;
|
||||
return result;
|
||||
}
|
||||
__int128_t sa = a >> (N - 1);
|
||||
__int128_t abs_a = (a ^ sa) - sa;
|
||||
__int128_t sb = b >> (N - 1);
|
||||
__int128_t abs_b = (b ^ sb) - sb;
|
||||
if (abs_a < 2 || abs_b < 2)
|
||||
return result;
|
||||
if (sa == sb) {
|
||||
if (abs_a > MAX / abs_b)
|
||||
*overflow = 1;
|
||||
} else {
|
||||
if (abs_a > MIN / -abs_b)
|
||||
*overflow = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
1686
contrib/libc++/src/filesystem/operations.cpp
Normal file
1686
contrib/libc++/src/filesystem/operations.cpp
Normal file
File diff suppressed because it is too large
Load Diff
52
contrib/libc++/src/include/apple_availability.h
Normal file
52
contrib/libc++/src/include/apple_availability.h
Normal file
@ -0,0 +1,52 @@
|
||||
//===------------------------ apple_availability.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_SRC_INCLUDE_APPLE_AVAILABILITY_H
|
||||
#define _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101300
|
||||
#define _LIBCPP_USE_UTIMENSAT
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110000
|
||||
#define _LIBCPP_USE_UTIMENSAT
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 110000
|
||||
#define _LIBCPP_USE_UTIMENSAT
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 40000
|
||||
#define _LIBCPP_USE_UTIMENSAT
|
||||
#endif
|
||||
#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
|
||||
|
||||
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
|
||||
#define _LIBCPP_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000
|
||||
#define _LIBCPP_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 100000
|
||||
#define _LIBCPP_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
|
||||
#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000
|
||||
#define _LIBCPP_USE_CLOCK_GETTIME
|
||||
#endif
|
||||
#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
#endif // _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if defined(_LIBCPP_MSVCRT)
|
||||
#if defined(_LIBCPP_MSVCRT_LIKE)
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
@ -30,7 +30,7 @@
|
||||
// No _LIBCPP_ELAST needed on Apple
|
||||
#elif defined(__sun__)
|
||||
#define _LIBCPP_ELAST ESTALE
|
||||
#elif defined(_LIBCPP_MSVCRT)
|
||||
#elif defined(_LIBCPP_MSVCRT_LIKE)
|
||||
#define _LIBCPP_ELAST (_sys_nerr - 1)
|
||||
#else
|
||||
// Warn here so that the person doing the libcxx port has an easier time:
|
||||
|
@ -4240,6 +4240,7 @@ static bool checked_string_to_char_convert(char& dest,
|
||||
// FIXME: Work around specific multibyte sequences that we can reasonable
|
||||
// translate into a different single byte.
|
||||
switch (wout) {
|
||||
case L'\u202F': // narrow non-breaking space
|
||||
case L'\u00A0': // non-breaking space
|
||||
dest = ' ';
|
||||
return true;
|
||||
@ -4659,7 +4660,7 @@ static
|
||||
string*
|
||||
init_am_pm()
|
||||
{
|
||||
static string am_pm[24];
|
||||
static string am_pm[2];
|
||||
am_pm[0] = "AM";
|
||||
am_pm[1] = "PM";
|
||||
return am_pm;
|
||||
@ -4669,7 +4670,7 @@ static
|
||||
wstring*
|
||||
init_wam_pm()
|
||||
{
|
||||
static wstring am_pm[24];
|
||||
static wstring am_pm[2];
|
||||
am_pm[0] = L"AM";
|
||||
am_pm[1] = L"PM";
|
||||
return am_pm;
|
||||
|
@ -8,7 +8,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "optional"
|
||||
#include "experimental/optional"
|
||||
|
||||
namespace std
|
||||
{
|
||||
@ -21,8 +20,23 @@ const char* bad_optional_access::what() const _NOEXCEPT {
|
||||
|
||||
} // std
|
||||
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
// Preserve std::experimental::bad_optional_access for ABI compatibility
|
||||
// Even though it no longer exists in a header file
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
|
||||
: public std::logic_error
|
||||
{
|
||||
public:
|
||||
bad_optional_access() : std::logic_error("Bad optional Access") {}
|
||||
|
||||
// Get the key function ~bad_optional_access() into the dylib
|
||||
virtual ~bad_optional_access() _NOEXCEPT;
|
||||
};
|
||||
|
||||
bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
@ -15,30 +15,18 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_ACRTIMP)
|
||||
#define _ACRTIMP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined(_VCRTIMP)
|
||||
#define _VCRTIMP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined(__CRTDECL)
|
||||
#define __CRTDECL __cdecl
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
typedef void (__CRTDECL* terminate_handler)();
|
||||
_ACRTIMP terminate_handler __cdecl set_terminate(
|
||||
typedef void (__cdecl* terminate_handler)();
|
||||
_LIBCPP_CRT_FUNC terminate_handler __cdecl set_terminate(
|
||||
terminate_handler _NewTerminateHandler) throw();
|
||||
_ACRTIMP terminate_handler __cdecl _get_terminate();
|
||||
_LIBCPP_CRT_FUNC terminate_handler __cdecl _get_terminate();
|
||||
|
||||
typedef void (__CRTDECL* unexpected_handler)();
|
||||
_VCRTIMP unexpected_handler __cdecl set_unexpected(
|
||||
typedef void (__cdecl* unexpected_handler)();
|
||||
unexpected_handler __cdecl set_unexpected(
|
||||
unexpected_handler _NewUnexpectedHandler) throw();
|
||||
_VCRTIMP unexpected_handler __cdecl _get_unexpected();
|
||||
unexpected_handler __cdecl _get_unexpected();
|
||||
|
||||
_VCRTIMP int __cdecl __uncaught_exceptions();
|
||||
int __cdecl __uncaught_exceptions();
|
||||
}
|
||||
|
||||
namespace std {
|
||||
@ -109,6 +97,7 @@ bad_array_length::what() const _NOEXCEPT
|
||||
return "bad_array_length";
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_NO_VCRUNTIME)
|
||||
bad_cast::bad_cast() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
@ -137,7 +126,6 @@ bad_typeid::what() const _NOEXCEPT
|
||||
return "std::bad_typeid";
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_NO_VCRUNTIME)
|
||||
exception::~exception() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user