diff options
Diffstat (limited to 'lib/libcxx/include/experimental')
28 files changed, 7816 insertions, 0 deletions
diff --git a/lib/libcxx/include/experimental/__config b/lib/libcxx/include/experimental/__config new file mode 100644 index 00000000000..9a7bbe85d8d --- /dev/null +++ b/lib/libcxx/include/experimental/__config @@ -0,0 +1,50 @@ +// -*- C++ -*- +//===--------------------------- __config ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_CONFIG +#define _LIBCPP_EXPERIMENTAL_CONFIG + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } } +#define _VSTD_EXPERIMENTAL std::experimental + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { +#define _LIBCPP_END_NAMESPACE_LFTS } } } +#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1 + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { +#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } } +#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2 + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr { +#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS } +#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr + +#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \ + namespace chrono { namespace experimental { inline namespace fundamentals_v1 { +#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } } + +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem { \ + inline namespace v1 { + +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ + } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL + + +#define _VSTD_FS ::std::experimental::filesystem::v1 + +#endif diff --git a/lib/libcxx/include/experimental/__memory b/lib/libcxx/include/experimental/__memory new file mode 100644 index 00000000000..229fea605bf --- /dev/null +++ b/lib/libcxx/include/experimental/__memory @@ -0,0 +1,90 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL___MEMORY +#define _LIBCPP_EXPERIMENTAL___MEMORY + +#include <experimental/__config> +#include <experimental/utility> // for erased_type +#include <__functional_base> +#include <type_traits> + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +template < + class _Tp, class _Alloc + , bool = uses_allocator<_Tp, _Alloc>::value + , bool = __has_allocator_type<_Tp>::value + > +struct __lfts_uses_allocator : public false_type {}; + +template <class _Tp, class _Alloc> +struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {}; + +template <class _Tp, class _Alloc, bool HasAlloc> +struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {}; + +template <class _Tp, class _Alloc> +struct __lfts_uses_allocator<_Tp, _Alloc, false, true> + : public integral_constant<bool + , is_convertible<_Alloc, typename _Tp::allocator_type>::value + || is_same<erased_type, typename _Tp::allocator_type>::value + > +{}; + +template <bool _UsesAlloc, class _Tp, class _Alloc, class ..._Args> +struct __lfts_uses_alloc_ctor_imp +{ + static const int value = 0; +}; + +template <class _Tp, class _Alloc, class ..._Args> +struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...> +{ + static const bool __ic_first + = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; + + static const bool __ic_second = + conditional< + __ic_first, + false_type, + is_constructible<_Tp, _Args..., _Alloc> + >::type::value; + + static_assert(__ic_first || __ic_second, + "Request for uses allocator construction is ill-formed"); + + static const int value = __ic_first ? 1 : 2; +}; + +template <class _Tp, class _Alloc, class ..._Args> +struct __lfts_uses_alloc_ctor + : integral_constant<int, + __lfts_uses_alloc_ctor_imp< + __lfts_uses_allocator<_Tp, _Alloc>::value + , _Tp, _Alloc, _Args... + >::value + > +{}; + +template <class _Tp, class _Alloc, class ..._Args> +inline _LIBCPP_INLINE_VISIBILITY +void __lfts_user_alloc_construct( + _Tp * __store, const _Alloc & __a, _Args &&... __args) +{ + _VSTD::__user_alloc_construct_impl( + typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type() + , __store, __a, _VSTD::forward<_Args>(__args)... + ); +} + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL___MEMORY */ diff --git a/lib/libcxx/include/experimental/algorithm b/lib/libcxx/include/experimental/algorithm new file mode 100644 index 00000000000..3902111c54e --- /dev/null +++ b/lib/libcxx/include/experimental/algorithm @@ -0,0 +1,120 @@ +// -*- C++ -*- +//===-------------------------- algorithm ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ALGORITHM +#define _LIBCPP_EXPERIMENTAL_ALGORITHM + +/* + experimental/algorithm synopsis + +#include <algorithm> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + +template <class ForwardIterator, class Searcher> +ForwardIterator search(ForwardIterator first, ForwardIterator last, + const Searcher &searcher); +template <class PopulationIterator, class SampleIterator, class Distance, + class UniformRandomNumberGenerator> +SampleIterator sample(PopulationIterator first, PopulationIterator last, + SampleIterator out, Distance n, + UniformRandomNumberGenerator &&g); + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> +#include <algorithm> +#include <type_traits> + +#include <__undef_min_max> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + + +template <class _ForwardIterator, class _Searcher> +_LIBCPP_INLINE_VISIBILITY +_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) +{ return __s(__f, __l).first; } + + +template <class _PopulationIterator, class _SampleIterator, class _Distance, + class _UniformRandomNumberGenerator> +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __out, + _Distance __n, + _UniformRandomNumberGenerator &&__g, + input_iterator_tag) { + + _Distance __k = 0; + for (; __first != __last && __k < __n; ++__first, (void)++__k) + __out[__k] = *__first; + _Distance __sz = __k; + for (; __first != __last; ++__first, (void)++__k) { + _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g); + if (__r < __sz) + __out[__r] = *__first; + } + return __out + _VSTD::min(__n, __k); +} + +template <class _PopulationIterator, class _SampleIterator, class _Distance, + class _UniformRandomNumberGenerator> +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __out, + _Distance __n, + _UniformRandomNumberGenerator &&__g, + forward_iterator_tag) { + _Distance __unsampled_sz = _VSTD::distance(__first, __last); + for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) { + _Distance __r = + _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g); + if (__r < __n) { + *__out++ = *__first; + --__n; + } + } + return __out; +} + +template <class _PopulationIterator, class _SampleIterator, class _Distance, + class _UniformRandomNumberGenerator> +_LIBCPP_INLINE_VISIBILITY +_SampleIterator sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __out, + _Distance __n, _UniformRandomNumberGenerator &&__g) { + typedef typename iterator_traits<_PopulationIterator>::iterator_category + _PopCategory; + typedef typename iterator_traits<_PopulationIterator>::difference_type + _Difference; + typedef typename common_type<_Distance, _Difference>::type _CommonType; + _LIBCPP_ASSERT(__n >= 0, "N must be a positive number."); + return _VSTD_LFTS::__sample( + __first, __last, __out, _CommonType(__n), + _VSTD::forward<_UniformRandomNumberGenerator>(__g), + _PopCategory()); +} + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */ diff --git a/lib/libcxx/include/experimental/any b/lib/libcxx/include/experimental/any new file mode 100644 index 00000000000..4c732496c52 --- /dev/null +++ b/lib/libcxx/include/experimental/any @@ -0,0 +1,592 @@ +// -*- C++ -*- +//===------------------------------ any -----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ANY +#define _LIBCPP_EXPERIMENTAL_ANY + +/* + experimental/any synopsis + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + class bad_any_cast : public bad_cast + { + public: + virtual const char* what() const noexcept; + }; + + class any + { + public: + + // 6.3.1 any construct/destruct + any() noexcept; + + any(const any& other); + any(any&& other) noexcept; + + template <class ValueType> + any(ValueType&& value); + + ~any(); + + // 6.3.2 any assignments + any& operator=(const any& rhs); + any& operator=(any&& rhs) noexcept; + + template <class ValueType> + any& operator=(ValueType&& rhs); + + // 6.3.3 any modifiers + void clear() noexcept; + void swap(any& rhs) noexcept; + + // 6.3.4 any observers + bool empty() const noexcept; + const type_info& type() const noexcept; + }; + + // 6.4 Non-member functions + void swap(any& x, any& y) noexcept; + + template<class ValueType> + ValueType any_cast(const any& operand); + template<class ValueType> + ValueType any_cast(any& operand); + template<class ValueType> + ValueType any_cast(any&& operand); + + template<class ValueType> + const ValueType* any_cast(const any* operand) noexcept; + template<class ValueType> + ValueType* any_cast(any* operand) noexcept; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> +#include <memory> +#include <new> +#include <typeinfo> +#include <type_traits> +#include <cstdlib> +#include <cassert> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast +{ +public: + virtual const char* what() const _NOEXCEPT; +}; + +#if _LIBCPP_STD_VER > 11 // C++ > 11 + +_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY +inline void __throw_bad_any_cast() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_any_cast(); +#else + assert(!"bad_any_cast"); +#endif +} + +// Forward declarations +class any; + +template <class _ValueType> +typename add_pointer<typename add_const<_ValueType>::type>::type +_LIBCPP_INLINE_VISIBILITY +any_cast(any const *) _NOEXCEPT; + +template <class _ValueType> +typename add_pointer<_ValueType>::type +_LIBCPP_INLINE_VISIBILITY +any_cast(any *) _NOEXCEPT; + +namespace __any_imp +{ + typedef typename aligned_storage<3*sizeof(void*), alignment_of<void*>::value>::type + _Buffer; + + template <class _Tp> + struct _IsSmallObject + : public integral_constant<bool + , sizeof(_Tp) <= sizeof(_Buffer) + && alignment_of<_Buffer>::value + % alignment_of<_Tp>::value == 0 + && is_nothrow_move_constructible<_Tp>::value + > + {}; + + enum class _Action + { + _Destroy, + _Copy, + _Move, + _Get, + _TypeInfo + }; + + template <class _Tp> + struct _SmallHandler; + + template <class _Tp> + struct _LargeHandler; + + template <class _Tp> + using _Handler = typename conditional<_IsSmallObject<_Tp>::value + , _SmallHandler<_Tp> + , _LargeHandler<_Tp> + >::type; + template <class _ValueType> + using _EnableIfNotAny = typename + enable_if< + !is_same<typename decay<_ValueType>::type, any>::value + >::type; + +} // namespace __any_imp + +class any +{ +public: + // 6.3.1 any construct/destruct + _LIBCPP_INLINE_VISIBILITY + any() _NOEXCEPT : __h(nullptr) {} + + _LIBCPP_INLINE_VISIBILITY + any(any const & __other) : __h(nullptr) + { + if (__other.__h) __other.__call(_Action::_Copy, this); + } + + _LIBCPP_INLINE_VISIBILITY + any(any && __other) _NOEXCEPT : __h(nullptr) + { + if (__other.__h) __other.__call(_Action::_Move, this); + } + + template < + class _ValueType + , class = __any_imp::_EnableIfNotAny<_ValueType> + > + _LIBCPP_INLINE_VISIBILITY + any(_ValueType && __value); + + _LIBCPP_INLINE_VISIBILITY + ~any() + { + this->clear(); + } + + // 6.3.2 any assignments + _LIBCPP_INLINE_VISIBILITY + any & operator=(any const & __rhs) + { + any(__rhs).swap(*this); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + any & operator=(any && __rhs) _NOEXCEPT + { + any(_VSTD::move(__rhs)).swap(*this); + return *this; + } + + template < + class _ValueType + , class = __any_imp::_EnableIfNotAny<_ValueType> + > + _LIBCPP_INLINE_VISIBILITY + any & operator=(_ValueType && __rhs); + + // 6.3.3 any modifiers + _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT + { + if (__h) this->__call(_Action::_Destroy); + } + + _LIBCPP_INLINE_VISIBILITY + void swap(any & __rhs) _NOEXCEPT; + + // 6.3.4 any observers + _LIBCPP_INLINE_VISIBILITY + bool empty() const _NOEXCEPT + { + return __h == nullptr; + } + +#if !defined(_LIBCPP_NO_RTTI) + _LIBCPP_INLINE_VISIBILITY + const type_info & type() const _NOEXCEPT + { + if (__h) { + return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo)); + } else { + return typeid(void); + } + } +#endif + +private: + typedef __any_imp::_Action _Action; + + typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *); + + union _Storage + { + void * __ptr; + __any_imp::_Buffer __buf; + }; + + _LIBCPP_ALWAYS_INLINE + void * __call(_Action __a, any * __other = nullptr, + type_info const * __info = nullptr) const + { + return __h(__a, this, __other, __info); + } + + _LIBCPP_ALWAYS_INLINE + void * __call(_Action __a, any * __other = nullptr, + type_info const * __info = nullptr) + { + return __h(__a, this, __other, __info); + } + + template <class> + friend struct __any_imp::_SmallHandler; + template <class> + friend struct __any_imp::_LargeHandler; + + template <class _ValueType> + friend typename add_pointer<typename add_const<_ValueType>::type>::type + any_cast(any const *) _NOEXCEPT; + + template <class _ValueType> + friend typename add_pointer<_ValueType>::type + any_cast(any *) _NOEXCEPT; + + _HandleFuncPtr __h; + _Storage __s; +}; + +namespace __any_imp +{ + + template <class _Tp> + struct _LIBCPP_TYPE_VIS_ONLY _SmallHandler + { + _LIBCPP_INLINE_VISIBILITY + static void* __handle(_Action __act, any const * __this, any * __other, + type_info const * __info) + { + switch (__act) + { + case _Action::_Destroy: + __destroy(const_cast<any &>(*__this)); + return nullptr; + case _Action::_Copy: + __copy(*__this, *__other); + return nullptr; + case _Action::_Move: + __move(const_cast<any &>(*__this), *__other); + return nullptr; + case _Action::_Get: + return __get(const_cast<any &>(*__this), __info); + case _Action::_TypeInfo: + return __type_info(); + } + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + static void __create(any & __dest, _Up && __v) + { + ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v)); + __dest.__h = &_SmallHandler::__handle; + } + + private: + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __destroy(any & __this) + { + _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf)); + __value.~_Tp(); + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __copy(any const & __this, any & __dest) + { + _SmallHandler::__create(__dest, *static_cast<_Tp const *>( + static_cast<void const *>(&__this.__s.__buf))); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __move(any & __this, any & __dest) + { + _SmallHandler::__create(__dest, _VSTD::move( + *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf)))); + __destroy(__this); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __get(any & __this, type_info const * __info) + { +#if !defined(_LIBCPP_NO_RTTI) + if (typeid(_Tp) == *__info) { + return static_cast<void*>(&__this.__s.__buf); + } + return nullptr; +#else + return static_cast<void*>(&__this.__s.__buf); +#endif + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __type_info() + { +#if !defined(_LIBCPP_NO_RTTI) + return const_cast<void*>(static_cast<void const *>(&typeid(_Tp))); +#else + return nullptr; +#endif + } + }; + + template <class _Tp> + struct _LIBCPP_TYPE_VIS_ONLY _LargeHandler + { + _LIBCPP_INLINE_VISIBILITY + static void* __handle(_Action __act, any const * __this, any * __other, + type_info const * __info) + { + switch (__act) + { + case _Action::_Destroy: + __destroy(const_cast<any &>(*__this)); + return nullptr; + case _Action::_Copy: + __copy(*__this, *__other); + return nullptr; + case _Action::_Move: + __move(const_cast<any &>(*__this), *__other); + return nullptr; + case _Action::_Get: + return __get(const_cast<any &>(*__this), __info); + case _Action::_TypeInfo: + return __type_info(); + } + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + static void __create(any & __dest, _Up && __v) + { + typedef allocator<_Tp> _Alloc; + typedef __allocator_destructor<_Alloc> _Dp; + _Alloc __a; + unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v)); + __dest.__s.__ptr = __hold.release(); + __dest.__h = &_LargeHandler::__handle; + } + + private: + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __destroy(any & __this) + { + delete static_cast<_Tp*>(__this.__s.__ptr); + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __copy(any const & __this, any & __dest) + { + _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr)); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __move(any & __this, any & __dest) + { + __dest.__s.__ptr = __this.__s.__ptr; + __dest.__h = &_LargeHandler::__handle; + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __get(any & __this, type_info const * __info) + { +#if !defined(_LIBCPP_NO_RTTI) + if (typeid(_Tp) == *__info) { + return static_cast<void*>(__this.__s.__ptr); + } + return nullptr; +#else + return static_cast<void*>(__this.__s.__ptr); +#endif + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __type_info() + { +#if !defined(_LIBCPP_NO_RTTI) + return const_cast<void*>(static_cast<void const *>(&typeid(_Tp))); +#else + return nullptr; +#endif + } + }; + +} // namespace __any_imp + + +template <class _ValueType, class> +any::any(_ValueType && __v) : __h(nullptr) +{ + typedef typename decay<_ValueType>::type _Tp; + static_assert(is_copy_constructible<_Tp>::value, + "_ValueType must be CopyConstructible."); + typedef __any_imp::_Handler<_Tp> _HandlerType; + _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v)); +} + +template <class _ValueType, class> +any & any::operator=(_ValueType && __v) +{ + typedef typename decay<_ValueType>::type _Tp; + static_assert(is_copy_constructible<_Tp>::value, + "_ValueType must be CopyConstructible."); + any(_VSTD::forward<_ValueType>(__v)).swap(*this); + return *this; +} + +inline +void any::swap(any & __rhs) _NOEXCEPT +{ + if (__h && __rhs.__h) { + any __tmp; + __rhs.__call(_Action::_Move, &__tmp); + this->__call(_Action::_Move, &__rhs); + __tmp.__call(_Action::_Move, this); + } + else if (__h) { + this->__call(_Action::_Move, &__rhs); + } + else if (__rhs.__h) { + __rhs.__call(_Action::_Move, this); + } +} + +// 6.4 Non-member functions + +inline _LIBCPP_INLINE_VISIBILITY +void swap(any & __lhs, any & __rhs) _NOEXCEPT +{ + __lhs.swap(__rhs); +} + +template <class _ValueType> +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any const & __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename add_const<typename remove_reference<_ValueType>::type>::type + _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template <class _ValueType> +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any & __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename remove_reference<_ValueType>::type _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template <class _ValueType> +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any && __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename remove_reference<_ValueType>::type _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template <class _ValueType> +inline +typename add_pointer<typename add_const<_ValueType>::type>::type +any_cast(any const * __any) _NOEXCEPT +{ + static_assert(!is_reference<_ValueType>::value, + "_ValueType may not be a reference."); + return any_cast<_ValueType>(const_cast<any *>(__any)); +} + +template <class _ValueType> +typename add_pointer<_ValueType>::type +any_cast(any * __any) _NOEXCEPT +{ + using __any_imp::_Action; + static_assert(!is_reference<_ValueType>::value, + "_ValueType may not be a reference."); + typedef typename add_pointer<_ValueType>::type _ReturnType; + if (__any && __any->__h) { + + return static_cast<_ReturnType>( + __any->__call(_Action::_Get, nullptr, +#if !defined(_LIBCPP_NO_RTTI) + &typeid(_ValueType) +#else + nullptr +#endif + )); + + } + return nullptr; +} + +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_LFTS + +#endif // _LIBCPP_EXPERIMENTAL_ANY diff --git a/lib/libcxx/include/experimental/chrono b/lib/libcxx/include/experimental/chrono new file mode 100644 index 00000000000..ca9e5f852ea --- /dev/null +++ b/lib/libcxx/include/experimental/chrono @@ -0,0 +1,59 @@ +// -*- C++ -*- +//===------------------------------ chrono ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_CHRONO +#define _LIBCPP_EXPERIMENTAL_CHRONO + +/** + experimental/chrono synopsis + +// C++1y + +#include <chrono> + +namespace std { +namespace chrono { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.12.4, customization traits + template <class Rep> constexpr bool treat_as_floating_point_v + = treat_as_floating_point<Rep>::value; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace chrono +} // namespace std + + */ + +#include <experimental/__config> +#include <chrono> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER > 11 + +_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v + = treat_as_floating_point<_Rep>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +_LIBCPP_END_NAMESPACE_CHRONO_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */ diff --git a/lib/libcxx/include/experimental/deque b/lib/libcxx/include/experimental/deque new file mode 100644 index 00000000000..f8495743c1f --- /dev/null +++ b/lib/libcxx/include/experimental/deque @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- deque ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_DEQUE +#define _LIBCPP_EXPERIMENTAL_DEQUE +/* + experimental/deque synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using deque = std::deque<T,polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <deque> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */ diff --git a/lib/libcxx/include/experimental/dynarray b/lib/libcxx/include/experimental/dynarray new file mode 100644 index 00000000000..4a06908e11b --- /dev/null +++ b/lib/libcxx/include/experimental/dynarray @@ -0,0 +1,321 @@ +// -*- C++ -*- +//===-------------------------- dynarray ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_DYNARRAY +#define _LIBCPP_DYNARRAY + +#include <__config> +#if _LIBCPP_STD_VER > 11 + +/* + dynarray synopsis + +namespace std { namespace experimental { + +template< typename T > +class dynarray +{ + // types: + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef T* pointer; + typedef const T* const_pointer; + typedef implementation-defined iterator; + typedef implementation-defined const_iterator; + typedef reverse_iterator<iterator> reverse_iterator; + typedef reverse_iterator<const_iterator> const_reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +public: + // construct/copy/destroy: + explicit dynarray(size_type c); + dynarray(size_type c, const T& v); + dynarray(const dynarray& d); + dynarray(initializer_list<T>); + + template <class Alloc> + dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc); + template <class Alloc> + dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc); + template <class Alloc> + dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc); + template <class Alloc> + dynarray(allocator_arg_t, const Alloc& a, initializer_list<T>, const Alloc& alloc); + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + iterator begin() noexcept; + const_iterator begin() const noexcept; + const_iterator cbegin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; + const_iterator cend() const noexcept; + + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator crbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crend() const noexcept; + + // capacity: + size_type size() const noexcept; + size_type max_size() const noexcept; + bool empty() const noexcept; + + // element access: + reference operator[](size_type n); + const_reference operator[](size_type n) const; + + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + const_reference at(size_type n) const; + reference at(size_type n); + + // data access: + T* data() noexcept; + const T* data() const noexcept; + + // mutating member functions: + void fill(const T& v); +}; + +}} // std::experimental + +*/ + +#include <__functional_base> +#include <iterator> +#include <stdexcept> +#include <initializer_list> +#include <new> +#include <algorithm> + +#include <__undef___deallocate> + +#if defined(_LIBCPP_NO_EXCEPTIONS) + #include <cassert> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +namespace std { namespace experimental { inline namespace __array_extensions_v1 { + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY dynarray +{ +public: + // types: + typedef dynarray __self; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + +private: + size_t __size_; + value_type * __base_; + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {} + + static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) + { + if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count ) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_array_length(); +#else + assert(!"dynarray::allocation"); +#endif + } + return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count)); + } + + static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept + { + _VSTD::__deallocate (static_cast<void *> (__ptr)); + } + +public: + + _LIBCPP_INLINE_VISIBILITY + explicit dynarray(size_type __c); + _LIBCPP_INLINE_VISIBILITY + dynarray(size_type __c, const value_type& __v); + _LIBCPP_INLINE_VISIBILITY + dynarray(const dynarray& __d); + _LIBCPP_INLINE_VISIBILITY + dynarray(initializer_list<value_type>); + +// We're not implementing these right now. +// Updated with the resolution of LWG issue #2255 +// template <typename _Alloc> +// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c); +// template <typename _Alloc> +// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v); +// template <typename _Alloc> +// dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d); +// template <typename _Alloc> +// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>); + + dynarray& operator=(const dynarray&) = delete; + _LIBCPP_INLINE_VISIBILITY + ~dynarray(); + + // iterators: + inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); } + + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } + + // capacity: + inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; } + + // element access: + inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; } + + inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; } + + inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const; + inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n); + + // data access: + inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; } + inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; } + + // mutating member functions: + inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); } +}; + +template <class _Tp> +inline +dynarray<_Tp>::dynarray(size_type __c) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type; +} + +template <class _Tp> +inline +dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type (__v); +} + +template <class _Tp> +inline +dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray () +{ + size_t sz = __il.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __il.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template <class _Tp> +inline +dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () +{ + size_t sz = __d.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __d.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template <class _Tp> +inline +dynarray<_Tp>::~dynarray() +{ + value_type *__data = data () + __size_; + for ( size_t i = 0; i < __size_; ++i ) + (--__data)->value_type::~value_type(); + __deallocate ( __base_ ); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::reference +dynarray<_Tp>::at(size_type __n) +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::const_reference +dynarray<_Tp>::at(size_type __n) const +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +}}} + + +_LIBCPP_BEGIN_NAMESPACE_STD +template <class _Tp, class _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {}; +_LIBCPP_END_NAMESPACE_STD + +#endif // if _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_DYNARRAY diff --git a/lib/libcxx/include/experimental/filesystem b/lib/libcxx/include/experimental/filesystem new file mode 100644 index 00000000000..7de93fdf8f1 --- /dev/null +++ b/lib/libcxx/include/experimental/filesystem @@ -0,0 +1,2052 @@ +// -*- C++ -*- +//===--------------------------- filesystem -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM +#define _LIBCPP_EXPERIMENTAL_FILESYSTEM +/* + filesystem synopsis + + namespace std { namespace experimental { namespace filesystem { inline namespace v1 { + + class path; + + void swap(path& lhs, path& rhs) _NOEXCEPT; + size_t hash_value(const path& p) _NOEXCEPT; + + bool operator==(const path& lhs, const path& rhs) _NOEXCEPT; + bool operator!=(const path& lhs, const path& rhs) _NOEXCEPT; + bool operator< (const path& lhs, const path& rhs) _NOEXCEPT; + bool operator<=(const path& lhs, const path& rhs) _NOEXCEPT; + bool operator> (const path& lhs, const path& rhs) _NOEXCEPT; + bool operator>=(const path& lhs, const path& rhs) _NOEXCEPT; + + path operator/ (const path& lhs, const path& rhs); + + template <class charT, class traits> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, const path& p); + + template <class charT, class traits> + basic_istream<charT, traits>& + operator>>(basic_istream<charT, traits>& is, path& p); + + template <class Source> + path u8path(const Source& source); + template <class InputIterator> + path u8path(InputIterator first, InputIterator last); + + class filesystem_error; + class directory_entry; + + class directory_iterator; + + // enable directory_iterator range-based for statements + directory_iterator begin(directory_iterator iter) noexcept; + directory_iterator end(const directory_iterator&) noexcept; + + class recursive_directory_iterator; + + // enable recursive_directory_iterator range-based for statements + recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; + recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; + + class file_status; + + struct space_info + { + uintmax_t capacity; + uintmax_t free; + uintmax_t available; + }; + + enum class file_type; + enum class perms; + enum class copy_options; + enum class directory_options; + + typedef chrono::time_point<trivial-clock> file_time_type; + + // operational functions + + path absolute(const path& p, const path& base=current_path()); + + path canonical(const path& p, const path& base = current_path()); + path canonical(const path& p, error_code& ec); + path canonical(const path& p, const path& base, error_code& ec); + + void copy(const path& from, const path& to); + void copy(const path& from, const path& to, error_code& ec) _NOEXCEPT; + void copy(const path& from, const path& to, copy_options options); + void copy(const path& from, const path& to, copy_options options, + error_code& ec) _NOEXCEPT; + + bool copy_file(const path& from, const path& to); + bool copy_file(const path& from, const path& to, error_code& ec) _NOEXCEPT; + bool copy_file(const path& from, const path& to, copy_options option); + bool copy_file(const path& from, const path& to, copy_options option, + error_code& ec) _NOEXCEPT; + + void copy_symlink(const path& existing_symlink, const path& new_symlink); + void copy_symlink(const path& existing_symlink, const path& new_symlink, + error_code& ec) _NOEXCEPT; + + bool create_directories(const path& p); + bool create_directories(const path& p, error_code& ec) _NOEXCEPT; + + bool create_directory(const path& p); + bool create_directory(const path& p, error_code& ec) _NOEXCEPT; + + bool create_directory(const path& p, const path& attributes); + bool create_directory(const path& p, const path& attributes, + error_code& ec) _NOEXCEPT; + + void create_directory_symlink(const path& to, const path& new_symlink); + void create_directory_symlink(const path& to, const path& new_symlink, + error_code& ec) _NOEXCEPT; + + void create_hard_link(const path& to, const path& new_hard_link); + void create_hard_link(const path& to, const path& new_hard_link, + error_code& ec) _NOEXCEPT; + + void create_symlink(const path& to, const path& new_symlink); + void create_symlink(const path& to, const path& new_symlink, + error_code& ec) _NOEXCEPT; + + path current_path(); + path current_path(error_code& ec); + void current_path(const path& p); + void current_path(const path& p, error_code& ec) _NOEXCEPT; + + bool exists(file_status s) _NOEXCEPT; + bool exists(const path& p); + bool exists(const path& p, error_code& ec) _NOEXCEPT; + + bool equivalent(const path& p1, const path& p2); + bool equivalent(const path& p1, const path& p2, error_code& ec) _NOEXCEPT; + + uintmax_t file_size(const path& p); + uintmax_t file_size(const path& p, error_code& ec) _NOEXCEPT; + + uintmax_t hard_link_count(const path& p); + uintmax_t hard_link_count(const path& p, error_code& ec) _NOEXCEPT; + + bool is_block_file(file_status s) _NOEXCEPT; + bool is_block_file(const path& p); + bool is_block_file(const path& p, error_code& ec) _NOEXCEPT; + + bool is_character_file(file_status s) _NOEXCEPT; + bool is_character_file(const path& p); + bool is_character_file(const path& p, error_code& ec) _NOEXCEPT; + + bool is_directory(file_status s) _NOEXCEPT; + bool is_directory(const path& p); + bool is_directory(const path& p, error_code& ec) _NOEXCEPT; + + bool is_empty(const path& p); + bool is_empty(const path& p, error_code& ec) _NOEXCEPT; + + bool is_fifo(file_status s) _NOEXCEPT; + bool is_fifo(const path& p); + bool is_fifo(const path& p, error_code& ec) _NOEXCEPT; + + bool is_other(file_status s) _NOEXCEPT; + bool is_other(const path& p); + bool is_other(const path& p, error_code& ec) _NOEXCEPT; + + bool is_regular_file(file_status s) _NOEXCEPT; + bool is_regular_file(const path& p); + bool is_regular_file(const path& p, error_code& ec) _NOEXCEPT; + + bool is_socket(file_status s) _NOEXCEPT; + bool is_socket(const path& p); + bool is_socket(const path& p, error_code& ec) _NOEXCEPT; + + bool is_symlink(file_status s) _NOEXCEPT; + bool is_symlink(const path& p); + bool is_symlink(const path& p, error_code& ec) _NOEXCEPT; + + file_time_type last_write_time(const path& p); + file_time_type last_write_time(const path& p, error_code& ec) _NOEXCEPT; + void last_write_time(const path& p, file_time_type new_time); + void last_write_time(const path& p, file_time_type new_time, + error_code& ec) _NOEXCEPT; + + void permissions(const path& p, perms prms); + void permissions(const path& p, perms prms, error_code& ec) _NOEXCEPT; + + path read_symlink(const path& p); + path read_symlink(const path& p, error_code& ec); + + bool remove(const path& p); + bool remove(const path& p, error_code& ec) _NOEXCEPT; + + uintmax_t remove_all(const path& p); + uintmax_t remove_all(const path& p, error_code& ec) _NOEXCEPT; + + void rename(const path& from, const path& to); + void rename(const path& from, const path& to, error_code& ec) _NOEXCEPT; + + void resize_file(const path& p, uintmax_t size); + void resize_file(const path& p, uintmax_t size, error_code& ec) _NOEXCEPT; + + space_info space(const path& p); + space_info space(const path& p, error_code& ec) _NOEXCEPT; + + file_status status(const path& p); + file_status status(const path& p, error_code& ec) _NOEXCEPT; + + bool status_known(file_status s) _NOEXCEPT; + + file_status symlink_status(const path& p); + file_status symlink_status(const path& p, error_code& ec) _NOEXCEPT; + + path system_complete(const path& p); + path system_complete(const path& p, error_code& ec); + + path temp_directory_path(); + path temp_directory_path(error_code& ec); + +} } } } // namespaces std::experimental::filesystem::v1 + +*/ + +#include <experimental/__config> +#include <cstddef> +#include <chrono> +#include <iterator> +#include <iosfwd> +#include <locale> +#include <memory> +#include <stack> +#include <string> +#include <system_error> +#include <utility> +#include <iomanip> // for quoted +#include <experimental/string_view> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#define __cpp_lib_experimental_filesystem 201406 + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +typedef chrono::time_point<std::chrono::system_clock> file_time_type; + +struct _LIBCPP_TYPE_VIS space_info +{ + uintmax_t capacity; + uintmax_t free; + uintmax_t available; +}; + +enum class _LIBCPP_TYPE_VIS file_type : signed char +{ + none = 0, + not_found = -1, + regular = 1, + directory = 2, + symlink = 3, + block = 4, + character = 5, + fifo = 6, + socket = 7, + unknown = 8 +}; + +enum class _LIBCPP_TYPE_VIS perms : unsigned +{ + none = 0, + + owner_read = 0400, + owner_write = 0200, + owner_exec = 0100, + owner_all = 0700, + + group_read = 040, + group_write = 020, + group_exec = 010, + group_all = 070, + + others_read = 04, + others_write = 02, + others_exec = 01, + others_all = 07, + + all = 0777, + + set_uid = 04000, + set_gid = 02000, + sticky_bit = 01000, + mask = 07777, + unknown = 0xFFFF, + + add_perms = 0x10000, + remove_perms = 0x20000, + symlink_nofollow = 0x40000 +}; + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator&(perms _LHS, perms _RHS) +{ return static_cast<perms>(static_cast<unsigned>(_LHS) & static_cast<unsigned>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator|(perms _LHS, perms _RHS) +{ return static_cast<perms>(static_cast<unsigned>(_LHS) | static_cast<unsigned>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator^(perms _LHS, perms _RHS) +{ return static_cast<perms>(static_cast<unsigned>(_LHS) ^ static_cast<unsigned>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR perms operator~(perms _LHS) +{ return static_cast<perms>(~static_cast<unsigned>(_LHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline perms& operator&=(perms& _LHS, perms _RHS) +{ return _LHS = _LHS & _RHS; } + +_LIBCPP_INLINE_VISIBILITY +inline perms& operator|=(perms& _LHS, perms _RHS) +{ return _LHS = _LHS | _RHS; } + +_LIBCPP_INLINE_VISIBILITY +inline perms& operator^=(perms& _LHS, perms _RHS) +{ return _LHS = _LHS ^ _RHS; } + +enum class _LIBCPP_TYPE_VIS copy_options : unsigned short +{ + none = 0, + skip_existing = 1, + overwrite_existing = 2, + update_existing = 4, + recursive = 8, + copy_symlinks = 16, + skip_symlinks = 32, + directories_only = 64, + create_symlinks = 128, + create_hard_links = 256, + __in_recursive_copy = 512, +}; + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator&(copy_options _LHS, copy_options _RHS) +{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) & static_cast<unsigned short>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator|(copy_options _LHS, copy_options _RHS) +{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) | static_cast<unsigned short>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator^(copy_options _LHS, copy_options _RHS) +{ return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^ static_cast<unsigned short>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR copy_options operator~(copy_options _LHS) +{ return static_cast<copy_options>(~static_cast<unsigned short>(_LHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) +{ return _LHS = _LHS & _RHS; } + +_LIBCPP_INLINE_VISIBILITY +inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) +{ return _LHS = _LHS | _RHS; } + +_LIBCPP_INLINE_VISIBILITY +inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) +{ return _LHS = _LHS ^ _RHS; } + + +enum class directory_options : unsigned char +{ + none = 0, + follow_directory_symlink = 1, + skip_permission_denied = 2 +}; + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator&(directory_options _LHS, directory_options _RHS) +{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) & static_cast<unsigned char>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator|(directory_options _LHS, directory_options _RHS) +{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) | static_cast<unsigned char>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator^(directory_options _LHS, directory_options _RHS) +{ return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^ static_cast<unsigned char>(_RHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR directory_options operator~(directory_options _LHS) +{ return static_cast<directory_options>(~static_cast<unsigned char>(_LHS)); } + +_LIBCPP_INLINE_VISIBILITY +inline directory_options& operator&=(directory_options& _LHS, directory_options _RHS) +{ return _LHS = _LHS & _RHS; } + +_LIBCPP_INLINE_VISIBILITY +inline directory_options& operator|=(directory_options& _LHS, directory_options _RHS) +{ return _LHS = _LHS | _RHS; } + +_LIBCPP_INLINE_VISIBILITY +inline directory_options& operator^=(directory_options& _LHS, directory_options _RHS) +{ return _LHS = _LHS ^ _RHS; } + + +class _LIBCPP_TYPE_VIS file_status +{ +public: + // constructors + _LIBCPP_INLINE_VISIBILITY + explicit file_status(file_type __ft = file_type::none, + perms __prms = perms::unknown) _NOEXCEPT + : __ft_(__ft), __prms_(__prms) + {} + + file_status(const file_status&) _NOEXCEPT = default; + file_status(file_status&&) _NOEXCEPT = default; + + _LIBCPP_INLINE_VISIBILITY + ~file_status() {} + + file_status& operator=(const file_status&) _NOEXCEPT = default; + file_status& operator=(file_status&&) _NOEXCEPT = default; + + // observers + _LIBCPP_ALWAYS_INLINE + file_type type() const _NOEXCEPT { + return __ft_; + } + + _LIBCPP_ALWAYS_INLINE + perms permissions() const _NOEXCEPT { + return __prms_; + } + + // modifiers + _LIBCPP_ALWAYS_INLINE + void type(file_type __ft) _NOEXCEPT { + __ft_ = __ft; + } + + _LIBCPP_ALWAYS_INLINE + void permissions(perms __p) _NOEXCEPT { + __prms_ = __p; + } +private: + file_type __ft_; + perms __prms_; +}; + +class _LIBCPP_TYPE_VIS directory_entry; + +template <class _Tp> struct __can_convert_char { + static const bool value = false; +}; +template <> struct __can_convert_char<char> { + static const bool value = true; + using __char_type = char; +}; +template <> struct __can_convert_char<wchar_t> { + static const bool value = true; + using __char_type = wchar_t; +}; +template <> struct __can_convert_char<char16_t> { + static const bool value = true; + using __char_type = char16_t; +}; +template <> struct __can_convert_char<char32_t> { + static const bool value = true; + using __char_type = char32_t; +}; + +template <class _ECharT> +typename enable_if<__can_convert_char<_ECharT>::value, bool>::type +__is_separator(_ECharT __e) { + return __e == _ECharT('/'); +}; + +struct _NullSentinal {}; + +template <class _Tp> +using _Void = void; + +template <class _Tp, class = void> +struct __is_pathable_string : public false_type {}; + +template <class _ECharT, class _Traits, class _Alloc> +struct __is_pathable_string<basic_string<_ECharT, _Traits, _Alloc>, + _Void<typename __can_convert_char<_ECharT>::__char_type>> +: public __can_convert_char<_ECharT> +{ + using _Str = basic_string<_ECharT, _Traits, _Alloc>; + using _Base = __can_convert_char<_ECharT>; + static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } + static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); } + static _ECharT __first_or_null(_Str const& __s) { + return __s.empty() ? _ECharT{} : __s[0]; + } +}; + +template <class _Source, + class _DS = typename decay<_Source>::type, + class _UnqualPtrType = typename remove_const< + typename remove_pointer<_DS>::type>::type, + bool _IsCharPtr = is_pointer<_DS>::value && + __can_convert_char<_UnqualPtrType>::value + > +struct __is_pathable_char_array : false_type {}; + +template <class _Source, class _ECharT, class _UPtr> +struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> + : __can_convert_char<typename remove_const<_ECharT>::type> +{ + using _Base = __can_convert_char<typename remove_const<_ECharT>::type>; + + static _ECharT const* __range_begin(const _ECharT* __b) { return __b; } + static _ECharT const* __range_end(const _ECharT* __b) + { + using _Iter = const _ECharT*; + const _ECharT __sentinal = _ECharT{}; + _Iter __e = __b; + for (; *__e != __sentinal; ++__e) + ; + return __e; + } + + static _ECharT __first_or_null(const _ECharT* __b) { return *__b; } +}; + +template <class _Iter, bool _IsIt = __is_input_iterator<_Iter>::value, class = void> +struct __is_pathable_iter : false_type {}; + +template <class _Iter> +struct __is_pathable_iter<_Iter, true, + _Void<typename __can_convert_char<typename iterator_traits<_Iter>::value_type>::__char_type>> + : __can_convert_char<typename iterator_traits<_Iter>::value_type> +{ + using _ECharT = typename iterator_traits<_Iter>::value_type; + using _Base = __can_convert_char<_ECharT>; + + static _Iter __range_begin(_Iter __b) { return __b; } + static _NullSentinal __range_end(_Iter) { return _NullSentinal{}; } + + static _ECharT __first_or_null(_Iter __b) { return *__b; } +}; + +template <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::value, + bool _IsCharIterT = __is_pathable_char_array<_Tp>::value, + bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value + > +struct __is_pathable : false_type { + static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false"); +}; + +template <class _Tp> +struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {}; + + +template <class _Tp> +struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {}; + + +template <class _Tp> +struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; + + +template <class _ECharT> +struct _PathCVT { + static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible"); + + typedef __narrow_to_utf8<sizeof(_ECharT)*__CHAR_BIT__> _Narrower; + + static void __append_range(string& __dest, _ECharT const* __b, _ECharT const* __e) { + _Narrower()(back_inserter(__dest), __b, __e); + } + + template <class _Iter> + static void __append_range(string& __dest, _Iter __b, _Iter __e) { + static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); + if (__b == __e) return; + basic_string<_ECharT> __tmp(__b, __e); + _Narrower()(back_inserter(__dest), __tmp.data(), + __tmp.data() + __tmp.length()); + } + + template <class _Iter> + static void __append_range(string& __dest, _Iter __b, _NullSentinal) { + static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); + const _ECharT __sentinal = _ECharT{}; + if (*__b == __sentinal) return; + basic_string<_ECharT> __tmp; + for (; *__b != __sentinal; ++__b) + __tmp.push_back(*__b); + _Narrower()(back_inserter(__dest), __tmp.data(), + __tmp.data() + __tmp.length()); + } + + template <class _Source> + static void __append_source(string& __dest, _Source const& __s) + { + using _Traits = __is_pathable<_Source>; + __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s)); + } +}; + +template <> +struct _PathCVT<char> { + template <class _Iter> + static void __append_range(string& __dest, _Iter __b, _Iter __e) { + for (; __b != __e; ++__b) + __dest.push_back(*__b); + } + + template <class _Iter> + static void __append_range(string& __dest, _Iter __b, _NullSentinal) { + const char __sentinal = char{}; + for (; *__b != __sentinal; ++__b) + __dest.push_back(*__b); + } + + template <class _Source> + static void __append_source(string& __dest, _Source const& __s) + { + using _Traits = __is_pathable<_Source>; + __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s)); + } +}; + + +class _LIBCPP_TYPE_VIS path +{ + template <class _SourceOrIter, class _Tp = path&> + using _EnableIfPathable = typename + enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; + + template <class _Tp> + using _SourceChar = typename __is_pathable<_Tp>::__char_type; + + template <class _Tp> + using _SourceCVT = _PathCVT<_SourceChar<_Tp>>; + +public: + typedef char value_type; + typedef basic_string<value_type> string_type; + static _LIBCPP_CONSTEXPR value_type preferred_separator = '/'; + + // constructors and destructor + _LIBCPP_INLINE_VISIBILITY path() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {} + _LIBCPP_INLINE_VISIBILITY path(path&& __p) _NOEXCEPT : __pn_(_VSTD::move(__p.__pn_)) {} + + _LIBCPP_INLINE_VISIBILITY + path(string_type&& __s) _NOEXCEPT : __pn_(_VSTD::move(__s)) {} + + template < + class _Source, + class = _EnableIfPathable<_Source, void> + > + path(const _Source& __src) { + _SourceCVT<_Source>::__append_source(__pn_, __src); + } + + template <class _InputIt> + path(_InputIt __first, _InputIt __last) { + typedef typename iterator_traits<_InputIt>::value_type _ItVal; + _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); + } + + // TODO Implement locale conversions. + template <class _Source, + class = _EnableIfPathable<_Source, void> + > + path(const _Source& __src, const locale& __loc); + template <class _InputIt> + path(_InputIt __first, _InputIt _last, const locale& __loc); + + _LIBCPP_INLINE_VISIBILITY + ~path() = default; + + // assignments + _LIBCPP_INLINE_VISIBILITY + path& operator=(const path& __p) { + __pn_ = __p.__pn_; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& operator=(path&& __p) _NOEXCEPT { + __pn_ = _VSTD::move(__p.__pn_); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& operator=(string_type&& __s) _NOEXCEPT { + __pn_ = _VSTD::move(__s); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& assign(string_type&& __s) _NOEXCEPT { + __pn_ = _VSTD::move(__s); + return *this; + } + + template <class _Source> + _LIBCPP_INLINE_VISIBILITY + _EnableIfPathable<_Source> + operator=(const _Source& __src) + { return this->assign(__src); } + + + template <class _Source> + _EnableIfPathable<_Source> + assign(const _Source& __src) { + __pn_.clear(); + _SourceCVT<_Source>::__append_source(__pn_, __src); + return *this; + } + + template <class _InputIt> + path& assign(_InputIt __first, _InputIt __last) { + typedef typename iterator_traits<_InputIt>::value_type _ItVal; + __pn_.clear(); + _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); + return *this; + } + +private: + template <class _ECharT> + void __append_sep_if_needed(_ECharT __first_or_null) { + const _ECharT __null_val = {}; + bool __append_sep = !empty() && + !__is_separator(__pn_.back()) && + __first_or_null != __null_val && // non-empty + !__is_separator(__first_or_null); + if (__append_sep) + __pn_ += preferred_separator; + } + +public: + // appends + path& operator/=(const path& __p) { + __append_sep_if_needed(__p.empty() ? char{} : __p.__pn_[0]); + __pn_ += __p.native(); + return *this; + } + + template <class _Source> + _LIBCPP_INLINE_VISIBILITY + _EnableIfPathable<_Source> + operator/=(const _Source& __src) { + return this->append(__src); + } + + template <class _Source> + _EnableIfPathable<_Source> + append(const _Source& __src) { + using _Traits = __is_pathable<_Source>; + using _CVT = _PathCVT<_SourceChar<_Source>>; + __append_sep_if_needed(_Traits::__first_or_null(__src)); + _CVT::__append_source(__pn_, __src); + return *this; + } + + template <class _InputIt> + path& append(_InputIt __first, _InputIt __last) { + typedef typename iterator_traits<_InputIt>::value_type _ItVal; + static_assert(__can_convert_char<_ItVal>::value, "Must convertible"); + using _CVT = _PathCVT<_ItVal>; + if (__first != __last) { + __append_sep_if_needed(*__first); + _CVT::__append_range(__pn_, __first, __last); + } + return *this; + } + + // concatenation + _LIBCPP_INLINE_VISIBILITY + path& operator+=(const path& __x) { + __pn_ += __x.__pn_; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& operator+=(const string_type& __x) { + __pn_ += __x; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& operator+=(const value_type* __x) { + __pn_ += __x; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + path& operator+=(value_type __x) { + __pn_ += __x; + return *this; + } + + + template <class _ECharT> + typename enable_if<__can_convert_char<_ECharT>::value, path&>::type + operator+=(_ECharT __x) + { + basic_string<_ECharT> __tmp; + __tmp += __x; + _PathCVT<_ECharT>::__append_source(__pn_, __tmp); + return *this; + } + + template <class _Source> + _EnableIfPathable<_Source> + operator+=(const _Source& __x) { + return this->concat(__x); + } + + template <class _Source> + _EnableIfPathable<_Source> + concat(const _Source& __x) { + _SourceCVT<_Source>::__append_source(__pn_, __x); + return *this; + } + + template <class _InputIt> + path& concat(_InputIt __first, _InputIt __last) { + typedef typename iterator_traits<_InputIt>::value_type _ItVal; + _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); + return *this; + } + + // modifiers + _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT { + __pn_.clear(); + } + + path& make_preferred() { return *this; } + path& remove_filename() { return *this = parent_path(); } + + path& replace_filename(const path& __replacement) { + remove_filename(); + return (*this /= __replacement); + } + + path& replace_extension(const path& __replacement = path()); + + _LIBCPP_INLINE_VISIBILITY + void swap(path& __rhs) _NOEXCEPT { + __pn_.swap(__rhs.__pn_); + } + + // native format observers + _LIBCPP_INLINE_VISIBILITY + const string_type& native() const _NOEXCEPT { + return __pn_; + } + + _LIBCPP_INLINE_VISIBILITY + const value_type* c_str() const _NOEXCEPT { return __pn_.c_str(); } + + _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; } + + template <class _ECharT, class _Traits = char_traits<_ECharT>, + class _Allocator = allocator<_ECharT> > + basic_string<_ECharT, _Traits, _Allocator> + string(const _Allocator& __a = _Allocator()) const { + using _CVT = __widen_from_utf8<sizeof(_ECharT)*__CHAR_BIT__>; + using _Str = basic_string<_ECharT, _Traits, _Allocator>; + _Str __s(__a); + __s.reserve(__pn_.size()); + _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); + return __s; + } + + _LIBCPP_INLINE_VISIBILITY std::string string() const { return __pn_; } + _LIBCPP_INLINE_VISIBILITY std::wstring wstring() const { return string<wchar_t>(); } + _LIBCPP_INLINE_VISIBILITY std::string u8string() const { return __pn_; } + _LIBCPP_INLINE_VISIBILITY std::u16string u16string() const { return string<char16_t>(); } + _LIBCPP_INLINE_VISIBILITY std::u32string u32string() const { return string<char32_t>(); } + + // generic format observers + template <class _ECharT, class _Traits = char_traits<_ECharT>, + class _Allocator = allocator<_ECharT> + > + basic_string<_ECharT, _Traits, _Allocator> + generic_string(const _Allocator& __a = _Allocator()) const { + return string<_ECharT, _Traits, _Allocator>(__a); + } + + std::string generic_string() const { return __pn_; } + std::wstring generic_wstring() const { return string<wchar_t>(); } + std::string generic_u8string() const { return __pn_; } + std::u16string generic_u16string() const { return string<char16_t>(); } + std::u32string generic_u32string() const { return string<char32_t>(); } + +private: + _LIBCPP_FUNC_VIS int __compare(const value_type*) const; + _LIBCPP_FUNC_VIS string_view __root_name() const; + _LIBCPP_FUNC_VIS string_view __root_directory() const; + _LIBCPP_FUNC_VIS string_view __relative_path() const; + _LIBCPP_FUNC_VIS string_view __parent_path() const; + _LIBCPP_FUNC_VIS string_view __filename() const; + _LIBCPP_FUNC_VIS string_view __stem() const; + _LIBCPP_FUNC_VIS string_view __extension() const; + +public: + // compare + _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const _NOEXCEPT { return __compare(__p.c_str());} + _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s.c_str()); } + _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { return __compare(__s); } + + // decomposition + _LIBCPP_INLINE_VISIBILITY path root_name() const { return __root_name().to_string(); } + _LIBCPP_INLINE_VISIBILITY path root_directory() const { return __root_directory().to_string(); } + _LIBCPP_INLINE_VISIBILITY path root_path() const { return root_name().append(__root_directory().to_string()); } + _LIBCPP_INLINE_VISIBILITY path relative_path() const { return __relative_path().to_string(); } + _LIBCPP_INLINE_VISIBILITY path parent_path() const { return __parent_path().to_string(); } + _LIBCPP_INLINE_VISIBILITY path filename() const { return __filename().to_string(); } + _LIBCPP_INLINE_VISIBILITY path stem() const { return __stem().to_string();} + _LIBCPP_INLINE_VISIBILITY path extension() const { return __extension().to_string(); } + + // query + _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT { return __pn_.empty(); } + + _LIBCPP_INLINE_VISIBILITY bool has_root_name() const { return !__root_name().empty(); } + _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return !__root_directory().empty(); } + _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { return !(__root_name().empty() && __root_directory().empty()); } + _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { return !__relative_path().empty(); } + _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { return !__parent_path().empty(); } + _LIBCPP_INLINE_VISIBILITY bool has_filename() const { return !__filename().empty(); } + _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); } + _LIBCPP_INLINE_VISIBILITY bool has_extension() const { return !__extension().empty(); } + + _LIBCPP_INLINE_VISIBILITY bool is_absolute() const { return has_root_directory(); } + _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); } + + // iterators + class _LIBCPP_TYPE_VIS iterator; + typedef iterator const_iterator; + + _LIBCPP_FUNC_VIS iterator begin() const; + _LIBCPP_FUNC_VIS iterator end() const; + +private: + inline _LIBCPP_INLINE_VISIBILITY + path& __assign_view(string_view const& __s) noexcept { __pn_ = __s.to_string(); return *this; } + string_type __pn_; +}; + +inline _LIBCPP_ALWAYS_INLINE +void swap(path& __lhs, path& __rhs) _NOEXCEPT { + __lhs.swap(__rhs); +} + +_LIBCPP_FUNC_VIS +size_t hash_value(const path& __p) _NOEXCEPT; + +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) == 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) != 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator<(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) < 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator<=(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) <= 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator>(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) > 0; } + +inline _LIBCPP_INLINE_VISIBILITY +bool operator>=(const path& __lhs, const path& __rhs) _NOEXCEPT +{ return __lhs.compare(__rhs) >= 0; } + +inline _LIBCPP_INLINE_VISIBILITY +path operator/(const path& __lhs, const path& __rhs) { + return path(__lhs) /= __rhs; +} + +template <class _CharT, class _Traits> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<is_same<_CharT, char>::value && + is_same<_Traits, char_traits<char>>::value, + basic_ostream<_CharT, _Traits>& +>::type +operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { + __os << std::__quoted(__p.native()); + return __os; +} + +template <class _CharT, class _Traits> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<!is_same<_CharT, char>::value || + !is_same<_Traits, char_traits<char>>::value, + basic_ostream<_CharT, _Traits>& +>::type +operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { + __os << std::__quoted(__p.string<_CharT, _Traits>()); + return __os; +} + +template <class _CharT, class _Traits> +_LIBCPP_INLINE_VISIBILITY +basic_istream<_CharT, _Traits>& +operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) +{ + basic_string<_CharT, _Traits> __tmp; + __is >> __quoted(__tmp); + __p = __tmp; + return __is; +} + +template <class _Source> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<__is_pathable<_Source>::value, path>::type +u8path(const _Source& __s){ + static_assert(is_same<typename __is_pathable<_Source>::__char_type, char>::value, + "u8path(Source const&) requires Source have a character type of type 'char'"); + return path(__s); +} + +template <class _InputIt> +_LIBCPP_INLINE_VISIBILITY +typename enable_if<__is_pathable<_InputIt>::value, path>::type +u8path(_InputIt __f, _InputIt __l) { + static_assert(is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, + "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"); + return path(__f, __l); +} + +class _LIBCPP_TYPE_VIS path::iterator +{ +public: + typedef bidirectional_iterator_tag iterator_category; + typedef path value_type; + typedef std::ptrdiff_t difference_type; + typedef const path* pointer; + typedef const path& reference; +public: + _LIBCPP_INLINE_VISIBILITY + iterator() : __elem_(), __path_ptr_(nullptr), __pos_(0) {} + + iterator(const iterator&) = default; + ~iterator() = default; + + iterator& operator=(const iterator&) = default; + + _LIBCPP_INLINE_VISIBILITY + reference operator*() const { + return __elem_; + } + + _LIBCPP_INLINE_VISIBILITY + pointer operator->() const { + return &__elem_; + } + + _LIBCPP_INLINE_VISIBILITY + iterator& operator++() { + return __increment(); + } + + _LIBCPP_INLINE_VISIBILITY + iterator operator++(int) { + iterator __it(*this); + this->operator++(); + return __it; + } + + _LIBCPP_INLINE_VISIBILITY + iterator& operator--() { + return __decrement(); + } + + _LIBCPP_INLINE_VISIBILITY + iterator operator--(int) { + iterator __it(*this); + this->operator--(); + return __it; + } + +private: + friend class path; + friend bool operator==(const iterator&, const iterator&); + + _LIBCPP_FUNC_VIS iterator& __increment(); + _LIBCPP_FUNC_VIS iterator& __decrement(); + + path __elem_; + const path* __path_ptr_; + size_t __pos_; +}; + +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) { + return __lhs.__path_ptr_ == __rhs.__path_ptr_ && + __lhs.__pos_ == __rhs.__pos_; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const path::iterator& __lhs, const path::iterator& __rhs) { + return !(__lhs == __rhs); +} + +class _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error +{ +public: + _LIBCPP_INLINE_VISIBILITY + filesystem_error(const string& __what, error_code __ec) + : system_error(__ec, __what), + __paths_(make_shared<_Storage>(path(), path())) + {} + + _LIBCPP_INLINE_VISIBILITY + filesystem_error(const string& __what, const path& __p1, error_code __ec) + : system_error(__ec, __what), + __paths_(make_shared<_Storage>(__p1, path())) + {} + + _LIBCPP_INLINE_VISIBILITY + filesystem_error(const string& __what, const path& __p1, const path& __p2, + error_code __ec) + : system_error(__ec, __what), + __paths_(make_shared<_Storage>(__p1, __p2)) + {} + + _LIBCPP_INLINE_VISIBILITY + const path& path1() const _NOEXCEPT { + return __paths_->first; + } + + _LIBCPP_INLINE_VISIBILITY + const path& path2() const _NOEXCEPT { + return __paths_->second; + } + + _LIBCPP_FUNC_VIS + ~filesystem_error() override; // key function + + // TODO(ericwf): Create a custom error message. + //const char* what() const _NOEXCEPT; + +private: + typedef pair<path, path> _Storage; + shared_ptr<_Storage> __paths_; +}; + +// operational functions + +_LIBCPP_FUNC_VIS +path __canonical(const path&, const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +void __copy(const path& __from, const path& __to, copy_options __opt, + error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +bool __copy_file(const path& __from, const path& __to, copy_options __opt, + error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, + error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +bool __create_directories(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +bool __create_directory(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +bool __create_directory(const path& p, const path & attributes, + error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +void __create_directory_symlink(const path& __to, const path& __new_symlink, + error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +void __create_hard_link(const path& __to, const path& __new_hard_link, + error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +void __create_symlink(const path& __to, const path& __new_symlink, + error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +path __current_path(error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +void __current_path(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +bool __equivalent(const path&, const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +uintmax_t __file_size(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +uintmax_t __hard_link_count(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +bool __fs_is_empty(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +file_time_type __last_write_time(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +void __last_write_time(const path& p, file_time_type new_time, + error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +void __permissions(const path& p, perms prms, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +path __read_symlink(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +bool __remove(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +uintmax_t __remove_all(const path& p, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +void __rename(const path& from, const path& to, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +void __resize_file(const path& p, uintmax_t size, error_code *ec=nullptr); +_LIBCPP_FUNC_VIS +space_info __space(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +file_status __status(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +file_status __symlink_status(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +path __system_complete(const path&, error_code *__ec=nullptr); +_LIBCPP_FUNC_VIS +path __temp_directory_path(error_code *__ec=nullptr); + +inline _LIBCPP_INLINE_VISIBILITY +path current_path() { + return __current_path(); +} + +inline _LIBCPP_INLINE_VISIBILITY +path current_path(error_code& __ec) { + return __current_path(&__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void current_path(const path& __p) { + __current_path(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +void current_path(const path& __p, error_code& __ec) _NOEXCEPT { + __current_path(__p, &__ec); +} + +_LIBCPP_FUNC_VIS +path absolute(const path&, const path& __p2 = current_path()); + +inline _LIBCPP_INLINE_VISIBILITY +path canonical(const path& __p, const path& __base = current_path()) { + return __canonical(__p, __base); +} + +inline _LIBCPP_INLINE_VISIBILITY +path canonical(const path& __p, error_code& __ec) { + path __base = __current_path(&__ec); + if (__ec) return {}; + return __canonical(__p, __base, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +path canonical(const path& __p, const path& __base, error_code& __ec) { + return __canonical(__p, __base, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void copy(const path& __from, const path& __to) { + __copy(__from, __to, copy_options::none); +} + +inline _LIBCPP_INLINE_VISIBILITY +void copy(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT { + __copy(__from, __to, copy_options::none, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void copy(const path& __from, const path& __to, copy_options __opt) { + __copy(__from, __to, __opt); +} + +inline _LIBCPP_INLINE_VISIBILITY +void copy(const path& __from, const path& __to, + copy_options __opt, error_code& __ec) _NOEXCEPT { + __copy(__from, __to, __opt, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool copy_file(const path& __from, const path& __to) { + return __copy_file(__from, __to, copy_options::none); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool copy_file(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT { + return __copy_file(__from, __to, copy_options::none, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool copy_file(const path& __from, const path& __to, copy_options __opt) { + return __copy_file(__from, __to, __opt); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool copy_file(const path& __from, const path& __to, + copy_options __opt, error_code& __ec) _NOEXCEPT { + return __copy_file(__from, __to, __opt, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void copy_symlink(const path& __existing, const path& __new) { + __copy_symlink(__existing, __new); +} + +inline _LIBCPP_INLINE_VISIBILITY +void copy_symlink(const path& __ext, const path& __new, error_code& __ec) _NOEXCEPT { + __copy_symlink(__ext, __new, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool create_directories(const path& __p) { + return __create_directories(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool create_directories(const path& __p, error_code& __ec) _NOEXCEPT { + return __create_directories(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool create_directory(const path& __p) { + return __create_directory(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool create_directory(const path& __p, error_code& __ec) _NOEXCEPT { + return __create_directory(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool create_directory(const path& __p, const path& __attrs) { + return __create_directory(__p, __attrs); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool create_directory(const path& __p, const path& __attrs, error_code& __ec) _NOEXCEPT { + return __create_directory(__p, __attrs, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void create_directory_symlink(const path& __to, const path& __new) { + __create_directory_symlink(__to, __new); +} + +inline _LIBCPP_INLINE_VISIBILITY +void create_directory_symlink(const path& __to, const path& __new, + error_code& __ec) _NOEXCEPT { + __create_directory_symlink(__to, __new, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void create_hard_link(const path& __to, const path& __new) { + __create_hard_link(__to, __new); +} + +inline _LIBCPP_INLINE_VISIBILITY +void create_hard_link(const path& __to, const path& __new, error_code& __ec) _NOEXCEPT { + __create_hard_link(__to, __new, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void create_symlink(const path& __to, const path& __new) { + __create_symlink(__to, __new); +} + +inline _LIBCPP_INLINE_VISIBILITY +void create_symlink(const path& __to, const path& __new, error_code& __ec) _NOEXCEPT { + return __create_symlink(__to, __new, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool status_known(file_status __s) _NOEXCEPT { + return __s.type() != file_type::none; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool exists(file_status __s) _NOEXCEPT { + return status_known(__s) && __s.type() != file_type::not_found; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool exists(const path& __p) { + return exists(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool exists(const path& __p, error_code& __ec) _NOEXCEPT { + auto __s = __status(__p, &__ec); + if (status_known(__s)) __ec.clear(); + return exists(__s); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool equivalent(const path& __p1, const path& __p2) { + return __equivalent(__p1, __p2); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool equivalent(const path& __p1, const path& __p2, error_code& __ec) _NOEXCEPT { + return __equivalent(__p1, __p2, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +uintmax_t file_size(const path& __p) { + return __file_size(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +uintmax_t file_size(const path& __p, error_code& __ec) _NOEXCEPT { + return __file_size(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +uintmax_t hard_link_count(const path& __p) { + return __hard_link_count(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +uintmax_t hard_link_count(const path& __p, error_code& __ec) _NOEXCEPT { + return __hard_link_count(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_block_file(file_status __s) _NOEXCEPT { + return __s.type() == file_type::block; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_block_file(const path& __p) { + return is_block_file(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_block_file(const path& __p, error_code& __ec) _NOEXCEPT { + return is_block_file(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_character_file(file_status __s) _NOEXCEPT { + return __s.type() == file_type::character; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_character_file(const path& __p) { + return is_character_file(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_character_file(const path& __p, error_code& __ec) _NOEXCEPT { + return is_character_file(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_directory(file_status __s) _NOEXCEPT { + return __s.type() == file_type::directory; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_directory(const path& __p) { + return is_directory(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_directory(const path& __p, error_code& __ec) _NOEXCEPT { + return is_directory(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_empty(const path& __p) { + return __fs_is_empty(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_empty(const path& __p, error_code& __ec) _NOEXCEPT { + return __fs_is_empty(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_fifo(file_status __s) _NOEXCEPT { + return __s.type() == file_type::fifo; +} +inline _LIBCPP_INLINE_VISIBILITY +bool is_fifo(const path& __p) { + return is_fifo(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_fifo(const path& __p, error_code& __ec) _NOEXCEPT { + return is_fifo(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_regular_file(file_status __s) _NOEXCEPT { + return __s.type() == file_type::regular; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_regular_file(const path& __p) { + return is_regular_file(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_regular_file(const path& __p, error_code& __ec) _NOEXCEPT { + return is_regular_file(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_socket(file_status __s) _NOEXCEPT { + return __s.type() == file_type::socket; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_socket(const path& __p) { + return is_socket(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_socket(const path& __p, error_code& __ec) _NOEXCEPT { + return is_socket(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_symlink(file_status __s) _NOEXCEPT { + return __s.type() == file_type::symlink; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_symlink(const path& __p) { + return is_symlink(__symlink_status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_symlink(const path& __p, error_code& __ec) _NOEXCEPT { + return is_symlink(__symlink_status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_other(file_status __s) _NOEXCEPT { + return exists(__s) + && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_other(const path& __p) { + return is_other(__status(__p)); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool is_other(const path& __p, error_code& __ec) _NOEXCEPT { + return is_other(__status(__p, &__ec)); +} + +inline _LIBCPP_INLINE_VISIBILITY +file_time_type last_write_time(const path& __p) { + return __last_write_time(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +file_time_type last_write_time(const path& __p, error_code& __ec) _NOEXCEPT { + return __last_write_time(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void last_write_time(const path& __p, file_time_type __t) { + __last_write_time(__p, __t); +} + +inline _LIBCPP_INLINE_VISIBILITY +void last_write_time(const path& __p, file_time_type __t, error_code& __ec) _NOEXCEPT { + __last_write_time(__p, __t, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void permissions(const path& __p, perms __prms) { + __permissions(__p, __prms); +} + +inline _LIBCPP_INLINE_VISIBILITY +void permissions(const path& __p, perms __prms, error_code& __ec) { + __permissions(__p, __prms, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +path read_symlink(const path& __p) { + return __read_symlink(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +path read_symlink(const path& __p, error_code& __ec) { + return __read_symlink(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool remove(const path& __p) { + return __remove(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool remove(const path& __p, error_code& __ec) _NOEXCEPT { + return __remove(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +uintmax_t remove_all(const path& __p) { + return __remove_all(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +uintmax_t remove_all(const path& __p, error_code& __ec) _NOEXCEPT { + return __remove_all(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void rename(const path& __from, const path& __to) { + return __rename(__from, __to); +} + +inline _LIBCPP_INLINE_VISIBILITY +void rename(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT { + return __rename(__from, __to, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +void resize_file(const path& __p, uintmax_t __ns) { + return __resize_file(__p, __ns); +} + +inline _LIBCPP_INLINE_VISIBILITY +void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) _NOEXCEPT { + return __resize_file(__p, __ns, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +space_info space(const path& __p) { + return __space(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +space_info space(const path& __p, error_code& __ec) _NOEXCEPT { + return __space(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +file_status status(const path& __p) { + return __status(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +file_status status(const path& __p, error_code& __ec) _NOEXCEPT { + return __status(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +file_status symlink_status(const path& __p) { + return __symlink_status(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +file_status symlink_status(const path& __p, error_code& __ec) _NOEXCEPT { + return __symlink_status(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +path system_complete(const path& __p) { + return __system_complete(__p); +} + +inline _LIBCPP_INLINE_VISIBILITY +path system_complete(const path& __p, error_code& __ec) { + return __system_complete(__p, &__ec); +} + +inline _LIBCPP_INLINE_VISIBILITY +path temp_directory_path() { + return __temp_directory_path(); +} + +inline _LIBCPP_INLINE_VISIBILITY +path temp_directory_path(error_code& __ec) { + return __temp_directory_path(&__ec); +} + + +class directory_entry +{ + typedef _VSTD_FS::path _Path; + +public: + // constructors and destructors + directory_entry() _NOEXCEPT = default; + directory_entry(directory_entry const&) = default; + directory_entry(directory_entry&&) _NOEXCEPT = default; + + _LIBCPP_INLINE_VISIBILITY + explicit directory_entry(_Path const& __p) : __p_(__p) {} + + ~directory_entry() {} + + directory_entry& operator=(directory_entry const&) = default; + directory_entry& operator=(directory_entry&&) _NOEXCEPT = default; + + _LIBCPP_INLINE_VISIBILITY + void assign(_Path const& __p) { + __p_ = __p; + } + + _LIBCPP_INLINE_VISIBILITY + void replace_filename(_Path const& __p) { + __p_ = __p_.parent_path() / __p; + } + + _LIBCPP_INLINE_VISIBILITY + _Path const& path() const _NOEXCEPT { + return __p_; + } + + _LIBCPP_INLINE_VISIBILITY + operator const _Path&() const _NOEXCEPT { + return __p_; + } + + _LIBCPP_INLINE_VISIBILITY + file_status status() const { + return _VSTD_FS::status(__p_); + } + + _LIBCPP_INLINE_VISIBILITY + file_status status(error_code& __ec) const _NOEXCEPT { + return _VSTD_FS::status(__p_, __ec); + } + + _LIBCPP_INLINE_VISIBILITY + file_status symlink_status() const { + return _VSTD_FS::symlink_status(__p_); + } + + _LIBCPP_INLINE_VISIBILITY + file_status symlink_status(error_code& __ec) const _NOEXCEPT { + return _VSTD_FS::symlink_status(__p_, __ec); + } + + _LIBCPP_INLINE_VISIBILITY + bool operator< (directory_entry const& __rhs) const _NOEXCEPT { + return __p_ < __rhs.__p_; + } + + _LIBCPP_INLINE_VISIBILITY + bool operator==(directory_entry const& __rhs) const _NOEXCEPT { + return __p_ == __rhs.__p_; + } + + _LIBCPP_INLINE_VISIBILITY + bool operator!=(directory_entry const& __rhs) const _NOEXCEPT { + return __p_ != __rhs.__p_; + } + + _LIBCPP_INLINE_VISIBILITY + bool operator<=(directory_entry const& __rhs) const _NOEXCEPT { + return __p_ <= __rhs.__p_; + } + + _LIBCPP_INLINE_VISIBILITY + bool operator> (directory_entry const& __rhs) const _NOEXCEPT { + return __p_ > __rhs.__p_; + } + + _LIBCPP_INLINE_VISIBILITY + bool operator>=(directory_entry const& __rhs) const _NOEXCEPT { + return __p_ >= __rhs.__p_; + } +private: + _Path __p_; +}; + + +class directory_iterator; +class recursive_directory_iterator; +class __dir_stream; + +class __dir_element_proxy { +public: + + inline _LIBCPP_INLINE_VISIBILITY + directory_entry operator*() { return _VSTD::move(__elem_); } + +private: + friend class directory_iterator; + friend class recursive_directory_iterator; + explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {} + __dir_element_proxy(__dir_element_proxy&& __o) : __elem_(_VSTD::move(__o.__elem_)) {} + directory_entry __elem_; +}; + +class directory_iterator +{ +public: + typedef directory_entry value_type; + typedef ptrdiff_t difference_type; + typedef value_type const* pointer; + typedef value_type const& reference; + typedef input_iterator_tag iterator_category; + +public: + //ctor & dtor + directory_iterator() _NOEXCEPT + { } + + explicit directory_iterator(const path& __p) + : directory_iterator(__p, nullptr) + { } + + directory_iterator(const path& __p, directory_options __opts) + : directory_iterator(__p, nullptr, __opts) + { } + + directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT + : directory_iterator(__p, &__ec) + { } + + directory_iterator(const path& __p, directory_options __opts, + error_code& __ec) _NOEXCEPT + : directory_iterator(__p, &__ec, __opts) + { } + + directory_iterator(const directory_iterator&) = default; + directory_iterator(directory_iterator&&) = default; + directory_iterator& operator=(const directory_iterator&) = default; + + directory_iterator& operator=(directory_iterator&& __o) _NOEXCEPT { + // non-default implementation provided to support self-move assign. + if (this != &__o) { + __imp_ = _VSTD::move(__o.__imp_); + } + return *this; + } + + ~directory_iterator() = default; + + const directory_entry& operator*() const { + _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); + return __deref(); + } + + const directory_entry* operator->() const + { return &**this; } + + directory_iterator& operator++() + { return __increment(); } + + __dir_element_proxy operator++(int) { + __dir_element_proxy __p(**this); + __increment(); + return __p; + } + + directory_iterator& increment(error_code& __ec) _NOEXCEPT + { return __increment(&__ec); } + +private: + friend bool operator==(const directory_iterator& __lhs, + const directory_iterator& __rhs) _NOEXCEPT; + + // construct the dir_stream + _LIBCPP_FUNC_VIS + directory_iterator(const path&, error_code *, directory_options = directory_options::none); + _LIBCPP_FUNC_VIS + directory_iterator& __increment(error_code * __ec = nullptr); + _LIBCPP_FUNC_VIS + const directory_entry& __deref() const; + +private: + shared_ptr<__dir_stream> __imp_; +}; + + +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const directory_iterator& __lhs, + const directory_iterator& __rhs) _NOEXCEPT { + return __lhs.__imp_ == __rhs.__imp_; +} + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const directory_iterator& __lhs, + const directory_iterator& __rhs) _NOEXCEPT { + return !(__lhs == __rhs); +} + +// enable directory_iterator range-based for statements +inline _LIBCPP_INLINE_VISIBILITY +directory_iterator begin(directory_iterator __iter) _NOEXCEPT { + return __iter; +} + +inline _LIBCPP_INLINE_VISIBILITY +directory_iterator end(const directory_iterator&) _NOEXCEPT { + return directory_iterator(); +} + +class recursive_directory_iterator { +public: + using value_type = directory_entry; + using difference_type = std::ptrdiff_t; + using pointer = directory_entry const *; + using reference = directory_entry const &; + using iterator_category = std::input_iterator_tag; + +public: + // constructors and destructor + _LIBCPP_INLINE_VISIBILITY + recursive_directory_iterator() _NOEXCEPT + : __rec_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + explicit recursive_directory_iterator(const path& __p, + directory_options __xoptions = directory_options::none) + : recursive_directory_iterator(__p, __xoptions, nullptr) + { } + + _LIBCPP_INLINE_VISIBILITY + recursive_directory_iterator(const path& __p, + directory_options __xoptions, error_code& __ec) _NOEXCEPT + : recursive_directory_iterator(__p, __xoptions, &__ec) + { } + + _LIBCPP_INLINE_VISIBILITY + recursive_directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT + : recursive_directory_iterator(__p, directory_options::none, &__ec) + { } + + recursive_directory_iterator(const recursive_directory_iterator&) = default; + recursive_directory_iterator(recursive_directory_iterator&&) = default; + + recursive_directory_iterator & + operator=(const recursive_directory_iterator&) = default; + + _LIBCPP_INLINE_VISIBILITY + recursive_directory_iterator & + operator=(recursive_directory_iterator&& __o) noexcept { + // non-default implementation provided to support self-move assign. + if (this != &__o) { + __imp_ = _VSTD::move(__o.__imp_); + __rec_ = __o.__rec_; + } + return *this; + } + + ~recursive_directory_iterator() = default; + + _LIBCPP_INLINE_VISIBILITY + const directory_entry& operator*() const + { return __deref(); } + + _LIBCPP_INLINE_VISIBILITY + const directory_entry* operator->() const + { return &__deref(); } + + recursive_directory_iterator& operator++() + { return __increment(); } + + _LIBCPP_INLINE_VISIBILITY + __dir_element_proxy operator++(int) { + __dir_element_proxy __p(**this); + __increment(); + return __p; + } + + _LIBCPP_INLINE_VISIBILITY + recursive_directory_iterator& increment(error_code& __ec) _NOEXCEPT + { return __increment(&__ec); } + + _LIBCPP_FUNC_VIS directory_options options() const; + _LIBCPP_FUNC_VIS int depth() const; + + _LIBCPP_INLINE_VISIBILITY + void pop() { __pop(); } + + _LIBCPP_INLINE_VISIBILITY + void pop(error_code& __ec) + { __pop(&__ec); } + + _LIBCPP_INLINE_VISIBILITY + bool recursion_pending() const + { return __rec_; } + + _LIBCPP_INLINE_VISIBILITY + void disable_recursion_pending() + { __rec_ = false; } + +private: + recursive_directory_iterator(const path& __p, directory_options __opt, + error_code *__ec); + + _LIBCPP_FUNC_VIS + const directory_entry& __deref() const; + + _LIBCPP_FUNC_VIS + bool __try_recursion(error_code* __ec); + + _LIBCPP_FUNC_VIS + void __advance(error_code* __ec=nullptr); + + _LIBCPP_FUNC_VIS + recursive_directory_iterator& __increment(error_code *__ec=nullptr); + + _LIBCPP_FUNC_VIS + void __pop(error_code* __ec=nullptr); + + friend bool operator==(const recursive_directory_iterator&, + const recursive_directory_iterator&) _NOEXCEPT; + + struct __shared_imp; + shared_ptr<__shared_imp> __imp_; + bool __rec_; +}; // class recursive_directory_iterator + + +_LIBCPP_INLINE_VISIBILITY +inline bool operator==(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) _NOEXCEPT +{ + return __lhs.__imp_ == __rhs.__imp_; +} + +_LIBCPP_INLINE_VISIBILITY +inline bool operator!=(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) _NOEXCEPT +{ + return !(__lhs == __rhs); +} +// enable recursive_directory_iterator range-based for statements +inline _LIBCPP_INLINE_VISIBILITY +recursive_directory_iterator begin(recursive_directory_iterator __iter) _NOEXCEPT { + return __iter; +} + +inline _LIBCPP_INLINE_VISIBILITY +recursive_directory_iterator end(const recursive_directory_iterator&) _NOEXCEPT { + return recursive_directory_iterator(); +} + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM diff --git a/lib/libcxx/include/experimental/forward_list b/lib/libcxx/include/experimental/forward_list new file mode 100644 index 00000000000..55e195f446f --- /dev/null +++ b/lib/libcxx/include/experimental/forward_list @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- forward_list -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST +#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST +/* + experimental/forward_list synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using forward_list = std::forward_list<T,polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <forward_list> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */ diff --git a/lib/libcxx/include/experimental/functional b/lib/libcxx/include/experimental/functional new file mode 100644 index 00000000000..75fc8e99f35 --- /dev/null +++ b/lib/libcxx/include/experimental/functional @@ -0,0 +1,459 @@ +// -*- C++ -*- +//===-------------------------- functional --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL +#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL + +/* + experimental/functional synopsis + +#include <algorithm> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.9.9, Function object binders + template <class T> constexpr bool is_bind_expression_v + = is_bind_expression<T>::value; + template <class T> constexpr int is_placeholder_v + = is_placeholder<T>::value; + + // 4.2, Class template function + template<class> class function; // undefined + template<class R, class... ArgTypes> class function<R(ArgTypes...)>; + + template<class R, class... ArgTypes> + void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&); + + template<class R, class... ArgTypes> + bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; + template<class R, class... ArgTypes> + bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; + template<class R, class... ArgTypes> + bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; + template<class R, class... ArgTypes> + bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; + + // 4.3, Searchers + template<class ForwardIterator, class BinaryPredicate = equal_to<>> + class default_searcher; + + template<class RandomAccessIterator, + class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>, + class BinaryPredicate = equal_to<>> + class boyer_moore_searcher; + + template<class RandomAccessIterator, + class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>, + class BinaryPredicate = equal_to<>> + class boyer_moore_horspool_searcher; + + template<class ForwardIterator, class BinaryPredicate = equal_to<>> + default_searcher<ForwardIterator, BinaryPredicate> + make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last, + BinaryPredicate pred = BinaryPredicate()); + + template<class RandomAccessIterator, + class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>, + class BinaryPredicate = equal_to<>> + boyer_moore_searcher<RandomAccessIterator, Hash, BinaryPredicate> + make_boyer_moore_searcher( + RandomAccessIterator pat_first, RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + + template<class RandomAccessIterator, + class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>, + class BinaryPredicate = equal_to<>> + boyer_moore_horspool_searcher<RandomAccessIterator, Hash, BinaryPredicate> + make_boyer_moore_horspool_searcher( + RandomAccessIterator pat_first, RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + + } // namespace fundamentals_v1 + } // namespace experimental + + template<class R, class... ArgTypes, class Alloc> + struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>; + +} // namespace std + +*/ + +#include <experimental/__config> +#include <functional> + +#include <algorithm> +#include <type_traits> +#include <vector> +#include <array> +#include <unordered_map> + +#include <__undef_min_max> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#if _LIBCPP_STD_VER > 11 +// default searcher +template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class default_searcher { +public: + _LIBCPP_INLINE_VISIBILITY + default_searcher(_ForwardIterator __f, _ForwardIterator __l, + _BinaryPredicate __p = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__p) {} + + template <typename _ForwardIterator2> + _LIBCPP_INLINE_VISIBILITY + pair<_ForwardIterator2, _ForwardIterator2> + operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const + { + return _VSTD::__search(__f, __l, __first_, __last_, __pred_, + typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(), + typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category()); + } + +private: + _ForwardIterator __first_; + _ForwardIterator __last_; + _BinaryPredicate __pred_; + }; + +template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +default_searcher<_ForwardIterator, _BinaryPredicate> +make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ()) +{ + return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p); +} + +template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*useArray*/> class _BMSkipTable; + +// General case for BM data searching; use a map +template<class _Key, typename _Value, class _Hash, class _BinaryPredicate> +class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> { +public: // TODO private: + typedef _Value value_type; + typedef _Key key_type; + + const _Value __default_value_; + std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred) + : __default_value_(__default), __table(__sz, __hf, __pred) {} + + _LIBCPP_INLINE_VISIBILITY + void insert(const key_type &__key, value_type __val) + { + __table [__key] = __val; // Would skip_.insert (val) be better here? + } + + _LIBCPP_INLINE_VISIBILITY + value_type operator [](const key_type & __key) const + { + auto __it = __table.find (__key); + return __it == __table.end() ? __default_value_ : __it->second; + } +}; + + +// Special case small numeric values; use an array +template<class _Key, typename _Value, class _Hash, class _BinaryPredicate> +class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> { +private: + typedef _Value value_type; + typedef _Key key_type; + + typedef typename std::make_unsigned<key_type>::type unsigned_key_type; + typedef std::array<value_type, _VSTD::numeric_limits<unsigned_key_type>::max()> skip_map; + skip_map __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(std::size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/) + { + std::fill_n(__table.begin(), __table.size(), __default); + } + + _LIBCPP_INLINE_VISIBILITY + void insert(key_type __key, value_type __val) + { + __table[static_cast<unsigned_key_type>(__key)] = __val; + } + + _LIBCPP_INLINE_VISIBILITY + value_type operator [](key_type __key) const + { + return __table[static_cast<unsigned_key_type>(__key)]; + } +}; + + +template <class _RandomAccessIterator1, + class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class boyer_moore_searcher { +private: + typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; + typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; + typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate, + _VSTD::is_integral<value_type>::value && // what about enums? + sizeof(value_type) == 1 && + is_same<_Hash, hash<value_type>>::value && + is_same<_BinaryPredicate, equal_to<>>::value + > skip_table_type; + +public: + boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__pred), + __pattern_length_(_VSTD::distance(__first_, __last_)), + __skip_{make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)}, + __suffix_{make_shared<vector<difference_type>>(__pattern_length_ + 1)} + { + // build the skip table + for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i ) + __skip_->insert(*__f, __i); + + this->__build_suffix_table ( __first_, __last_, __pred_ ); + } + + template <typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + static_assert ( std::is_same< + typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type, + typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + if (__f == __l ) return make_pair(__l, __l); // empty corpus + if (__first_ == __last_) return make_pair(__f, __f); // empty pattern + + // If the pattern is larger than the corpus, we can't find it! + if ( __pattern_length_ > _VSTD::distance (__f, __l)) + return make_pair(__l, __l); + + // Do the search + return this->__search(__f, __l); + } + +public: // TODO private: + _RandomAccessIterator1 __first_; + _RandomAccessIterator1 __last_; + _BinaryPredicate __pred_; + difference_type __pattern_length_; + shared_ptr<skip_table_type> __skip_; + shared_ptr<vector<difference_type>> __suffix_; + + template <typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + _RandomAccessIterator2 __cur = __f; + const _RandomAccessIterator2 __last = __l - __pattern_length_; + const skip_table_type & __skip = *__skip_.get(); + const vector<difference_type> & __suffix = *__suffix_.get(); + + while (__cur <= __last) + { + + // Do we match right where we are? + difference_type __j = __pattern_length_; + while (__pred_(__first_ [__j-1], __cur [__j-1])) { + __j--; + // We matched - we're done! + if ( __j == 0 ) + return make_pair(__cur, __cur + __pattern_length_); + } + + // Since we didn't match, figure out how far to skip forward + difference_type __k = __skip[__cur [ __j - 1 ]]; + difference_type __m = __j - __k - 1; + if (__k < __j && __m > __suffix[ __j ]) + __cur += __m; + else + __cur += __suffix[ __j ]; + } + + return make_pair(__l, __l); // We didn't find anything + } + + + template<typename _Iterator, typename _Container> + void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix ) + { + const std::size_t __count = _VSTD::distance(__f, __l); + + __prefix[0] = 0; + std::size_t __k = 0; + for ( std::size_t __i = 1; __i < __count; ++__i ) + { + while ( __k > 0 && !__pred ( __f[__k], __f[__i] )) + __k = __prefix [ __k - 1 ]; + + if ( __pred ( __f[__k], __f[__i] )) + __k++; + __prefix [ __i ] = __k; + } + } + + void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _BinaryPredicate __pred) + { + const std::size_t __count = _VSTD::distance(__f, __l); + vector<difference_type> & __suffix = *__suffix_.get(); + if (__count > 0) + { + _VSTD::vector<value_type> __scratch(__count); + + __compute_bm_prefix(__f, __l, __pred, __scratch); + for ( std::size_t __i = 0; __i <= __count; __i++ ) + __suffix[__i] = __count - __scratch[__count-1]; + + typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter; + __compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch); + + for ( std::size_t __i = 0; __i < __count; __i++ ) + { + const std::size_t __j = __count - __scratch[__i]; + const difference_type __k = __i - __scratch[__i] + 1; + + if (__suffix[__j] > __k) + __suffix[__j] = __k; + } + } + } + +}; + +template<class _RandomAccessIterator, + class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> +make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, + _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) +{ + return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p); +} + +// boyer-moore-horspool +template <class _RandomAccessIterator1, + class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class boyer_moore_horspool_searcher { +private: + typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; + typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; + typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate, + _VSTD::is_integral<value_type>::value && // what about enums? + sizeof(value_type) == 1 && + is_same<_Hash, hash<value_type>>::value && + is_same<_BinaryPredicate, equal_to<>>::value + > skip_table_type; + +public: + boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__pred), + __pattern_length_(_VSTD::distance(__first_, __last_)), + __skip_{_VSTD::make_shared<skip_table_type>(__pattern_length_, __pattern_length_, __hf, __pred_)} + { + // build the skip table + if ( __f != __l ) + { + __l = __l - 1; + for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i ) + __skip_->insert(*__f, __pattern_length_ - 1 - __i); + } + } + + template <typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + static_assert ( std::is_same< + typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type, + typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + if (__f == __l ) return make_pair(__l, __l); // empty corpus + if (__first_ == __last_) return make_pair(__f, __f); // empty pattern + + // If the pattern is larger than the corpus, we can't find it! + if ( __pattern_length_ > _VSTD::distance (__f, __l)) + return make_pair(__l, __l); + + // Do the search + return this->__search(__f, __l); + } + +private: + _RandomAccessIterator1 __first_; + _RandomAccessIterator1 __last_; + _BinaryPredicate __pred_; + difference_type __pattern_length_; + shared_ptr<skip_table_type> __skip_; + + template <typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const { + _RandomAccessIterator2 __cur = __f; + const _RandomAccessIterator2 __last = __l - __pattern_length_; + const skip_table_type & __skip = *__skip_.get(); + + while (__cur <= __last) + { + // Do we match right where we are? + difference_type __j = __pattern_length_; + while (__pred_(__first_[__j-1], __cur[__j-1])) + { + __j--; + // We matched - we're done! + if ( __j == 0 ) + return make_pair(__cur, __cur + __pattern_length_); + } + __cur += __skip[__cur[__pattern_length_-1]]; + } + + return make_pair(__l, __l); + } +}; + +template<class _RandomAccessIterator, + class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> +make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, + _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) +{ + return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p); +} + +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */ diff --git a/lib/libcxx/include/experimental/iterator b/lib/libcxx/include/experimental/iterator new file mode 100644 index 00000000000..da593febe2b --- /dev/null +++ b/lib/libcxx/include/experimental/iterator @@ -0,0 +1,114 @@ +// -*- C++ -*- +//===----------------------------- iterator -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR +#define _LIBCPP_EXPERIMENTAL_ITERATOR + +/* +namespace std { + namespace experimental { + inline namespace fundamentals_v2 { + + template <class DelimT, class charT = char, class traits = char_traits<charT>> + class ostream_joiner { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_ostream<charT, traits> ostream_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + ostream_joiner(ostream_type& s, const DelimT& delimiter); + ostream_joiner(ostream_type& s, DelimT&& delimiter); + + template<typename T> + ostream_joiner& operator=(const T& value); + + ostream_joiner& operator*() noexcept; + ostream_joiner& operator++() noexcept; + ostream_joiner& operator++(int) noexcept; + private: + ostream_type* out_stream; // exposition only + DelimT delim; // exposition only + bool first_element; // exposition only + }; + + template <class charT, class traits, class DelimT> + ostream_joiner<decay_t<DelimT>, charT, traits> + make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter); + + } // inline namespace fundamentals_v2 + } // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <iterator> + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>> +class ostream_joiner { +public: + + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<char_type,traits_type> ostream_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + ostream_joiner(ostream_type& __os, _Delim&& __d) + : __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {} + + ostream_joiner(ostream_type& __os, const _Delim& __d) + : __out(_VSTD::addressof(__os)), __delim(__d), __first(true) {} + + + template<typename _Tp> + ostream_joiner& operator=(const _Tp& __v) + { + if (!__first) + *__out << __delim; + __first = false; + *__out << __v; + return *this; + } + + ostream_joiner& operator*() _NOEXCEPT { return *this; } + ostream_joiner& operator++() _NOEXCEPT { return *this; } + ostream_joiner& operator++(int) _NOEXCEPT { return *this; } + +private: + ostream_type* __out; + _Delim __delim; + bool __first; +}; + + +template <class _CharT, class _Traits, class _Delim> +ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits> +make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d) +{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); } + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif // _LIBCPP_EXPERIMENTAL_ITERATOR diff --git a/lib/libcxx/include/experimental/list b/lib/libcxx/include/experimental/list new file mode 100644 index 00000000000..1678ee3e93c --- /dev/null +++ b/lib/libcxx/include/experimental/list @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- list ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_LIST +#define _LIBCPP_EXPERIMENTAL_LIST +/* + experimental/list synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using list = std::list<T,polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <list> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_LIST */ diff --git a/lib/libcxx/include/experimental/map b/lib/libcxx/include/experimental/map new file mode 100644 index 00000000000..cff2c5e52c0 --- /dev/null +++ b/lib/libcxx/include/experimental/map @@ -0,0 +1,57 @@ +// -*- C++ -*- +//===----------------------------- map ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_MAP +#define _LIBCPP_EXPERIMENTAL_MAP +/* + experimental/map synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class Key, class T, class Compare = less<Key>> + using map = std::map<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + + template <class Key, class T, class Compare = less<Key>> + using multimap = std::multimap<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <map> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Key, class _Value, class _Compare = less<_Key>> +using map = _VSTD::map<_Key, _Value, _Compare, + polymorphic_allocator<pair<const _Key, _Value>>>; + +template <class _Key, class _Value, class _Compare = less<_Key>> +using multimap = _VSTD::multimap<_Key, _Value, _Compare, + polymorphic_allocator<pair<const _Key, _Value>>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_MAP */ diff --git a/lib/libcxx/include/experimental/memory_resource b/lib/libcxx/include/experimental/memory_resource new file mode 100644 index 00000000000..9b345210ee5 --- /dev/null +++ b/lib/libcxx/include/experimental/memory_resource @@ -0,0 +1,422 @@ +// -*- C++ -*- +//===------------------------ memory_resource -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE +#define _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE + +/** + experimental/memory_resource synopsis + +// C++1y + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + class memory_resource; + + bool operator==(const memory_resource& a, + const memory_resource& b) noexcept; + bool operator!=(const memory_resource& a, + const memory_resource& b) noexcept; + + template <class Tp> class polymorphic_allocator; + + template <class T1, class T2> + bool operator==(const polymorphic_allocator<T1>& a, + const polymorphic_allocator<T2>& b) noexcept; + template <class T1, class T2> + bool operator!=(const polymorphic_allocator<T1>& a, + const polymorphic_allocator<T2>& b) noexcept; + + // The name resource_adaptor_imp is for exposition only. + template <class Allocator> class resource_adaptor_imp; + + template <class Allocator> + using resource_adaptor = resource_adaptor_imp< + allocator_traits<Allocator>::rebind_alloc<char>>; + + // Global memory resources + memory_resource* new_delete_resource() noexcept; + memory_resource* null_memory_resource() noexcept; + + // The default memory resource + memory_resource* set_default_resource(memory_resource* r) noexcept; + memory_resource* get_default_resource() noexcept; + + // Standard memory resources + struct pool_options; + class synchronized_pool_resource; + class unsynchronized_pool_resource; + class monotonic_buffer_resource; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <experimental/__memory> +#include <limits> +#include <memory> +#include <new> +#include <stdexcept> +#include <tuple> +#include <type_traits> +#include <utility> +#include <cstddef> +#include <cstdlib> +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +// Round __s up to next multiple of __a. +inline _LIBCPP_INLINE_VISIBILITY +size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT +{ + _LIBCPP_ASSERT(__s + __a > __s, "aligned allocation size overflows"); + return (__s + __a - 1) & ~(__a - 1); +} + +// 8.5, memory.resource +class _LIBCPP_TYPE_VIS_ONLY memory_resource +{ + static const size_t __max_align = alignof(max_align_t); + +// 8.5.2, memory.resource.public +public: + virtual ~memory_resource() = default; + + _LIBCPP_INLINE_VISIBILITY + void* allocate(size_t __bytes, size_t __align = __max_align) + { return do_allocate(__bytes, __align); } + + _LIBCPP_INLINE_VISIBILITY + void deallocate(void * __p, size_t __bytes, size_t __align = __max_align) + { do_deallocate(__p, __bytes, __align); } + + _LIBCPP_INLINE_VISIBILITY + bool is_equal(memory_resource const & __other) const _NOEXCEPT + { return do_is_equal(__other); } + +// 8.5.3, memory.resource.priv +protected: + virtual void* do_allocate(size_t, size_t) = 0; + virtual void do_deallocate(void*, size_t, size_t) = 0; + virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0; +}; + +// 8.5.4, memory.resource.eq +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(memory_resource const & __lhs, + memory_resource const & __rhs) _NOEXCEPT +{ + return &__lhs == &__rhs || __lhs.is_equal(__rhs); +} + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(memory_resource const & __lhs, + memory_resource const & __rhs) _NOEXCEPT +{ + return !(__lhs == __rhs); +} + +_LIBCPP_FUNC_VIS +memory_resource * new_delete_resource() _NOEXCEPT; + +_LIBCPP_FUNC_VIS +memory_resource * null_memory_resource() _NOEXCEPT; + +_LIBCPP_FUNC_VIS +memory_resource * get_default_resource() _NOEXCEPT; + +_LIBCPP_FUNC_VIS +memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT; + +// 8.6, memory.polymorphic.allocator.class + +// 8.6.1, memory.polymorphic.allocator.overview +template <class _ValueType> +class _LIBCPP_TYPE_VIS_ONLY polymorphic_allocator +{ +public: + typedef _ValueType value_type; + + // 8.6.2, memory.polymorphic.allocator.ctor + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator() _NOEXCEPT + : __res_(_VSTD_LFTS_PMR::get_default_resource()) + {} + + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator(memory_resource * __r) _NOEXCEPT + : __res_(__r) + {} + + polymorphic_allocator(polymorphic_allocator const &) = default; + + template <class _Tp> + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator(polymorphic_allocator<_Tp> const & __other) _NOEXCEPT + : __res_(__other.resource()) + {} + + polymorphic_allocator & + operator=(polymorphic_allocator const &) = delete; + + // 8.6.3, memory.polymorphic.allocator.mem + _LIBCPP_INLINE_VISIBILITY + _ValueType* allocate(size_t __n) { + if (__n > max_size()) { + __libcpp_throw(length_error( + "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" + " 'n' exceeds maximum supported size")); + } + return static_cast<_ValueType*>( + __res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)) + ); + } + + _LIBCPP_INLINE_VISIBILITY + void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT { + _LIBCPP_ASSERT(__n <= max_size(), + "deallocate called for size which exceeds max_size()"); + __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType)); + } + + template <class _Tp, class ..._Ts> + _LIBCPP_INLINE_VISIBILITY + void construct(_Tp* __p, _Ts &&... __args) + { + _VSTD_LFTS::__lfts_user_alloc_construct( + __p, resource(), _VSTD::forward<_Ts>(__args)... + ); + } + + template <class _T1, class _T2, class ..._Args1, class ..._Args2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2>* __p, piecewise_construct_t, + tuple<_Args1...> __x, tuple<_Args2...> __y) + { + ::new ((void*)__p) pair<_T1, _T2>(piecewise_construct + , __transform_tuple( + typename __lfts_uses_alloc_ctor< + _T1, memory_resource*, _Args1... + >::type() + , _VSTD::move(__x) + , typename __make_tuple_indices<sizeof...(_Args1)>::type{} + ) + , __transform_tuple( + typename __lfts_uses_alloc_ctor< + _T2, memory_resource*, _Args2... + >::type() + , _VSTD::move(__y) + , typename __make_tuple_indices<sizeof...(_Args2)>::type{} + ) + ); + } + + template <class _T1, class _T2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2>* __p) { + construct(__p, piecewise_construct, tuple<>(), tuple<>()); + } + + template <class _T1, class _T2, class _Up, class _Vp> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2> * __p, _Up && __u, _Vp && __v) { + construct(__p, piecewise_construct + , _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__u)) + , _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__v))); + } + + template <class _T1, class _T2, class _U1, class _U2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> const & __pr) { + construct(__p, piecewise_construct + , _VSTD::forward_as_tuple(__pr.first) + , _VSTD::forward_as_tuple(__pr.second)); + } + + template <class _T1, class _T2, class _U1, class _U2> + _LIBCPP_INLINE_VISIBILITY + void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> && __pr){ + construct(__p, piecewise_construct + , _VSTD::forward_as_tuple(_VSTD::forward<_U1>(__pr.first)) + , _VSTD::forward_as_tuple(_VSTD::forward<_U2>(__pr.second))); + } + + template <class _Tp> + _LIBCPP_INLINE_VISIBILITY + void destroy(_Tp * __p) _NOEXCEPT + { __p->~_Tp(); } + + _LIBCPP_INLINE_VISIBILITY + size_t max_size() const _NOEXCEPT + { return numeric_limits<size_t>::max() / sizeof(value_type); } + + _LIBCPP_INLINE_VISIBILITY + polymorphic_allocator + select_on_container_copy_construction() const _NOEXCEPT + { return polymorphic_allocator(); } + + _LIBCPP_INLINE_VISIBILITY + memory_resource * resource() const _NOEXCEPT + { return __res_; } + +private: + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<_Args&&...> + __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, + __tuple_indices<_Idx...>) const + { + return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...); + } + + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<allocator_arg_t const&, memory_resource*, _Args&&...> + __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t, + __tuple_indices<_Idx...>) const + { + using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>; + return _Tup(allocator_arg, resource(), + _VSTD::get<_Idx>(_VSTD::move(__t))...); + } + + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<_Args&&..., memory_resource*> + __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t, + __tuple_indices<_Idx...>) const + { + using _Tup = tuple<_Args&&..., memory_resource*>; + return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource()); + } + + memory_resource * __res_; +}; + +// 8.6.4, memory.polymorphic.allocator.eq + +template <class _Tp, class _Up> +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(polymorphic_allocator<_Tp> const & __lhs, + polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT +{ + return *__lhs.resource() == *__rhs.resource(); +} + +template <class _Tp, class _Up> +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(polymorphic_allocator<_Tp> const & __lhs, + polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT +{ + return !(__lhs == __rhs); +} + +// 8.7, memory.resource.adaptor + +// 8.7.1, memory.resource.adaptor.overview +template <class _CharAlloc> +class _LIBCPP_TYPE_VIS_ONLY __resource_adaptor_imp + : public memory_resource +{ + using _CTraits = allocator_traits<_CharAlloc>; + static_assert(is_same<typename _CTraits::value_type, char>::value + && is_same<typename _CTraits::pointer, char*>::value + && is_same<typename _CTraits::void_pointer, void*>::value, ""); + + static const size_t _MaxAlign = alignof(max_align_t); + + using _Alloc = typename _CTraits::template rebind_alloc< + typename aligned_storage<_MaxAlign, _MaxAlign>::type + >; + + using _ValueType = typename _Alloc::value_type; + + _Alloc __alloc_; + +public: + typedef _CharAlloc allocator_type; + + __resource_adaptor_imp() = default; + __resource_adaptor_imp(__resource_adaptor_imp const &) = default; + __resource_adaptor_imp(__resource_adaptor_imp &&) = default; + + // 8.7.2, memory.resource.adaptor.ctor + + _LIBCPP_INLINE_VISIBILITY + explicit __resource_adaptor_imp(allocator_type const & __a) + : __alloc_(__a) + {} + + _LIBCPP_INLINE_VISIBILITY + explicit __resource_adaptor_imp(allocator_type && __a) + : __alloc_(_VSTD::move(__a)) + {} + + __resource_adaptor_imp & + operator=(__resource_adaptor_imp const &) = default; + + _LIBCPP_INLINE_VISIBILITY + allocator_type get_allocator() const + { return __alloc_; } + +// 8.7.3, memory.resource.adaptor.mem +protected: + virtual void * do_allocate(size_t __bytes, size_t) + { + if (__bytes > __max_size()) { + __libcpp_throw(length_error( + "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)" + " 'bytes' exceeds maximum supported size")); + } + size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; + return __alloc_.allocate(__s); + } + + virtual void do_deallocate(void * __p, size_t __bytes, size_t) + { + _LIBCPP_ASSERT(__bytes <= __max_size(), + "do_deallocate called for size which exceeds the maximum allocation size"); + size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; + __alloc_.deallocate((_ValueType*)__p, __s); + } + + virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT { + __resource_adaptor_imp const * __p + = dynamic_cast<__resource_adaptor_imp const *>(&__other); + return __p ? __alloc_ == __p->__alloc_ : false; + } + +private: + _LIBCPP_INLINE_VISIBILITY + size_t __max_size() const _NOEXCEPT { + return numeric_limits<size_t>::max() - _MaxAlign; + } +}; + +template <class _Alloc> +using resource_adaptor = __resource_adaptor_imp< + typename allocator_traits<_Alloc>::template rebind_alloc<char> + >; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */ diff --git a/lib/libcxx/include/experimental/optional b/lib/libcxx/include/experimental/optional new file mode 100644 index 00000000000..3912438ec10 --- /dev/null +++ b/lib/libcxx/include/experimental/optional @@ -0,0 +1,902 @@ +// -*- C++ -*- +//===-------------------------- optional ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_OPTIONAL +#define _LIBCPP_OPTIONAL + +/* + optional synopsis + +// C++1y + +namespace std { namespace experimental { inline namespace fundamentals_v1 { + + // 5.3, optional for object types + template <class T> class optional; + + // 5.4, In-place construction + struct in_place_t{}; + constexpr in_place_t in_place{}; + + // 5.5, No-value state indicator + struct nullopt_t{see below}; + constexpr nullopt_t nullopt(unspecified); + + // 5.6, Class bad_optional_access + class bad_optional_access; + + // 5.7, Relational operators + template <class T> + constexpr bool operator==(const optional<T>&, const optional<T>&); + template <class T> + constexpr bool operator!=(const optional<T>&, const optional<T>&); + template <class T> + constexpr bool operator<(const optional<T>&, const optional<T>&); + template <class T> + constexpr bool operator>(const optional<T>&, const optional<T>&); + template <class T> + constexpr bool operator<=(const optional<T>&, const optional<T>&); + template <class T> + constexpr bool operator>=(const optional<T>&, const optional<T>&); + + // 5.8, Comparison with nullopt + template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept; + template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept; + template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept; + template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept; + template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept; + template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept; + template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept; + template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept; + template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept; + template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept; + template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept; + template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept; + + // 5.9, Comparison with T + template <class T> constexpr bool operator==(const optional<T>&, const T&); + template <class T> constexpr bool operator==(const T&, const optional<T>&); + template <class T> constexpr bool operator!=(const optional<T>&, const T&); + template <class T> constexpr bool operator!=(const T&, const optional<T>&); + template <class T> constexpr bool operator<(const optional<T>&, const T&); + template <class T> constexpr bool operator<(const T&, const optional<T>&); + template <class T> constexpr bool operator<=(const optional<T>&, const T&); + template <class T> constexpr bool operator<=(const T&, const optional<T>&); + template <class T> constexpr bool operator>(const optional<T>&, const T&); + template <class T> constexpr bool operator>(const T&, const optional<T>&); + template <class T> constexpr bool operator>=(const optional<T>&, const T&); + template <class T> constexpr bool operator>=(const T&, const optional<T>&); + + // 5.10, Specialized algorithms + template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below); + template <class T> constexpr optional<see below> make_optional(T&&); + + template <class T> + class optional + { + public: + typedef T value_type; + + // 5.3.1, Constructors + constexpr optional() noexcept; + constexpr optional(nullopt_t) noexcept; + optional(const optional&); + optional(optional&&) noexcept(see below); + constexpr optional(const T&); + constexpr optional(T&&); + template <class... Args> constexpr explicit optional(in_place_t, Args&&...); + template <class U, class... Args> + constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...); + + // 5.3.2, Destructor + ~optional(); + + // 5.3.3, Assignment + optional& operator=(nullopt_t) noexcept; + optional& operator=(const optional&); + optional& operator=(optional&&) noexcept(see below); + template <class U> optional& operator=(U&&); + template <class... Args> void emplace(Args&&...); + template <class U, class... Args> + void emplace(initializer_list<U>, Args&&...); + + // 5.3.4, Swap + void swap(optional&) noexcept(see below); + + // 5.3.5, Observers + constexpr T const* operator ->() const; + constexpr T* operator ->(); + constexpr T const& operator *() const &; + constexpr T& operator *() &; + constexpr T&& operator *() &&; + constexpr const T&& operator *() const &&; + constexpr explicit operator bool() const noexcept; + constexpr T const& value() const &; + constexpr T& value() &; + constexpr T&& value() &&; + constexpr const T&& value() const &&; + template <class U> constexpr T value_or(U&&) const &; + template <class U> constexpr T value_or(U&&) &&; + + private: + T* val; // exposition only + }; + + } // namespace fundamentals_v1 + } // namespace experimental + + // 5.11, Hash support + template <class T> struct hash; + template <class T> struct hash<experimental::optional<T>>; + +} // namespace std + +*/ + +#include <experimental/__config> +#include <functional> +#include <stdexcept> + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL +class _LIBCPP_EXCEPTION_ABI bad_optional_access + : public std::logic_error +{ +public: + bad_optional_access() : std::logic_error("Bad optional Access") {} + +// Get the key function ~bad_optional_access() into the dylib + virtual ~bad_optional_access() _NOEXCEPT; +}; + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL + + +#if _LIBCPP_STD_VER > 11 + +#include <initializer_list> +#include <type_traits> +#include <new> +#include <__functional_base> +#include <__undef_min_max> +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +struct in_place_t {}; +constexpr in_place_t in_place{}; + +struct nullopt_t +{ + explicit constexpr nullopt_t(int) noexcept {} +}; + +constexpr nullopt_t nullopt{0}; + +template <class _Tp, bool = is_trivially_destructible<_Tp>::value> +class __optional_storage +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + ~__optional_storage() + { + if (__engaged_) + __val_.~value_type(); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible<value_type>::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template <class _Tp> +class __optional_storage<_Tp, true> +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible<value_type>::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template <class _Tp> +class optional + : private __optional_storage<_Tp> +{ + typedef __optional_storage<_Tp> __base; +public: + typedef _Tp value_type; + + static_assert(!is_reference<value_type>::value, + "Instantiation of optional with a reference type is ill-formed."); + static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value, + "Instantiation of optional with a in_place_t type is ill-formed."); + static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value, + "Instantiation of optional with a nullopt_t type is ill-formed."); + static_assert(is_object<value_type>::value, + "Instantiation of optional with a non-object type is undefined behavior."); + static_assert(is_nothrow_destructible<value_type>::value, + "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior."); + + _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {} + _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default; + _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default; + _LIBCPP_INLINE_VISIBILITY ~optional() = default; + _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v) + : __base(__v) {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v) + : __base(_VSTD::move(__v)) {} + + template <class... _Args, + class = typename enable_if + < + is_constructible<value_type, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, _Args&&... __args) + : __base(in_place, _VSTD::forward<_Args>(__args)...) {} + + template <class _Up, class... _Args, + class = typename enable_if + < + is_constructible<value_type, initializer_list<_Up>&, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + optional& operator=(nullopt_t) noexcept + { + if (this->__engaged_) + { + this->__val_.~value_type(); + this->__engaged_ = false; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(const optional& __opt) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = __opt.__val_; + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(optional&& __opt) + noexcept(is_nothrow_move_assignable<value_type>::value && + is_nothrow_move_constructible<value_type>::value) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = _VSTD::move(__opt.__val_); + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + template <class _Up, + class = typename enable_if + < + is_same<typename remove_reference<_Up>::type, value_type>::value && + is_constructible<value_type, _Up>::value && + is_assignable<value_type&, _Up>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(_Up&& __v) + { + if (this->__engaged_) + this->__val_ = _VSTD::forward<_Up>(__v); + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); + this->__engaged_ = true; + } + return *this; + } + + template <class... _Args, + class = typename enable_if + < + is_constructible<value_type, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(_Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + template <class _Up, class... _Args, + class = typename enable_if + < + is_constructible<value_type, initializer_list<_Up>&, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + _LIBCPP_INLINE_VISIBILITY + void + swap(optional& __opt) + noexcept(is_nothrow_move_constructible<value_type>::value && + __is_nothrow_swappable<value_type>::value) + { + using _VSTD::swap; + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + swap(this->__val_, __opt.__val_); + } + else + { + if (this->__engaged_) + { + ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); + this->__val_.~value_type(); + } + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + __opt.__val_.~value_type(); + } + swap(this->__engaged_, __opt.__engaged_); + } + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + operator->() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return __operator_arrow(__has_operator_addressof<value_type>{}); + } + + _LIBCPP_INLINE_VISIBILITY + value_type* + operator->() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + const value_type& + operator*() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& + operator*() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + constexpr explicit operator bool() const noexcept {return this->__engaged_;} + + _LIBCPP_INLINE_VISIBILITY + constexpr value_type const& value() const + { + if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_optional_access(); +#else + assert(!"bad optional access"); +#endif + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& value() + { + if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_optional_access(); +#else + assert(!"bad optional access"); +#endif + return this->__val_; + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + constexpr value_type value_or(_Up&& __v) const& + { + static_assert(is_copy_constructible<value_type>::value, + "optional<T>::value_or: T must be copy constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional<T>::value_or: U must be convertible to T"); + return this->__engaged_ ? this->__val_ : + static_cast<value_type>(_VSTD::forward<_Up>(__v)); + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + value_type value_or(_Up&& __v) && + { + static_assert(is_move_constructible<value_type>::value, + "optional<T>::value_or: T must be move constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional<T>::value_or: U must be convertible to T"); + return this->__engaged_ ? _VSTD::move(this->__val_) : + static_cast<value_type>(_VSTD::forward<_Up>(__v)); + } + +private: + _LIBCPP_INLINE_VISIBILITY + value_type const* + __operator_arrow(true_type) const + { + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + __operator_arrow(false_type) const + { + return &this->__val_; + } +}; + +// Comparisons between optionals +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (static_cast<bool>(__x) != static_cast<bool>(__y)) + return false; + if (!static_cast<bool>(__x)) + return true; + return *__x == *__y; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return !(__x == __y); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (!static_cast<bool>(__y)) + return false; + if (!static_cast<bool>(__x)) + return true; + return *__x < *__y; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return __y < __x; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return !(__y < __x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + return !(__x < __y); +} + + +// Comparisons with nullopt +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>&, nullopt_t) noexcept +{ + return false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const optional<_Tp>&, nullopt_t) noexcept +{ + return true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return !static_cast<bool>(__x); +} + +// Comparisons with T +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? *__x == __v : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? *__x == __v : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? !(*__x == __v) : true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator!=(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? !(*__x == __v) : true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const optional<_Tp>& __x, const _Tp& __v) +{ + return !(__x > __v); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<=(const _Tp& __v, const optional<_Tp>& __x) +{ + return !(__v > __x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? __v < __x : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? __x < __v : true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const optional<_Tp>& __x, const _Tp& __v) +{ + return !(__x < __v); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator>=(const _Tp& __v, const optional<_Tp>& __x) +{ + return !(__v < __x); +} + + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +void +swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) +{ + __x.swap(__y); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +optional<typename decay<_Tp>::type> +make_optional(_Tp&& __v) +{ + return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v)); +} + +_LIBCPP_END_NAMESPACE_LFTS + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::optional<_Tp> > +{ + typedef std::experimental::optional<_Tp> argument_type; + typedef size_t result_type; + + _LIBCPP_INLINE_VISIBILITY + result_type operator()(const argument_type& __opt) const _NOEXCEPT + { + return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0; + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_OPTIONAL diff --git a/lib/libcxx/include/experimental/propagate_const b/lib/libcxx/include/experimental/propagate_const new file mode 100644 index 00000000000..f267ba275c2 --- /dev/null +++ b/lib/libcxx/include/experimental/propagate_const @@ -0,0 +1,576 @@ +// -*- C++ -*- +//===------------------------ propagate_const -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST +#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST +/* + propagate_const synopsis + + namespace std { namespace experimental { inline namespace fundamentals_v2 { + + // [propagate_const] + template <class T> class propagate_const; + + // [propagate_const.underlying], underlying pointer access + constexpr const _Tp& _VSTD_LFTS_V2::get_underlying(const propagate_const<T>& pt) noexcept; + constexpr T& _VSTD_LFTS_V2::get_underlying(propagate_const<T>& pt) noexcept; + + // [propagate_const.relational], relational operators + template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t); + template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu); + template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t); + template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu); + template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u); + template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu); + template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu); + + // [propagate_const.algorithms], specialized algorithms + template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below); + + template <class T> + class propagate_const + { + + public: + typedef remove_reference_t<decltype(*declval<T&>())> element_type; + + // [propagate_const.ctor], constructors + constexpr propagate_const() = default; + propagate_const(const propagate_const& p) = delete; + constexpr propagate_const(propagate_const&& p) = default; + template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below + template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below + + // [propagate_const.assignment], assignment + propagate_const& operator=(const propagate_const& p) = delete; + constexpr propagate_const& operator=(propagate_const&& p) = default; + template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu); + template <class U> constexpr propagate_const& operator=(U&& u); // see below + + // [propagate_const.const_observers], const observers + explicit constexpr operator bool() const; + constexpr const element_type* operator->() const; + constexpr operator const element_type*() const; // Not always defined + constexpr const element_type& operator*() const; + constexpr const element_type* get() const; + + // [propagate_const.non_const_observers], non-const observers + constexpr element_type* operator->(); + constexpr operator element_type*(); // Not always defined + constexpr element_type& operator*(); + constexpr element_type* get(); + + // [propagate_const.modifiers], modifiers + constexpr void swap(propagate_const& pt) noexcept(see below) + + private: + T t_; // exposition only + }; + + } // namespace fundamentals_v2 + } // namespace experimental + + // [propagate_const.hash], hash support + template <class T> struct hash<experimental::fundamentals_v2::propagate_const<T>>; + + // [propagate_const.comparison_function_objects], comparison function objects + template <class T> struct equal_to<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct not_equal_to<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct less<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct greater<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct less_equal<experimental::fundamentals_v2::propagate_const<T>>; + template <class T> struct greater_equal<experimental::fundamentals_v2::propagate_const<T>>; + +} // namespace std + +*/ + +#include <experimental/__config> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER > 11 + +#include <type_traits> +#include <utility> +#include <functional> + +_LIBCPP_BEGIN_NAMESPACE_LFTS_V2 + + +template <class _Tp> +class propagate_const; +template <class _Up> _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; +template <class _Up> _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; + +template <class _Tp> +class propagate_const +{ +public: + typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type; + + static_assert(!is_array<_Tp>::value, + "Instantiation of propagate_const with an array type is ill-formed."); + static_assert(!is_reference<_Tp>::value, + "Instantiation of propagate_const with a reference type is ill-formed."); + static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value), + "Instantiation of propagate_const with a function-pointer type is ill-formed."); + static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value), + "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed."); + +private: + template <class _Up> + static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) + { + return __u; + } + + template <class _Up> + static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) + { + return __get_pointer(__u.get()); + } + + template <class _Up> + static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) + { + return __u; + } + + template <class _Up> + static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) + { + return __get_pointer(__u.get()); + } + + template <class _Up> + struct __is_propagate_const : false_type + { + }; + + template <class _Up> + struct __is_propagate_const<propagate_const<_Up>> : true_type + { + }; + + _Tp __t_; + +public: + + template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& ::_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; + template <class _Up> friend _LIBCPP_CONSTEXPR _Up& ::_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; + + _LIBCPP_CONSTEXPR propagate_const() = default; + + propagate_const(const propagate_const&) = delete; + + _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default; + + template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value && + is_constructible<_Tp, _Up&&>::value,bool> = true> + explicit _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) + : __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu))) + { + } + + template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && + is_constructible<_Tp, _Up&&>::value,bool> = false> + _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) + : __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu))) + { + } + + template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value && + is_constructible<_Tp, _Up&&>::value && + !__is_propagate_const<decay_t<_Up>>::value,bool> = true> + explicit _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) + : __t_(std::forward<_Up>(__u)) + { + } + + template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && + is_constructible<_Tp, _Up&&>::value && + !__is_propagate_const<decay_t<_Up>>::value,bool> = false> + _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) + : __t_(std::forward<_Up>(__u)) + { + } + + propagate_const& operator=(const propagate_const&) = delete; + + _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default; + + template <class _Up> + _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) + { + __t_ = std::move(_VSTD_LFTS_V2::get_underlying(__pu)); + return *this; + } + + template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>> + _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) + { + __t_ = std::forward<_Up>(__u); + return *this; + } + + _LIBCPP_CONSTEXPR const element_type* get() const + { + return __get_pointer(__t_); + } + + _LIBCPP_CONSTEXPR element_type* get() + { + return __get_pointer(__t_); + } + + explicit _LIBCPP_CONSTEXPR operator bool() const + { + return get() != nullptr; + } + + _LIBCPP_CONSTEXPR const element_type* operator->() const + { + return get(); + } + + template <class _Tp_ = _Tp, class _Up = enable_if_t<is_convertible< + const _Tp_, const element_type *>::value>> + _LIBCPP_CONSTEXPR operator const element_type *() const { + return get(); + } + + _LIBCPP_CONSTEXPR const element_type& operator*() const + { + return *get(); + } + + _LIBCPP_CONSTEXPR element_type* operator->() + { + return get(); + } + + template <class _Tp_ = _Tp, class _Up = enable_if_t< + is_convertible<_Tp_, element_type *>::value>> + _LIBCPP_CONSTEXPR operator element_type *() { + return get(); + } + + _LIBCPP_CONSTEXPR element_type& operator*() + { + return *get(); + } + + _LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) + { + using _VSTD::swap; + swap(__t_, __pt.__t_); + } +}; + + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) == nullptr; +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) +{ + return nullptr == _VSTD_LFTS_V2::get_underlying(__pt); +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) != nullptr; +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) +{ + return nullptr != _VSTD_LFTS_V2::get_underlying(__pt); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) == _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) != _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) < _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) > _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) <= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, + const propagate_const<_Up>& __pu) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) >= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) == __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) != __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) < __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) > __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) <= __u; +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) +{ + return _VSTD_LFTS_V2::get_underlying(__pt) >= __u; +} + + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t == _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t != _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t < _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t > _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t <= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp, class _Up> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) +{ + return __t >= _VSTD_LFTS_V2::get_underlying(__pu); +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) +{ + using _VSTD::swap; + swap(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT +{ + return __pt.__t_; +} + +template <class _Tp> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT +{ + return __pt.__t_; +} + +_LIBCPP_END_NAMESPACE_LFTS_V2 + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct hash<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef size_t result_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type; + + size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const + { + return std::hash<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1)); + } +}; + +template <class _Tp> +struct equal_to<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct not_equal_to<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::not_equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct less<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::less<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct greater<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::greater<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct less_equal<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::less_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +template <class _Tp> +struct greater_equal<experimental::fundamentals_v2::propagate_const<_Tp>> +{ + typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; + typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; + + bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, + const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const + { + return std::greater_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST + diff --git a/lib/libcxx/include/experimental/ratio b/lib/libcxx/include/experimental/ratio new file mode 100644 index 00000000000..757f24e0861 --- /dev/null +++ b/lib/libcxx/include/experimental/ratio @@ -0,0 +1,77 @@ +// -*- C++ -*- +//===------------------------------ ratio ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_RATIO +#define _LIBCPP_EXPERIMENTAL_RATIO + +/** + experimental/ratio synopsis + C++1y +#include <ratio> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.11.5, ratio comparison + template <class R1, class R2> constexpr bool ratio_equal_v + = ratio_equal<R1, R2>::value; + template <class R1, class R2> constexpr bool ratio_not_equal_v + = ratio_not_equal<R1, R2>::value; + template <class R1, class R2> constexpr bool ratio_less_v + = ratio_less<R1, R2>::value; + template <class R1, class R2> constexpr bool ratio_less_equal_v + = ratio_less_equal<R1, R2>::value; + template <class R1, class R2> constexpr bool ratio_greater_v + = ratio_greater<R1, R2>::value; + template <class R1, class R2> constexpr bool ratio_greater_equal_v + = ratio_greater_equal<R1, R2>::value; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <ratio> + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v + = ratio_equal<_R1, _R2>::value; + +template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v + = ratio_not_equal<_R1, _R2>::value; + +template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v + = ratio_less<_R1, _R2>::value; + +template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v + = ratio_less_equal<_R1, _R2>::value; + +template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v + = ratio_greater<_R1, _R2>::value; + +template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v + = ratio_greater_equal<_R1, _R2>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif // _LIBCPP_EXPERIMENTAL_RATIO diff --git a/lib/libcxx/include/experimental/regex b/lib/libcxx/include/experimental/regex new file mode 100644 index 00000000000..d38891c374b --- /dev/null +++ b/lib/libcxx/include/experimental/regex @@ -0,0 +1,62 @@ +// -*- C++ -*- +//===----------------------------- regex ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_REGEX +#define _LIBCPP_EXPERIMENTAL_REGEX +/* + experimental/regex synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class BidirectionalIterator> + using match_results = + std::match_results<BidirectionalIterator, + polymorphic_allocator<sub_match<BidirectionalIterator>>>; + + typedef match_results<const char*> cmatch; + typedef match_results<const wchar_t*> wcmatch; + typedef match_results<string::const_iterator> smatch; + typedef match_results<wstring::const_iterator> wsmatch; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <regex> +#include <experimental/string> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _BiDirIter> +using match_results = + _VSTD::match_results<_BiDirIter, + polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>; + +typedef match_results<const char*> cmatch; +typedef match_results<const wchar_t*> wcmatch; +typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch; +typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_REGEX */ diff --git a/lib/libcxx/include/experimental/set b/lib/libcxx/include/experimental/set new file mode 100644 index 00000000000..20cf6d4a389 --- /dev/null +++ b/lib/libcxx/include/experimental/set @@ -0,0 +1,57 @@ +// -*- C++ -*- +//===--------------------------- list ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_SET +#define _LIBCPP_EXPERIMENTAL_SET +/* + experimental/set synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class Key, class T, class Compare = less<Key>> + using set = std::set<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + + template <class Key, class T, class Compare = less<Key>> + using multiset = std::multiset<Key, T, Compare, + polymorphic_allocator<pair<const Key,T>>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <set> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Value, class _Compare = less<_Value>> +using set = _VSTD::set<_Value, _Compare, + polymorphic_allocator<_Value>>; + +template <class _Value, class _Compare = less<_Value>> +using multiset = _VSTD::multiset<_Value, _Compare, + polymorphic_allocator<_Value>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_SET */ diff --git a/lib/libcxx/include/experimental/string b/lib/libcxx/include/experimental/string new file mode 100644 index 00000000000..8b8545128f2 --- /dev/null +++ b/lib/libcxx/include/experimental/string @@ -0,0 +1,62 @@ +// -*- C++ -*- +//===--------------------------- string ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_STRING +#define _LIBCPP_EXPERIMENTAL_STRING +/* + experimental/string synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + // basic_string using polymorphic allocator in namespace pmr + template <class charT, class traits = char_traits<charT>> + using basic_string = + std::basic_string<charT, traits, polymorphic_allocator<charT>>; + + // basic_string typedef names using polymorphic allocator in namespace + // std::experimental::pmr + typedef basic_string<char> string; + typedef basic_string<char16_t> u16string; + typedef basic_string<char32_t> u32string; + typedef basic_string<wchar_t> wstring; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <string> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _CharT, class _Traits = char_traits<_CharT>> +using basic_string = + _VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>; + +typedef basic_string<char> string; +typedef basic_string<char16_t> u16string; +typedef basic_string<char32_t> u32string; +typedef basic_string<wchar_t> wstring; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_STRING */ diff --git a/lib/libcxx/include/experimental/string_view b/lib/libcxx/include/experimental/string_view new file mode 100644 index 00000000000..0a7239b4c0b --- /dev/null +++ b/lib/libcxx/include/experimental/string_view @@ -0,0 +1,813 @@ +// -*- C++ -*- +//===------------------------ string_view ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_LFTS_STRING_VIEW +#define _LIBCPP_LFTS_STRING_VIEW + +/* +string_view synopsis + +namespace std { + namespace experimental { + inline namespace library_fundamentals_v1 { + + // 7.2, Class template basic_string_view + template<class charT, class traits = char_traits<charT>> + class basic_string_view; + + // 7.9, basic_string_view non-member comparison functions + template<class charT, class traits> + constexpr bool operator==(basic_string_view<charT, traits> x, + basic_string_view<charT, traits> y) noexcept; + template<class charT, class traits> + constexpr bool operator!=(basic_string_view<charT, traits> x, + basic_string_view<charT, traits> y) noexcept; + template<class charT, class traits> + constexpr bool operator< (basic_string_view<charT, traits> x, + basic_string_view<charT, traits> y) noexcept; + template<class charT, class traits> + constexpr bool operator> (basic_string_view<charT, traits> x, + basic_string_view<charT, traits> y) noexcept; + template<class charT, class traits> + constexpr bool operator<=(basic_string_view<charT, traits> x, + basic_string_view<charT, traits> y) noexcept; + template<class charT, class traits> + constexpr bool operator>=(basic_string_view<charT, traits> x, + basic_string_view<charT, traits> y) noexcept; + // see below, sufficient additional overloads of comparison functions + + // 7.10, Inserters and extractors + template<class charT, class traits> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, + basic_string_view<charT, traits> str); + + // basic_string_view typedef names + typedef basic_string_view<char> string_view; + typedef basic_string_view<char16_t> u16string_view; + typedef basic_string_view<char32_t> u32string_view; + typedef basic_string_view<wchar_t> wstring_view; + + template<class charT, class traits = char_traits<charT>> + class basic_string_view { + public: + // types + typedef traits traits_type; + typedef charT value_type; + typedef charT* pointer; + typedef const charT* const_pointer; + typedef charT& reference; + typedef const charT& const_reference; + typedef implementation-defined const_iterator; + typedef const_iterator iterator; + typedef reverse_iterator<const_iterator> const_reverse_iterator; + typedef const_reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + static constexpr size_type npos = size_type(-1); + + // 7.3, basic_string_view constructors and assignment operators + constexpr basic_string_view() noexcept; + constexpr basic_string_view(const basic_string_view&) noexcept = default; + basic_string_view& operator=(const basic_string_view&) noexcept = default; + template<class Allocator> + basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept; + constexpr basic_string_view(const charT* str); + constexpr basic_string_view(const charT* str, size_type len); + + // 7.4, basic_string_view iterator support + constexpr const_iterator begin() const noexcept; + constexpr const_iterator end() const noexcept; + constexpr const_iterator cbegin() const noexcept; + constexpr const_iterator cend() const noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crbegin() const noexcept; + const_reverse_iterator crend() const noexcept; + + // 7.5, basic_string_view capacity + constexpr size_type size() const noexcept; + constexpr size_type length() const noexcept; + constexpr size_type max_size() const noexcept; + constexpr bool empty() const noexcept; + + // 7.6, basic_string_view element access + constexpr const_reference operator[](size_type pos) const; + constexpr const_reference at(size_type pos) const; + constexpr const_reference front() const; + constexpr const_reference back() const; + constexpr const_pointer data() const noexcept; + + // 7.7, basic_string_view modifiers + constexpr void clear() noexcept; + constexpr void remove_prefix(size_type n); + constexpr void remove_suffix(size_type n); + constexpr void swap(basic_string_view& s) noexcept; + + // 7.8, basic_string_view string operations + template<class Allocator> + explicit operator basic_string<charT, traits, Allocator>() const; + template<class Allocator = allocator<charT>> + basic_string<charT, traits, Allocator> to_string( + const Allocator& a = Allocator()) const; + + size_type copy(charT* s, size_type n, size_type pos = 0) const; + + constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; + constexpr int compare(basic_string_view s) const noexcept; + constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; + constexpr int compare(size_type pos1, size_type n1, + basic_string_view s, size_type pos2, size_type n2) const; + constexpr int compare(const charT* s) const; + constexpr int compare(size_type pos1, size_type n1, const charT* s) const; + constexpr int compare(size_type pos1, size_type n1, + const charT* s, size_type n2) const; + constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; + constexpr size_type find(charT c, size_type pos = 0) const noexcept; + constexpr size_type find(const charT* s, size_type pos, size_type n) const; + constexpr size_type find(const charT* s, size_type pos = 0) const; + constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; + constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; + constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; + constexpr size_type rfind(const charT* s, size_type pos = npos) const; + constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; + constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; + constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; + constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; + constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; + constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; + constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; + constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; + constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; + constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept; + constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; + constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; + constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; + + private: + const_pointer data_; // exposition only + size_type size_; // exposition only + }; + + } // namespace fundamentals_v1 + } // namespace experimental + + // 7.11, Hash support + template <class T> struct hash; + template <> struct hash<experimental::string_view>; + template <> struct hash<experimental::u16string_view>; + template <> struct hash<experimental::u32string_view>; + template <> struct hash<experimental::wstring_view>; + +} // namespace std + + +*/ + +#include <experimental/__config> + +#include <string> +#include <algorithm> +#include <iterator> +#include <ostream> +#include <stdexcept> +#include <iomanip> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + + template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> > + class _LIBCPP_TYPE_VIS_ONLY basic_string_view { + public: + // types + typedef _Traits traits_type; + typedef _CharT value_type; + typedef const _CharT* pointer; + typedef const _CharT* const_pointer; + typedef const _CharT& reference; + typedef const _CharT& const_reference; + typedef const_pointer const_iterator; // See [string.view.iterators] + typedef const_iterator iterator; + typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; + typedef const_reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); + + // [string.view.cons], construct/copy + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view(const basic_string_view&) _NOEXCEPT = default; + + _LIBCPP_INLINE_VISIBILITY + basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; + + template<class _Allocator> + _LIBCPP_INLINE_VISIBILITY + basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT + : __data (__str.data()), __size(__str.size()) {} + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view(const _CharT* __s, size_type __len) + : __data(__s), __size(__len) + { +// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + basic_string_view(const _CharT* __s) + : __data(__s), __size(_Traits::length(__s)) {} + + // [string.view.iterators], iterators + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator begin() const _NOEXCEPT { return cbegin(); } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator end() const _NOEXCEPT { return cend(); } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator cbegin() const _NOEXCEPT { return __data; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_iterator cend() const _NOEXCEPT { return __data + __size; } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } + + _LIBCPP_INLINE_VISIBILITY + const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } + + // [string.view.capacity], capacity + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + size_type size() const _NOEXCEPT { return __size; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + size_type length() const _NOEXCEPT { return __size; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); } + + _LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY + empty() const _NOEXCEPT { return __size == 0; } + + // [string.view.access], element access + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference operator[](size_type __pos) const { return __data[__pos]; } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference at(size_type __pos) const + { + return __pos >= size() + ? (__libcpp_throw(out_of_range("string_view::at")), __data[0]) + : __data[__pos]; + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference front() const + { + return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0]; + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_reference back() const + { + return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1]; + } + + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + const_pointer data() const _NOEXCEPT { return __data; } + + // [string.view.modifiers], modifiers: + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT + { + __data = nullptr; + __size = 0; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void remove_prefix(size_type __n) _NOEXCEPT + { + _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()"); + __data += __n; + __size -= __n; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void remove_suffix(size_type __n) _NOEXCEPT + { + _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()"); + __size -= __n; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + void swap(basic_string_view& __other) _NOEXCEPT + { + const value_type *__p = __data; + __data = __other.__data; + __other.__data = __p; + + size_type __sz = __size; + __size = __other.__size; + __other.__size = __sz; +// _VSTD::swap( __data, __other.__data ); +// _VSTD::swap( __size, __other.__size ); + } + + // [string.view.ops], string operations: + template<class _Allocator> + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const + { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); } + + template<class _Allocator = allocator<_CharT> > + _LIBCPP_INLINE_VISIBILITY + basic_string<_CharT, _Traits, _Allocator> + to_string( const _Allocator& __a = _Allocator()) const + { return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); } + + size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const + { + if ( __pos > size()) + __libcpp_throw(out_of_range("string_view::copy")); + size_type __rlen = _VSTD::min( __n, size() - __pos ); + _VSTD::copy_n(begin() + __pos, __rlen, __s ); + return __rlen; + } + + _LIBCPP_CONSTEXPR + basic_string_view substr(size_type __pos = 0, size_type __n = npos) const + { +// if (__pos > size()) +// throw out_of_range("string_view::substr"); +// size_type __rlen = _VSTD::min( __n, size() - __pos ); +// return basic_string_view(data() + __pos, __rlen); + return __pos > size() + ? (__libcpp_throw((out_of_range("string_view::substr"))), basic_string_view()) + : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT + { + size_type __rlen = _VSTD::min( size(), __sv.size()); + int __retval = _Traits::compare(data(), __sv.data(), __rlen); + if ( __retval == 0 ) // first __rlen chars matched + __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 ); + return __retval; + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const + { + return substr(__pos1, __n1).compare(__sv); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare( size_type __pos1, size_type __n1, + basic_string_view _sv, size_type __pos2, size_type __n2) const + { + return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(const _CharT* __s) const + { + return compare(basic_string_view(__s)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(size_type __pos1, size_type __n1, const _CharT* __s) const + { + return substr(__pos1, __n1).compare(basic_string_view(__s)); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const + { + return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); + } + + // find + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); + return _VSTD::__str_find<value_type, size_type, traits_type, npos> + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT + { + return _VSTD::__str_find<value_type, size_type, traits_type, npos> + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); + return _VSTD::__str_find<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find(const _CharT* __s, size_type __pos = 0) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr"); + return _VSTD::__str_find<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // rfind + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT + { + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type rfind(const _CharT* __s, size_type __pos=npos) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr"); + return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_first_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr"); + return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT + { return find(__c, __pos); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); + return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_of(const _CharT* __s, size_type __pos=0) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr"); + return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_last_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr"); + return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT + { return rfind(__c, __pos); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); + return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_of(const _CharT* __s, size_type __pos=npos) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr"); + return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_first_not_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr"); + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT + { + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); + return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + // find_last_not_of + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT + { + _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr"); + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __s.data(), __pos, __s.size()); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT + { + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __c, __pos); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, __n); + } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const + { + _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); + return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> + (data(), size(), __s, __pos, traits_type::length(__s)); + } + + private: + const value_type* __data; + size_type __size; + }; + + + // [string.view.comparison] + // operator == + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator==(basic_string_view<_CharT, _Traits> __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator==(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; + } + + + // operator != + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) + return true; + return __lhs.compare(__rhs) != 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator!=(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) + return true; + return __lhs.compare(__rhs) != 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + if ( __lhs.size() != __rhs.size()) + return true; + return __lhs.compare(__rhs) != 0; + } + + + // operator < + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) < 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) < 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) < 0; + } + + + // operator > + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) > 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) > 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) > 0; + } + + + // operator <= + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) <= 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<=(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) <= 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) <= 0; + } + + + // operator >= + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) >= 0; + } + + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>=(basic_string_view<_CharT, _Traits> __lhs, + typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) >= 0; + } + + template<class _CharT, class _Traits> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, + basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT + { + return __lhs.compare(__rhs) >= 0; + } + + + // [string.view.io] + template<class _CharT, class _Traits> + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) + { + return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size()); + } + + typedef basic_string_view<char> string_view; + typedef basic_string_view<char16_t> u16string_view; + typedef basic_string_view<char32_t> u32string_view; + typedef basic_string_view<wchar_t> wstring_view; + +_LIBCPP_END_NAMESPACE_LFTS +_LIBCPP_BEGIN_NAMESPACE_STD + +// [string.view.hash] +// Shamelessly stolen from <string> +template<class _CharT, class _Traits> +struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> > + : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t> +{ + size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT; +}; + +template<class _CharT, class _Traits> +size_t +hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()( + const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT +{ + return __do_string_hash(__val.data(), __val.data() + __val.size()); +} + +#if _LIBCPP_STD_VER > 11 +template <class _CharT, class _Traits> +__quoted_output_proxy<_CharT, const _CharT *, _Traits> +quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv, + _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_output_proxy<_CharT, const _CharT *, _Traits> + ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape ); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_LFTS_STRING_VIEW diff --git a/lib/libcxx/include/experimental/system_error b/lib/libcxx/include/experimental/system_error new file mode 100644 index 00000000000..2ec23854461 --- /dev/null +++ b/lib/libcxx/include/experimental/system_error @@ -0,0 +1,63 @@ +// -*- C++ -*- +//===-------------------------- system_error ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR +#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR + +/** + experimental/system_error synopsis + +// C++1y + +#include <system_error> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 19.5, System error support + template <class T> constexpr bool is_error_code_enum_v + = is_error_code_enum<T>::value; + template <class T> constexpr bool is_error_condition_enum_v + = is_error_condition_enum<T>::value; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <system_error> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_code_enum_v + = is_error_code_enum<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_condition_enum_v + = is_error_condition_enum<_Tp>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR */ diff --git a/lib/libcxx/include/experimental/tuple b/lib/libcxx/include/experimental/tuple new file mode 100644 index 00000000000..e00d2ec1a92 --- /dev/null +++ b/lib/libcxx/include/experimental/tuple @@ -0,0 +1,82 @@ +// -*- C++ -*- +//===----------------------------- tuple ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_TUPLE +#define _LIBCPP_EXPERIMENTAL_TUPLE + +/* + experimental/tuple synopsis + +// C++1y + +#include <tuple> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.4.2.5, tuple helper classes + template <class T> constexpr size_t tuple_size_v + = tuple_size<T>::value; + + // 3.2.2, Calling a function with a tuple of arguments + template <class F, class Tuple> + constexpr decltype(auto) apply(F&& f, Tuple&& t); + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +# include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +# include <tuple> +# include <utility> +# include <__functional_base> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +template <class _Tp> +_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value; +#endif + +template <class _Fn, class _Tuple, size_t ..._Id> +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 +decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t, + integer_sequence<size_t, _Id...>) { + return _VSTD::__invoke_constexpr( + _VSTD::forward<_Fn>(__f), + _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))... + ); +} + +template <class _Fn, class _Tuple> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +decltype(auto) apply(_Fn && __f, _Tuple && __t) { + return _VSTD_LFTS::__apply_tuple_impl( + _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t), + make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>() + ); +} + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */ diff --git a/lib/libcxx/include/experimental/type_traits b/lib/libcxx/include/experimental/type_traits new file mode 100644 index 00000000000..ae49fc176c0 --- /dev/null +++ b/lib/libcxx/include/experimental/type_traits @@ -0,0 +1,427 @@ +// -*- C++ -*- +//===-------------------------- type_traits -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS +#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS + +/** + experimental/type_traits synopsis + +// C++1y +#include <type_traits> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.10.4.1, primary type categories + template <class T> constexpr bool is_void_v + = is_void<T>::value; + template <class T> constexpr bool is_null_pointer_v + = is_null_pointer<T>::value; + template <class T> constexpr bool is_integral_v + = is_integral<T>::value; + template <class T> constexpr bool is_floating_point_v + = is_floating_point<T>::value; + template <class T> constexpr bool is_array_v + = is_array<T>::value; + template <class T> constexpr bool is_pointer_v + = is_pointer<T>::value; + template <class T> constexpr bool is_lvalue_reference_v + = is_lvalue_reference<T>::value; + template <class T> constexpr bool is_rvalue_reference_v + = is_rvalue_reference<T>::value; + template <class T> constexpr bool is_member_object_pointer_v + = is_member_object_pointer<T>::value; + template <class T> constexpr bool is_member_function_pointer_v + = is_member_function_pointer<T>::value; + template <class T> constexpr bool is_enum_v + = is_enum<T>::value; + template <class T> constexpr bool is_union_v + = is_union<T>::value; + template <class T> constexpr bool is_class_v + = is_class<T>::value; + template <class T> constexpr bool is_function_v + = is_function<T>::value; + + // See C++14 20.10.4.2, composite type categories + template <class T> constexpr bool is_reference_v + = is_reference<T>::value; + template <class T> constexpr bool is_arithmetic_v + = is_arithmetic<T>::value; + template <class T> constexpr bool is_fundamental_v + = is_fundamental<T>::value; + template <class T> constexpr bool is_object_v + = is_object<T>::value; + template <class T> constexpr bool is_scalar_v + = is_scalar<T>::value; + template <class T> constexpr bool is_compound_v + = is_compound<T>::value; + template <class T> constexpr bool is_member_pointer_v + = is_member_pointer<T>::value; + + // See C++14 20.10.4.3, type properties + template <class T> constexpr bool is_const_v + = is_const<T>::value; + template <class T> constexpr bool is_volatile_v + = is_volatile<T>::value; + template <class T> constexpr bool is_trivial_v + = is_trivial<T>::value; + template <class T> constexpr bool is_trivially_copyable_v + = is_trivially_copyable<T>::value; + template <class T> constexpr bool is_standard_layout_v + = is_standard_layout<T>::value; + template <class T> constexpr bool is_pod_v + = is_pod<T>::value; + template <class T> constexpr bool is_literal_type_v + = is_literal_type<T>::value; + template <class T> constexpr bool is_empty_v + = is_empty<T>::value; + template <class T> constexpr bool is_polymorphic_v + = is_polymorphic<T>::value; + template <class T> constexpr bool is_abstract_v + = is_abstract<T>::value; + template <class T> constexpr bool is_final_v + = is_final<T>::value; + template <class T> constexpr bool is_signed_v + = is_signed<T>::value; + template <class T> constexpr bool is_unsigned_v + = is_unsigned<T>::value; + template <class T, class... Args> constexpr bool is_constructible_v + = is_constructible<T, Args...>::value; + template <class T> constexpr bool is_default_constructible_v + = is_default_constructible<T>::value; + template <class T> constexpr bool is_copy_constructible_v + = is_copy_constructible<T>::value; + template <class T> constexpr bool is_move_constructible_v + = is_move_constructible<T>::value; + template <class T, class U> constexpr bool is_assignable_v + = is_assignable<T, U>::value; + template <class T> constexpr bool is_copy_assignable_v + = is_copy_assignable<T>::value; + template <class T> constexpr bool is_move_assignable_v + = is_move_assignable<T>::value; + template <class T> constexpr bool is_destructible_v + = is_destructible<T>::value; + template <class T, class... Args> constexpr bool is_trivially_constructible_v + = is_trivially_constructible<T, Args...>::value; + template <class T> constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible<T>::value; + template <class T> constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<T>::value; + template <class T> constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible<T>::value; + template <class T, class U> constexpr bool is_trivially_assignable_v + = is_trivially_assignable<T, U>::value; + template <class T> constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<T>::value; + template <class T> constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable<T>::value; + template <class T> constexpr bool is_trivially_destructible_v + = is_trivially_destructible<T>::value; + template <class T, class... Args> constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible<T, Args...>::value; + template <class T> constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<T>::value; + template <class T> constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<T>::value; + template <class T> constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<T>::value; + template <class T, class U> constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable<T, U>::value; + template <class T> constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<T>::value; + template <class T> constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<T>::value; + template <class T> constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible<T>::value; + template <class T> constexpr bool has_virtual_destructor_v + = has_virtual_destructor<T>::value; + + // See C++14 20.10.5, type property queries + template <class T> constexpr size_t alignment_of_v + = alignment_of<T>::value; + template <class T> constexpr size_t rank_v + = rank<T>::value; + template <class T, unsigned I = 0> constexpr size_t extent_v + = extent<T, I>::value; + + // See C++14 20.10.6, type relations + template <class T, class U> constexpr bool is_same_v + = is_same<T, U>::value; + template <class Base, class Derived> constexpr bool is_base_of_v + = is_base_of<Base, Derived>::value; + template <class From, class To> constexpr bool is_convertible_v + = is_convertible<From, To>::value; + + // 3.3.2, Other type transformations + template <class> class invocation_type; // not defined + template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>; + template <class> class raw_invocation_type; // not defined + template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>; + + template <class T> + using invocation_type_t = typename invocation_type<T>::type; + template <class T> + using raw_invocation_type_t = typename raw_invocation_type<T>::type; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +// C++14 20.10.4.1, primary type categories + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; + +// C++14 20.10.4.2, composite type categories + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; + +// C++14 20.10.4.3, type properties + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; + +template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Ts...>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Up>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; + +template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Ts...>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Up>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; + +template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Ts...>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Up>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; + +// C++14 20.10.5, type properties queries + +template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; + +template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Id>::value; + +// C++14 20.10.6, type relations + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Tp, _Up>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v + = is_convertible<_Tp, _Up>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +// 3.3.2, Other type transformations +/* +template <class> +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type; + +template <class _Fn, class ..._Args> +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>; + +template <class> +class _LIBCPP_TYPE_VIS_ONLY invokation_type; + +template <class _Fn, class ..._Args> +class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>; + +template <class _Tp> +using invokation_type_t = typename invokation_type<_Tp>::type; + +template <class _Tp> +using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; +*/ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */ diff --git a/lib/libcxx/include/experimental/unordered_map b/lib/libcxx/include/experimental/unordered_map new file mode 100644 index 00000000000..1f998c2d4c7 --- /dev/null +++ b/lib/libcxx/include/experimental/unordered_map @@ -0,0 +1,65 @@ +// -*- C++ -*- +//===------------------------- unordered_map ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_MAP +#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP +/* + experimental/unordered_map synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class Key, class T, + class Hash = hash<Key>, + class Pred = equal_to<Key>> + using unordered_map = + std::unordered_map<Key, T, Hash, Pred, + polymorphic_allocator<pair<const Key,T>>>; + + template <class Key, class T, + class Hash = hash<Key>, + class Pred = equal_to<Key>> + using unordered_multimap = + std::unordered_multimap<Key, T, Hash, Pred, + polymorphic_allocator<pair<const Key,T>>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <unordered_map> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Key, class _Value, + class _Hash = hash<_Key>, class _Pred = equal_to<_Key>> +using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred, + polymorphic_allocator<pair<const _Key, _Value>>>; + +template <class _Key, class _Value, + class _Hash = hash<_Key>, class _Pred = equal_to<_Key>> +using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred, + polymorphic_allocator<pair<const _Key, _Value>>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */ diff --git a/lib/libcxx/include/experimental/unordered_set b/lib/libcxx/include/experimental/unordered_set new file mode 100644 index 00000000000..d00a8375340 --- /dev/null +++ b/lib/libcxx/include/experimental/unordered_set @@ -0,0 +1,59 @@ +// -*- C++ -*- +//===------------------------- unordered_set ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_SET +#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET +/* + experimental/unordered_set synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T, class Hash = hash<T>, class Pred = equal_to<T>> + using unordered_set = std::unordered_set<T, Hash, Pred, + polymorphic_allocator<T>>; + + template <class T, class Hash = hash<T>, class Pred = equal_to<T>> + using unordered_multiset = std::unordered_multiset<T, Hash, Pred, + polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <unordered_set> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _Value, + class _Hash = hash<_Value>, class _Pred = equal_to<_Value>> +using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred, + polymorphic_allocator<_Value>>; + +template <class _Value, + class _Hash = hash<_Value>, class _Pred = equal_to<_Value>> +using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred, + polymorphic_allocator<_Value>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */ diff --git a/lib/libcxx/include/experimental/utility b/lib/libcxx/include/experimental/utility new file mode 100644 index 00000000000..b5fca6c775b --- /dev/null +++ b/lib/libcxx/include/experimental/utility @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===-------------------------- utility ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_UTILITY +#define _LIBCPP_EXPERIMENTAL_UTILITY + +/* + experimental/utility synopsis + +// C++1y + +#include <utility> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + 3.1.2, erased-type placeholder + struct erased_type { }; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <utility> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + + struct _LIBCPP_TYPE_VIS_ONLY erased_type { }; + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */ diff --git a/lib/libcxx/include/experimental/vector b/lib/libcxx/include/experimental/vector new file mode 100644 index 00000000000..bd10492bfef --- /dev/null +++ b/lib/libcxx/include/experimental/vector @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===--------------------------- vector ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_VECTOR +#define _LIBCPP_EXPERIMENTAL_VECTOR +/* + experimental/vector synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { +namespace pmr { + + template <class T> + using vector = std::vector<T, polymorphic_allocator<T>>; + +} // namespace pmr +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <vector> +#include <experimental/memory_resource> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR + +template <class _ValueT> +using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>; + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */ |