mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Add more missing C / C++ headers
This commit is contained in:
parent
b9dc74b672
commit
8dd4ec68d0
152 changed files with 30711 additions and 6267 deletions
18
third_party/libcxx/README.cosmo
vendored
18
third_party/libcxx/README.cosmo
vendored
|
@ -1,6 +1,14 @@
|
|||
Upstream origin
|
||||
DESCRIPTION
|
||||
|
||||
git@github.com:llvm-mirror/libcxx.git
|
||||
commit 78d6a7767ed57b50122a161b91f59f19c9bd0d19
|
||||
Author: Zoe Carver <z.zoelec2@gmail.com>
|
||||
Date: Tue Oct 22 15:16:49 2019 +0000
|
||||
LLVM's C++ Standard Template Library
|
||||
|
||||
ORIGIN
|
||||
|
||||
git@github.com:llvm-mirror/libcxx.git
|
||||
commit 78d6a7767ed57b50122a161b91f59f19c9bd0d19
|
||||
Author: Zoe Carver <z.zoelec2@gmail.com>
|
||||
Date: Tue Oct 22 15:16:49 2019 +0000
|
||||
|
||||
LOCAL CHANGES
|
||||
|
||||
- Break apart locale.cpp due to its outrageous build times
|
||||
|
|
1
third_party/libcxx/__config
vendored
1
third_party/libcxx/__config
vendored
|
@ -14,6 +14,7 @@
|
|||
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#define _LIBCPP_HAS_NO_THREADS
|
||||
#define _LIBCPP_ABI_UNSTABLE
|
||||
#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
// #define _LIBCPP_NO_EXCEPTIONS
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
|
672
third_party/libcxx/any
vendored
Normal file
672
third_party/libcxx/any
vendored
Normal file
|
@ -0,0 +1,672 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===------------------------------ any -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_ANY
|
||||
#define _LIBCPP_ANY
|
||||
|
||||
/*
|
||||
any synopsis
|
||||
|
||||
namespace std {
|
||||
|
||||
class bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const noexcept;
|
||||
};
|
||||
|
||||
class any
|
||||
{
|
||||
public:
|
||||
|
||||
// 6.3.1 any construct/destruct
|
||||
any() noexcept;
|
||||
|
||||
any(const any& other);
|
||||
any(any&& other) noexcept;
|
||||
|
||||
template <class ValueType>
|
||||
any(ValueType&& value);
|
||||
|
||||
~any();
|
||||
|
||||
// 6.3.2 any assignments
|
||||
any& operator=(const any& rhs);
|
||||
any& operator=(any&& rhs) noexcept;
|
||||
|
||||
template <class ValueType>
|
||||
any& operator=(ValueType&& rhs);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
template <class ValueType, class... Args>
|
||||
decay_t<ValueType>& emplace(Args&&... args);
|
||||
template <class ValueType, class U, class... Args>
|
||||
decay_t<ValueType>& emplace(initializer_list<U>, Args&&...);
|
||||
void reset() noexcept;
|
||||
void swap(any& rhs) noexcept;
|
||||
|
||||
// 6.3.4 any observers
|
||||
bool has_value() const noexcept;
|
||||
const type_info& type() const noexcept;
|
||||
};
|
||||
|
||||
// 6.4 Non-member functions
|
||||
void swap(any& x, any& y) noexcept;
|
||||
|
||||
template <class T, class ...Args>
|
||||
any make_any(Args&& ...args);
|
||||
template <class T, class U, class ...Args>
|
||||
any make_any(initializer_list<U>, Args&& ...args);
|
||||
|
||||
template<class ValueType>
|
||||
ValueType any_cast(const any& operand);
|
||||
template<class ValueType>
|
||||
ValueType any_cast(any& operand);
|
||||
template<class ValueType>
|
||||
ValueType any_cast(any&& operand);
|
||||
|
||||
template<class ValueType>
|
||||
const ValueType* any_cast(const any* operand) noexcept;
|
||||
template<class ValueType>
|
||||
ValueType* any_cast(any* operand) noexcept;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/experimental/__config"
|
||||
#include "third_party/libcxx/memory"
|
||||
#include "third_party/libcxx/new"
|
||||
#include "third_party/libcxx/typeinfo"
|
||||
#include "third_party/libcxx/type_traits"
|
||||
#include "third_party/libcxx/cstdlib"
|
||||
#include "third_party/libcxx/version"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
_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 _LIBCPP_TEMPLATE_VIS any;
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
add_pointer_t<add_const_t<_ValueType>>
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
|
||||
|
||||
namespace __any_imp
|
||||
{
|
||||
using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
|
||||
|
||||
template <class _Tp>
|
||||
using _IsSmallObject = integral_constant<bool
|
||||
, sizeof(_Tp) <= sizeof(_Buffer)
|
||||
&& alignment_of<_Buffer>::value
|
||||
% alignment_of<_Tp>::value == 0
|
||||
&& is_nothrow_move_constructible<_Tp>::value
|
||||
>;
|
||||
|
||||
enum class _Action {
|
||||
_Destroy,
|
||||
_Copy,
|
||||
_Move,
|
||||
_Get,
|
||||
_TypeInfo
|
||||
};
|
||||
|
||||
template <class _Tp> struct _SmallHandler;
|
||||
template <class _Tp> struct _LargeHandler;
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { static constexpr int __id = 0; };
|
||||
template <class _Tp> constexpr int __unique_typeinfo<_Tp>::__id;
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr const void* __get_fallback_typeid() {
|
||||
return &__unique_typeinfo<decay_t<_Tp>>::__id;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool __compare_typeid(type_info const* __id, const void* __fallback_id)
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
if (__id && *__id == typeid(_Tp))
|
||||
return true;
|
||||
#endif
|
||||
if (!__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
using _Handler = conditional_t<
|
||||
_IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;
|
||||
|
||||
} // namespace __any_imp
|
||||
|
||||
class _LIBCPP_TEMPLATE_VIS any
|
||||
{
|
||||
public:
|
||||
// construct/destruct
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr any() _NOEXCEPT : __h(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(any const & __other) : __h(nullptr)
|
||||
{
|
||||
if (__other.__h) __other.__call(_Action::_Copy, this);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(any && __other) _NOEXCEPT : __h(nullptr)
|
||||
{
|
||||
if (__other.__h) __other.__call(_Action::_Move, this);
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class _Tp = decay_t<_ValueType>
|
||||
, class = enable_if_t<
|
||||
!is_same<_Tp, any>::value &&
|
||||
!__is_inplace_type<_ValueType>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(_ValueType && __value);
|
||||
|
||||
template <class _ValueType, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value
|
||||
>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit any(in_place_type_t<_ValueType>, _Args&&... __args);
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~any() { this->reset(); }
|
||||
|
||||
// assignments
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any const & __rhs) {
|
||||
any(__rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any && __rhs) _NOEXCEPT {
|
||||
any(_VSTD::move(__rhs)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class _Tp = decay_t<_ValueType>
|
||||
, class = enable_if_t<
|
||||
!is_same<_Tp, any>::value
|
||||
&& is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(_ValueType && __rhs);
|
||||
|
||||
template <class _ValueType, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& emplace(_Args&&... args);
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& emplace(initializer_list<_Up>, _Args&&...);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __rhs) _NOEXCEPT;
|
||||
|
||||
// 6.3.4 any observers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool has_value() const _NOEXCEPT { return __h != nullptr; }
|
||||
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const type_info & type() const _NOEXCEPT {
|
||||
if (__h) {
|
||||
return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
|
||||
} else {
|
||||
return typeid(void);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef __any_imp::_Action _Action;
|
||||
using _HandleFuncPtr = void* (*)(_Action, any const *, any *, const type_info *,
|
||||
const void* __fallback_info);
|
||||
|
||||
union _Storage {
|
||||
constexpr _Storage() : __ptr(nullptr) {}
|
||||
void * __ptr;
|
||||
__any_imp::_Buffer __buf;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr,
|
||||
const void* __fallback_info = nullptr) const
|
||||
{
|
||||
return __h(__a, this, __other, __info, __fallback_info);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr,
|
||||
const void* __fallback_info = nullptr)
|
||||
{
|
||||
return __h(__a, this, __other, __info, __fallback_info);
|
||||
}
|
||||
|
||||
template <class>
|
||||
friend struct __any_imp::_SmallHandler;
|
||||
template <class>
|
||||
friend struct __any_imp::_LargeHandler;
|
||||
|
||||
template <class _ValueType>
|
||||
friend add_pointer_t<add_const_t<_ValueType>>
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
friend add_pointer_t<_ValueType>
|
||||
any_cast(any *) _NOEXCEPT;
|
||||
|
||||
_HandleFuncPtr __h = nullptr;
|
||||
_Storage __s;
|
||||
};
|
||||
|
||||
namespace __any_imp
|
||||
{
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS _SmallHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this, any * __other,
|
||||
type_info const * __info, const void* __fallback_info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<any &>(*__this));
|
||||
return nullptr;
|
||||
case _Action::_Copy:
|
||||
__copy(*__this, *__other);
|
||||
return nullptr;
|
||||
case _Action::_Move:
|
||||
__move(const_cast<any &>(*__this), *__other);
|
||||
return nullptr;
|
||||
case _Action::_Get:
|
||||
return __get(const_cast<any &>(*__this), __info, __fallback_info);
|
||||
case _Action::_TypeInfo:
|
||||
return __type_info();
|
||||
}
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _Tp& __create(any & __dest, _Args&&... __args) {
|
||||
_Tp* __ret = ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
|
||||
__dest.__h = &_SmallHandler::__handle;
|
||||
return *__ret;
|
||||
}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(any & __this) {
|
||||
_Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
|
||||
__value.~_Tp();
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __copy(any const & __this, any & __dest) {
|
||||
_SmallHandler::__create(__dest, *static_cast<_Tp const *>(
|
||||
static_cast<void const *>(&__this.__s.__buf)));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __move(any & __this, any & __dest) {
|
||||
_SmallHandler::__create(__dest, _VSTD::move(
|
||||
*static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
|
||||
__destroy(__this);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __get(any & __this,
|
||||
type_info const * __info,
|
||||
const void* __fallback_id)
|
||||
{
|
||||
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
|
||||
return static_cast<void*>(&__this.__s.__buf);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __type_info()
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS _LargeHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this,
|
||||
any * __other, type_info const * __info,
|
||||
void const* __fallback_info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<any &>(*__this));
|
||||
return nullptr;
|
||||
case _Action::_Copy:
|
||||
__copy(*__this, *__other);
|
||||
return nullptr;
|
||||
case _Action::_Move:
|
||||
__move(const_cast<any &>(*__this), *__other);
|
||||
return nullptr;
|
||||
case _Action::_Get:
|
||||
return __get(const_cast<any &>(*__this), __info, __fallback_info);
|
||||
case _Action::_TypeInfo:
|
||||
return __type_info();
|
||||
}
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _Tp& __create(any & __dest, _Args&&... __args) {
|
||||
typedef allocator<_Tp> _Alloc;
|
||||
typedef __allocator_destructor<_Alloc> _Dp;
|
||||
_Alloc __a;
|
||||
unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
|
||||
_Tp* __ret = ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
|
||||
__dest.__s.__ptr = __hold.release();
|
||||
__dest.__h = &_LargeHandler::__handle;
|
||||
return *__ret;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(any & __this){
|
||||
delete static_cast<_Tp*>(__this.__s.__ptr);
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __copy(any const & __this, any & __dest) {
|
||||
_LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __move(any & __this, any & __dest) {
|
||||
__dest.__s.__ptr = __this.__s.__ptr;
|
||||
__dest.__h = &_LargeHandler::__handle;
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __get(any & __this, type_info const * __info,
|
||||
void const* __fallback_info)
|
||||
{
|
||||
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
|
||||
return static_cast<void*>(__this.__s.__ptr);
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __type_info()
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace __any_imp
|
||||
|
||||
|
||||
template <class _ValueType, class _Tp, class>
|
||||
any::any(_ValueType && __v) : __h(nullptr)
|
||||
{
|
||||
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
|
||||
}
|
||||
|
||||
template <class _ValueType, class ..._Args, class _Tp, class>
|
||||
any::any(in_place_type_t<_ValueType>, _Args&&... __args) {
|
||||
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
|
||||
any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) {
|
||||
__any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType, class, class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
any & any::operator=(_ValueType && __v)
|
||||
{
|
||||
any(_VSTD::forward<_ValueType>(__v)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _ValueType, class ..._Args, class _Tp, class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& any::emplace(_Args&&... __args) {
|
||||
reset();
|
||||
return __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
|
||||
reset();
|
||||
return __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void any::swap(any & __rhs) _NOEXCEPT
|
||||
{
|
||||
if (this == &__rhs)
|
||||
return;
|
||||
if (__h && __rhs.__h) {
|
||||
any __tmp;
|
||||
__rhs.__call(_Action::_Move, &__tmp);
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
__tmp.__call(_Action::_Move, this);
|
||||
}
|
||||
else if (__h) {
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
}
|
||||
else if (__rhs.__h) {
|
||||
__rhs.__call(_Action::_Move, this);
|
||||
}
|
||||
}
|
||||
|
||||
// 6.4 Non-member functions
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __lhs, any & __rhs) _NOEXCEPT
|
||||
{
|
||||
__lhs.swap(__rhs);
|
||||
}
|
||||
|
||||
template <class _Tp, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
any make_any(_Args&&... __args) {
|
||||
return any(in_place_type<_Tp>, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
any make_any(initializer_list<_Up> __il, _Args&&... __args) {
|
||||
return any(in_place_type<_Tp>, __il, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any const & __v)
|
||||
{
|
||||
using _RawValueType = __uncvref_t<_ValueType>;
|
||||
static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
|
||||
"ValueType is required to be a const lvalue reference "
|
||||
"or a CopyConstructible type");
|
||||
auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return static_cast<_ValueType>(*__tmp);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any & __v)
|
||||
{
|
||||
using _RawValueType = __uncvref_t<_ValueType>;
|
||||
static_assert(is_constructible<_ValueType, _RawValueType &>::value,
|
||||
"ValueType is required to be an lvalue reference "
|
||||
"or a CopyConstructible type");
|
||||
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return static_cast<_ValueType>(*__tmp);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any && __v)
|
||||
{
|
||||
using _RawValueType = __uncvref_t<_ValueType>;
|
||||
static_assert(is_constructible<_ValueType, _RawValueType>::value,
|
||||
"ValueType is required to be an rvalue reference "
|
||||
"or a CopyConstructible type");
|
||||
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return static_cast<_ValueType>(_VSTD::move(*__tmp));
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
add_pointer_t<add_const_t<_ValueType>>
|
||||
any_cast(any const * __any) _NOEXCEPT
|
||||
{
|
||||
static_assert(!is_reference<_ValueType>::value,
|
||||
"_ValueType may not be a reference.");
|
||||
return _VSTD::any_cast<_ValueType>(const_cast<any *>(__any));
|
||||
}
|
||||
|
||||
template <class _RetType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_RetType __pointer_or_func_cast(void* __p, /*IsFunction*/false_type) noexcept {
|
||||
return static_cast<_RetType>(__p);
|
||||
}
|
||||
|
||||
template <class _RetType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
add_pointer_t<_ValueType>
|
||||
any_cast(any * __any) _NOEXCEPT
|
||||
{
|
||||
using __any_imp::_Action;
|
||||
static_assert(!is_reference<_ValueType>::value,
|
||||
"_ValueType may not be a reference.");
|
||||
typedef typename add_pointer<_ValueType>::type _ReturnType;
|
||||
if (__any && __any->__h) {
|
||||
void *__p = __any->__call(_Action::_Get, nullptr,
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
&typeid(_ValueType),
|
||||
#else
|
||||
nullptr,
|
||||
#endif
|
||||
__any_imp::__get_fallback_typeid<_ValueType>());
|
||||
return _VSTD::__pointer_or_func_cast<_ReturnType>(
|
||||
__p, is_function<_ValueType>{});
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ANY
|
29
third_party/libcxx/ccomplex
vendored
Normal file
29
third_party/libcxx/ccomplex
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- ccomplex ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CCOMPLEX
|
||||
#define _LIBCPP_CCOMPLEX
|
||||
|
||||
/*
|
||||
ccomplex synopsis
|
||||
|
||||
#include "third_party/libcxx/complex"
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/complex"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
// hh 080623 Created
|
||||
|
||||
#endif // _LIBCPP_CCOMPLEX
|
82
third_party/libcxx/cfenv
vendored
Normal file
82
third_party/libcxx/cfenv
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===---------------------------- cfenv -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CFENV
|
||||
#define _LIBCPP_CFENV
|
||||
|
||||
/*
|
||||
cfenv synopsis
|
||||
|
||||
This entire header is C99 / C++0X
|
||||
|
||||
Macros:
|
||||
|
||||
FE_DIVBYZERO
|
||||
FE_INEXACT
|
||||
FE_INVALID
|
||||
FE_OVERFLOW
|
||||
FE_UNDERFLOW
|
||||
FE_ALL_EXCEPT
|
||||
FE_DOWNWARD
|
||||
FE_TONEAREST
|
||||
FE_TOWARDZERO
|
||||
FE_UPWARD
|
||||
FE_DFL_ENV
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
fenv_t
|
||||
fexcept_t
|
||||
|
||||
int feclearexcept(int excepts);
|
||||
int fegetexceptflag(fexcept_t* flagp, int excepts);
|
||||
int feraiseexcept(int excepts);
|
||||
int fesetexceptflag(const fexcept_t* flagp, int excepts);
|
||||
int fetestexcept(int excepts);
|
||||
int fegetround();
|
||||
int fesetround(int round);
|
||||
int fegetenv(fenv_t* envp);
|
||||
int feholdexcept(fenv_t* envp);
|
||||
int fesetenv(const fenv_t* envp);
|
||||
int feupdateenv(const fenv_t* envp);
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "libc/runtime/fenv.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::fenv_t;
|
||||
using ::fexcept_t;
|
||||
|
||||
using ::feclearexcept;
|
||||
using ::fegetexceptflag;
|
||||
using ::feraiseexcept;
|
||||
using ::fesetexceptflag;
|
||||
using ::fetestexcept;
|
||||
using ::fegetround;
|
||||
using ::fesetround;
|
||||
using ::fegetenv;
|
||||
using ::feholdexcept;
|
||||
using ::fesetenv;
|
||||
using ::feupdateenv;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CFENV
|
81
third_party/libcxx/cfloat
vendored
Normal file
81
third_party/libcxx/cfloat
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- cfloat -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CFLOAT
|
||||
#define _LIBCPP_CFLOAT
|
||||
|
||||
/*
|
||||
cfloat synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
FLT_ROUNDS
|
||||
FLT_EVAL_METHOD // C99
|
||||
FLT_RADIX
|
||||
|
||||
FLT_HAS_SUBNORM // C11
|
||||
DBL_HAS_SUBNORM // C11
|
||||
LDBL_HAS_SUBNORM // C11
|
||||
|
||||
FLT_MANT_DIG
|
||||
DBL_MANT_DIG
|
||||
LDBL_MANT_DIG
|
||||
|
||||
DECIMAL_DIG // C99
|
||||
FLT_DECIMAL_DIG // C11
|
||||
DBL_DECIMAL_DIG // C11
|
||||
LDBL_DECIMAL_DIG // C11
|
||||
|
||||
FLT_DIG
|
||||
DBL_DIG
|
||||
LDBL_DIG
|
||||
|
||||
FLT_MIN_EXP
|
||||
DBL_MIN_EXP
|
||||
LDBL_MIN_EXP
|
||||
|
||||
FLT_MIN_10_EXP
|
||||
DBL_MIN_10_EXP
|
||||
LDBL_MIN_10_EXP
|
||||
|
||||
FLT_MAX_EXP
|
||||
DBL_MAX_EXP
|
||||
LDBL_MAX_EXP
|
||||
|
||||
FLT_MAX_10_EXP
|
||||
DBL_MAX_10_EXP
|
||||
LDBL_MAX_10_EXP
|
||||
|
||||
FLT_MAX
|
||||
DBL_MAX
|
||||
LDBL_MAX
|
||||
|
||||
FLT_EPSILON
|
||||
DBL_EPSILON
|
||||
LDBL_EPSILON
|
||||
|
||||
FLT_MIN
|
||||
DBL_MIN
|
||||
LDBL_MIN
|
||||
|
||||
FLT_TRUE_MIN // C11
|
||||
DBL_TRUE_MIN // C11
|
||||
LDBL_TRUE_MIN // C11
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/fenv.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CFLOAT
|
259
third_party/libcxx/cinttypes
vendored
Normal file
259
third_party/libcxx/cinttypes
vendored
Normal file
|
@ -0,0 +1,259 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- cinttypes --------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CINTTYPES
|
||||
#define _LIBCPP_CINTTYPES
|
||||
|
||||
/*
|
||||
cinttypes synopsis
|
||||
|
||||
This entire header is C99 / C++0X
|
||||
|
||||
#include "third_party/libcxx/cstdint" // <cinttypes> includes <cstdint>
|
||||
|
||||
Macros:
|
||||
|
||||
PRId8
|
||||
PRId16
|
||||
PRId32
|
||||
PRId64
|
||||
|
||||
PRIdLEAST8
|
||||
PRIdLEAST16
|
||||
PRIdLEAST32
|
||||
PRIdLEAST64
|
||||
|
||||
PRIdFAST8
|
||||
PRIdFAST16
|
||||
PRIdFAST32
|
||||
PRIdFAST64
|
||||
|
||||
PRIdMAX
|
||||
PRIdPTR
|
||||
|
||||
PRIi8
|
||||
PRIi16
|
||||
PRIi32
|
||||
PRIi64
|
||||
|
||||
PRIiLEAST8
|
||||
PRIiLEAST16
|
||||
PRIiLEAST32
|
||||
PRIiLEAST64
|
||||
|
||||
PRIiFAST8
|
||||
PRIiFAST16
|
||||
PRIiFAST32
|
||||
PRIiFAST64
|
||||
|
||||
PRIiMAX
|
||||
PRIiPTR
|
||||
|
||||
PRIo8
|
||||
PRIo16
|
||||
PRIo32
|
||||
PRIo64
|
||||
|
||||
PRIoLEAST8
|
||||
PRIoLEAST16
|
||||
PRIoLEAST32
|
||||
PRIoLEAST64
|
||||
|
||||
PRIoFAST8
|
||||
PRIoFAST16
|
||||
PRIoFAST32
|
||||
PRIoFAST64
|
||||
|
||||
PRIoMAX
|
||||
PRIoPTR
|
||||
|
||||
PRIu8
|
||||
PRIu16
|
||||
PRIu32
|
||||
PRIu64
|
||||
|
||||
PRIuLEAST8
|
||||
PRIuLEAST16
|
||||
PRIuLEAST32
|
||||
PRIuLEAST64
|
||||
|
||||
PRIuFAST8
|
||||
PRIuFAST16
|
||||
PRIuFAST32
|
||||
PRIuFAST64
|
||||
|
||||
PRIuMAX
|
||||
PRIuPTR
|
||||
|
||||
PRIx8
|
||||
PRIx16
|
||||
PRIx32
|
||||
PRIx64
|
||||
|
||||
PRIxLEAST8
|
||||
PRIxLEAST16
|
||||
PRIxLEAST32
|
||||
PRIxLEAST64
|
||||
|
||||
PRIxFAST8
|
||||
PRIxFAST16
|
||||
PRIxFAST32
|
||||
PRIxFAST64
|
||||
|
||||
PRIxMAX
|
||||
PRIxPTR
|
||||
|
||||
PRIX8
|
||||
PRIX16
|
||||
PRIX32
|
||||
PRIX64
|
||||
|
||||
PRIXLEAST8
|
||||
PRIXLEAST16
|
||||
PRIXLEAST32
|
||||
PRIXLEAST64
|
||||
|
||||
PRIXFAST8
|
||||
PRIXFAST16
|
||||
PRIXFAST32
|
||||
PRIXFAST64
|
||||
|
||||
PRIXMAX
|
||||
PRIXPTR
|
||||
|
||||
SCNd8
|
||||
SCNd16
|
||||
SCNd32
|
||||
SCNd64
|
||||
|
||||
SCNdLEAST8
|
||||
SCNdLEAST16
|
||||
SCNdLEAST32
|
||||
SCNdLEAST64
|
||||
|
||||
SCNdFAST8
|
||||
SCNdFAST16
|
||||
SCNdFAST32
|
||||
SCNdFAST64
|
||||
|
||||
SCNdMAX
|
||||
SCNdPTR
|
||||
|
||||
SCNi8
|
||||
SCNi16
|
||||
SCNi32
|
||||
SCNi64
|
||||
|
||||
SCNiLEAST8
|
||||
SCNiLEAST16
|
||||
SCNiLEAST32
|
||||
SCNiLEAST64
|
||||
|
||||
SCNiFAST8
|
||||
SCNiFAST16
|
||||
SCNiFAST32
|
||||
SCNiFAST64
|
||||
|
||||
SCNiMAX
|
||||
SCNiPTR
|
||||
|
||||
SCNo8
|
||||
SCNo16
|
||||
SCNo32
|
||||
SCNo64
|
||||
|
||||
SCNoLEAST8
|
||||
SCNoLEAST16
|
||||
SCNoLEAST32
|
||||
SCNoLEAST64
|
||||
|
||||
SCNoFAST8
|
||||
SCNoFAST16
|
||||
SCNoFAST32
|
||||
SCNoFAST64
|
||||
|
||||
SCNoMAX
|
||||
SCNoPTR
|
||||
|
||||
SCNu8
|
||||
SCNu16
|
||||
SCNu32
|
||||
SCNu64
|
||||
|
||||
SCNuLEAST8
|
||||
SCNuLEAST16
|
||||
SCNuLEAST32
|
||||
SCNuLEAST64
|
||||
|
||||
SCNuFAST8
|
||||
SCNuFAST16
|
||||
SCNuFAST32
|
||||
SCNuFAST64
|
||||
|
||||
SCNuMAX
|
||||
SCNuPTR
|
||||
|
||||
SCNx8
|
||||
SCNx16
|
||||
SCNx32
|
||||
SCNx64
|
||||
|
||||
SCNxLEAST8
|
||||
SCNxLEAST16
|
||||
SCNxLEAST32
|
||||
SCNxLEAST64
|
||||
|
||||
SCNxFAST8
|
||||
SCNxFAST16
|
||||
SCNxFAST32
|
||||
SCNxFAST64
|
||||
|
||||
SCNxMAX
|
||||
SCNxPTR
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
imaxdiv_t
|
||||
|
||||
intmax_t imaxabs(intmax_t j);
|
||||
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
|
||||
intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
|
||||
uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
|
||||
intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
|
||||
uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/cstdint"
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using::imaxdiv_t;
|
||||
using::imaxabs;
|
||||
using::imaxdiv;
|
||||
using::strtoimax;
|
||||
using::strtoumax;
|
||||
using::wcstoimax;
|
||||
using::wcstoumax;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CINTTYPES
|
25
third_party/libcxx/ciso646
vendored
Normal file
25
third_party/libcxx/ciso646
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- ciso646 ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CISO646
|
||||
#define _LIBCPP_CISO646
|
||||
|
||||
/*
|
||||
ciso646 synopsis
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CISO646
|
679
third_party/libcxx/compare
vendored
Normal file
679
third_party/libcxx/compare
vendored
Normal file
|
@ -0,0 +1,679 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===-------------------------- compare -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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 "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/type_traits"
|
||||
#include "third_party/libcxx/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
|
1496
third_party/libcxx/complex
vendored
Normal file
1496
third_party/libcxx/complex
vendored
Normal file
File diff suppressed because it is too large
Load diff
20
third_party/libcxx/countof.internal.hh
vendored
Normal file
20
third_party/libcxx/countof.internal.hh
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_LIBCXX_COUNTOF_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_LIBCXX_COUNTOF_H_
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T, size_t N>
|
||||
inline _LIBCPP_CONSTEXPR size_t countof(const T (&)[N]) {
|
||||
return N;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline _LIBCPP_CONSTEXPR size_t countof(const T* const begin,
|
||||
const T* const end) {
|
||||
return static_cast<size_t>(end - begin);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_LIBCXX_COUNTOF_H_ */
|
48
third_party/libcxx/csetjmp
vendored
Normal file
48
third_party/libcxx/csetjmp
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- csetjmp ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CSETJMP
|
||||
#define _LIBCPP_CSETJMP
|
||||
|
||||
/*
|
||||
csetjmp synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
setjmp
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
jmp_buf
|
||||
|
||||
void longjmp(jmp_buf env, int val);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::jmp_buf;
|
||||
using ::longjmp;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSETJMP
|
62
third_party/libcxx/csignal
vendored
Normal file
62
third_party/libcxx/csignal
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- csignal ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CSIGNAL
|
||||
#define _LIBCPP_CSIGNAL
|
||||
|
||||
/*
|
||||
csignal synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
SIG_DFL
|
||||
SIG_ERR
|
||||
SIG_IGN
|
||||
SIGABRT
|
||||
SIGFPE
|
||||
SIGILL
|
||||
SIGINT
|
||||
SIGSEGV
|
||||
SIGTERM
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
sig_atomic_t
|
||||
|
||||
void (*signal(int sig, void (*func)(int)))(int);
|
||||
int raise(int sig);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::sig_atomic_t;
|
||||
using ::signal;
|
||||
using ::raise;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSIGNAL
|
32
third_party/libcxx/cstdbool
vendored
Normal file
32
third_party/libcxx/cstdbool
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- cstdbool ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CSTDBOOL
|
||||
#define _LIBCPP_CSTDBOOL
|
||||
|
||||
/*
|
||||
cstdbool synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
__bool_true_false_are_defined
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#undef __bool_true_false_are_defined
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif // _LIBCPP_CSTDBOOL
|
29
third_party/libcxx/ctgmath
vendored
Normal file
29
third_party/libcxx/ctgmath
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===-------------------------- ctgmath -----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CTGMATH
|
||||
#define _LIBCPP_CTGMATH
|
||||
|
||||
/*
|
||||
ctgmath synopsis
|
||||
|
||||
#include "third_party/libcxx/ccomplex"
|
||||
#include "third_party/libcxx/cmath"
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/ccomplex"
|
||||
#include "third_party/libcxx/cmath"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CTGMATH
|
20
third_party/libcxx/execution
vendored
Normal file
20
third_party/libcxx/execution
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===------------------------- execution ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXECUTION
|
||||
#define _LIBCPP_EXECUTION
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
|
||||
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
|
||||
# include "third_party/libcxx/__pstl_execution"
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXECUTION
|
2645
third_party/libcxx/filesystem
vendored
Normal file
2645
third_party/libcxx/filesystem
vendored
Normal file
File diff suppressed because it is too large
Load diff
1782
third_party/libcxx/forward_list
vendored
Normal file
1782
third_party/libcxx/forward_list
vendored
Normal file
File diff suppressed because it is too large
Load diff
1764
third_party/libcxx/fstream
vendored
Normal file
1764
third_party/libcxx/fstream
vendored
Normal file
File diff suppressed because it is too large
Load diff
671
third_party/libcxx/iomanip
vendored
Normal file
671
third_party/libcxx/iomanip
vendored
Normal file
|
@ -0,0 +1,671 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- iomanip ----------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_IOMANIP
|
||||
#define _LIBCPP_IOMANIP
|
||||
|
||||
/*
|
||||
iomanip synopsis
|
||||
|
||||
namespace std {
|
||||
|
||||
// types T1, T2, ... are unspecified implementation types
|
||||
T1 resetiosflags(ios_base::fmtflags mask);
|
||||
T2 setiosflags (ios_base::fmtflags mask);
|
||||
T3 setbase(int base);
|
||||
template<charT> T4 setfill(charT c);
|
||||
T5 setprecision(int n);
|
||||
T6 setw(int n);
|
||||
template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
|
||||
template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
|
||||
template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
|
||||
template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
|
||||
|
||||
template <class charT>
|
||||
T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
T12 quoted(const basic_string<charT, traits, Allocator>& s,
|
||||
charT delim=charT('"'), charT escape=charT('\\')); // C++14
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
T13 quoted(basic_string<charT, traits, Allocator>& s,
|
||||
charT delim=charT('"'), charT escape=charT('\\')); // C++14
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/__string"
|
||||
#include "third_party/libcxx/istream"
|
||||
#include "third_party/libcxx/version"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// resetiosflags
|
||||
|
||||
class __iom_t1
|
||||
{
|
||||
ios_base::fmtflags __mask_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x)
|
||||
{
|
||||
__is.unsetf(__x.__mask_);
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x)
|
||||
{
|
||||
__os.unsetf(__x.__mask_);
|
||||
return __os;
|
||||
}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t1
|
||||
resetiosflags(ios_base::fmtflags __mask)
|
||||
{
|
||||
return __iom_t1(__mask);
|
||||
}
|
||||
|
||||
// setiosflags
|
||||
|
||||
class __iom_t2
|
||||
{
|
||||
ios_base::fmtflags __mask_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x)
|
||||
{
|
||||
__is.setf(__x.__mask_);
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x)
|
||||
{
|
||||
__os.setf(__x.__mask_);
|
||||
return __os;
|
||||
}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t2
|
||||
setiosflags(ios_base::fmtflags __mask)
|
||||
{
|
||||
return __iom_t2(__mask);
|
||||
}
|
||||
|
||||
// setbase
|
||||
|
||||
class __iom_t3
|
||||
{
|
||||
int __base_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __iom_t3(int __b) : __base_(__b) {}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x)
|
||||
{
|
||||
__is.setf(__x.__base_ == 8 ? ios_base::oct :
|
||||
__x.__base_ == 10 ? ios_base::dec :
|
||||
__x.__base_ == 16 ? ios_base::hex :
|
||||
ios_base::fmtflags(0), ios_base::basefield);
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x)
|
||||
{
|
||||
__os.setf(__x.__base_ == 8 ? ios_base::oct :
|
||||
__x.__base_ == 10 ? ios_base::dec :
|
||||
__x.__base_ == 16 ? ios_base::hex :
|
||||
ios_base::fmtflags(0), ios_base::basefield);
|
||||
return __os;
|
||||
}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t3
|
||||
setbase(int __base)
|
||||
{
|
||||
return __iom_t3(__base);
|
||||
}
|
||||
|
||||
// setfill
|
||||
|
||||
template<class _CharT>
|
||||
class __iom_t4
|
||||
{
|
||||
_CharT __fill_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __iom_t4(_CharT __c) : __fill_(__c) {}
|
||||
|
||||
template <class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x)
|
||||
{
|
||||
__os.fill(__x.__fill_);
|
||||
return __os;
|
||||
}
|
||||
};
|
||||
|
||||
template<class _CharT>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t4<_CharT>
|
||||
setfill(_CharT __c)
|
||||
{
|
||||
return __iom_t4<_CharT>(__c);
|
||||
}
|
||||
|
||||
// setprecision
|
||||
|
||||
class __iom_t5
|
||||
{
|
||||
int __n_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __iom_t5(int __n) : __n_(__n) {}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x)
|
||||
{
|
||||
__is.precision(__x.__n_);
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x)
|
||||
{
|
||||
__os.precision(__x.__n_);
|
||||
return __os;
|
||||
}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t5
|
||||
setprecision(int __n)
|
||||
{
|
||||
return __iom_t5(__n);
|
||||
}
|
||||
|
||||
// setw
|
||||
|
||||
class __iom_t6
|
||||
{
|
||||
int __n_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __iom_t6(int __n) : __n_(__n) {}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x)
|
||||
{
|
||||
__is.width(__x.__n_);
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
friend
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x)
|
||||
{
|
||||
__os.width(__x.__n_);
|
||||
return __os;
|
||||
}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t6
|
||||
setw(int __n)
|
||||
{
|
||||
return __iom_t6(__n);
|
||||
}
|
||||
|
||||
// get_money
|
||||
|
||||
template <class _MoneyT> class __iom_t7;
|
||||
|
||||
template <class _CharT, class _Traits, class _MoneyT>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
|
||||
|
||||
template <class _MoneyT>
|
||||
class __iom_t7
|
||||
{
|
||||
_MoneyT& __mon_;
|
||||
bool __intl_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t7(_MoneyT& __mon, bool __intl)
|
||||
: __mon_(__mon), __intl_(__intl) {}
|
||||
|
||||
template <class _CharT, class _Traits, class _Mp>
|
||||
friend
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x);
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _MoneyT>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
typedef money_get<_CharT, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
const _Fp& __mf = use_facet<_Fp>(__is.getloc());
|
||||
__mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
|
||||
__is.setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__is.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _MoneyT>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t7<_MoneyT>
|
||||
get_money(_MoneyT& __mon, bool __intl = false)
|
||||
{
|
||||
return __iom_t7<_MoneyT>(__mon, __intl);
|
||||
}
|
||||
|
||||
// put_money
|
||||
|
||||
template <class _MoneyT> class __iom_t8;
|
||||
|
||||
template <class _CharT, class _Traits, class _MoneyT>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
|
||||
|
||||
template <class _MoneyT>
|
||||
class __iom_t8
|
||||
{
|
||||
const _MoneyT& __mon_;
|
||||
bool __intl_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t8(const _MoneyT& __mon, bool __intl)
|
||||
: __mon_(__mon), __intl_(__intl) {}
|
||||
|
||||
template <class _CharT, class _Traits, class _Mp>
|
||||
friend
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x);
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _MoneyT>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
|
||||
typedef money_put<_CharT, _Op> _Fp;
|
||||
const _Fp& __mf = use_facet<_Fp>(__os.getloc());
|
||||
if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
|
||||
__os.setstate(ios_base::badbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _MoneyT>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t8<_MoneyT>
|
||||
put_money(const _MoneyT& __mon, bool __intl = false)
|
||||
{
|
||||
return __iom_t8<_MoneyT>(__mon, __intl);
|
||||
}
|
||||
|
||||
// get_time
|
||||
|
||||
template <class _CharT> class __iom_t9;
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
|
||||
|
||||
template <class _CharT>
|
||||
class __iom_t9
|
||||
{
|
||||
tm* __tm_;
|
||||
const _CharT* __fmt_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t9(tm* __tm, const _CharT* __fmt)
|
||||
: __tm_(__tm), __fmt_(__fmt) {}
|
||||
|
||||
template <class _Cp, class _Traits>
|
||||
friend
|
||||
basic_istream<_Cp, _Traits>&
|
||||
operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x);
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
|
||||
if (__s)
|
||||
{
|
||||
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
|
||||
typedef time_get<_CharT, _Ip> _Fp;
|
||||
ios_base::iostate __err = ios_base::goodbit;
|
||||
const _Fp& __tf = use_facet<_Fp>(__is.getloc());
|
||||
__tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,
|
||||
__x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
|
||||
__is.setstate(__err);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__is.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t9<_CharT>
|
||||
get_time(tm* __tm, const _CharT* __fmt)
|
||||
{
|
||||
return __iom_t9<_CharT>(__tm, __fmt);
|
||||
}
|
||||
|
||||
// put_time
|
||||
|
||||
template <class _CharT> class __iom_t10;
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
|
||||
|
||||
template <class _CharT>
|
||||
class __iom_t10
|
||||
{
|
||||
const tm* __tm_;
|
||||
const _CharT* __fmt_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t10(const tm* __tm, const _CharT* __fmt)
|
||||
: __tm_(__tm), __fmt_(__fmt) {}
|
||||
|
||||
template <class _Cp, class _Traits>
|
||||
friend
|
||||
basic_ostream<_Cp, _Traits>&
|
||||
operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x);
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
||||
if (__s)
|
||||
{
|
||||
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
|
||||
typedef time_put<_CharT, _Op> _Fp;
|
||||
const _Fp& __tf = use_facet<_Fp>(__os.getloc());
|
||||
if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,
|
||||
__x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
|
||||
__os.setstate(ios_base::badbit);
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
__os.__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__iom_t10<_CharT>
|
||||
put_time(const tm* __tm, const _CharT* __fmt)
|
||||
{
|
||||
return __iom_t10<_CharT>(__tm, __fmt);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _ForwardIterator>
|
||||
std::basic_ostream<_CharT, _Traits> &
|
||||
__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
|
||||
_ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
|
||||
{
|
||||
_VSTD::basic_string<_CharT, _Traits> __str;
|
||||
__str.push_back(__delim);
|
||||
for ( ; __first != __last; ++ __first )
|
||||
{
|
||||
if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
|
||||
__str.push_back(__escape);
|
||||
__str.push_back(*__first);
|
||||
}
|
||||
__str.push_back(__delim);
|
||||
return __put_character_sequence(__os, __str.data(), __str.size());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _String>
|
||||
basic_istream<_CharT, _Traits> &
|
||||
__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape )
|
||||
{
|
||||
__string.clear ();
|
||||
_CharT __c;
|
||||
__is >> __c;
|
||||
if ( __is.fail ())
|
||||
return __is;
|
||||
|
||||
if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string
|
||||
{
|
||||
__is.unget ();
|
||||
__is >> __string;
|
||||
return __is;
|
||||
}
|
||||
|
||||
__save_flags<_CharT, _Traits> sf(__is);
|
||||
noskipws (__is);
|
||||
while (true)
|
||||
{
|
||||
__is >> __c;
|
||||
if ( __is.fail ())
|
||||
break;
|
||||
if (_Traits::eq (__c, __escape))
|
||||
{
|
||||
__is >> __c;
|
||||
if ( __is.fail ())
|
||||
break;
|
||||
}
|
||||
else if (_Traits::eq (__c, __delim))
|
||||
break;
|
||||
__string.push_back ( __c );
|
||||
}
|
||||
return __is;
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Traits, class _Iter>
|
||||
basic_ostream<_CharT, _Traits>& operator<<(
|
||||
basic_ostream<_CharT, _Traits>& __os,
|
||||
const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
|
||||
{
|
||||
return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
struct __quoted_proxy
|
||||
{
|
||||
basic_string<_CharT, _Traits, _Allocator> &__string;
|
||||
_CharT __delim;
|
||||
_CharT __escape;
|
||||
|
||||
__quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e)
|
||||
: __string(__s), __delim(__d), __escape(__e) {}
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_ostream<_CharT, _Traits>& operator<<(
|
||||
basic_ostream<_CharT, _Traits>& __os,
|
||||
const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
|
||||
{
|
||||
return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);
|
||||
}
|
||||
|
||||
// extractor for non-const basic_string& proxies
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>& operator>>(
|
||||
basic_istream<_CharT, _Traits>& __is,
|
||||
const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
|
||||
{
|
||||
return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_output_proxy<_CharT, const _CharT *>
|
||||
quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\'))
|
||||
{
|
||||
const _CharT *__end = __s;
|
||||
while ( *__end ) ++__end;
|
||||
return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
__quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT,
|
||||
typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
( __s.cbegin(), __s.cend (), __delim, __escape );
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_proxy<_CharT, _Traits, _Allocator>
|
||||
__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
|
||||
}
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
|
||||
quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted(__s, __delim, __escape);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__quoted_proxy<_CharT, _Traits, _Allocator>
|
||||
quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted(__s, __delim, __escape);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
__quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
quoted (basic_string_view <_CharT, _Traits> __sv,
|
||||
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_IOMANIP
|
35
third_party/libcxx/libcxx.mk
vendored
35
third_party/libcxx/libcxx.mk
vendored
|
@ -7,8 +7,6 @@ THIRD_PARTY_LIBCXX_ARTIFACTS += THIRD_PARTY_LIBCXX_A
|
|||
THIRD_PARTY_LIBCXX = $(THIRD_PARTY_LIBCXX_A_DEPS) $(THIRD_PARTY_LIBCXX_A)
|
||||
THIRD_PARTY_LIBCXX_A = o/$(MODE)/third_party/libcxx/libcxx.a
|
||||
|
||||
# third_party/libcxx/__functional_base_03 \
|
||||
|
||||
THIRD_PARTY_LIBCXX_A_HDRS = \
|
||||
third_party/libcxx/__bit_reference \
|
||||
third_party/libcxx/__bsd_locale_fallbacks.h \
|
||||
|
@ -30,28 +28,41 @@ THIRD_PARTY_LIBCXX_A_HDRS = \
|
|||
third_party/libcxx/__tuple \
|
||||
third_party/libcxx/__undef_macros \
|
||||
third_party/libcxx/algorithm \
|
||||
third_party/libcxx/any \
|
||||
third_party/libcxx/array \
|
||||
third_party/libcxx/atomic \
|
||||
third_party/libcxx/atomic_support.hh \
|
||||
third_party/libcxx/bit \
|
||||
third_party/libcxx/bitset \
|
||||
third_party/libcxx/cassert \
|
||||
third_party/libcxx/ccomplex \
|
||||
third_party/libcxx/cctype \
|
||||
third_party/libcxx/cerrno \
|
||||
third_party/libcxx/cfenv \
|
||||
third_party/libcxx/cfloat \
|
||||
third_party/libcxx/charconv \
|
||||
third_party/libcxx/chrono \
|
||||
third_party/libcxx/cinttypes \
|
||||
third_party/libcxx/ciso646 \
|
||||
third_party/libcxx/climits \
|
||||
third_party/libcxx/clocale \
|
||||
third_party/libcxx/cmath \
|
||||
third_party/libcxx/codecvt \
|
||||
third_party/libcxx/compare \
|
||||
third_party/libcxx/complex \
|
||||
third_party/libcxx/condition_variable \
|
||||
third_party/libcxx/config_elast.h \
|
||||
third_party/libcxx/countof.internal.hh \
|
||||
third_party/libcxx/csetjmp \
|
||||
third_party/libcxx/csignal \
|
||||
third_party/libcxx/cstdarg \
|
||||
third_party/libcxx/cstdbool \
|
||||
third_party/libcxx/cstddef \
|
||||
third_party/libcxx/cstdint \
|
||||
third_party/libcxx/cstdio \
|
||||
third_party/libcxx/cstdlib \
|
||||
third_party/libcxx/cstring \
|
||||
third_party/libcxx/ctgmath \
|
||||
third_party/libcxx/ctime \
|
||||
third_party/libcxx/ctype.h \
|
||||
third_party/libcxx/cwchar \
|
||||
|
@ -61,11 +72,16 @@ THIRD_PARTY_LIBCXX_A_HDRS = \
|
|||
third_party/libcxx/exception \
|
||||
third_party/libcxx/exception_fallback.hh \
|
||||
third_party/libcxx/exception_pointer_unimplemented.hh \
|
||||
third_party/libcxx/execution \
|
||||
third_party/libcxx/experimental/__config \
|
||||
third_party/libcxx/filesystem \
|
||||
third_party/libcxx/forward_list \
|
||||
third_party/libcxx/fstream \
|
||||
third_party/libcxx/functional \
|
||||
third_party/libcxx/include/atomic_support.hh \
|
||||
third_party/libcxx/include/config_elast.hh \
|
||||
third_party/libcxx/initializer_list \
|
||||
third_party/libcxx/iomanip \
|
||||
third_party/libcxx/ios \
|
||||
third_party/libcxx/iosfwd \
|
||||
third_party/libcxx/iostream \
|
||||
|
@ -90,6 +106,8 @@ THIRD_PARTY_LIBCXX_A_HDRS = \
|
|||
third_party/libcxx/random \
|
||||
third_party/libcxx/ratio \
|
||||
third_party/libcxx/refstring.hh \
|
||||
third_party/libcxx/regex \
|
||||
third_party/libcxx/scoped_allocator \
|
||||
third_party/libcxx/set \
|
||||
third_party/libcxx/sstream \
|
||||
third_party/libcxx/stack \
|
||||
|
@ -101,14 +119,17 @@ THIRD_PARTY_LIBCXX_A_HDRS = \
|
|||
third_party/libcxx/string \
|
||||
third_party/libcxx/string.h \
|
||||
third_party/libcxx/string_view \
|
||||
third_party/libcxx/strstream \
|
||||
third_party/libcxx/system_error \
|
||||
third_party/libcxx/thread \
|
||||
third_party/libcxx/tuple \
|
||||
third_party/libcxx/type_traits \
|
||||
third_party/libcxx/typeindex \
|
||||
third_party/libcxx/typeinfo \
|
||||
third_party/libcxx/unordered_map \
|
||||
third_party/libcxx/unordered_set \
|
||||
third_party/libcxx/utility \
|
||||
third_party/libcxx/valarray \
|
||||
third_party/libcxx/variant \
|
||||
third_party/libcxx/vector \
|
||||
third_party/libcxx/version \
|
||||
|
@ -126,15 +147,21 @@ THIRD_PARTY_LIBCXX_A_SRCS_CC = \
|
|||
third_party/libcxx/hash.cc \
|
||||
third_party/libcxx/ios.cc \
|
||||
third_party/libcxx/iostream.cc \
|
||||
third_party/libcxx/locale.cc \
|
||||
third_party/libcxx/locale1.cc \
|
||||
third_party/libcxx/locale2.cc \
|
||||
third_party/libcxx/locale3.cc \
|
||||
third_party/libcxx/locale4.cc \
|
||||
third_party/libcxx/memory.cc \
|
||||
third_party/libcxx/mutex.cc \
|
||||
third_party/libcxx/new.cc \
|
||||
third_party/libcxx/optional.cc \
|
||||
third_party/libcxx/random.cc \
|
||||
third_party/libcxx/regex.cc \
|
||||
third_party/libcxx/stdexcept.cc \
|
||||
third_party/libcxx/string.cc \
|
||||
third_party/libcxx/strstream.cc \
|
||||
third_party/libcxx/system_error.cc \
|
||||
third_party/libcxx/valarray.cc \
|
||||
third_party/libcxx/vector.cc
|
||||
|
||||
THIRD_PARTY_LIBCXX_A_SRCS = \
|
||||
|
@ -182,8 +209,6 @@ $(THIRD_PARTY_LIBCXX_A_OBJS): private \
|
|||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
o/$(MODE)/third_party/libcxx/locale.o: private QUOTA = -C32 -M1024m
|
||||
|
||||
THIRD_PARTY_LIBCXX_LIBS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x)))
|
||||
THIRD_PARTY_LIBCXX_SRCS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x)_SRCS))
|
||||
THIRD_PARTY_LIBCXX_HDRS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
6146
third_party/libcxx/locale.cc
vendored
6146
third_party/libcxx/locale.cc
vendored
File diff suppressed because it is too large
Load diff
1660
third_party/libcxx/locale1.cc
vendored
Normal file
1660
third_party/libcxx/locale1.cc
vendored
Normal file
File diff suppressed because it is too large
Load diff
2904
third_party/libcxx/locale2.cc
vendored
Normal file
2904
third_party/libcxx/locale2.cc
vendored
Normal file
File diff suppressed because it is too large
Load diff
723
third_party/libcxx/locale3.cc
vendored
Normal file
723
third_party/libcxx/locale3.cc
vendored
Normal file
|
@ -0,0 +1,723 @@
|
|||
// clang-format off
|
||||
//===------------------------- locale.cpp ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/string"
|
||||
#include "third_party/libcxx/locale"
|
||||
#include "third_party/libcxx/codecvt"
|
||||
#include "third_party/libcxx/vector"
|
||||
#include "third_party/libcxx/algorithm"
|
||||
#include "third_party/libcxx/typeinfo"
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
#include "third_party/libcxx/type_traits"
|
||||
#endif
|
||||
#include "third_party/libcxx/clocale"
|
||||
#include "third_party/libcxx/cstring"
|
||||
#include "third_party/libcxx/cwctype"
|
||||
#include "third_party/libcxx/__sso_allocator"
|
||||
#include "third_party/libcxx/include/atomic_support.hh"
|
||||
#include "libc/str/locale.h"
|
||||
#include "third_party/libcxx/countof.internal.hh"
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
// On Linux, wint_t and wchar_t have different signed-ness, and this causes
|
||||
// lots of noise in the build log, but no bugs that I know of.
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
namespace {
|
||||
|
||||
_LIBCPP_NORETURN static void __throw_runtime_error(const string &msg)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw runtime_error(msg);
|
||||
#else
|
||||
(void)msg;
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool __checked_string_to_wchar_convert(wchar_t& dest,
|
||||
const char* ptr,
|
||||
locale_t loc);
|
||||
bool __checked_string_to_char_convert(char& dest,
|
||||
const char* ptr,
|
||||
locale_t __loc);
|
||||
|
||||
struct __libcpp_unique_locale {
|
||||
__libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {}
|
||||
|
||||
~__libcpp_unique_locale() {
|
||||
if (__loc_)
|
||||
freelocale(__loc_);
|
||||
}
|
||||
|
||||
explicit operator bool() const { return __loc_; }
|
||||
|
||||
locale_t& get() { return __loc_; }
|
||||
|
||||
locale_t __loc_;
|
||||
private:
|
||||
__libcpp_unique_locale(__libcpp_unique_locale const&);
|
||||
__libcpp_unique_locale& operator=(__libcpp_unique_locale const&);
|
||||
};
|
||||
|
||||
// moneypunct_byname
|
||||
|
||||
template <class charT>
|
||||
static
|
||||
void
|
||||
__init_pat(money_base::pattern& pat, basic_string<charT>& __curr_symbol_,
|
||||
bool intl, char cs_precedes, char sep_by_space, char sign_posn,
|
||||
charT space_char)
|
||||
{
|
||||
const char sign = static_cast<char>(money_base::sign);
|
||||
const char space = static_cast<char>(money_base::space);
|
||||
const char none = static_cast<char>(money_base::none);
|
||||
const char symbol = static_cast<char>(money_base::symbol);
|
||||
const char value = static_cast<char>(money_base::value);
|
||||
const bool symbol_contains_sep = intl && __curr_symbol_.size() == 4;
|
||||
|
||||
// Comments on case branches reflect 'C11 7.11.2.1 The localeconv
|
||||
// function'. "Space between sign and symbol or value" means that
|
||||
// if the sign is adjacent to the symbol, there's a space between
|
||||
// them, and otherwise there's a space between the sign and value.
|
||||
//
|
||||
// C11's localeconv specifies that the fourth character of an
|
||||
// international curr_symbol is used to separate the sign and
|
||||
// value when sep_by_space says to do so. C++ can't represent
|
||||
// that, so we just use a space. When sep_by_space says to
|
||||
// separate the symbol and value-or-sign with a space, we rearrange the
|
||||
// curr_symbol to put its spacing character on the correct side of
|
||||
// the symbol.
|
||||
//
|
||||
// We also need to avoid adding an extra space between the sign
|
||||
// and value when the currency symbol is suppressed (by not
|
||||
// setting showbase). We match glibc's strfmon by interpreting
|
||||
// sep_by_space==1 as "omit the space when the currency symbol is
|
||||
// absent".
|
||||
//
|
||||
// Users who want to get this right should use ICU instead.
|
||||
|
||||
switch (cs_precedes)
|
||||
{
|
||||
case 0: // value before curr_symbol
|
||||
if (symbol_contains_sep) {
|
||||
// Move the separator to before the symbol, to place it
|
||||
// between the value and symbol.
|
||||
rotate(__curr_symbol_.begin(), __curr_symbol_.begin() + 3,
|
||||
__curr_symbol_.end());
|
||||
}
|
||||
switch (sign_posn)
|
||||
{
|
||||
case 0: // Parentheses surround the quantity and currency symbol.
|
||||
pat.field[0] = sign;
|
||||
pat.field[1] = value;
|
||||
pat.field[2] = none; // Any space appears in the symbol.
|
||||
pat.field[3] = symbol;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
// This case may have changed between C99 and C11;
|
||||
// assume the currency symbol matches the intention.
|
||||
case 2: // Space between sign and currency or value.
|
||||
// The "sign" is two parentheses, so no space here either.
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[2]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.insert(0, 1, space_char);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: // The sign string precedes the quantity and currency symbol.
|
||||
pat.field[0] = sign;
|
||||
pat.field[3] = symbol;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = value;
|
||||
pat.field[2] = none;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = value;
|
||||
pat.field[2] = none;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[2]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.insert(0, 1, space_char);
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = space;
|
||||
pat.field[2] = value;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// has already appeared after the sign.
|
||||
__curr_symbol_.erase(__curr_symbol_.begin());
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: // The sign string succeeds the quantity and currency symbol.
|
||||
pat.field[0] = value;
|
||||
pat.field[3] = sign;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = symbol;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[1]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.insert(0, 1, space_char);
|
||||
}
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = symbol;
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = space;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// should not be removed if showbase is absent.
|
||||
__curr_symbol_.erase(__curr_symbol_.begin());
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3: // The sign string immediately precedes the currency symbol.
|
||||
pat.field[0] = value;
|
||||
pat.field[3] = symbol;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = sign;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = space;
|
||||
pat.field[2] = sign;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// has already appeared before the sign.
|
||||
__curr_symbol_.erase(__curr_symbol_.begin());
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = sign;
|
||||
pat.field[2] = none;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[2]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.insert(0, 1, space_char);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4: // The sign string immediately succeeds the currency symbol.
|
||||
pat.field[0] = value;
|
||||
pat.field[3] = sign;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = symbol;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = symbol;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[1]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.insert(0, 1, space_char);
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = space;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// should not disappear when showbase is absent.
|
||||
__curr_symbol_.erase(__curr_symbol_.begin());
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: // curr_symbol before value
|
||||
switch (sign_posn)
|
||||
{
|
||||
case 0: // Parentheses surround the quantity and currency symbol.
|
||||
pat.field[0] = sign;
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = none; // Any space appears in the symbol.
|
||||
pat.field[3] = value;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
// This case may have changed between C99 and C11;
|
||||
// assume the currency symbol matches the intention.
|
||||
case 2: // Space between sign and currency or value.
|
||||
// The "sign" is two parentheses, so no space here either.
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[2]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.insert(0, 1, space_char);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: // The sign string precedes the quantity and currency symbol.
|
||||
pat.field[0] = sign;
|
||||
pat.field[3] = value;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = none;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = none;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[2]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.push_back(space_char);
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = space;
|
||||
pat.field[2] = symbol;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// has already appeared after the sign.
|
||||
__curr_symbol_.pop_back();
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: // The sign string succeeds the quantity and currency symbol.
|
||||
pat.field[0] = symbol;
|
||||
pat.field[3] = sign;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = value;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = value;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[1]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.push_back(space_char);
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = value;
|
||||
pat.field[2] = space;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// will appear before the sign.
|
||||
__curr_symbol_.pop_back();
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3: // The sign string immediately precedes the currency symbol.
|
||||
pat.field[0] = sign;
|
||||
pat.field[3] = value;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = none;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = symbol;
|
||||
pat.field[2] = none;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[2]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.push_back(space_char);
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = space;
|
||||
pat.field[2] = symbol;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// has already appeared after the sign.
|
||||
__curr_symbol_.pop_back();
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4: // The sign string immediately succeeds the currency symbol.
|
||||
pat.field[0] = symbol;
|
||||
pat.field[3] = value;
|
||||
switch (sep_by_space)
|
||||
{
|
||||
case 0: // No space separates the currency symbol and value.
|
||||
pat.field[1] = sign;
|
||||
pat.field[2] = none;
|
||||
return;
|
||||
case 1: // Space between currency-and-sign or currency and value.
|
||||
pat.field[1] = sign;
|
||||
pat.field[2] = space;
|
||||
if (symbol_contains_sep) {
|
||||
// Remove the separator from the symbol, since it
|
||||
// should not disappear when showbase is absent.
|
||||
__curr_symbol_.pop_back();
|
||||
}
|
||||
return;
|
||||
case 2: // Space between sign and currency or value.
|
||||
pat.field[1] = none;
|
||||
pat.field[2] = sign;
|
||||
if (!symbol_contains_sep) {
|
||||
// We insert the space into the symbol instead of
|
||||
// setting pat.field[1]=space so that when
|
||||
// showbase is not set, the space goes away too.
|
||||
__curr_symbol_.push_back(space_char);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pat.field[0] = symbol;
|
||||
pat.field[1] = sign;
|
||||
pat.field[2] = none;
|
||||
pat.field[3] = value;
|
||||
}
|
||||
|
||||
template<>
|
||||
void
|
||||
moneypunct_byname<char, false>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<char, false> base;
|
||||
__libcpp_unique_locale loc(nm);
|
||||
if (!loc)
|
||||
__throw_runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (!__checked_string_to_char_convert(__decimal_point_,
|
||||
lc->mon_decimal_point,
|
||||
loc.get()))
|
||||
__decimal_point_ = base::do_decimal_point();
|
||||
if (!__checked_string_to_char_convert(__thousands_sep_,
|
||||
lc->mon_thousands_sep,
|
||||
loc.get()))
|
||||
__thousands_sep_ = base::do_thousands_sep();
|
||||
|
||||
__grouping_ = lc->mon_grouping;
|
||||
__curr_symbol_ = lc->currency_symbol;
|
||||
if (lc->frac_digits != CHAR_MAX)
|
||||
__frac_digits_ = lc->frac_digits;
|
||||
else
|
||||
__frac_digits_ = base::do_frac_digits();
|
||||
if (lc->p_sign_posn == 0)
|
||||
__positive_sign_ = "()";
|
||||
else
|
||||
__positive_sign_ = lc->positive_sign;
|
||||
if (lc->n_sign_posn == 0)
|
||||
__negative_sign_ = "()";
|
||||
else
|
||||
__negative_sign_ = lc->negative_sign;
|
||||
// Assume the positive and negative formats will want spaces in
|
||||
// the same places in curr_symbol since there's no way to
|
||||
// represent anything else.
|
||||
string_type __dummy_curr_symbol = __curr_symbol_;
|
||||
__init_pat(__pos_format_, __dummy_curr_symbol, false,
|
||||
lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
|
||||
__init_pat(__neg_format_, __curr_symbol_, false,
|
||||
lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
|
||||
}
|
||||
|
||||
template<>
|
||||
void
|
||||
moneypunct_byname<char, true>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<char, true> base;
|
||||
__libcpp_unique_locale loc(nm);
|
||||
if (!loc)
|
||||
__throw_runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (!__checked_string_to_char_convert(__decimal_point_,
|
||||
lc->mon_decimal_point,
|
||||
loc.get()))
|
||||
__decimal_point_ = base::do_decimal_point();
|
||||
if (!__checked_string_to_char_convert(__thousands_sep_,
|
||||
lc->mon_thousands_sep,
|
||||
loc.get()))
|
||||
__thousands_sep_ = base::do_thousands_sep();
|
||||
__grouping_ = lc->mon_grouping;
|
||||
__curr_symbol_ = lc->int_curr_symbol;
|
||||
if (lc->int_frac_digits != CHAR_MAX)
|
||||
__frac_digits_ = lc->int_frac_digits;
|
||||
else
|
||||
__frac_digits_ = base::do_frac_digits();
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
if (lc->p_sign_posn == 0)
|
||||
#else // _LIBCPP_MSVCRT
|
||||
if (lc->int_p_sign_posn == 0)
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
__positive_sign_ = "()";
|
||||
else
|
||||
__positive_sign_ = lc->positive_sign;
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
if(lc->n_sign_posn == 0)
|
||||
#else // _LIBCPP_MSVCRT
|
||||
if (lc->int_n_sign_posn == 0)
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
__negative_sign_ = "()";
|
||||
else
|
||||
__negative_sign_ = lc->negative_sign;
|
||||
// Assume the positive and negative formats will want spaces in
|
||||
// the same places in curr_symbol since there's no way to
|
||||
// represent anything else.
|
||||
string_type __dummy_curr_symbol = __curr_symbol_;
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
__init_pat(__pos_format_, __dummy_curr_symbol, true,
|
||||
lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
|
||||
__init_pat(__neg_format_, __curr_symbol_, true,
|
||||
lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
|
||||
#else // _LIBCPP_MSVCRT
|
||||
__init_pat(__pos_format_, __dummy_curr_symbol, true,
|
||||
lc->int_p_cs_precedes, lc->int_p_sep_by_space,
|
||||
lc->int_p_sign_posn, ' ');
|
||||
__init_pat(__neg_format_, __curr_symbol_, true,
|
||||
lc->int_n_cs_precedes, lc->int_n_sep_by_space,
|
||||
lc->int_n_sign_posn, ' ');
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
}
|
||||
|
||||
template<>
|
||||
void
|
||||
moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<wchar_t, false> base;
|
||||
__libcpp_unique_locale loc(nm);
|
||||
if (!loc)
|
||||
__throw_runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (!__checked_string_to_wchar_convert(__decimal_point_,
|
||||
lc->mon_decimal_point,
|
||||
loc.get()))
|
||||
__decimal_point_ = base::do_decimal_point();
|
||||
if (!__checked_string_to_wchar_convert(__thousands_sep_,
|
||||
lc->mon_thousands_sep,
|
||||
loc.get()))
|
||||
__thousands_sep_ = base::do_thousands_sep();
|
||||
__grouping_ = lc->mon_grouping;
|
||||
wchar_t wbuf[100];
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = lc->currency_symbol;
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbuf + j;
|
||||
__curr_symbol_.assign(wbuf, wbe);
|
||||
if (lc->frac_digits != CHAR_MAX)
|
||||
__frac_digits_ = lc->frac_digits;
|
||||
else
|
||||
__frac_digits_ = base::do_frac_digits();
|
||||
if (lc->p_sign_posn == 0)
|
||||
__positive_sign_ = L"()";
|
||||
else
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->positive_sign;
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
__positive_sign_.assign(wbuf, wbe);
|
||||
}
|
||||
if (lc->n_sign_posn == 0)
|
||||
__negative_sign_ = L"()";
|
||||
else
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->negative_sign;
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
__negative_sign_.assign(wbuf, wbe);
|
||||
}
|
||||
// Assume the positive and negative formats will want spaces in
|
||||
// the same places in curr_symbol since there's no way to
|
||||
// represent anything else.
|
||||
string_type __dummy_curr_symbol = __curr_symbol_;
|
||||
__init_pat(__pos_format_, __dummy_curr_symbol, false,
|
||||
lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
|
||||
__init_pat(__neg_format_, __curr_symbol_, false,
|
||||
lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
|
||||
}
|
||||
|
||||
template<>
|
||||
void
|
||||
moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<wchar_t, true> base;
|
||||
__libcpp_unique_locale loc(nm);
|
||||
if (!loc)
|
||||
__throw_runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
|
||||
lconv* lc = __libcpp_localeconv_l(loc.get());
|
||||
if (!__checked_string_to_wchar_convert(__decimal_point_,
|
||||
lc->mon_decimal_point,
|
||||
loc.get()))
|
||||
__decimal_point_ = base::do_decimal_point();
|
||||
if (!__checked_string_to_wchar_convert(__thousands_sep_,
|
||||
lc->mon_thousands_sep,
|
||||
loc.get()))
|
||||
__thousands_sep_ = base::do_thousands_sep();
|
||||
__grouping_ = lc->mon_grouping;
|
||||
wchar_t wbuf[100];
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = lc->int_curr_symbol;
|
||||
size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbuf + j;
|
||||
__curr_symbol_.assign(wbuf, wbe);
|
||||
if (lc->int_frac_digits != CHAR_MAX)
|
||||
__frac_digits_ = lc->int_frac_digits;
|
||||
else
|
||||
__frac_digits_ = base::do_frac_digits();
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
if (lc->p_sign_posn == 0)
|
||||
#else // _LIBCPP_MSVCRT
|
||||
if (lc->int_p_sign_posn == 0)
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
__positive_sign_ = L"()";
|
||||
else
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->positive_sign;
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
__positive_sign_.assign(wbuf, wbe);
|
||||
}
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
if (lc->n_sign_posn == 0)
|
||||
#else // _LIBCPP_MSVCRT
|
||||
if (lc->int_n_sign_posn == 0)
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
__negative_sign_ = L"()";
|
||||
else
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->negative_sign;
|
||||
j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
|
||||
if (j == size_t(-1))
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
__negative_sign_.assign(wbuf, wbe);
|
||||
}
|
||||
// Assume the positive and negative formats will want spaces in
|
||||
// the same places in curr_symbol since there's no way to
|
||||
// represent anything else.
|
||||
string_type __dummy_curr_symbol = __curr_symbol_;
|
||||
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
__init_pat(__pos_format_, __dummy_curr_symbol, true,
|
||||
lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
|
||||
__init_pat(__neg_format_, __curr_symbol_, true,
|
||||
lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
|
||||
#else // _LIBCPP_MSVCRT
|
||||
__init_pat(__pos_format_, __dummy_curr_symbol, true,
|
||||
lc->int_p_cs_precedes, lc->int_p_sep_by_space,
|
||||
lc->int_p_sign_posn, L' ');
|
||||
__init_pat(__neg_format_, __curr_symbol_, true,
|
||||
lc->int_n_cs_precedes, lc->int_n_sep_by_space,
|
||||
lc->int_n_sign_posn, L' ');
|
||||
#endif // !_LIBCPP_MSVCRT
|
||||
}
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, false>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, true>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, false>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, true>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, false>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, true>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, false>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, true>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<wchar_t>;
|
||||
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<char>;
|
||||
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<wchar_t>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
1010
third_party/libcxx/locale4.cc
vendored
Normal file
1010
third_party/libcxx/locale4.cc
vendored
Normal file
File diff suppressed because it is too large
Load diff
6663
third_party/libcxx/regex
vendored
Normal file
6663
third_party/libcxx/regex
vendored
Normal file
File diff suppressed because it is too large
Load diff
315
third_party/libcxx/regex.cc
vendored
Normal file
315
third_party/libcxx/regex.cc
vendored
Normal file
|
@ -0,0 +1,315 @@
|
|||
// clang-format off
|
||||
//===-------------------------- regex.cpp ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/regex"
|
||||
#include "third_party/libcxx/algorithm"
|
||||
#include "third_party/libcxx/iterator"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
static
|
||||
const char*
|
||||
make_error_type_string(regex_constants::error_type ecode)
|
||||
{
|
||||
switch (ecode)
|
||||
{
|
||||
case regex_constants::error_collate:
|
||||
return "The expression contained an invalid collating element name.";
|
||||
case regex_constants::error_ctype:
|
||||
return "The expression contained an invalid character class name.";
|
||||
case regex_constants::error_escape:
|
||||
return "The expression contained an invalid escaped character, or a "
|
||||
"trailing escape.";
|
||||
case regex_constants::error_backref:
|
||||
return "The expression contained an invalid back reference.";
|
||||
case regex_constants::error_brack:
|
||||
return "The expression contained mismatched [ and ].";
|
||||
case regex_constants::error_paren:
|
||||
return "The expression contained mismatched ( and ).";
|
||||
case regex_constants::error_brace:
|
||||
return "The expression contained mismatched { and }.";
|
||||
case regex_constants::error_badbrace:
|
||||
return "The expression contained an invalid range in a {} expression.";
|
||||
case regex_constants::error_range:
|
||||
return "The expression contained an invalid character range, "
|
||||
"such as [b-a] in most encodings.";
|
||||
case regex_constants::error_space:
|
||||
return "There was insufficient memory to convert the expression into "
|
||||
"a finite state machine.";
|
||||
case regex_constants::error_badrepeat:
|
||||
return "One of *?+{ was not preceded by a valid regular expression.";
|
||||
case regex_constants::error_complexity:
|
||||
return "The complexity of an attempted match against a regular "
|
||||
"expression exceeded a pre-set level.";
|
||||
case regex_constants::error_stack:
|
||||
return "There was insufficient memory to determine whether the regular "
|
||||
"expression could match the specified character sequence.";
|
||||
case regex_constants::__re_err_grammar:
|
||||
return "An invalid regex grammar has been requested.";
|
||||
case regex_constants::__re_err_empty:
|
||||
return "An empty regex is not allowed in the POSIX grammar.";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "Unknown error type";
|
||||
}
|
||||
|
||||
regex_error::regex_error(regex_constants::error_type ecode)
|
||||
: runtime_error(make_error_type_string(ecode)),
|
||||
__code_(ecode)
|
||||
{}
|
||||
|
||||
regex_error::~regex_error() throw() {}
|
||||
|
||||
namespace {
|
||||
|
||||
struct collationnames
|
||||
{
|
||||
const char* elem_;
|
||||
char char_;
|
||||
};
|
||||
|
||||
const collationnames collatenames[] =
|
||||
{
|
||||
{"A", 0x41},
|
||||
{"B", 0x42},
|
||||
{"C", 0x43},
|
||||
{"D", 0x44},
|
||||
{"E", 0x45},
|
||||
{"F", 0x46},
|
||||
{"G", 0x47},
|
||||
{"H", 0x48},
|
||||
{"I", 0x49},
|
||||
{"J", 0x4a},
|
||||
{"K", 0x4b},
|
||||
{"L", 0x4c},
|
||||
{"M", 0x4d},
|
||||
{"N", 0x4e},
|
||||
{"NUL", 0x00},
|
||||
{"O", 0x4f},
|
||||
{"P", 0x50},
|
||||
{"Q", 0x51},
|
||||
{"R", 0x52},
|
||||
{"S", 0x53},
|
||||
{"T", 0x54},
|
||||
{"U", 0x55},
|
||||
{"V", 0x56},
|
||||
{"W", 0x57},
|
||||
{"X", 0x58},
|
||||
{"Y", 0x59},
|
||||
{"Z", 0x5a},
|
||||
{"a", 0x61},
|
||||
{"alert", 0x07},
|
||||
{"ampersand", 0x26},
|
||||
{"apostrophe", 0x27},
|
||||
{"asterisk", 0x2a},
|
||||
{"b", 0x62},
|
||||
{"backslash", 0x5c},
|
||||
{"backspace", 0x08},
|
||||
{"c", 0x63},
|
||||
{"carriage-return", 0x0d},
|
||||
{"circumflex", 0x5e},
|
||||
{"circumflex-accent", 0x5e},
|
||||
{"colon", 0x3a},
|
||||
{"comma", 0x2c},
|
||||
{"commercial-at", 0x40},
|
||||
{"d", 0x64},
|
||||
{"dollar-sign", 0x24},
|
||||
{"e", 0x65},
|
||||
{"eight", 0x38},
|
||||
{"equals-sign", 0x3d},
|
||||
{"exclamation-mark", 0x21},
|
||||
{"f", 0x66},
|
||||
{"five", 0x35},
|
||||
{"form-feed", 0x0c},
|
||||
{"four", 0x34},
|
||||
{"full-stop", 0x2e},
|
||||
{"g", 0x67},
|
||||
{"grave-accent", 0x60},
|
||||
{"greater-than-sign", 0x3e},
|
||||
{"h", 0x68},
|
||||
{"hyphen", 0x2d},
|
||||
{"hyphen-minus", 0x2d},
|
||||
{"i", 0x69},
|
||||
{"j", 0x6a},
|
||||
{"k", 0x6b},
|
||||
{"l", 0x6c},
|
||||
{"left-brace", 0x7b},
|
||||
{"left-curly-bracket", 0x7b},
|
||||
{"left-parenthesis", 0x28},
|
||||
{"left-square-bracket", 0x5b},
|
||||
{"less-than-sign", 0x3c},
|
||||
{"low-line", 0x5f},
|
||||
{"m", 0x6d},
|
||||
{"n", 0x6e},
|
||||
{"newline", 0x0a},
|
||||
{"nine", 0x39},
|
||||
{"number-sign", 0x23},
|
||||
{"o", 0x6f},
|
||||
{"one", 0x31},
|
||||
{"p", 0x70},
|
||||
{"percent-sign", 0x25},
|
||||
{"period", 0x2e},
|
||||
{"plus-sign", 0x2b},
|
||||
{"q", 0x71},
|
||||
{"question-mark", 0x3f},
|
||||
{"quotation-mark", 0x22},
|
||||
{"r", 0x72},
|
||||
{"reverse-solidus", 0x5c},
|
||||
{"right-brace", 0x7d},
|
||||
{"right-curly-bracket", 0x7d},
|
||||
{"right-parenthesis", 0x29},
|
||||
{"right-square-bracket", 0x5d},
|
||||
{"s", 0x73},
|
||||
{"semicolon", 0x3b},
|
||||
{"seven", 0x37},
|
||||
{"six", 0x36},
|
||||
{"slash", 0x2f},
|
||||
{"solidus", 0x2f},
|
||||
{"space", 0x20},
|
||||
{"t", 0x74},
|
||||
{"tab", 0x09},
|
||||
{"three", 0x33},
|
||||
{"tilde", 0x7e},
|
||||
{"two", 0x32},
|
||||
{"u", 0x75},
|
||||
{"underscore", 0x5f},
|
||||
{"v", 0x76},
|
||||
{"vertical-line", 0x7c},
|
||||
{"vertical-tab", 0x0b},
|
||||
{"w", 0x77},
|
||||
{"x", 0x78},
|
||||
{"y", 0x79},
|
||||
{"z", 0x7a},
|
||||
{"zero", 0x30}
|
||||
};
|
||||
|
||||
struct classnames
|
||||
{
|
||||
const char* elem_;
|
||||
regex_traits<char>::char_class_type mask_;
|
||||
};
|
||||
|
||||
const classnames ClassNames[] =
|
||||
{
|
||||
{"alnum", ctype_base::alnum},
|
||||
{"alpha", ctype_base::alpha},
|
||||
{"blank", ctype_base::blank},
|
||||
{"cntrl", ctype_base::cntrl},
|
||||
{"d", ctype_base::digit},
|
||||
{"digit", ctype_base::digit},
|
||||
{"graph", ctype_base::graph},
|
||||
{"lower", ctype_base::lower},
|
||||
{"print", ctype_base::print},
|
||||
{"punct", ctype_base::punct},
|
||||
{"s", ctype_base::space},
|
||||
{"space", ctype_base::space},
|
||||
{"upper", ctype_base::upper},
|
||||
{"w", regex_traits<char>::__regex_word},
|
||||
{"xdigit", ctype_base::xdigit}
|
||||
};
|
||||
|
||||
struct use_strcmp
|
||||
{
|
||||
bool operator()(const collationnames& x, const char* y)
|
||||
{return strcmp(x.elem_, y) < 0;}
|
||||
bool operator()(const classnames& x, const char* y)
|
||||
{return strcmp(x.elem_, y) < 0;}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
string
|
||||
__get_collation_name(const char* s)
|
||||
{
|
||||
const collationnames* i =
|
||||
_VSTD::lower_bound(begin(collatenames), end(collatenames), s, use_strcmp());
|
||||
string r;
|
||||
if (i != end(collatenames) && strcmp(s, i->elem_) == 0)
|
||||
r = char(i->char_);
|
||||
return r;
|
||||
}
|
||||
|
||||
regex_traits<char>::char_class_type
|
||||
__get_classname(const char* s, bool __icase)
|
||||
{
|
||||
const classnames* i =
|
||||
_VSTD::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
|
||||
regex_traits<char>::char_class_type r = 0;
|
||||
if (i != end(ClassNames) && strcmp(s, i->elem_) == 0)
|
||||
{
|
||||
r = i->mask_;
|
||||
if (r == regex_traits<char>::__regex_word)
|
||||
r |= ctype_base::alnum | ctype_base::upper | ctype_base::lower;
|
||||
else if (__icase)
|
||||
{
|
||||
if (r & (ctype_base::lower | ctype_base::upper))
|
||||
r |= ctype_base::alpha;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
__match_any_but_newline<char>::__exec(__state& __s) const
|
||||
{
|
||||
if (__s.__current_ != __s.__last_)
|
||||
{
|
||||
switch (*__s.__current_)
|
||||
{
|
||||
case '\r':
|
||||
case '\n':
|
||||
__s.__do_ = __state::__reject;
|
||||
__s.__node_ = nullptr;
|
||||
break;
|
||||
default:
|
||||
__s.__do_ = __state::__accept_and_consume;
|
||||
++__s.__current_;
|
||||
__s.__node_ = this->first();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__s.__do_ = __state::__reject;
|
||||
__s.__node_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
__match_any_but_newline<wchar_t>::__exec(__state& __s) const
|
||||
{
|
||||
if (__s.__current_ != __s.__last_)
|
||||
{
|
||||
switch (*__s.__current_)
|
||||
{
|
||||
case '\r':
|
||||
case '\n':
|
||||
case 0x2028:
|
||||
case 0x2029:
|
||||
__s.__do_ = __state::__reject;
|
||||
__s.__node_ = nullptr;
|
||||
break;
|
||||
default:
|
||||
__s.__do_ = __state::__accept_and_consume;
|
||||
++__s.__current_;
|
||||
__s.__node_ = this->first();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__s.__do_ = __state::__reject;
|
||||
__s.__node_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
684
third_party/libcxx/scoped_allocator
vendored
Normal file
684
third_party/libcxx/scoped_allocator
vendored
Normal file
|
@ -0,0 +1,684 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===-------------------------- scoped_allocator --------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_SCOPED_ALLOCATOR
|
||||
#define _LIBCPP_SCOPED_ALLOCATOR
|
||||
|
||||
/*
|
||||
scoped_allocator synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class OuterAlloc, class... InnerAllocs>
|
||||
class scoped_allocator_adaptor : public OuterAlloc
|
||||
{
|
||||
typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only
|
||||
scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only
|
||||
public:
|
||||
|
||||
typedef OuterAlloc outer_allocator_type;
|
||||
typedef see below inner_allocator_type;
|
||||
|
||||
typedef typename OuterTraits::value_type value_type;
|
||||
typedef typename OuterTraits::size_type size_type;
|
||||
typedef typename OuterTraits::difference_type difference_type;
|
||||
typedef typename OuterTraits::pointer pointer;
|
||||
typedef typename OuterTraits::const_pointer const_pointer;
|
||||
typedef typename OuterTraits::void_pointer void_pointer;
|
||||
typedef typename OuterTraits::const_void_pointer const_void_pointer;
|
||||
|
||||
typedef see below propagate_on_container_copy_assignment;
|
||||
typedef see below propagate_on_container_move_assignment;
|
||||
typedef see below propagate_on_container_swap;
|
||||
typedef see below is_always_equal;
|
||||
|
||||
template <class Tp>
|
||||
struct rebind
|
||||
{
|
||||
typedef scoped_allocator_adaptor<
|
||||
OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other;
|
||||
};
|
||||
|
||||
scoped_allocator_adaptor();
|
||||
template <class OuterA2>
|
||||
scoped_allocator_adaptor(OuterA2&& outerAlloc,
|
||||
const InnerAllocs&... innerAllocs) noexcept;
|
||||
scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
|
||||
scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;
|
||||
template <class OuterA2>
|
||||
scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;
|
||||
template <class OuterA2>
|
||||
scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
|
||||
|
||||
scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
|
||||
scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
|
||||
~scoped_allocator_adaptor();
|
||||
|
||||
inner_allocator_type& inner_allocator() noexcept;
|
||||
const inner_allocator_type& inner_allocator() const noexcept;
|
||||
|
||||
outer_allocator_type& outer_allocator() noexcept;
|
||||
const outer_allocator_type& outer_allocator() const noexcept;
|
||||
|
||||
pointer allocate(size_type n); // [[nodiscard]] in C++20
|
||||
pointer allocate(size_type n, const_void_pointer hint); // [[nodiscard]] in C++20
|
||||
void deallocate(pointer p, size_type n) noexcept;
|
||||
|
||||
size_type max_size() const;
|
||||
template <class T, class... Args> void construct(T* p, Args&& args);
|
||||
template <class T1, class T2, class... Args1, class... Args2>
|
||||
void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x,
|
||||
tuple<Args2...> y);
|
||||
template <class T1, class T2>
|
||||
void construct(pair<T1, T2>* p);
|
||||
template <class T1, class T2, class U, class V>
|
||||
void construct(pair<T1, T2>* p, U&& x, V&& y);
|
||||
template <class T1, class T2, class U, class V>
|
||||
void construct(pair<T1, T2>* p, const pair<U, V>& x);
|
||||
template <class T1, class T2, class U, class V>
|
||||
void construct(pair<T1, T2>* p, pair<U, V>&& x);
|
||||
template <class T> void destroy(T* p);
|
||||
|
||||
template <class T> void destroy(T* p) noexcept;
|
||||
|
||||
scoped_allocator_adaptor select_on_container_copy_construction() const noexcept;
|
||||
};
|
||||
|
||||
template <class OuterA1, class OuterA2, class... InnerAllocs>
|
||||
bool
|
||||
operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
||||
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
||||
|
||||
template <class OuterA1, class OuterA2, class... InnerAllocs>
|
||||
bool
|
||||
operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
||||
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/memory"
|
||||
#include "third_party/libcxx/version"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
// scoped_allocator_adaptor
|
||||
|
||||
template <class ..._Allocs>
|
||||
class scoped_allocator_adaptor;
|
||||
|
||||
template <class ..._Allocs> struct __get_poc_copy_assignment;
|
||||
|
||||
template <class _A0>
|
||||
struct __get_poc_copy_assignment<_A0>
|
||||
{
|
||||
static const bool value = allocator_traits<_A0>::
|
||||
propagate_on_container_copy_assignment::value;
|
||||
};
|
||||
|
||||
template <class _A0, class ..._Allocs>
|
||||
struct __get_poc_copy_assignment<_A0, _Allocs...>
|
||||
{
|
||||
static const bool value =
|
||||
allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||
|
||||
__get_poc_copy_assignment<_Allocs...>::value;
|
||||
};
|
||||
|
||||
template <class ..._Allocs> struct __get_poc_move_assignment;
|
||||
|
||||
template <class _A0>
|
||||
struct __get_poc_move_assignment<_A0>
|
||||
{
|
||||
static const bool value = allocator_traits<_A0>::
|
||||
propagate_on_container_move_assignment::value;
|
||||
};
|
||||
|
||||
template <class _A0, class ..._Allocs>
|
||||
struct __get_poc_move_assignment<_A0, _Allocs...>
|
||||
{
|
||||
static const bool value =
|
||||
allocator_traits<_A0>::propagate_on_container_move_assignment::value ||
|
||||
__get_poc_move_assignment<_Allocs...>::value;
|
||||
};
|
||||
|
||||
template <class ..._Allocs> struct __get_poc_swap;
|
||||
|
||||
template <class _A0>
|
||||
struct __get_poc_swap<_A0>
|
||||
{
|
||||
static const bool value = allocator_traits<_A0>::
|
||||
propagate_on_container_swap::value;
|
||||
};
|
||||
|
||||
template <class _A0, class ..._Allocs>
|
||||
struct __get_poc_swap<_A0, _Allocs...>
|
||||
{
|
||||
static const bool value =
|
||||
allocator_traits<_A0>::propagate_on_container_swap::value ||
|
||||
__get_poc_swap<_Allocs...>::value;
|
||||
};
|
||||
|
||||
template <class ..._Allocs> struct __get_is_always_equal;
|
||||
|
||||
template <class _A0>
|
||||
struct __get_is_always_equal<_A0>
|
||||
{
|
||||
static const bool value = allocator_traits<_A0>::is_always_equal::value;
|
||||
};
|
||||
|
||||
template <class _A0, class ..._Allocs>
|
||||
struct __get_is_always_equal<_A0, _Allocs...>
|
||||
{
|
||||
static const bool value =
|
||||
allocator_traits<_A0>::is_always_equal::value &&
|
||||
__get_is_always_equal<_Allocs...>::value;
|
||||
};
|
||||
|
||||
template <class ..._Allocs>
|
||||
class __scoped_allocator_storage;
|
||||
|
||||
template <class _OuterAlloc, class... _InnerAllocs>
|
||||
class __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
|
||||
: public _OuterAlloc
|
||||
{
|
||||
typedef _OuterAlloc outer_allocator_type;
|
||||
protected:
|
||||
typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;
|
||||
|
||||
private:
|
||||
inner_allocator_type __inner_;
|
||||
|
||||
protected:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage() _NOEXCEPT {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(_OuterA2&& __outerAlloc,
|
||||
const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
|
||||
: outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),
|
||||
__inner_(__innerAllocs...) {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, const _OuterA2&>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(
|
||||
const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
|
||||
: outer_allocator_type(__other.outer_allocator()),
|
||||
__inner_(__other.inner_allocator()) {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(
|
||||
__scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
|
||||
: outer_allocator_type(_VSTD::move(__other.outer_allocator())),
|
||||
__inner_(_VSTD::move(__other.inner_allocator())) {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(_OuterA2&& __o,
|
||||
const inner_allocator_type& __i) _NOEXCEPT
|
||||
: outer_allocator_type(_VSTD::forward<_OuterA2>(__o)),
|
||||
__inner_(__i)
|
||||
{
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inner_allocator_type& inner_allocator() _NOEXCEPT {return __inner_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
outer_allocator_type& outer_allocator() _NOEXCEPT
|
||||
{return static_cast<outer_allocator_type&>(*this);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const outer_allocator_type& outer_allocator() const _NOEXCEPT
|
||||
{return static_cast<const outer_allocator_type&>(*this);}
|
||||
|
||||
scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
select_on_container_copy_construction() const _NOEXCEPT
|
||||
{
|
||||
return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
|
||||
(
|
||||
allocator_traits<outer_allocator_type>::
|
||||
select_on_container_copy_construction(outer_allocator()),
|
||||
allocator_traits<inner_allocator_type>::
|
||||
select_on_container_copy_construction(inner_allocator())
|
||||
);
|
||||
}
|
||||
|
||||
template <class...> friend class __scoped_allocator_storage;
|
||||
};
|
||||
|
||||
template <class _OuterAlloc>
|
||||
class __scoped_allocator_storage<_OuterAlloc>
|
||||
: public _OuterAlloc
|
||||
{
|
||||
typedef _OuterAlloc outer_allocator_type;
|
||||
protected:
|
||||
typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage() _NOEXCEPT {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT
|
||||
: outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, const _OuterA2&>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(
|
||||
const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT
|
||||
: outer_allocator_type(__other.outer_allocator()) {}
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__scoped_allocator_storage(
|
||||
__scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT
|
||||
: outer_allocator_type(_VSTD::move(__other.outer_allocator())) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inner_allocator_type& inner_allocator() _NOEXCEPT
|
||||
{return static_cast<inner_allocator_type&>(*this);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const inner_allocator_type& inner_allocator() const _NOEXCEPT
|
||||
{return static_cast<const inner_allocator_type&>(*this);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
outer_allocator_type& outer_allocator() _NOEXCEPT
|
||||
{return static_cast<outer_allocator_type&>(*this);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const outer_allocator_type& outer_allocator() const _NOEXCEPT
|
||||
{return static_cast<const outer_allocator_type&>(*this);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor<outer_allocator_type>
|
||||
select_on_container_copy_construction() const _NOEXCEPT
|
||||
{return scoped_allocator_adaptor<outer_allocator_type>(
|
||||
allocator_traits<outer_allocator_type>::
|
||||
select_on_container_copy_construction(outer_allocator())
|
||||
);}
|
||||
|
||||
__scoped_allocator_storage(const outer_allocator_type& __o,
|
||||
const inner_allocator_type& __i) _NOEXCEPT;
|
||||
|
||||
template <class...> friend class __scoped_allocator_storage;
|
||||
};
|
||||
|
||||
// __outermost
|
||||
|
||||
template <class _Alloc>
|
||||
decltype(declval<_Alloc>().outer_allocator(), true_type())
|
||||
__has_outer_allocator_test(_Alloc&& __a);
|
||||
|
||||
template <class _Alloc>
|
||||
false_type
|
||||
__has_outer_allocator_test(const volatile _Alloc& __a);
|
||||
|
||||
template <class _Alloc>
|
||||
struct __has_outer_allocator
|
||||
: public common_type
|
||||
<
|
||||
decltype(__has_outer_allocator_test(declval<_Alloc&>()))
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
|
||||
struct __outermost
|
||||
{
|
||||
typedef _Alloc type;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
type& operator()(type& __a) const _NOEXCEPT {return __a;}
|
||||
};
|
||||
|
||||
template <class _Alloc>
|
||||
struct __outermost<_Alloc, true>
|
||||
{
|
||||
typedef typename remove_reference
|
||||
<
|
||||
decltype(_VSTD::declval<_Alloc>().outer_allocator())
|
||||
>::type _OuterAlloc;
|
||||
typedef typename __outermost<_OuterAlloc>::type type;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
type& operator()(_Alloc& __a) const _NOEXCEPT
|
||||
{return __outermost<_OuterAlloc>()(__a.outer_allocator());}
|
||||
};
|
||||
|
||||
template <class _OuterAlloc, class... _InnerAllocs>
|
||||
class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
|
||||
: public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
|
||||
{
|
||||
typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
|
||||
typedef allocator_traits<_OuterAlloc> _OuterTraits;
|
||||
public:
|
||||
typedef _OuterAlloc outer_allocator_type;
|
||||
typedef typename base::inner_allocator_type inner_allocator_type;
|
||||
typedef typename _OuterTraits::size_type size_type;
|
||||
typedef typename _OuterTraits::difference_type difference_type;
|
||||
typedef typename _OuterTraits::pointer pointer;
|
||||
typedef typename _OuterTraits::const_pointer const_pointer;
|
||||
typedef typename _OuterTraits::void_pointer void_pointer;
|
||||
typedef typename _OuterTraits::const_void_pointer const_void_pointer;
|
||||
|
||||
typedef integral_constant
|
||||
<
|
||||
bool,
|
||||
__get_poc_copy_assignment<outer_allocator_type,
|
||||
_InnerAllocs...>::value
|
||||
> propagate_on_container_copy_assignment;
|
||||
typedef integral_constant
|
||||
<
|
||||
bool,
|
||||
__get_poc_move_assignment<outer_allocator_type,
|
||||
_InnerAllocs...>::value
|
||||
> propagate_on_container_move_assignment;
|
||||
typedef integral_constant
|
||||
<
|
||||
bool,
|
||||
__get_poc_swap<outer_allocator_type, _InnerAllocs...>::value
|
||||
> propagate_on_container_swap;
|
||||
typedef integral_constant
|
||||
<
|
||||
bool,
|
||||
__get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value
|
||||
> is_always_equal;
|
||||
|
||||
template <class _Tp>
|
||||
struct rebind
|
||||
{
|
||||
typedef scoped_allocator_adaptor
|
||||
<
|
||||
typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs...
|
||||
> other;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor() _NOEXCEPT {}
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor(_OuterA2&& __outerAlloc,
|
||||
const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
|
||||
: base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}
|
||||
// scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, const _OuterA2&>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor(
|
||||
const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
|
||||
: base(__other) {}
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor(
|
||||
scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
|
||||
: base(_VSTD::move(__other)) {}
|
||||
|
||||
// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
|
||||
// scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
|
||||
// ~scoped_allocator_adaptor() = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inner_allocator_type& inner_allocator() _NOEXCEPT
|
||||
{return base::inner_allocator();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const inner_allocator_type& inner_allocator() const _NOEXCEPT
|
||||
{return base::inner_allocator();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
outer_allocator_type& outer_allocator() _NOEXCEPT
|
||||
{return base::outer_allocator();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const outer_allocator_type& outer_allocator() const _NOEXCEPT
|
||||
{return base::outer_allocator();}
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer allocate(size_type __n)
|
||||
{return allocator_traits<outer_allocator_type>::
|
||||
allocate(outer_allocator(), __n);}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer allocate(size_type __n, const_void_pointer __hint)
|
||||
{return allocator_traits<outer_allocator_type>::
|
||||
allocate(outer_allocator(), __n, __hint);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void deallocate(pointer __p, size_type __n) _NOEXCEPT
|
||||
{allocator_traits<outer_allocator_type>::
|
||||
deallocate(outer_allocator(), __p, __n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const
|
||||
{return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
|
||||
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(_Tp* __p, _Args&& ...__args)
|
||||
{__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(),
|
||||
__p, _VSTD::forward<_Args>(__args)...);}
|
||||
|
||||
template <class _T1, class _T2, class... _Args1, class... _Args2>
|
||||
void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
|
||||
tuple<_Args1...> __x, tuple<_Args2...> __y)
|
||||
{
|
||||
typedef __outermost<outer_allocator_type> _OM;
|
||||
allocator_traits<typename _OM::type>::construct(
|
||||
_OM()(outer_allocator()), __p, piecewise_construct
|
||||
, __transform_tuple(
|
||||
typename __uses_alloc_ctor<
|
||||
_T1, inner_allocator_type&, _Args1...
|
||||
>::type()
|
||||
, _VSTD::move(__x)
|
||||
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
|
||||
)
|
||||
, __transform_tuple(
|
||||
typename __uses_alloc_ctor<
|
||||
_T2, inner_allocator_type&, _Args2...
|
||||
>::type()
|
||||
, _VSTD::move(__y)
|
||||
, typename __make_tuple_indices<sizeof...(_Args2)>::type{}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
void construct(pair<_T1, _T2>* __p)
|
||||
{ construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
|
||||
construct(__p, piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y)));
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
|
||||
construct(__p, piecewise_construct,
|
||||
_VSTD::forward_as_tuple(__x.first),
|
||||
_VSTD::forward_as_tuple(__x.second));
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
|
||||
construct(__p, piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void destroy(_Tp* __p)
|
||||
{
|
||||
typedef __outermost<outer_allocator_type> _OM;
|
||||
allocator_traits<typename _OM::type>::
|
||||
destroy(_OM()(outer_allocator()), __p);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT
|
||||
{return base::select_on_container_copy_construction();}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
template <class _OuterA2,
|
||||
class = typename enable_if<
|
||||
is_constructible<outer_allocator_type, _OuterA2>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_allocator_adaptor(_OuterA2&& __o,
|
||||
const inner_allocator_type& __i) _NOEXCEPT
|
||||
: base(_VSTD::forward<_OuterA2>(__o), __i) {}
|
||||
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args)
|
||||
{
|
||||
typedef __outermost<outer_allocator_type> _OM;
|
||||
allocator_traits<typename _OM::type>::construct
|
||||
(
|
||||
_OM()(outer_allocator()),
|
||||
__p,
|
||||
_VSTD::forward<_Args>(__args)...
|
||||
);
|
||||
}
|
||||
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args)
|
||||
{
|
||||
typedef __outermost<outer_allocator_type> _OM;
|
||||
allocator_traits<typename _OM::type>::construct
|
||||
(
|
||||
_OM()(outer_allocator()),
|
||||
__p, allocator_arg, inner_allocator(),
|
||||
_VSTD::forward<_Args>(__args)...
|
||||
);
|
||||
}
|
||||
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args)
|
||||
{
|
||||
typedef __outermost<outer_allocator_type> _OM;
|
||||
allocator_traits<typename _OM::type>::construct
|
||||
(
|
||||
_OM()(outer_allocator()),
|
||||
__p,
|
||||
_VSTD::forward<_Args>(__args)...,
|
||||
inner_allocator()
|
||||
);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<_Args&&...>
|
||||
__transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
|
||||
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;
|
||||
return _Tup(allocator_arg, inner_allocator(),
|
||||
_VSTD::get<_Idx>(_VSTD::move(__t))...);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<_Args&&..., inner_allocator_type&>
|
||||
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
using _Tup = tuple<_Args&&..., inner_allocator_type&>;
|
||||
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator());
|
||||
}
|
||||
|
||||
template <class...> friend class __scoped_allocator_storage;
|
||||
};
|
||||
|
||||
template <class _OuterA1, class _OuterA2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const scoped_allocator_adaptor<_OuterA1>& __a,
|
||||
const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT
|
||||
{
|
||||
return __a.outer_allocator() == __b.outer_allocator();
|
||||
}
|
||||
|
||||
template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,
|
||||
const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT
|
||||
{
|
||||
return __a.outer_allocator() == __b.outer_allocator() &&
|
||||
__a.inner_allocator() == __b.inner_allocator();
|
||||
}
|
||||
|
||||
template <class _OuterA1, class _OuterA2, class... _InnerAllocs>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
|
||||
const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT
|
||||
{
|
||||
return !(__a == __b);
|
||||
}
|
||||
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_SCOPED_ALLOCATOR
|
400
third_party/libcxx/strstream
vendored
Normal file
400
third_party/libcxx/strstream
vendored
Normal file
|
@ -0,0 +1,400 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===--------------------------- strstream --------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_STRSTREAM
|
||||
#define _LIBCPP_STRSTREAM
|
||||
|
||||
/*
|
||||
strstream synopsis
|
||||
|
||||
class strstreambuf
|
||||
: public basic_streambuf<char>
|
||||
{
|
||||
public:
|
||||
explicit strstreambuf(streamsize alsize_arg = 0);
|
||||
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
|
||||
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
|
||||
strstreambuf(const char* gnext_arg, streamsize n);
|
||||
|
||||
strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
|
||||
strstreambuf(const signed char* gnext_arg, streamsize n);
|
||||
strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
|
||||
strstreambuf(const unsigned char* gnext_arg, streamsize n);
|
||||
|
||||
strstreambuf(strstreambuf&& rhs);
|
||||
strstreambuf& operator=(strstreambuf&& rhs);
|
||||
|
||||
virtual ~strstreambuf();
|
||||
|
||||
void swap(strstreambuf& rhs);
|
||||
|
||||
void freeze(bool freezefl = true);
|
||||
char* str();
|
||||
int pcount() const;
|
||||
|
||||
protected:
|
||||
virtual int_type overflow (int_type c = EOF);
|
||||
virtual int_type pbackfail(int_type c = EOF);
|
||||
virtual int_type underflow();
|
||||
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
virtual pos_type seekpos(pos_type sp,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
virtual streambuf* setbuf(char* s, streamsize n);
|
||||
|
||||
private:
|
||||
typedef T1 strstate; // exposition only
|
||||
static const strstate allocated; // exposition only
|
||||
static const strstate constant; // exposition only
|
||||
static const strstate dynamic; // exposition only
|
||||
static const strstate frozen; // exposition only
|
||||
strstate strmode; // exposition only
|
||||
streamsize alsize; // exposition only
|
||||
void* (*palloc)(size_t); // exposition only
|
||||
void (*pfree)(void*); // exposition only
|
||||
};
|
||||
|
||||
class istrstream
|
||||
: public basic_istream<char>
|
||||
{
|
||||
public:
|
||||
explicit istrstream(const char* s);
|
||||
explicit istrstream(char* s);
|
||||
istrstream(const char* s, streamsize n);
|
||||
istrstream(char* s, streamsize n);
|
||||
|
||||
virtual ~istrstream();
|
||||
|
||||
strstreambuf* rdbuf() const;
|
||||
char *str();
|
||||
|
||||
private:
|
||||
strstreambuf sb; // exposition only
|
||||
};
|
||||
|
||||
class ostrstream
|
||||
: public basic_ostream<char>
|
||||
{
|
||||
public:
|
||||
ostrstream();
|
||||
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
|
||||
|
||||
virtual ~ostrstream();
|
||||
|
||||
strstreambuf* rdbuf() const;
|
||||
void freeze(bool freezefl = true);
|
||||
char* str();
|
||||
int pcount() const;
|
||||
|
||||
private:
|
||||
strstreambuf sb; // exposition only
|
||||
};
|
||||
|
||||
class strstream
|
||||
: public basic_iostream<char>
|
||||
{
|
||||
public:
|
||||
// Types
|
||||
typedef char char_type;
|
||||
typedef char_traits<char>::int_type int_type;
|
||||
typedef char_traits<char>::pos_type pos_type;
|
||||
typedef char_traits<char>::off_type off_type;
|
||||
|
||||
// constructors/destructor
|
||||
strstream();
|
||||
strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
|
||||
|
||||
virtual ~strstream();
|
||||
|
||||
// Members:
|
||||
strstreambuf* rdbuf() const;
|
||||
void freeze(bool freezefl = true);
|
||||
int pcount() const;
|
||||
char* str();
|
||||
|
||||
private:
|
||||
strstreambuf sb; // exposition only
|
||||
};
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/ostream"
|
||||
#include "third_party/libcxx/istream"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TYPE_VIS strstreambuf
|
||||
: public streambuf
|
||||
{
|
||||
public:
|
||||
explicit strstreambuf(streamsize __alsize = 0);
|
||||
strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
|
||||
strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
|
||||
strstreambuf(const char* __gnext, streamsize __n);
|
||||
|
||||
strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
|
||||
strstreambuf(const signed char* __gnext, streamsize __n);
|
||||
strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
|
||||
strstreambuf(const unsigned char* __gnext, streamsize __n);
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf(strstreambuf&& __rhs);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf& operator=(strstreambuf&& __rhs);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
virtual ~strstreambuf();
|
||||
|
||||
void swap(strstreambuf& __rhs);
|
||||
|
||||
void freeze(bool __freezefl = true);
|
||||
char* str();
|
||||
int pcount() const;
|
||||
|
||||
protected:
|
||||
virtual int_type overflow (int_type __c = EOF);
|
||||
virtual int_type pbackfail(int_type __c = EOF);
|
||||
virtual int_type underflow();
|
||||
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
|
||||
ios_base::openmode __which = ios_base::in | ios_base::out);
|
||||
virtual pos_type seekpos(pos_type __sp,
|
||||
ios_base::openmode __which = ios_base::in | ios_base::out);
|
||||
|
||||
private:
|
||||
typedef unsigned __mode_type;
|
||||
static const __mode_type __allocated = 0x01;
|
||||
static const __mode_type __constant = 0x02;
|
||||
static const __mode_type __dynamic = 0x04;
|
||||
static const __mode_type __frozen = 0x08;
|
||||
static const streamsize __default_alsize = 4096;
|
||||
|
||||
__mode_type __strmode_;
|
||||
streamsize __alsize_;
|
||||
void* (*__palloc_)(size_t);
|
||||
void (*__pfree_)(void*);
|
||||
|
||||
void __init(char* __gnext, streamsize __n, char* __pbeg);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf::strstreambuf(strstreambuf&& __rhs)
|
||||
: streambuf(__rhs),
|
||||
__strmode_(__rhs.__strmode_),
|
||||
__alsize_(__rhs.__alsize_),
|
||||
__palloc_(__rhs.__palloc_),
|
||||
__pfree_(__rhs.__pfree_)
|
||||
{
|
||||
__rhs.setg(nullptr, nullptr, nullptr);
|
||||
__rhs.setp(nullptr, nullptr);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf&
|
||||
strstreambuf::operator=(strstreambuf&& __rhs)
|
||||
{
|
||||
if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
|
||||
{
|
||||
if (__pfree_)
|
||||
__pfree_(eback());
|
||||
else
|
||||
delete [] eback();
|
||||
}
|
||||
streambuf::operator=(__rhs);
|
||||
__strmode_ = __rhs.__strmode_;
|
||||
__alsize_ = __rhs.__alsize_;
|
||||
__palloc_ = __rhs.__palloc_;
|
||||
__pfree_ = __rhs.__pfree_;
|
||||
__rhs.setg(nullptr, nullptr, nullptr);
|
||||
__rhs.setp(nullptr, nullptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
class _LIBCPP_TYPE_VIS istrstream
|
||||
: public istream
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit istrstream(const char* __s)
|
||||
: istream(&__sb_), __sb_(__s, 0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit istrstream(char* __s)
|
||||
: istream(&__sb_), __sb_(__s, 0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
istrstream(const char* __s, streamsize __n)
|
||||
: istream(&__sb_), __sb_(__s, __n) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
istrstream(char* __s, streamsize __n)
|
||||
: istream(&__sb_), __sb_(__s, __n) {}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
istrstream(istrstream&& __rhs)
|
||||
: istream(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
istream::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
istrstream& operator=(istrstream&& __rhs)
|
||||
{
|
||||
istream::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
virtual ~istrstream();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(istrstream& __rhs)
|
||||
{
|
||||
istream::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char *str() {return __sb_.str();}
|
||||
|
||||
private:
|
||||
strstreambuf __sb_;
|
||||
};
|
||||
|
||||
class _LIBCPP_TYPE_VIS ostrstream
|
||||
: public ostream
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
ostrstream()
|
||||
: ostream(&__sb_) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
|
||||
: ostream(&__sb_),
|
||||
__sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
|
||||
{}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
ostrstream(ostrstream&& __rhs)
|
||||
: ostream(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
ostream::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
ostrstream& operator=(ostrstream&& __rhs)
|
||||
{
|
||||
ostream::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
virtual ~ostrstream();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(ostrstream& __rhs)
|
||||
{
|
||||
ostream::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char* str() {return __sb_.str();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int pcount() const {return __sb_.pcount();}
|
||||
|
||||
private:
|
||||
strstreambuf __sb_; // exposition only
|
||||
};
|
||||
|
||||
class _LIBCPP_TYPE_VIS strstream
|
||||
: public iostream
|
||||
{
|
||||
public:
|
||||
// Types
|
||||
typedef char char_type;
|
||||
typedef char_traits<char>::int_type int_type;
|
||||
typedef char_traits<char>::pos_type pos_type;
|
||||
typedef char_traits<char>::off_type off_type;
|
||||
|
||||
// constructors/destructor
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstream()
|
||||
: iostream(&__sb_) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
|
||||
: iostream(&__sb_),
|
||||
__sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
|
||||
{}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstream(strstream&& __rhs)
|
||||
: iostream(_VSTD::move(__rhs)),
|
||||
__sb_(_VSTD::move(__rhs.__sb_))
|
||||
{
|
||||
iostream::set_rdbuf(&__sb_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstream& operator=(strstream&& __rhs)
|
||||
{
|
||||
iostream::operator=(_VSTD::move(__rhs));
|
||||
__sb_ = _VSTD::move(__rhs.__sb_);
|
||||
return *this;
|
||||
}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
virtual ~strstream();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(strstream& __rhs)
|
||||
{
|
||||
iostream::swap(__rhs);
|
||||
__sb_.swap(__rhs.__sb_);
|
||||
}
|
||||
|
||||
// Members:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
int pcount() const {return __sb_.pcount();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
char* str() {return __sb_.str();}
|
||||
|
||||
private:
|
||||
strstreambuf __sb_; // exposition only
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STRSTREAM
|
336
third_party/libcxx/strstream.cc
vendored
Normal file
336
third_party/libcxx/strstream.cc
vendored
Normal file
|
@ -0,0 +1,336 @@
|
|||
// clang-format off
|
||||
//===------------------------ strstream.cpp -------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/strstream"
|
||||
#include "third_party/libcxx/algorithm"
|
||||
#include "third_party/libcxx/climits"
|
||||
#include "third_party/libcxx/cstring"
|
||||
#include "third_party/libcxx/cstdlib"
|
||||
#include "third_party/libcxx/__debug"
|
||||
#include "third_party/libcxx/__undef_macros"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
strstreambuf::strstreambuf(streamsize __alsize)
|
||||
: __strmode_(__dynamic),
|
||||
__alsize_(__alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*))
|
||||
: __strmode_(__dynamic),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(__palloc),
|
||||
__pfree_(__pfree)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
strstreambuf::__init(char* __gnext, streamsize __n, char* __pbeg)
|
||||
{
|
||||
if (__n == 0)
|
||||
__n = static_cast<streamsize>(strlen(__gnext));
|
||||
else if (__n < 0)
|
||||
__n = INT_MAX;
|
||||
if (__pbeg == nullptr)
|
||||
setg(__gnext, __gnext, __gnext + __n);
|
||||
else
|
||||
{
|
||||
setg(__gnext, __gnext, __pbeg);
|
||||
setp(__pbeg, __pbeg + __n);
|
||||
}
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(char* __gnext, streamsize __n, char* __pbeg)
|
||||
: __strmode_(),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init(__gnext, __n, __pbeg);
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(const char* __gnext, streamsize __n)
|
||||
: __strmode_(__constant),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init(const_cast<char *>(__gnext), __n, nullptr);
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg)
|
||||
: __strmode_(),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n)
|
||||
: __strmode_(__constant),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg)
|
||||
: __strmode_(),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n)
|
||||
: __strmode_(__constant),
|
||||
__alsize_(__default_alsize),
|
||||
__palloc_(nullptr),
|
||||
__pfree_(nullptr)
|
||||
{
|
||||
__init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
|
||||
}
|
||||
|
||||
strstreambuf::~strstreambuf()
|
||||
{
|
||||
if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
|
||||
{
|
||||
if (__pfree_)
|
||||
__pfree_(eback());
|
||||
else
|
||||
delete [] eback();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
strstreambuf::swap(strstreambuf& __rhs)
|
||||
{
|
||||
streambuf::swap(__rhs);
|
||||
_VSTD::swap(__strmode_, __rhs.__strmode_);
|
||||
_VSTD::swap(__alsize_, __rhs.__alsize_);
|
||||
_VSTD::swap(__palloc_, __rhs.__palloc_);
|
||||
_VSTD::swap(__pfree_, __rhs.__pfree_);
|
||||
}
|
||||
|
||||
void
|
||||
strstreambuf::freeze(bool __freezefl)
|
||||
{
|
||||
if (__strmode_ & __dynamic)
|
||||
{
|
||||
if (__freezefl)
|
||||
__strmode_ |= __frozen;
|
||||
else
|
||||
__strmode_ &= ~__frozen;
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
strstreambuf::str()
|
||||
{
|
||||
if (__strmode_ & __dynamic)
|
||||
__strmode_ |= __frozen;
|
||||
return eback();
|
||||
}
|
||||
|
||||
int
|
||||
strstreambuf::pcount() const
|
||||
{
|
||||
return static_cast<int>(pptr() - pbase());
|
||||
}
|
||||
|
||||
strstreambuf::int_type
|
||||
strstreambuf::overflow(int_type __c)
|
||||
{
|
||||
if (__c == EOF)
|
||||
return int_type(0);
|
||||
if (pptr() == epptr())
|
||||
{
|
||||
if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0)
|
||||
return int_type(EOF);
|
||||
size_t old_size = static_cast<size_t> ((epptr() ? epptr() : egptr()) - eback());
|
||||
size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2*old_size);
|
||||
if (new_size == 0)
|
||||
new_size = __default_alsize;
|
||||
char* buf = nullptr;
|
||||
if (__palloc_)
|
||||
buf = static_cast<char*>(__palloc_(new_size));
|
||||
else
|
||||
buf = new char[new_size];
|
||||
if (buf == nullptr)
|
||||
return int_type(EOF);
|
||||
if (old_size != 0) {
|
||||
_LIBCPP_ASSERT(eback(), "overflow copying from NULL");
|
||||
memcpy(buf, eback(), static_cast<size_t>(old_size));
|
||||
}
|
||||
ptrdiff_t ninp = gptr() - eback();
|
||||
ptrdiff_t einp = egptr() - eback();
|
||||
ptrdiff_t nout = pptr() - pbase();
|
||||
if (__strmode_ & __allocated)
|
||||
{
|
||||
if (__pfree_)
|
||||
__pfree_(eback());
|
||||
else
|
||||
delete [] eback();
|
||||
}
|
||||
setg(buf, buf + ninp, buf + einp);
|
||||
setp(buf + einp, buf + new_size);
|
||||
__pbump(nout);
|
||||
__strmode_ |= __allocated;
|
||||
}
|
||||
*pptr() = static_cast<char>(__c);
|
||||
pbump(1);
|
||||
return int_type(static_cast<unsigned char>(__c));
|
||||
}
|
||||
|
||||
strstreambuf::int_type
|
||||
strstreambuf::pbackfail(int_type __c)
|
||||
{
|
||||
if (eback() == gptr())
|
||||
return EOF;
|
||||
if (__c == EOF)
|
||||
{
|
||||
gbump(-1);
|
||||
return int_type(0);
|
||||
}
|
||||
if (__strmode_ & __constant)
|
||||
{
|
||||
if (gptr()[-1] == static_cast<char>(__c))
|
||||
{
|
||||
gbump(-1);
|
||||
return __c;
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
gbump(-1);
|
||||
*gptr() = static_cast<char>(__c);
|
||||
return __c;
|
||||
}
|
||||
|
||||
strstreambuf::int_type
|
||||
strstreambuf::underflow()
|
||||
{
|
||||
if (gptr() == egptr())
|
||||
{
|
||||
if (egptr() >= pptr())
|
||||
return EOF;
|
||||
setg(eback(), gptr(), pptr());
|
||||
}
|
||||
return int_type(static_cast<unsigned char>(*gptr()));
|
||||
}
|
||||
|
||||
strstreambuf::pos_type
|
||||
strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which)
|
||||
{
|
||||
off_type __p(-1);
|
||||
bool pos_in = (__which & ios::in) != 0;
|
||||
bool pos_out = (__which & ios::out) != 0;
|
||||
bool legal = false;
|
||||
switch (__way)
|
||||
{
|
||||
case ios::beg:
|
||||
case ios::end:
|
||||
if (pos_in || pos_out)
|
||||
legal = true;
|
||||
break;
|
||||
case ios::cur:
|
||||
if (pos_in != pos_out)
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
if (pos_in && gptr() == nullptr)
|
||||
legal = false;
|
||||
if (pos_out && pptr() == nullptr)
|
||||
legal = false;
|
||||
if (legal)
|
||||
{
|
||||
off_type newoff;
|
||||
char* seekhigh = epptr() ? epptr() : egptr();
|
||||
switch (__way)
|
||||
{
|
||||
case ios::beg:
|
||||
newoff = 0;
|
||||
break;
|
||||
case ios::cur:
|
||||
newoff = (pos_in ? gptr() : pptr()) - eback();
|
||||
break;
|
||||
case ios::end:
|
||||
newoff = seekhigh - eback();
|
||||
break;
|
||||
default:
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
newoff += __off;
|
||||
if (0 <= newoff && newoff <= seekhigh - eback())
|
||||
{
|
||||
char* newpos = eback() + newoff;
|
||||
if (pos_in)
|
||||
setg(eback(), newpos, _VSTD::max(newpos, egptr()));
|
||||
if (pos_out)
|
||||
{
|
||||
// min(pbase, newpos), newpos, epptr()
|
||||
__off = epptr() - newpos;
|
||||
setp(min(pbase(), newpos), epptr());
|
||||
__pbump((epptr() - pbase()) - __off);
|
||||
}
|
||||
__p = newoff;
|
||||
}
|
||||
}
|
||||
return pos_type(__p);
|
||||
}
|
||||
|
||||
strstreambuf::pos_type
|
||||
strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which)
|
||||
{
|
||||
off_type __p(-1);
|
||||
bool pos_in = (__which & ios::in) != 0;
|
||||
bool pos_out = (__which & ios::out) != 0;
|
||||
if (pos_in || pos_out)
|
||||
{
|
||||
if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr)))
|
||||
{
|
||||
off_type newoff = __sp;
|
||||
char* seekhigh = epptr() ? epptr() : egptr();
|
||||
if (0 <= newoff && newoff <= seekhigh - eback())
|
||||
{
|
||||
char* newpos = eback() + newoff;
|
||||
if (pos_in)
|
||||
setg(eback(), newpos, _VSTD::max(newpos, egptr()));
|
||||
if (pos_out)
|
||||
{
|
||||
// min(pbase, newpos), newpos, epptr()
|
||||
off_type temp = epptr() - newpos;
|
||||
setp(min(pbase(), newpos), epptr());
|
||||
__pbump((epptr() - pbase()) - temp);
|
||||
}
|
||||
__p = newoff;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pos_type(__p);
|
||||
}
|
||||
|
||||
istrstream::~istrstream()
|
||||
{
|
||||
}
|
||||
|
||||
ostrstream::~ostrstream()
|
||||
{
|
||||
}
|
||||
|
||||
strstream::~strstream()
|
||||
{
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
103
third_party/libcxx/typeindex
vendored
Normal file
103
third_party/libcxx/typeindex
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
// -*- C++ -*-
|
||||
// clang-format off
|
||||
//===-------------------------- typeindex ---------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_TYPEINDEX
|
||||
#define _LIBCPP_TYPEINDEX
|
||||
|
||||
/*
|
||||
|
||||
typeindex synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
class type_index
|
||||
{
|
||||
public:
|
||||
type_index(const type_info& rhs) noexcept;
|
||||
|
||||
bool operator==(const type_index& rhs) const noexcept;
|
||||
bool operator!=(const type_index& rhs) const noexcept;
|
||||
bool operator< (const type_index& rhs) const noexcept;
|
||||
bool operator<=(const type_index& rhs) const noexcept;
|
||||
bool operator> (const type_index& rhs) const noexcept;
|
||||
bool operator>=(const type_index& rhs) const noexcept;
|
||||
|
||||
size_t hash_code() const noexcept;
|
||||
const char* name() const noexcept;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<type_index>
|
||||
: public unary_function<type_index, size_t>
|
||||
{
|
||||
size_t operator()(type_index index) const noexcept;
|
||||
};
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/typeinfo"
|
||||
#include "third_party/libcxx/__functional_base"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TEMPLATE_VIS type_index
|
||||
{
|
||||
const type_info* __t_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const type_index& __y) const _NOEXCEPT
|
||||
{return *__t_ == *__y.__t_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const type_index& __y) const _NOEXCEPT
|
||||
{return *__t_ != *__y.__t_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator< (const type_index& __y) const _NOEXCEPT
|
||||
{return __t_->before(*__y.__t_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(const type_index& __y) const _NOEXCEPT
|
||||
{return !__y.__t_->before(*__t_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator> (const type_index& __y) const _NOEXCEPT
|
||||
{return __y.__t_->before(*__t_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(const type_index& __y) const _NOEXCEPT
|
||||
{return !__t_->before(*__y.__t_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char* name() const _NOEXCEPT {return __t_->name();}
|
||||
};
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS hash<type_index>
|
||||
: public unary_function<type_index, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(type_index __index) const _NOEXCEPT
|
||||
{return __index.hash_code();}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_TYPEINDEX
|
4943
third_party/libcxx/valarray
vendored
Normal file
4943
third_party/libcxx/valarray
vendored
Normal file
File diff suppressed because it is too large
Load diff
58
third_party/libcxx/valarray.cc
vendored
Normal file
58
third_party/libcxx/valarray.cc
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
// clang-format off
|
||||
//===------------------------ valarray.cpp --------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "third_party/libcxx/valarray"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
|
||||
#if _LIBCPP_ABI_VERSION == 1
|
||||
template _LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t);
|
||||
template _LIBCPP_FUNC_VIS valarray<size_t>::~valarray();
|
||||
#endif
|
||||
|
||||
template void valarray<size_t>::resize(size_t, size_t);
|
||||
|
||||
void
|
||||
gslice::__init(size_t __start)
|
||||
{
|
||||
valarray<size_t> __indices(__size_.size());
|
||||
size_t __k = __size_.size() != 0;
|
||||
for (size_t __i = 0; __i < __size_.size(); ++__i)
|
||||
__k *= __size_[__i];
|
||||
__1d_.resize(__k);
|
||||
if (__1d_.size())
|
||||
{
|
||||
__k = 0;
|
||||
__1d_[__k] = __start;
|
||||
while (true)
|
||||
{
|
||||
size_t __i = __indices.size() - 1;
|
||||
while (true)
|
||||
{
|
||||
if (++__indices[__i] < __size_[__i])
|
||||
{
|
||||
++__k;
|
||||
__1d_[__k] = __1d_[__k-1] + __stride_[__i];
|
||||
for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
|
||||
__1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__i == 0)
|
||||
return;
|
||||
__indices[__i--] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
Loading…
Add table
Add a link
Reference in a new issue