diff options
Diffstat (limited to 'lib/libcxx/include/experimental')
-rw-r--r-- | lib/libcxx/include/experimental/__config | 7 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/algorithm | 69 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/any | 20 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/coroutine | 296 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/dynarray | 53 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/filesystem | 214 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/functional | 9 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/iterator | 10 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/memory_resource | 31 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/numeric | 119 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/optional | 102 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/propagate_const | 12 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/string_view | 17 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/type_traits | 111 | ||||
-rw-r--r-- | lib/libcxx/include/experimental/utility | 2 |
15 files changed, 829 insertions, 243 deletions
diff --git a/lib/libcxx/include/experimental/__config b/lib/libcxx/include/experimental/__config index 9a7bbe85d8d..37f88c166dd 100644 --- a/lib/libcxx/include/experimental/__config +++ b/lib/libcxx/include/experimental/__config @@ -44,6 +44,13 @@ #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES \ + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace coroutines_v1 { + +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES \ + } _LIBCPP_END_NAMESPACE_EXPERIMENTAL + +#define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1 #define _VSTD_FS ::std::experimental::filesystem::v1 diff --git a/lib/libcxx/include/experimental/algorithm b/lib/libcxx/include/experimental/algorithm index 3902111c54e..a6a28f07181 100644 --- a/lib/libcxx/include/experimental/algorithm +++ b/lib/libcxx/include/experimental/algorithm @@ -39,17 +39,18 @@ SampleIterator sample(PopulationIterator first, PopulationIterator last, #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 +_LIBCPP_PUSH_MACROS +#include <__undef_macros> +_LIBCPP_BEGIN_NAMESPACE_LFTS + template <class _ForwardIterator, class _Searcher> _LIBCPP_INLINE_VISIBILITY _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) @@ -58,63 +59,15 @@ _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searc 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()); +inline _LIBCPP_INLINE_VISIBILITY +_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last, + _SampleIterator __output_iter, _Distance __n, + _UniformRandomNumberGenerator &&__g) { + return _VSTD::__sample(__first, __last, __output_iter, __n, __g); } _LIBCPP_END_NAMESPACE_LFTS +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */ diff --git a/lib/libcxx/include/experimental/any b/lib/libcxx/include/experimental/any index 4c732496c52..083a2909033 100644 --- a/lib/libcxx/include/experimental/any +++ b/lib/libcxx/include/experimental/any @@ -82,7 +82,6 @@ inline namespace fundamentals_v1 { #include <typeinfo> #include <type_traits> #include <cstdlib> -#include <cassert> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -90,7 +89,7 @@ inline namespace fundamentals_v1 { _LIBCPP_BEGIN_NAMESPACE_LFTS -class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast +class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { public: virtual const char* what() const _NOEXCEPT; @@ -98,13 +97,14 @@ public: #if _LIBCPP_STD_VER > 11 // C++ > 11 -_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY -inline void __throw_bad_any_cast() +_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST +void __throw_bad_any_cast() { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_any_cast(); #else - assert(!"bad_any_cast"); + _VSTD::abort(); #endif } @@ -293,7 +293,7 @@ namespace __any_imp { template <class _Tp> - struct _LIBCPP_TYPE_VIS_ONLY _SmallHandler + struct _LIBCPP_TEMPLATE_VIS _SmallHandler { _LIBCPP_INLINE_VISIBILITY static void* __handle(_Action __act, any const * __this, any * __other, @@ -374,7 +374,7 @@ namespace __any_imp }; template <class _Tp> - struct _LIBCPP_TYPE_VIS_ONLY _LargeHandler + struct _LIBCPP_TEMPLATE_VIS _LargeHandler { _LIBCPP_INLINE_VISIBILITY static void* __handle(_Action __act, any const * __this, any * __other, @@ -507,7 +507,7 @@ void swap(any & __lhs, any & __rhs) _NOEXCEPT } template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any const & __v) { static_assert( @@ -523,7 +523,7 @@ _ValueType any_cast(any const & __v) } template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any & __v) { static_assert( @@ -538,7 +538,7 @@ _ValueType any_cast(any & __v) } template <class _ValueType> -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any && __v) { static_assert( diff --git a/lib/libcxx/include/experimental/coroutine b/lib/libcxx/include/experimental/coroutine new file mode 100644 index 00000000000..ce795ad452c --- /dev/null +++ b/lib/libcxx/include/experimental/coroutine @@ -0,0 +1,296 @@ +// -*- C++ -*- +//===----------------------------- coroutine -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_COROUTINE +#define _LIBCPP_EXPERIMENTAL_COROUTINE + +/** + experimental/coroutine synopsis + +// C++next + +namespace std { +namespace experimental { +inline namespace coroutines_v1 { + + // 18.11.1 coroutine traits +template <typename R, typename... ArgTypes> +class coroutine_traits; +// 18.11.2 coroutine handle +template <typename Promise = void> +class coroutine_handle; +// 18.11.2.7 comparison operators: +bool operator==(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT; +bool operator!=(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT; +bool operator<(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT; +bool operator<=(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT; +bool operator>=(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT; +bool operator>(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT; +// 18.11.3 trivial awaitables +struct suspend_never; +struct suspend_always; +// 18.11.2.8 hash support: +template <class T> struct hash; +template <class P> struct hash<coroutine_handle<P>>; + +} // namespace coroutines_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <new> +#include <type_traits> +#include <functional> +#include <memory> // for hash<T*> +#include <cstddef> +#include <cassert> +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#ifdef _LIBCPP_HAS_NO_COROUTINES +# if defined(_LIBCPP_WARNING) + _LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler") +# else +# warning <experimental/coroutine> cannot be used with this compiler +# endif +#endif + +#ifndef _LIBCPP_HAS_NO_COROUTINES + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES + +template <class _Tp, class = void> +struct __coroutine_traits_sfinae {}; + +template <class _Tp> +struct __coroutine_traits_sfinae< + _Tp, typename __void_t<typename _Tp::promise_type>::type> +{ + using promise_type = typename _Tp::promise_type; +}; + +template <typename _Ret, typename... _Args> +struct _LIBCPP_TEMPLATE_VIS coroutine_traits + : public __coroutine_traits_sfinae<_Ret> +{ +}; + +template <typename _Promise = void> +class _LIBCPP_TEMPLATE_VIS coroutine_handle; + +template <> +class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> { +public: + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR coroutine_handle() _NOEXCEPT : __handle_(nullptr) {} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR coroutine_handle(nullptr_t) _NOEXCEPT : __handle_(nullptr) {} + + _LIBCPP_ALWAYS_INLINE + coroutine_handle& operator=(nullptr_t) _NOEXCEPT { + __handle_ = nullptr; + return *this; + } + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR void* address() const _NOEXCEPT { return __handle_; } + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return __handle_; } + + _LIBCPP_ALWAYS_INLINE + void operator()() { resume(); } + + _LIBCPP_ALWAYS_INLINE + void resume() { + _LIBCPP_ASSERT(__is_suspended(), + "resume() can only be called on suspended coroutines"); + _LIBCPP_ASSERT(!done(), + "resume() has undefined behavior when the coroutine is done"); + __builtin_coro_resume(__handle_); + } + + _LIBCPP_ALWAYS_INLINE + void destroy() { + _LIBCPP_ASSERT(__is_suspended(), + "destroy() can only be called on suspended coroutines"); + __builtin_coro_destroy(__handle_); + } + + _LIBCPP_ALWAYS_INLINE + bool done() const { + _LIBCPP_ASSERT(__is_suspended(), + "done() can only be called on suspended coroutines"); + return __builtin_coro_done(__handle_); + } + +public: + _LIBCPP_ALWAYS_INLINE + static coroutine_handle from_address(void* __addr) _NOEXCEPT { + coroutine_handle __tmp; + __tmp.__handle_ = __addr; + return __tmp; + } + + // FIXME: Should from_address(nullptr) be allowed? + _LIBCPP_ALWAYS_INLINE + static coroutine_handle from_address(nullptr_t) _NOEXCEPT { + return coroutine_handle(nullptr); + } + + template <class _Tp, bool _CallIsValid = false> + static coroutine_handle from_address(_Tp*) { + static_assert(_CallIsValid, + "coroutine_handle<void>::from_address cannot be called with " + "non-void pointers"); + } + +private: + bool __is_suspended() const _NOEXCEPT { + // FIXME actually implement a check for if the coro is suspended. + return __handle_; + } + + template <class _PromiseT> friend class coroutine_handle; + void* __handle_; +}; + +// 18.11.2.7 comparison operators: +inline _LIBCPP_ALWAYS_INLINE +bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return __x.address() == __y.address(); +} +inline _LIBCPP_ALWAYS_INLINE +bool operator!=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return !(__x == __y); +} +inline _LIBCPP_ALWAYS_INLINE +bool operator<(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return less<void*>()(__x.address(), __y.address()); +} +inline _LIBCPP_ALWAYS_INLINE +bool operator>(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return __y < __x; +} +inline _LIBCPP_ALWAYS_INLINE +bool operator<=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return !(__x > __y); +} +inline _LIBCPP_ALWAYS_INLINE +bool operator>=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return !(__x < __y); +} + +template <typename _Promise> +class _LIBCPP_TEMPLATE_VIS coroutine_handle : public coroutine_handle<> { + using _Base = coroutine_handle<>; +public: +#ifndef _LIBCPP_CXX03_LANG + // 18.11.2.1 construct/reset + using coroutine_handle<>::coroutine_handle; +#else + _LIBCPP_ALWAYS_INLINE coroutine_handle() _NOEXCEPT : _Base() {} + _LIBCPP_ALWAYS_INLINE coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {} +#endif + _LIBCPP_INLINE_VISIBILITY + coroutine_handle& operator=(nullptr_t) _NOEXCEPT { + _Base::operator=(nullptr); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + _Promise& promise() const { + return *reinterpret_cast<_Promise*>( + __builtin_coro_promise(this->__handle_, __alignof(_Promise), false)); + } + +public: + _LIBCPP_ALWAYS_INLINE + static coroutine_handle from_address(void* __addr) _NOEXCEPT { + coroutine_handle __tmp; + __tmp.__handle_ = __addr; + return __tmp; + } + + // NOTE: this overload isn't required by the standard but is needed so + // the deleted _Promise* overload doesn't make from_address(nullptr) + // ambiguous. + // FIXME: should from_address work with nullptr? + _LIBCPP_ALWAYS_INLINE + static coroutine_handle from_address(nullptr_t) _NOEXCEPT { + return coroutine_handle(nullptr); + } + + template <class _Tp, bool _CallIsValid = false> + static coroutine_handle from_address(_Tp*) { + static_assert(_CallIsValid, + "coroutine_handle<promise_type>::from_address cannot be called with " + "non-void pointers"); + } + + template <bool _CallIsValid = false> + static coroutine_handle from_address(_Promise*) { + static_assert(_CallIsValid, + "coroutine_handle<promise_type>::from_address cannot be used with " + "pointers to the coroutine's promise type; use 'from_promise' instead"); + } + + _LIBCPP_ALWAYS_INLINE + static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT { + typedef typename remove_cv<_Promise>::type _RawPromise; + coroutine_handle __tmp; + __tmp.__handle_ = __builtin_coro_promise( + _VSTD::addressof(const_cast<_RawPromise&>(__promise)), + __alignof(_Promise), true); + return __tmp; + } +}; + +struct _LIBCPP_TYPE_VIS suspend_never { + _LIBCPP_ALWAYS_INLINE + bool await_ready() const _NOEXCEPT { return true; } + _LIBCPP_ALWAYS_INLINE + void await_suspend(coroutine_handle<>) const _NOEXCEPT {} + _LIBCPP_ALWAYS_INLINE + void await_resume() const _NOEXCEPT {} +}; + +struct _LIBCPP_TYPE_VIS suspend_always { + _LIBCPP_ALWAYS_INLINE + bool await_ready() const _NOEXCEPT { return false; } + _LIBCPP_ALWAYS_INLINE + void await_suspend(coroutine_handle<>) const _NOEXCEPT {} + _LIBCPP_ALWAYS_INLINE + void await_resume() const _NOEXCEPT {} +}; + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct hash<_VSTD_CORO::coroutine_handle<_Tp> > { + using __arg_type = _VSTD_CORO::coroutine_handle<_Tp>; + _LIBCPP_INLINE_VISIBILITY + size_t operator()(__arg_type const& __v) const _NOEXCEPT + {return hash<void*>()(__v.address());} +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // !defined(_LIBCPP_HAS_NO_COROUTINES) + +#endif /* _LIBCPP_EXPERIMENTAL_COROUTINE */ diff --git a/lib/libcxx/include/experimental/dynarray b/lib/libcxx/include/experimental/dynarray index 4a06908e11b..16193317ad2 100644 --- a/lib/libcxx/include/experimental/dynarray +++ b/lib/libcxx/include/experimental/dynarray @@ -11,9 +11,6 @@ #ifndef _LIBCPP_DYNARRAY #define _LIBCPP_DYNARRAY -#include <__config> -#if _LIBCPP_STD_VER > 11 - /* dynarray synopsis @@ -96,6 +93,8 @@ public: }} // std::experimental */ +#include <__config> +#if _LIBCPP_STD_VER > 11 #include <__functional_base> #include <iterator> @@ -104,20 +103,17 @@ public: #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 +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + namespace std { namespace experimental { inline namespace __array_extensions_v1 { template <class _Tp> -struct _LIBCPP_TYPE_VIS_ONLY dynarray +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_DYNARRAY dynarray { public: // types: @@ -142,19 +138,14 @@ private: 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 - } + __throw_bad_array_length(); + return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count)); } - static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept + static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept { - _VSTD::__deallocate (static_cast<void *> (__ptr)); + _VSTD::__libcpp_deallocate (static_cast<void *> (__ptr)); } public: @@ -274,7 +265,7 @@ dynarray<_Tp>::~dynarray() value_type *__data = data () + __size_; for ( size_t i = 0; i < __size_; ++i ) (--__data)->value_type::~value_type(); - __deallocate ( __base_ ); + __deallocate_value( __base_ ); } template <class _Tp> @@ -283,13 +274,8 @@ 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 - } + __throw_out_of_range("dynarray::at"); + return data()[__n]; } @@ -299,13 +285,8 @@ 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 - } + __throw_out_of_range("dynarray::at"); + return data()[__n]; } @@ -314,8 +295,10 @@ dynarray<_Tp>::at(size_type __n) const _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, class _Alloc> -struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {}; +struct _LIBCPP_TEMPLATE_VIS uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {}; _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // if _LIBCPP_STD_VER > 11 #endif // _LIBCPP_DYNARRAY diff --git a/lib/libcxx/include/experimental/filesystem b/lib/libcxx/include/experimental/filesystem index 7de93fdf8f1..674490f6038 100644 --- a/lib/libcxx/include/experimental/filesystem +++ b/lib/libcxx/include/experimental/filesystem @@ -81,10 +81,10 @@ 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, error_code& ec); 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; + error_code& ec); bool copy_file(const path& from, const path& to); bool copy_file(const path& from, const path& to, error_code& ec) _NOEXCEPT; @@ -228,7 +228,7 @@ #include <system_error> #include <utility> #include <iomanip> // for quoted -#include <experimental/string_view> +#include <string_view> #include <__debug> @@ -249,7 +249,7 @@ struct _LIBCPP_TYPE_VIS space_info uintmax_t available; }; -enum class _LIBCPP_TYPE_VIS file_type : signed char +enum class _LIBCPP_ENUM_VIS file_type : signed char { none = 0, not_found = -1, @@ -263,7 +263,7 @@ enum class _LIBCPP_TYPE_VIS file_type : signed char unknown = 8 }; -enum class _LIBCPP_TYPE_VIS perms : unsigned +enum class _LIBCPP_ENUM_VIS perms : unsigned { none = 0, @@ -323,7 +323,7 @@ _LIBCPP_INLINE_VISIBILITY inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } -enum class _LIBCPP_TYPE_VIS copy_options : unsigned short +enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { none = 0, skip_existing = 1, @@ -367,7 +367,7 @@ inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) { return _LHS = _LHS ^ _RHS; } -enum class directory_options : unsigned char +enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { none = 0, follow_directory_symlink = 1, @@ -408,8 +408,10 @@ 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 + file_status() _NOEXCEPT : file_status(file_type::none) {} + _LIBCPP_INLINE_VISIBILITY + explicit file_status(file_type __ft, + perms __prms = perms::unknown) _NOEXCEPT : __ft_(__ft), __prms_(__prms) {} @@ -453,6 +455,9 @@ class _LIBCPP_TYPE_VIS directory_entry; template <class _Tp> struct __can_convert_char { static const bool value = false; }; +template <class _Tp> struct __can_convert_char<const _Tp> + : public __can_convert_char<_Tp> { +}; template <> struct __can_convert_char<char> { static const bool value = true; using __char_type = char; @@ -498,6 +503,21 @@ struct __is_pathable_string<basic_string<_ECharT, _Traits, _Alloc>, } }; + +template <class _ECharT, class _Traits> +struct __is_pathable_string<basic_string_view<_ECharT, _Traits>, + _Void<typename __can_convert_char<_ECharT>::__char_type>> +: public __can_convert_char<_ECharT> +{ + using _Str = basic_string_view<_ECharT, _Traits>; + 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< @@ -605,13 +625,23 @@ struct _PathCVT { template <> struct _PathCVT<char> { + template <class _Iter> - static void __append_range(string& __dest, _Iter __b, _Iter __e) { + static typename enable_if< + __is_exactly_input_iterator<_Iter>::value + >::type __append_range(string& __dest, _Iter __b, _Iter __e) { for (; __b != __e; ++__b) __dest.push_back(*__b); } template <class _Iter> + static typename enable_if< + __is_forward_iterator<_Iter>::value + >::type __append_range(string& __dest, _Iter __b, _Iter __e) { + __dest.__append_forward_unsafe(__b, __e); + } + + template <class _Iter> static void __append_range(string& __dest, _Iter __b, _NullSentinal) { const char __sentinal = char{}; for (; *__b != __sentinal; ++__b) @@ -622,7 +652,8 @@ struct _PathCVT<char> { 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)); + __append_range(__dest, _Traits::__range_begin(__s), + _Traits::__range_end(__s)); } }; @@ -642,6 +673,7 @@ class _LIBCPP_TYPE_VIS path public: typedef char value_type; typedef basic_string<value_type> string_type; + typedef _VSTD::string_view __string_view; static _LIBCPP_CONSTEXPR value_type preferred_separator = '/'; // constructors and destructor @@ -690,6 +722,7 @@ public: return *this; } + template <class = void> _LIBCPP_INLINE_VISIBILITY path& operator=(string_type&& __s) _NOEXCEPT { __pn_ = _VSTD::move(__s); @@ -740,6 +773,8 @@ private: public: // appends path& operator/=(const path& __p) { + _LIBCPP_ASSERT(!__p.has_root_name(), + "cannot append to a path with a root name"); __append_sep_if_needed(__p.empty() ? char{} : __p.__pn_[0]); __pn_ += __p.native(); return *this; @@ -788,6 +823,12 @@ public: } _LIBCPP_INLINE_VISIBILITY + path& operator+=(__string_view __x) { + __pn_ += __x; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY path& operator+=(const value_type* __x) { __pn_ += __x; return *this; @@ -799,7 +840,6 @@ public: return *this; } - template <class _ECharT> typename enable_if<__can_convert_char<_ECharT>::value, path&>::type operator+=(_ECharT __x) @@ -837,7 +877,15 @@ public: } path& make_preferred() { return *this; } - path& remove_filename() { return *this = parent_path(); } + + _LIBCPP_INLINE_VISIBILITY + path& remove_filename() { + if (__pn_.size() == __root_path_raw().size()) + clear(); + else + __pn_ = __parent_path(); + return *this; + } path& replace_filename(const path& __replacement) { remove_filename(); @@ -896,37 +944,40 @@ public: 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; + int __compare(__string_view) const; + __string_view __root_name() const; + __string_view __root_directory() const; + __string_view __root_path_raw() const; + __string_view __relative_path() const; + __string_view __parent_path() const; + __string_view __filename() const; + __string_view __stem() const; + __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 path& __p) const _NOEXCEPT { return __compare(__p.__pn_);} + _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { return __compare(__s); } + _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { return __compare(__s); } _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(); } + _LIBCPP_INLINE_VISIBILITY path root_name() const { return string_type(__root_name()); } + _LIBCPP_INLINE_VISIBILITY path root_directory() const { return string_type(__root_directory()); } + _LIBCPP_INLINE_VISIBILITY path root_path() const { return root_name().append(string_type(__root_directory())); } + _LIBCPP_INLINE_VISIBILITY path relative_path() const { return string_type(__relative_path()); } + _LIBCPP_INLINE_VISIBILITY path parent_path() const { return string_type(__parent_path()); } + _LIBCPP_INLINE_VISIBILITY path filename() const { return string_type(__filename()); } + _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem());} + _LIBCPP_INLINE_VISIBILITY path extension() const { return string_type(__extension()); } // query - _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT { return __pn_.empty(); } + _LIBCPP_NODISCARD_AFTER_CXX17 _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_root_path() const { return !__root_path_raw().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(); } @@ -940,12 +991,12 @@ public: class _LIBCPP_TYPE_VIS iterator; typedef iterator const_iterator; - _LIBCPP_FUNC_VIS iterator begin() const; - _LIBCPP_FUNC_VIS iterator end() const; + iterator begin() const; + iterator end() const; private: inline _LIBCPP_INLINE_VISIBILITY - path& __assign_view(string_view const& __s) noexcept { __pn_ = __s.to_string(); return *this; } + path& __assign_view(__string_view const& __s) noexcept { __pn_ = string_type(__s); return *this; } string_type __pn_; }; @@ -1041,13 +1092,17 @@ 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; + + typedef void __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator public: _LIBCPP_INLINE_VISIBILITY - iterator() : __elem_(), __path_ptr_(nullptr), __pos_(0) {} + iterator() : __stashed_elem_(), __path_ptr_(nullptr), + __entry_(), __state_(__singular) {} iterator(const iterator&) = default; ~iterator() = default; @@ -1056,16 +1111,20 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __elem_; + return __stashed_elem_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return &__elem_; + return &__stashed_elem_; } _LIBCPP_INLINE_VISIBILITY iterator& operator++() { + _LIBCPP_ASSERT(__state_ != __singular, + "attempting to increment a singular iterator"); + _LIBCPP_ASSERT(__state_ != __at_end, + "attempting to increment the end iterator"); return __increment(); } @@ -1078,6 +1137,10 @@ public: _LIBCPP_INLINE_VISIBILITY iterator& operator--() { + _LIBCPP_ASSERT(__state_ != __singular, + "attempting to decrement a singular iterator"); + _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(), + "attempting to decrement the begin iterator"); return __decrement(); } @@ -1090,20 +1153,26 @@ public: private: friend class path; + + static constexpr unsigned char __singular = 0; + static constexpr unsigned char __at_end = 6; + + inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&, const iterator&); - _LIBCPP_FUNC_VIS iterator& __increment(); - _LIBCPP_FUNC_VIS iterator& __decrement(); + iterator& __increment(); + iterator& __decrement(); - path __elem_; + path __stashed_elem_; const path* __path_ptr_; - size_t __pos_; + path::__string_view __entry_; + unsigned char __state_; }; 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_; + __lhs.__entry_.data() == __rhs.__entry_.data(); } inline _LIBCPP_INLINE_VISIBILITY @@ -1143,7 +1212,6 @@ public: return __paths_->second; } - _LIBCPP_FUNC_VIS ~filesystem_error() override; // key function // TODO(ericwf): Create a custom error message. @@ -1154,6 +1222,21 @@ private: shared_ptr<_Storage> __paths_; }; +template <class... _Args> +_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE +#ifndef _LIBCPP_NO_EXCEPTIONS +void __throw_filesystem_error(_Args && ...__args) +{ + throw filesystem_error(std::forward<_Args>(__args)...); +} +#else +void __throw_filesystem_error(_Args&&...) +{ + _VSTD::abort(); +} +#endif + + // operational functions _LIBCPP_FUNC_VIS @@ -1269,7 +1352,7 @@ void copy(const path& __from, const path& __to) { } inline _LIBCPP_INLINE_VISIBILITY -void copy(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT { +void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); } @@ -1280,7 +1363,7 @@ void copy(const path& __from, const path& __to, copy_options __opt) { inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, - copy_options __opt, error_code& __ec) _NOEXCEPT { + copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); } @@ -1479,7 +1562,7 @@ bool is_empty(const path& __p) { } inline _LIBCPP_INLINE_VISIBILITY -bool is_empty(const path& __p, error_code& __ec) _NOEXCEPT { +bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } @@ -1821,12 +1904,12 @@ public: : directory_iterator(__p, nullptr, __opts) { } - directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT + directory_iterator(const path& __p, error_code& __ec) : directory_iterator(__p, &__ec) { } directory_iterator(const path& __p, directory_options __opts, - error_code& __ec) _NOEXCEPT + error_code& __ec) : directory_iterator(__p, &__ec, __opts) { } @@ -1846,7 +1929,7 @@ public: const directory_entry& operator*() const { _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); - return __deref(); + return __dereference(); } const directory_entry* operator->() const @@ -1861,20 +1944,24 @@ public: return __p; } - directory_iterator& increment(error_code& __ec) _NOEXCEPT + directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } private: + inline _LIBCPP_INLINE_VISIBILITY 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); + 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; + const directory_entry& __dereference() const; private: shared_ptr<__dir_stream> __imp_; @@ -1927,12 +2014,12 @@ public: _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator(const path& __p, - directory_options __xoptions, error_code& __ec) _NOEXCEPT + directory_options __xoptions, error_code& __ec) : recursive_directory_iterator(__p, __xoptions, &__ec) { } _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT + recursive_directory_iterator(const path& __p, error_code& __ec) : recursive_directory_iterator(__p, directory_options::none, &__ec) { } @@ -1957,11 +2044,11 @@ public: _LIBCPP_INLINE_VISIBILITY const directory_entry& operator*() const - { return __deref(); } + { return __dereference(); } _LIBCPP_INLINE_VISIBILITY const directory_entry* operator->() const - { return &__deref(); } + { return &__dereference(); } recursive_directory_iterator& operator++() { return __increment(); } @@ -1974,7 +2061,7 @@ public: } _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator& increment(error_code& __ec) _NOEXCEPT + recursive_directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } _LIBCPP_FUNC_VIS directory_options options() const; @@ -2000,7 +2087,7 @@ private: error_code *__ec); _LIBCPP_FUNC_VIS - const directory_entry& __deref() const; + const directory_entry& __dereference() const; _LIBCPP_FUNC_VIS bool __try_recursion(error_code* __ec); @@ -2014,6 +2101,7 @@ private: _LIBCPP_FUNC_VIS void __pop(error_code* __ec=nullptr); + inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const recursive_directory_iterator&, const recursive_directory_iterator&) _NOEXCEPT; @@ -2023,9 +2111,9 @@ private: }; // class recursive_directory_iterator -_LIBCPP_INLINE_VISIBILITY -inline bool operator==(const recursive_directory_iterator& __lhs, - const recursive_directory_iterator& __rhs) _NOEXCEPT +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) _NOEXCEPT { return __lhs.__imp_ == __rhs.__imp_; } diff --git a/lib/libcxx/include/experimental/functional b/lib/libcxx/include/experimental/functional index 75fc8e99f35..a136cbb57c8 100644 --- a/lib/libcxx/include/experimental/functional +++ b/lib/libcxx/include/experimental/functional @@ -89,21 +89,22 @@ inline namespace fundamentals_v1 { #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_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_LFTS #if _LIBCPP_STD_VER > 11 @@ -456,4 +457,6 @@ make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIter _LIBCPP_END_NAMESPACE_LFTS +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */ diff --git a/lib/libcxx/include/experimental/iterator b/lib/libcxx/include/experimental/iterator index da593febe2b..ea672e96631 100644 --- a/lib/libcxx/include/experimental/iterator +++ b/lib/libcxx/include/experimental/iterator @@ -75,19 +75,19 @@ public: typedef void reference; ostream_joiner(ostream_type& __os, _Delim&& __d) - : __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {} + : __output_iter(_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) {} + : __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {} template<typename _Tp> ostream_joiner& operator=(const _Tp& __v) { if (!__first) - *__out << __delim; + *__output_iter << __delim; __first = false; - *__out << __v; + *__output_iter << __v; return *this; } @@ -96,7 +96,7 @@ public: ostream_joiner& operator++(int) _NOEXCEPT { return *this; } private: - ostream_type* __out; + ostream_type* __output_iter; _Delim __delim; bool __first; }; diff --git a/lib/libcxx/include/experimental/memory_resource b/lib/libcxx/include/experimental/memory_resource index 9b345210ee5..d101f3e0811 100644 --- a/lib/libcxx/include/experimental/memory_resource +++ b/lib/libcxx/include/experimental/memory_resource @@ -82,6 +82,9 @@ namespace pmr { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR // Round __s up to next multiple of __a. @@ -93,7 +96,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT } // 8.5, memory.resource -class _LIBCPP_TYPE_VIS_ONLY memory_resource +class _LIBCPP_TEMPLATE_VIS memory_resource { static const size_t __max_align = alignof(max_align_t); @@ -151,7 +154,7 @@ memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT; // 8.6.1, memory.polymorphic.allocator.overview template <class _ValueType> -class _LIBCPP_TYPE_VIS_ONLY polymorphic_allocator +class _LIBCPP_TEMPLATE_VIS polymorphic_allocator { public: typedef _ValueType value_type; @@ -181,10 +184,10 @@ public: // 8.6.3, memory.polymorphic.allocator.mem _LIBCPP_INLINE_VISIBILITY _ValueType* allocate(size_t __n) { - if (__n > max_size()) { - __libcpp_throw(length_error( + if (__n > __max_size()) { + __throw_length_error( "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" - " 'n' exceeds maximum supported size")); + " 'n' exceeds maximum supported size"); } return static_cast<_ValueType*>( __res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)) @@ -193,7 +196,7 @@ public: _LIBCPP_INLINE_VISIBILITY void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__n <= max_size(), + _LIBCPP_ASSERT(__n <= __max_size(), "deallocate called for size which exceeds max_size()"); __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType)); } @@ -266,10 +269,6 @@ public: { __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(); } @@ -309,6 +308,10 @@ private: return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource()); } + _LIBCPP_INLINE_VISIBILITY + size_t __max_size() const _NOEXCEPT + { return numeric_limits<size_t>::max() / sizeof(value_type); } + memory_resource * __res_; }; @@ -334,7 +337,7 @@ bool operator!=(polymorphic_allocator<_Tp> const & __lhs, // 8.7.1, memory.resource.adaptor.overview template <class _CharAlloc> -class _LIBCPP_TYPE_VIS_ONLY __resource_adaptor_imp +class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp : public memory_resource { using _CTraits = allocator_traits<_CharAlloc>; @@ -383,9 +386,9 @@ protected: virtual void * do_allocate(size_t __bytes, size_t) { if (__bytes > __max_size()) { - __libcpp_throw(length_error( + __throw_length_error( "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)" - " 'bytes' exceeds maximum supported size")); + " 'bytes' exceeds maximum supported size"); } size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; return __alloc_.allocate(__s); @@ -419,4 +422,6 @@ using resource_adaptor = __resource_adaptor_imp< _LIBCPP_END_NAMESPACE_LFTS_PMR +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */ diff --git a/lib/libcxx/include/experimental/numeric b/lib/libcxx/include/experimental/numeric new file mode 100644 index 00000000000..d784c08f0fe --- /dev/null +++ b/lib/libcxx/include/experimental/numeric @@ -0,0 +1,119 @@ +// -*- C++ -*- +//===--------------------------- numeric ----------------------------------===// +// +// 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_NUMERIC +#define _LIBCPP_EXPERIMENTAL_NUMERIC +/* + experimental/numeric synopsis + +// C++1z +namespace std { +namespace experimental { +inline namespace fundamentals_v2 { + + // 13.1.2, Greatest common divisor + template<class M, class N> + constexpr common_type_t<M,N> gcd(M m, N n); + + // 13.1.3, Least common multiple + template<class M, class N> + constexpr common_type_t<M,N> lcm(M m, N n); + +} // namespace fundamentals_v2 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> +#include <numeric> +#include <type_traits> // is_integral +#include <limits> // numeric_limits + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +#if _LIBCPP_STD_VER > 11 + +_LIBCPP_BEGIN_NAMESPACE_LFTS_V2 + +template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs; + +template <typename _Result, typename _Source> +struct __abs<_Result, _Source, true> { + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + _Result operator()(_Source __t) const noexcept + { + if (__t >= 0) return __t; + if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t); + return -__t; + } +}; + +template <typename _Result, typename _Source> +struct __abs<_Result, _Source, false> { + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + _Result operator()(_Source __t) const noexcept { return __t; } +}; + + +template<class _Tp> +_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN +inline _Tp __gcd(_Tp __m, _Tp __n) +{ + static_assert((!is_signed<_Tp>::value), "" ); + return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n); +} + + +template<class _Tp, class _Up> +_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY +common_type_t<_Tp,_Up> +gcd(_Tp __m, _Up __n) +{ + static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); + static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" ); + static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" ); + using _Rp = common_type_t<_Tp,_Up>; + using _Wp = make_unsigned_t<_Rp>; + return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd( + static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)), + static_cast<_Wp>(__abs<_Rp, _Up>()(__n)))); +} + +template<class _Tp, class _Up> +_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY +common_type_t<_Tp,_Up> +lcm(_Tp __m, _Up __n) +{ + static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); + static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" ); + static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" ); + if (__m == 0 || __n == 0) + return 0; + + using _Rp = common_type_t<_Tp,_Up>; + _Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n); + _Rp __val2 = __abs<_Rp, _Up>()(__n); + _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); + return __val1 * __val2; +} + +_LIBCPP_END_NAMESPACE_LFTS_V2 + +#endif /* _LIBCPP_STD_VER > 11 */ + +_LIBCPP_POP_MACROS + +#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */ diff --git a/lib/libcxx/include/experimental/optional b/lib/libcxx/include/experimental/optional index 3912438ec10..b251748fbf3 100644 --- a/lib/libcxx/include/experimental/optional +++ b/lib/libcxx/include/experimental/optional @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP_OPTIONAL -#define _LIBCPP_OPTIONAL +#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL +#define _LIBCPP_EXPERIMENTAL_OPTIONAL /* optional synopsis @@ -143,9 +143,24 @@ namespace std { namespace experimental { inline namespace fundamentals_v1 { #include <experimental/__config> #include <functional> #include <stdexcept> +#if _LIBCPP_STD_VER > 11 +#include <initializer_list> +#include <type_traits> +#include <new> +#include <__functional_base> +#include <__debug> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL -class _LIBCPP_EXCEPTION_ABI bad_optional_access +class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error { public: @@ -160,17 +175,6 @@ _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 {}; @@ -211,7 +215,7 @@ protected: : __engaged_(__x.__engaged_) { if (__engaged_) - ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_); } _LIBCPP_INLINE_VISIBILITY @@ -220,7 +224,7 @@ protected: : __engaged_(__x.__engaged_) { if (__engaged_) - ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); } _LIBCPP_INLINE_VISIBILITY @@ -262,7 +266,7 @@ protected: : __engaged_(__x.__engaged_) { if (__engaged_) - ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_); } _LIBCPP_INLINE_VISIBILITY @@ -271,7 +275,7 @@ protected: : __engaged_(__x.__engaged_) { if (__engaged_) - ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); } _LIBCPP_INLINE_VISIBILITY @@ -368,7 +372,7 @@ public: if (this->__engaged_) this->__val_.~value_type(); else - ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_); + ::new((void*)_VSTD::addressof(this->__val_)) value_type(__opt.__val_); this->__engaged_ = __opt.__engaged_; } return *this; @@ -390,7 +394,8 @@ public: if (this->__engaged_) this->__val_.~value_type(); else - ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + ::new((void*)_VSTD::addressof(this->__val_)) + value_type(_VSTD::move(__opt.__val_)); this->__engaged_ = __opt.__engaged_; } return *this; @@ -412,7 +417,7 @@ public: this->__val_ = _VSTD::forward<_Up>(__v); else { - ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); + ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); this->__engaged_ = true; } return *this; @@ -429,7 +434,8 @@ public: emplace(_Args&&... __args) { *this = nullopt; - ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); + ::new((void*)_VSTD::addressof(this->__val_)) + value_type(_VSTD::forward<_Args>(__args)...); this->__engaged_ = true; } @@ -444,7 +450,8 @@ public: emplace(initializer_list<_Up> __il, _Args&&... __args) { *this = nullopt; - ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); + ::new((void*)_VSTD::addressof(this->__val_)) + value_type(__il, _VSTD::forward<_Args>(__args)...); this->__engaged_ = true; } @@ -464,12 +471,14 @@ public: { if (this->__engaged_) { - ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); + ::new((void*)_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_)); + ::new((void*)_VSTD::addressof(this->__val_)) + value_type(_VSTD::move(__opt.__val_)); __opt.__val_.~value_type(); } swap(this->__engaged_, __opt.__engaged_); @@ -482,7 +491,11 @@ public: operator->() const { _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); +#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF + return __builtin_addressof(this->__val_); +#else return __operator_arrow(__has_operator_addressof<value_type>{}); +#endif } _LIBCPP_INLINE_VISIBILITY @@ -513,27 +526,32 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr explicit operator bool() const noexcept {return this->__engaged_;} - _LIBCPP_INLINE_VISIBILITY - constexpr value_type const& value() const - { - if (!this->__engaged_) + _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY +#ifndef _LIBCPP_NO_EXCEPTIONS +_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS +#endif + constexpr void __throw_bad_optional_access() const + { #ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_optional_access(); + throw bad_optional_access(); #else - assert(!"bad optional access"); + _VSTD::abort(); #endif + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS + constexpr value_type const& value() const + { + if (!this->__engaged_) + __throw_bad_optional_access(); return this->__val_; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS value_type& value() { if (!this->__engaged_) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_optional_access(); -#else - assert(!"bad optional access"); -#endif + __throw_bad_optional_access(); return this->__val_; } @@ -710,7 +728,7 @@ template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY constexpr bool -operator<=(nullopt_t, const optional<_Tp>& __x) noexcept +operator<=(nullopt_t, const optional<_Tp>&) noexcept { return true; } @@ -728,7 +746,7 @@ template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY constexpr bool -operator>(nullopt_t, const optional<_Tp>& __x) noexcept +operator>(nullopt_t, const optional<_Tp>&) noexcept { return false; } @@ -883,7 +901,7 @@ _LIBCPP_END_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::optional<_Tp> > +struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::optional<_Tp> > { typedef std::experimental::optional<_Tp> argument_type; typedef size_t result_type; @@ -899,4 +917,6 @@ _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 11 -#endif // _LIBCPP_OPTIONAL +_LIBCPP_POP_MACROS + +#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL diff --git a/lib/libcxx/include/experimental/propagate_const b/lib/libcxx/include/experimental/propagate_const index f267ba275c2..e7f7e9fc683 100644 --- a/lib/libcxx/include/experimental/propagate_const +++ b/lib/libcxx/include/experimental/propagate_const @@ -123,8 +123,14 @@ _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 _Up> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; + +template <class _Up> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +_Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; template <class _Tp> class propagate_const @@ -462,14 +468,12 @@ _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& _ } 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_; diff --git a/lib/libcxx/include/experimental/string_view b/lib/libcxx/include/experimental/string_view index 0a7239b4c0b..da104f9a121 100644 --- a/lib/libcxx/include/experimental/string_view +++ b/lib/libcxx/include/experimental/string_view @@ -189,10 +189,13 @@ namespace std { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_LFTS template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> > - class _LIBCPP_TYPE_VIS_ONLY basic_string_view { + class _LIBCPP_TEMPLATE_VIS basic_string_view { public: // types typedef _Traits traits_type; @@ -281,7 +284,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS const_reference at(size_type __pos) const { return __pos >= size() - ? (__libcpp_throw(out_of_range("string_view::at")), __data[0]) + ? (__throw_out_of_range("string_view::at"), __data[0]) : __data[__pos]; } @@ -352,7 +355,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { if ( __pos > size()) - __libcpp_throw(out_of_range("string_view::copy")); + __throw_out_of_range("string_view::copy"); size_type __rlen = _VSTD::min( __n, size() - __pos ); _VSTD::copy_n(begin() + __pos, __rlen, __s ); return __rlen; @@ -362,11 +365,11 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS basic_string_view substr(size_type __pos = 0, size_type __n = npos) const { // if (__pos > size()) -// throw out_of_range("string_view::substr"); +// __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()) + ? (__throw_out_of_range("string_view::substr"), basic_string_view()) : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); } @@ -783,7 +786,7 @@ _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> > +struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::basic_string_view<_CharT, _Traits> > : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t> { size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT; @@ -810,4 +813,6 @@ quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_LFTS_STRING_VIEW diff --git a/lib/libcxx/include/experimental/type_traits b/lib/libcxx/include/experimental/type_traits index ae49fc176c0..3a7593620a7 100644 --- a/lib/libcxx/include/experimental/type_traits +++ b/lib/libcxx/include/experimental/type_traits @@ -172,6 +172,45 @@ inline namespace fundamentals_v1 { template <class T> using raw_invocation_type_t = typename raw_invocation_type<T>::type; + // 3.3.3, Logical operator traits + template<class... B> struct conjunction; + template<class... B> constexpr bool conjunction_v = conjunction<B...>::value; + template<class... B> struct disjunction; + template<class... B> constexpr bool disjunction_v = disjunction<B...>::value; + template<class B> struct negation; + template<class B> constexpr bool negation_v = negation<B>::value; + + // 3.3.4, Detection idiom + template <class...> using void_t = void; + + struct nonesuch { + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + void operator=(nonesuch const&) = delete; + }; + + template <template<class...> class Op, class... Args> + using is_detected = see below; + template <template<class...> class Op, class... Args> + constexpr bool is_detected_v = is_detected<Op, Args...>::value; + template <template<class...> class Op, class... Args> + using detected_t = see below; + template <class Default, template<class...> class Op, class... Args> + using detected_or = see below; + template <class Default, template<class...> class Op, class... Args> + using detected_or_t = typename detected_or<Default, Op, Args...>::type; + template <class Expected, template<class...> class Op, class... Args> + using is_detected_exact = is_same<Expected, detected_t<Op, Args...>>; + template <class Expected, template<class...> class Op, class... Args> + constexpr bool is_detected_exact_v + = is_detected_exact<Expected, Op, Args...>::value; + template <class To, template<class...> class Op, class... Args> + using is_detected_convertible = is_convertible<detected_t<Op, Args...>, To>; + template <class To, template<class...> class Op, class... Args> + constexpr bool is_detected_convertible_v + = is_detected_convertible<To, Op, Args...>::value; + } // namespace fundamentals_v1 } // namespace experimental } // namespace std @@ -402,16 +441,16 @@ template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v // 3.3.2, Other type transformations /* template <class> -class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type; +class _LIBCPP_TEMPLATE_VIS raw_invocation_type; template <class _Fn, class ..._Args> -class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>; +class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>; template <class> -class _LIBCPP_TYPE_VIS_ONLY invokation_type; +class _LIBCPP_TEMPLATE_VIS invokation_type; template <class _Fn, class ..._Args> -class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>; +class _LIBCPP_TEMPLATE_VIS invokation_type<_Fn(_Args...)>; template <class _Tp> using invokation_type_t = typename invokation_type<_Tp>::type; @@ -420,6 +459,70 @@ template <class _Tp> using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; */ +// 3.3.3, Logical operator traits +template <class...> using void_t = void; + +template <class... _Args> +struct conjunction : _VSTD::__and_<_Args...> {}; +template <class... _Args> +_LIBCPP_CONSTEXPR bool conjunction_v = conjunction<_Args...>::value; + +template <class... _Args> +struct disjunction : _VSTD::__or_<_Args...> {}; +template <class... _Args> +_LIBCPP_CONSTEXPR bool disjunction_v = disjunction<_Args...>::value; + +template <class _Tp> +struct negation : _VSTD::__not_<_Tp> {}; +template<class _Tp> +_LIBCPP_CONSTEXPR bool negation_v = negation<_Tp>::value; + +// 3.3.4, Detection idiom +template <class...> using void_t = void; + +struct nonesuch { + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch (nonesuch const&) = delete; + void operator=(nonesuch const&) = delete; + }; + +template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args> +struct _DETECTOR { + using value_t = false_type; + using type = _Default; + }; + +template <class _Default, template <class...> class _Op, class... _Args> +struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> { + using value_t = true_type; + using type = _Op<_Args...>; + }; + + +template <template<class...> class _Op, class... _Args> + using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t; +template <template<class...> class _Op, class... _Args> + using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type; +template <template<class...> class _Op, class... _Args> + _LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value; + +template <class Default, template<class...> class _Op, class... _Args> + using detected_or = _DETECTOR<Default, void, _Op, _Args...>; +template <class Default, template<class...> class _Op, class... _Args> + using detected_or_t = typename detected_or<Default, _Op, _Args...>::type; + +template <class Expected, template<class...> class _Op, class... _Args> + using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>; +template <class Expected, template<class...> class _Op, class... _Args> + _LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<Expected, _Op, _Args...>::value; + +template <class To, template<class...> class _Op, class... _Args> + using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, To>; +template <class To, template<class...> class _Op, class... _Args> + _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value; + + _LIBCPP_END_NAMESPACE_LFTS #endif /* _LIBCPP_STD_VER > 11 */ diff --git a/lib/libcxx/include/experimental/utility b/lib/libcxx/include/experimental/utility index b5fca6c775b..8effa71c131 100644 --- a/lib/libcxx/include/experimental/utility +++ b/lib/libcxx/include/experimental/utility @@ -40,7 +40,7 @@ inline namespace fundamentals_v1 { _LIBCPP_BEGIN_NAMESPACE_LFTS - struct _LIBCPP_TYPE_VIS_ONLY erased_type { }; + struct _LIBCPP_TEMPLATE_VIS erased_type { }; _LIBCPP_END_NAMESPACE_LFTS |