diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/cxxsupp/libcxx/include/experimental | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/experimental')
22 files changed, 4725 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__config b/contrib/libs/cxxsupp/libcxx/include/experimental/__config new file mode 100644 index 0000000000..f85426d050 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__config @@ -0,0 +1,75 @@ +// -*- C++ -*- +//===--------------------------- __config ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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 + +#if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM) +# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */ +#else +# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM __attribute__((deprecated("std::experimental::filesystem has now been deprecated in favor of C++17's std::filesystem. Please stop using it and start using std::filesystem. This experimental version will be removed in LLVM 11. You can remove this warning by defining the _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM macro."))) +#endif + +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM { \ + inline namespace v1 { + +#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 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \ + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 { + +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \ + } _LIBCPP_END_NAMESPACE_EXPERIMENTAL + +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi { + +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ + } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD + +// TODO: support more targets +#if defined(__AVX__) +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 +#else +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 +#endif + +#endif diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__memory b/contrib/libs/cxxsupp/libcxx/include/experimental/__memory new file mode 100644 index 0000000000..b38b664b33 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__memory @@ -0,0 +1,114 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL___MEMORY +#define _LIBCPP_EXPERIMENTAL___MEMORY + +#include <__memory/allocator_arg_t.h> +#include <__memory/uses_allocator.h> +#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 _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); +} + +// FIXME: This should have a version which takes a non-const alloc. +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); +} + +// FIXME: This should have a version which takes a non-const alloc. +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); +} + +template <class _Tp, class _Alloc, class ..._Args> +inline _LIBCPP_INLINE_VISIBILITY +void __lfts_user_alloc_construct( + _Tp * __store, const _Alloc & __a, _Args &&... __args) +{ + ::std::experimental::fundamentals_v1::__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/contrib/libs/cxxsupp/libcxx/include/experimental/algorithm b/contrib/libs/cxxsupp/libcxx/include/experimental/algorithm new file mode 100644 index 0000000000..79572ff51f --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/algorithm @@ -0,0 +1,53 @@ +// -*- C++ -*- +//===-------------------------- algorithm ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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); + +// sample removed because it's now part of C++17 + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include <experimental/__config> +#include <algorithm> +#include <type_traits> + +#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; } + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/coroutine b/contrib/libs/cxxsupp/libcxx/include/experimental/coroutine new file mode 100644 index 0000000000..54ec74b9f9 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/coroutine @@ -0,0 +1,334 @@ +// -*- C++ -*- +//===----------------------------- coroutine -----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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 <__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 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_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR coroutine_handle() _NOEXCEPT : __handle_(nullptr) {} + + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR coroutine_handle(nullptr_t) _NOEXCEPT : __handle_(nullptr) {} + + _LIBCPP_INLINE_VISIBILITY + coroutine_handle& operator=(nullptr_t) _NOEXCEPT { + __handle_ = nullptr; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR void* address() const _NOEXCEPT { return __handle_; } + + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return __handle_; } + + _LIBCPP_INLINE_VISIBILITY + void operator()() { resume(); } + + _LIBCPP_INLINE_VISIBILITY + 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_INLINE_VISIBILITY + void destroy() { + _LIBCPP_ASSERT(__is_suspended(), + "destroy() can only be called on suspended coroutines"); + __builtin_coro_destroy(__handle_); + } + + _LIBCPP_INLINE_VISIBILITY + bool done() const { + _LIBCPP_ASSERT(__is_suspended(), + "done() can only be called on suspended coroutines"); + return __builtin_coro_done(__handle_); + } + +public: + _LIBCPP_INLINE_VISIBILITY + static coroutine_handle from_address(void* __addr) _NOEXCEPT { + coroutine_handle __tmp; + __tmp.__handle_ = __addr; + return __tmp; + } + + // FIXME: Should from_address(nullptr) be allowed? + _LIBCPP_INLINE_VISIBILITY + 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_INLINE_VISIBILITY +bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return __x.address() == __y.address(); +} +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return !(__x == __y); +} +inline _LIBCPP_INLINE_VISIBILITY +bool operator<(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return less<void*>()(__x.address(), __y.address()); +} +inline _LIBCPP_INLINE_VISIBILITY +bool operator>(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return __y < __x; +} +inline _LIBCPP_INLINE_VISIBILITY +bool operator<=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT { + return !(__x > __y); +} +inline _LIBCPP_INLINE_VISIBILITY +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_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT : _Base() {} + _LIBCPP_INLINE_VISIBILITY coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {} +#endif + _LIBCPP_INLINE_VISIBILITY + coroutine_handle& operator=(nullptr_t) _NOEXCEPT { + _Base::operator=(nullptr); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + _Promise& promise() const { + return *static_cast<_Promise*>( + __builtin_coro_promise(this->__handle_, _LIBCPP_ALIGNOF(_Promise), false)); + } + +public: + _LIBCPP_INLINE_VISIBILITY + 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_INLINE_VISIBILITY + 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_INLINE_VISIBILITY + 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)), + _LIBCPP_ALIGNOF(_Promise), true); + return __tmp; + } +}; + +#if __has_builtin(__builtin_coro_noop) +struct noop_coroutine_promise {}; + +template <> +class _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> + : public coroutine_handle<> { + using _Base = coroutine_handle<>; + using _Promise = noop_coroutine_promise; +public: + + _LIBCPP_INLINE_VISIBILITY + _Promise& promise() const { + return *static_cast<_Promise*>( + __builtin_coro_promise(this->__handle_, _LIBCPP_ALIGNOF(_Promise), false)); + } + + _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; } + _LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; } + + _LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {} + _LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {} + _LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {} + +private: + _LIBCPP_INLINE_VISIBILITY + friend coroutine_handle<noop_coroutine_promise> noop_coroutine() _NOEXCEPT; + + _LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT { + this->__handle_ = __builtin_coro_noop(); + } +}; + +using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; + +inline _LIBCPP_INLINE_VISIBILITY +noop_coroutine_handle noop_coroutine() _NOEXCEPT { + return noop_coroutine_handle(); +} +#endif // __has_builtin(__builtin_coro_noop) + +struct suspend_never { + _LIBCPP_INLINE_VISIBILITY + bool await_ready() const _NOEXCEPT { return true; } + _LIBCPP_INLINE_VISIBILITY + void await_suspend(coroutine_handle<>) const _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY + void await_resume() const _NOEXCEPT {} +}; + +struct suspend_always { + _LIBCPP_INLINE_VISIBILITY + bool await_ready() const _NOEXCEPT { return false; } + _LIBCPP_INLINE_VISIBILITY + void await_suspend(coroutine_handle<>) const _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY + 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/contrib/libs/cxxsupp/libcxx/include/experimental/deque b/contrib/libs/cxxsupp/libcxx/include/experimental/deque new file mode 100644 index 0000000000..73c2787c7a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/deque @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===--------------------------- deque ------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/filesystem b/contrib/libs/cxxsupp/libcxx/include/experimental/filesystem new file mode 100644 index 0000000000..d2e6237df3 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/filesystem @@ -0,0 +1,256 @@ +// -*- C++ -*- +//===--------------------------- filesystem -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef _LIBCPP_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); + + // fs.path.io operators are friends of path. + template <class charT, class traits> + friend basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, const path& p); + + template <class charT, class traits> + friend 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 perm_options; + enum class copy_options; + enum class directory_options; + + typedef chrono::time_point<trivial-clock> file_time_type; + + // operational functions + + path absolute(const path& p); + path absolute(const path& p, error_code &ec); + + path canonical(const path& p); + path canonical(const path& p, error_code& ec); + + void copy(const path& from, const path& to); + 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); + + bool copy_file(const path& from, const path& to); + bool copy_file(const path& from, const path& to, error_code& ec); + 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); + + 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); + + 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, + perm_options opts=perm_options::replace); + void permissions(const path& p, perms prms, error_code& ec) noexcept; + void permissions(const path& p, perms prms, perm_options opts, + error_code& ec); + + path proximate(const path& p, error_code& ec); + path proximate(const path& p, const path& base = current_path()); + path proximate(const path& p, const path& base, error_code &ec); + + path read_symlink(const path& p); + path read_symlink(const path& p, error_code& ec); + + path relative(const path& p, error_code& ec); + path relative(const path& p, const path& base=current_path()); + path relative(const path& p, const path& base, 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); + + 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 temp_directory_path(); + path temp_directory_path(error_code& ec); + + path weakly_canonical(path const& p); + path weakly_canonical(path const& p, error_code& ec); + + +} } } } // namespaces std::experimental::filesystem::v1 + +*/ + +#include <experimental/__config> +#include <filesystem> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +#ifndef _LIBCPP_CXX03_LANG + +#define __cpp_lib_experimental_filesystem 201406 + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +using namespace _VSTD_FS; + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +#endif // !_LIBCPP_CXX03_LANG + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/forward_list b/contrib/libs/cxxsupp/libcxx/include/experimental/forward_list new file mode 100644 index 0000000000..93f6debe9c --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/forward_list @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===--------------------------- forward_list -----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/functional b/contrib/libs/cxxsupp/libcxx/include/experimental/functional new file mode 100644 index 0000000000..e3220e16ca --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/functional @@ -0,0 +1,459 @@ +// -*- C++ -*- +//===-------------------------- functional --------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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 <__memory/uses_allocator.h> +#include <experimental/__config> +#include <functional> +#include <algorithm> +#include <type_traits> +#include <vector> +#include <array> +#include <unordered_map> + +#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 +// default searcher +template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> +class _LIBCPP_TEMPLATE_VIS default_searcher { +public: + _LIBCPP_INLINE_VISIBILITY + default_searcher(_ForwardIterator __f, _ForwardIterator __l, + _BinaryPredicate __p = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__p) {} + + template <typename _ForwardIterator2> + _LIBCPP_INLINE_VISIBILITY + pair<_ForwardIterator2, _ForwardIterator2> + operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const + { + return _VSTD::__search(__f, __l, __first_, __last_, __pred_, + typename iterator_traits<_ForwardIterator>::iterator_category(), + typename 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(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 make_unsigned<key_type>::type unsigned_key_type; + typedef std::array<value_type, numeric_limits<unsigned_key_type>::max()> skip_map; + skip_map __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(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<>> +class _LIBCPP_TEMPLATE_VIS 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, + 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::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type, + typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + 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 size_t __count = _VSTD::distance(__f, __l); + + __prefix[0] = 0; + size_t __k = 0; + for ( 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 size_t __count = _VSTD::distance(__f, __l); + vector<difference_type> & __suffix = *__suffix_.get(); + if (__count > 0) + { + vector<value_type> __scratch(__count); + + __compute_bm_prefix(__f, __l, __pred, __scratch); + for ( size_t __i = 0; __i <= __count; __i++ ) + __suffix[__i] = __count - __scratch[__count-1]; + + typedef reverse_iterator<_RandomAccessIterator1> _RevIter; + __compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch); + + for ( size_t __i = 0; __i < __count; __i++ ) + { + const 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<>> +class _LIBCPP_TEMPLATE_VIS 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, + 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::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type, + typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + 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 + +_LIBCPP_POP_MACROS + +#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/iterator b/contrib/libs/cxxsupp/libcxx/include/experimental/iterator new file mode 100644 index 0000000000..09ea2cbcc7 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/iterator @@ -0,0 +1,116 @@ +// -*- C++ -*- +//===----------------------------- iterator -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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 <__memory/addressof.h> +#include <__utility/move.h> +#include <__utility/forward.h> +#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) + : __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {} + + ostream_joiner(ostream_type& __os, const _Delim& __d) + : __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {} + + + template<typename _Tp> + ostream_joiner& operator=(const _Tp& __v) + { + if (!__first) + *__output_iter << __delim; + __first = false; + *__output_iter << __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* __output_iter; + _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/contrib/libs/cxxsupp/libcxx/include/experimental/list b/contrib/libs/cxxsupp/libcxx/include/experimental/list new file mode 100644 index 0000000000..adc64a8b53 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/list @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===--------------------------- list ------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/map b/contrib/libs/cxxsupp/libcxx/include/experimental/map new file mode 100644 index 0000000000..965d7582c9 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/map @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------- map ------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource b/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource new file mode 100644 index 0000000000..816d21f513 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource @@ -0,0 +1,425 @@ +// -*- C++ -*- +//===------------------------ memory_resource -----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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_PUSH_MACROS +#include <__undef_macros> + +_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 memory_resource +{ + static const size_t __max_align = _LIBCPP_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 +private: + 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_TEMPLATE_VIS 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()) { + __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), _LIBCPP_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), _LIBCPP_ALIGNOF(_ValueType)); + } + + template <class _Tp, class ..._Ts> + _LIBCPP_INLINE_VISIBILITY + void construct(_Tp* __p, _Ts &&... __args) + { + _VSTD_LFTS::__lfts_user_alloc_construct( + __p, *this, _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, polymorphic_allocator&, _Args1... + >::type() + , _VSTD::move(__x) + , typename __make_tuple_indices<sizeof...(_Args1)>::type{} + ) + , __transform_tuple( + typename __lfts_uses_alloc_ctor< + _T2, polymorphic_allocator&, _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 + 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&, polymorphic_allocator&, _Args&&...> + __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t, + __tuple_indices<_Idx...>) + { + using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>; + return _Tup(allocator_arg, *this, + _VSTD::get<_Idx>(_VSTD::move(__t))...); + } + + template <class ..._Args, size_t ..._Idx> + _LIBCPP_INLINE_VISIBILITY + tuple<_Args&&..., polymorphic_allocator&> + __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t, + __tuple_indices<_Idx...>) + { + using _Tup = tuple<_Args&&..., polymorphic_allocator&>; + return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., *this); + } + + _LIBCPP_INLINE_VISIBILITY + size_t __max_size() const _NOEXCEPT + { return numeric_limits<size_t>::max() / sizeof(value_type); } + + 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_TEMPLATE_VIS __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 = _LIBCPP_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 +private: + virtual void * do_allocate(size_t __bytes, size_t) + { + if (__bytes > __max_size()) { + __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; + } + + _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 + +_LIBCPP_POP_MACROS + +#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const b/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const new file mode 100644 index 0000000000..ce4b879b7e --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const @@ -0,0 +1,577 @@ +// -*- C++ -*- +//===------------------------ propagate_const -----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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> +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 +{ +public: + typedef remove_reference_t<decltype(*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) +{ + __pc1.swap(__pc2); +} + +template <class _Tp> +_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT +{ + return __pt.__t_; +} + +template <class _Tp> +_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/contrib/libs/cxxsupp/libcxx/include/experimental/regex b/contrib/libs/cxxsupp/libcxx/include/experimental/regex new file mode 100644 index 0000000000..dcd45ac56a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/regex @@ -0,0 +1,63 @@ +// -*- C++ -*- +//===----------------------------- regex ----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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<_VSTD_LFTS_PMR::string::const_iterator> smatch; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef match_results<const wchar_t*> wcmatch; +typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch; +#endif + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_REGEX */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/set b/contrib/libs/cxxsupp/libcxx/include/experimental/set new file mode 100644 index 0000000000..52f4df3842 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/set @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===--------------------------- list ------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/simd b/contrib/libs/cxxsupp/libcxx/include/experimental/simd new file mode 100644 index 0000000000..59a7139585 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/simd @@ -0,0 +1,1572 @@ +// -*- C++ -*- +//===------------------------------- simd ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_SIMD +#define _LIBCPP_EXPERIMENTAL_SIMD + +/* + experimental/simd synopsis + +namespace std::experimental { + +inline namespace parallelism_v2 { + +namespace simd_abi { + +struct scalar {}; +template <int N> struct fixed_size {}; +template <typename T> inline constexpr int max_fixed_size = implementation-defined; +template <typename T> using compatible = implementation-defined; +template <typename T> using native = implementation-defined; + +} // simd_abi + +struct element_aligned_tag {}; +struct vector_aligned_tag {}; +template <size_t> struct overaligned_tag {}; +inline constexpr element_aligned_tag element_aligned{}; +inline constexpr vector_aligned_tag vector_aligned{}; +template <size_t N> inline constexpr overaligned_tag<N> overaligned{}; + +// traits [simd.traits] +template <class T> struct is_abi_tag; +template <class T> inline constexpr bool is_abi_tag_v = is_abi_tag<T>::value; + +template <class T> struct is_simd; +template <class T> inline constexpr bool is_simd_v = is_simd<T>::value; + +template <class T> struct is_simd_mask; +template <class T> inline constexpr bool is_simd_mask_v = is_simd_mask<T>::value; + +template <class T> struct is_simd_flag_type; +template <class T> inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<T>::value; + +template <class T, size_t N> struct abi_for_size { using type = see below; }; +template <class T, size_t N> using abi_for_size_t = typename abi_for_size<T, N>::type; + +template <class T, class Abi = simd_abi::compatible<T>> struct simd_size; +template <class T, class Abi = simd_abi::compatible<T>> +inline constexpr size_t simd_size_v = simd_size<T, Abi>::value; + +template <class T, class U = typename T::value_type> struct memory_alignment; +template <class T, class U = typename T::value_type> +inline constexpr size_t memory_alignment_v = memory_alignment<T, U>::value; + +// class template simd [simd.class] +template <class T, class Abi = simd_abi::compatible<T>> class simd; +template <class T> using native_simd = simd<T, simd_abi::native<T>>; +template <class T, int N> using fixed_size_simd = simd<T, simd_abi::fixed_size<N>>; + +// class template simd_mask [simd.mask.class] +template <class T, class Abi = simd_abi::compatible<T>> class simd_mask; +template <class T> using native_simd_mask = simd_mask<T, simd_abi::native<T>>; +template <class T, int N> using fixed_size_simd_mask = simd_mask<T, simd_abi::fixed_size<N>>; + +// casts [simd.casts] +template <class T, class U, class Abi> see below simd_cast(const simd<U, Abi>&); +template <class T, class U, class Abi> see below static_simd_cast(const simd<U, Abi>&); + +template <class T, class Abi> +fixed_size_simd<T, simd_size_v<T, Abi>> to_fixed_size(const simd<T, Abi>&) noexcept; +template <class T, class Abi> +fixed_size_simd_mask<T, simd_size_v<T, Abi>> to_fixed_size(const simd_mask<T, Abi>&) noexcept; +template <class T, size_t N> native_simd<T> to_native(const fixed_size_simd<T, N>&) noexcept; +template <class T, size_t N> +native_simd_mask<T> to_native(const fixed_size_simd_mask<T, N>> &) noexcept; +template <class T, size_t N> simd<T> to_compatible(const fixed_size_simd<T, N>&) noexcept; +template <class T, size_t N> simd_mask<T> to_compatible(const fixed_size_simd_mask<T, N>&) noexcept; + +template <size_t... Sizes, class T, class Abi> +tuple<simd<T, abi_for_size_t<Sizes>>...> split(const simd<T, Abi>&); +template <size_t... Sizes, class T, class Abi> +tuple<simd_mask<T, abi_for_size_t<Sizes>>...> split(const simd_mask<T, Abi>&); +template <class V, class Abi> +array<V, simd_size_v<typename V::value_type, Abi> / V::size()> split( +const simd<typename V::value_type, Abi>&); +template <class V, class Abi> +array<V, simd_size_v<typename V::value_type, Abi> / V::size()> split( +const simd_mask<typename V::value_type, Abi>&); + +template <class T, class... Abis> +simd<T, abi_for_size_t<T, (simd_size_v<T, Abis> + ...)>> concat(const simd<T, Abis>&...); +template <class T, class... Abis> +simd_mask<T, abi_for_size_t<T, (simd_size_v<T, Abis> + ...)>> concat(const simd_mask<T, Abis>&...); + +// reductions [simd.mask.reductions] +template <class T, class Abi> bool all_of(const simd_mask<T, Abi>&) noexcept; +template <class T, class Abi> bool any_of(const simd_mask<T, Abi>&) noexcept; +template <class T, class Abi> bool none_of(const simd_mask<T, Abi>&) noexcept; +template <class T, class Abi> bool some_of(const simd_mask<T, Abi>&) noexcept; +template <class T, class Abi> int popcount(const simd_mask<T, Abi>&) noexcept; +template <class T, class Abi> int find_first_set(const simd_mask<T, Abi>&); +template <class T, class Abi> int find_last_set(const simd_mask<T, Abi>&); + +bool all_of(see below) noexcept; +bool any_of(see below) noexcept; +bool none_of(see below) noexcept; +bool some_of(see below) noexcept; +int popcount(see below) noexcept; +int find_first_set(see below) noexcept; +int find_last_set(see below) noexcept; + +// masked assignment [simd.whereexpr] +template <class M, class T> class const_where_expression; +template <class M, class T> class where_expression; + +// masked assignment [simd.mask.where] +template <class T> struct nodeduce { using type = T; }; // exposition only + +template <class T> using nodeduce_t = typename nodeduce<T>::type; // exposition only + +template <class T, class Abi> +where_expression<simd_mask<T, Abi>, simd<T, Abi>> +where(const typename simd<T, Abi>::mask_type&, simd<T, Abi>&) noexcept; + +template <class T, class Abi> +const_where_expression<simd_mask<T, Abi>, const simd<T, Abi>> +where(const typename simd<T, Abi>::mask_type&, const simd<T, Abi>&) noexcept; + +template <class T, class Abi> +where_expression<simd_mask<T, Abi>, simd_mask<T, Abi>> +where(const nodeduce_t<simd_mask<T, Abi>>&, simd_mask<T, Abi>&) noexcept; + +template <class T, class Abi> +const_where_expression<simd_mask<T, Abi>, const simd_mask<T, Abi>> +where(const nodeduce_t<simd_mask<T, Abi>>&, const simd_mask<T, Abi>&) noexcept; + +template <class T> where_expression<bool, T> where(see below k, T& d) noexcept; + +template <class T> +const_where_expression<bool, const T> where(see below k, const T& d) noexcept; + +// reductions [simd.reductions] +template <class T, class Abi, class BinaryOperation = std::plus<>> +T reduce(const simd<T, Abi>&, BinaryOperation = BinaryOperation()); + +template <class M, class V, class BinaryOperation> +typename V::value_type reduce(const const_where_expression<M, V>& x, +typename V::value_type neutral_element, BinaryOperation binary_op); + +template <class M, class V> +typename V::value_type reduce(const const_where_expression<M, V>& x, plus<> binary_op = plus<>()); + +template <class M, class V> +typename V::value_type reduce(const const_where_expression<M, V>& x, multiplies<> binary_op); + +template <class M, class V> +typename V::value_type reduce(const const_where_expression<M, V>& x, bit_and<> binary_op); + +template <class M, class V> +typename V::value_type reduce(const const_where_expression<M, V>& x, bit_or<> binary_op); + +template <class M, class V> +typename V::value_type reduce(const const_where_expression<M, V>& x, bit_xor<> binary_op); + +template <class T, class Abi> T hmin(const simd<T, Abi>&); +template <class M, class V> T hmin(const const_where_expression<M, V>&); +template <class T, class Abi> T hmax(const simd<T, Abi>&); +template <class M, class V> T hmax(const const_where_expression<M, V>&); + +// algorithms [simd.alg] +template <class T, class Abi> simd<T, Abi> min(const simd<T, Abi>&, const simd<T, Abi>&) noexcept; + +template <class T, class Abi> simd<T, Abi> max(const simd<T, Abi>&, const simd<T, Abi>&) noexcept; + +template <class T, class Abi> +std::pair<simd<T, Abi>, simd<T, Abi>> minmax(const simd<T, Abi>&, const simd<T, Abi>&) noexcept; + +template <class T, class Abi> +simd<T, Abi> clamp(const simd<T, Abi>& v, const simd<T, Abi>& lo, const simd<T, Abi>& hi); + +// [simd.whereexpr] +template <class M, class T> +class const_where_expression { + const M& mask; // exposition only + T& data; // exposition only +public: + const_where_expression(const const_where_expression&) = delete; + const_where_expression& operator=(const const_where_expression&) = delete; + remove_const_t<T> operator-() const &&; + template <class U, class Flags> void copy_to(U* mem, Flags f) const &&; +}; + +template <class M, class T> +class where_expression : public const_where_expression<M, T> { +public: + where_expression(const where_expression&) = delete; + where_expression& operator=(const where_expression&) = delete; + template <class U> void operator=(U&& x); + template <class U> void operator+=(U&& x); + template <class U> void operator-=(U&& x); + template <class U> void operator*=(U&& x); + template <class U> void operator/=(U&& x); + template <class U> void operator%=(U&& x); + template <class U> void operator&=(U&& x); + template <class U> void operator|=(U&& x); + template <class U> void operator^=(U&& x); + template <class U> void operator<<=(U&& x); + template <class U> void operator>>=(U&& x); + void operator++(); + void operator++(int); + void operator--(); + void operator--(int); + template <class U, class Flags> void copy_from(const U* mem, Flags); +}; + +// [simd.class] +template <class T, class Abi> class simd { +public: + using value_type = T; + using reference = see below; + using mask_type = simd_mask<T, Abi>; + + using abi_type = Abi; + static constexpr size_t size() noexcept; + simd() = default; + + // implicit type conversion constructor + template <class U> simd(const simd<U, simd_abi::fixed_size<size()>>&); + + // implicit broadcast constructor (see below for constraints) + template <class U> simd(U&& value); + + // generator constructor (see below for constraints) + template <class G> explicit simd(G&& gen); + + // load constructor + template <class U, class Flags> simd(const U* mem, Flags f); + + // loads [simd.load] + template <class U, class Flags> void copy_from(const U* mem, Flags f); + + // stores [simd.store] + template <class U, class Flags> void copy_to(U* mem, Flags f) const; + + // scalar access [simd.subscr] + reference operator[](size_t); + value_type operator[](size_t) const; + + // unary operators [simd.unary] + simd& operator++(); + simd operator++(int); + simd& operator--(); + simd operator--(int); + mask_type operator!() const; + simd operator~() const; // see below + simd operator+() const; + simd operator-() const; + + // binary operators [simd.binary] + friend simd operator+ (const simd&, const simd&); + friend simd operator- (const simd&, const simd&); + friend simd operator* (const simd&, const simd&); + friend simd operator/ (const simd&, const simd&); + friend simd operator% (const simd&, const simd&); + friend simd operator& (const simd&, const simd&); + friend simd operator| (const simd&, const simd&); + friend simd operator^ (const simd&, const simd&); + friend simd operator<<(const simd&, const simd&); + friend simd operator>>(const simd&, const simd&); + friend simd operator<<(const simd&, int); + friend simd operator>>(const simd&, int); + + // compound assignment [simd.cassign] + friend simd& operator+= (simd&, const simd&); + friend simd& operator-= (simd&, const simd&); + friend simd& operator*= (simd&, const simd&); + friend simd& operator/= (simd&, const simd&); + friend simd& operator%= (simd&, const simd&); + + friend simd& operator&= (simd&, const simd&); + friend simd& operator|= (simd&, const simd&); + friend simd& operator^= (simd&, const simd&); + friend simd& operator<<=(simd&, const simd&); + friend simd& operator>>=(simd&, const simd&); + friend simd& operator<<=(simd&, int); + friend simd& operator>>=(simd&, int); + + // compares [simd.comparison] + friend mask_type operator==(const simd&, const simd&); + friend mask_type operator!=(const simd&, const simd&); + friend mask_type operator>=(const simd&, const simd&); + friend mask_type operator<=(const simd&, const simd&); + friend mask_type operator> (const simd&, const simd&); + friend mask_type operator< (const simd&, const simd&); +}; + +// [simd.math] +template <class Abi> using scharv = simd<signed char, Abi>; // exposition only +template <class Abi> using shortv = simd<short, Abi>; // exposition only +template <class Abi> using intv = simd<int, Abi>; // exposition only +template <class Abi> using longv = simd<long int, Abi>; // exposition only +template <class Abi> using llongv = simd<long long int, Abi>; // exposition only +template <class Abi> using floatv = simd<float, Abi>; // exposition only +template <class Abi> using doublev = simd<double, Abi>; // exposition only +template <class Abi> using ldoublev = simd<long double, Abi>; // exposition only +template <class T, class V> using samesize = fixed_size_simd<T, V::size()>; // exposition only + +template <class Abi> floatv<Abi> acos(floatv<Abi> x); +template <class Abi> doublev<Abi> acos(doublev<Abi> x); +template <class Abi> ldoublev<Abi> acos(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> asin(floatv<Abi> x); +template <class Abi> doublev<Abi> asin(doublev<Abi> x); +template <class Abi> ldoublev<Abi> asin(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> atan(floatv<Abi> x); +template <class Abi> doublev<Abi> atan(doublev<Abi> x); +template <class Abi> ldoublev<Abi> atan(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> atan2(floatv<Abi> y, floatv<Abi> x); +template <class Abi> doublev<Abi> atan2(doublev<Abi> y, doublev<Abi> x); +template <class Abi> ldoublev<Abi> atan2(ldoublev<Abi> y, ldoublev<Abi> x); + +template <class Abi> floatv<Abi> cos(floatv<Abi> x); +template <class Abi> doublev<Abi> cos(doublev<Abi> x); +template <class Abi> ldoublev<Abi> cos(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> sin(floatv<Abi> x); +template <class Abi> doublev<Abi> sin(doublev<Abi> x); +template <class Abi> ldoublev<Abi> sin(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> tan(floatv<Abi> x); +template <class Abi> doublev<Abi> tan(doublev<Abi> x); +template <class Abi> ldoublev<Abi> tan(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> acosh(floatv<Abi> x); +template <class Abi> doublev<Abi> acosh(doublev<Abi> x); +template <class Abi> ldoublev<Abi> acosh(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> asinh(floatv<Abi> x); +template <class Abi> doublev<Abi> asinh(doublev<Abi> x); +template <class Abi> ldoublev<Abi> asinh(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> atanh(floatv<Abi> x); +template <class Abi> doublev<Abi> atanh(doublev<Abi> x); +template <class Abi> ldoublev<Abi> atanh(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> cosh(floatv<Abi> x); +template <class Abi> doublev<Abi> cosh(doublev<Abi> x); +template <class Abi> ldoublev<Abi> cosh(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> sinh(floatv<Abi> x); +template <class Abi> doublev<Abi> sinh(doublev<Abi> x); +template <class Abi> ldoublev<Abi> sinh(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> tanh(floatv<Abi> x); +template <class Abi> doublev<Abi> tanh(doublev<Abi> x); +template <class Abi> ldoublev<Abi> tanh(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> exp(floatv<Abi> x); +template <class Abi> doublev<Abi> exp(doublev<Abi> x); +template <class Abi> ldoublev<Abi> exp(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> exp2(floatv<Abi> x); +template <class Abi> doublev<Abi> exp2(doublev<Abi> x); +template <class Abi> ldoublev<Abi> exp2(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> expm1(floatv<Abi> x); +template <class Abi> doublev<Abi> expm1(doublev<Abi> x); +template <class Abi> ldoublev<Abi> expm1(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> frexp(floatv<Abi> value, samesize<int, floatv<Abi>>* exp); +template <class Abi> doublev<Abi> frexp(doublev<Abi> value, samesize<int, doublev<Abi>>* exp); +template <class Abi> ldoublev<Abi> frexp(ldoublev<Abi> value, samesize<int, ldoublev<Abi>>* exp); + +template <class Abi> samesize<int, floatv<Abi>> ilogb(floatv<Abi> x); +template <class Abi> samesize<int, doublev<Abi>> ilogb(doublev<Abi> x); +template <class Abi> samesize<int, ldoublev<Abi>> ilogb(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> ldexp(floatv<Abi> x, samesize<int, floatv<Abi>> exp); +template <class Abi> doublev<Abi> ldexp(doublev<Abi> x, samesize<int, doublev<Abi>> exp); +template <class Abi> ldoublev<Abi> ldexp(ldoublev<Abi> x, samesize<int, ldoublev<Abi>> exp); + +template <class Abi> floatv<Abi> log(floatv<Abi> x); +template <class Abi> doublev<Abi> log(doublev<Abi> x); +template <class Abi> ldoublev<Abi> log(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> log10(floatv<Abi> x); +template <class Abi> doublev<Abi> log10(doublev<Abi> x); +template <class Abi> ldoublev<Abi> log10(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> log1p(floatv<Abi> x); +template <class Abi> doublev<Abi> log1p(doublev<Abi> x); +template <class Abi> ldoublev<Abi> log1p(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> log2(floatv<Abi> x); +template <class Abi> doublev<Abi> log2(doublev<Abi> x); +template <class Abi> ldoublev<Abi> log2(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> logb(floatv<Abi> x); +template <class Abi> doublev<Abi> logb(doublev<Abi> x); +template <class Abi> ldoublev<Abi> logb(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> modf(floatv<Abi> value, floatv<Abi>* iptr); +template <class Abi> doublev<Abi> modf(doublev<Abi> value, doublev<Abi>* iptr); +template <class Abi> ldoublev<Abi> modf(ldoublev<Abi> value, ldoublev<Abi>* iptr); + +template <class Abi> floatv<Abi> scalbn(floatv<Abi> x, samesize<int, floatv<Abi>> n); +template <class Abi> doublev<Abi> scalbn(doublev<Abi> x, samesize<int, doublev<Abi>> n); +template <class Abi> ldoublev<Abi> scalbn(ldoublev<Abi> x, samesize<int, ldoublev<Abi>> n); +template <class Abi> floatv<Abi> scalbln(floatv<Abi> x, samesize<long int, floatv<Abi>> n); +template <class Abi> doublev<Abi> scalbln(doublev<Abi> x, samesize<long int, doublev<Abi>> n); +template <class Abi> ldoublev<Abi> scalbln(ldoublev<Abi> x, samesize<long int, ldoublev<Abi>> n); + +template <class Abi> floatv<Abi> cbrt(floatv<Abi> x); +template <class Abi> doublev<Abi> cbrt(doublev<Abi> x); +template <class Abi> ldoublev<Abi> cbrt(ldoublev<Abi> x); + +template <class Abi> scharv<Abi> abs(scharv<Abi> j); +template <class Abi> shortv<Abi> abs(shortv<Abi> j); +template <class Abi> intv<Abi> abs(intv<Abi> j); +template <class Abi> longv<Abi> abs(longv<Abi> j); +template <class Abi> llongv<Abi> abs(llongv<Abi> j); +template <class Abi> floatv<Abi> abs(floatv<Abi> j); +template <class Abi> doublev<Abi> abs(doublev<Abi> j); +template <class Abi> ldoublev<Abi> abs(ldoublev<Abi> j); + +template <class Abi> floatv<Abi> hypot(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y); +template <class Abi> floatv<Abi> hypot(floatv<Abi> x, floatv<Abi> y, floatv<Abi> z); +template <class Abi> doublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y, doublev<Abi> z); +template <class Abi> ldoublev<Abi> hypot(ldoublev<Abi> x, ldoublev<Abi> y, ldoublev<Abi> z); + +template <class Abi> floatv<Abi> pow(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> pow(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> pow(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> sqrt(floatv<Abi> x); +template <class Abi> doublev<Abi> sqrt(doublev<Abi> x); +template <class Abi> ldoublev<Abi> sqrt(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> erf(floatv<Abi> x); +template <class Abi> doublev<Abi> erf(doublev<Abi> x); +template <class Abi> ldoublev<Abi> erf(ldoublev<Abi> x); +template <class Abi> floatv<Abi> erfc(floatv<Abi> x); +template <class Abi> doublev<Abi> erfc(doublev<Abi> x); +template <class Abi> ldoublev<Abi> erfc(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> lgamma(floatv<Abi> x); +template <class Abi> doublev<Abi> lgamma(doublev<Abi> x); +template <class Abi> ldoublev<Abi> lgamma(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> tgamma(floatv<Abi> x); +template <class Abi> doublev<Abi> tgamma(doublev<Abi> x); +template <class Abi> ldoublev<Abi> tgamma(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> ceil(floatv<Abi> x); +template <class Abi> doublev<Abi> ceil(doublev<Abi> x); +template <class Abi> ldoublev<Abi> ceil(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> floor(floatv<Abi> x); +template <class Abi> doublev<Abi> floor(doublev<Abi> x); +template <class Abi> ldoublev<Abi> floor(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> nearbyint(floatv<Abi> x); +template <class Abi> doublev<Abi> nearbyint(doublev<Abi> x); +template <class Abi> ldoublev<Abi> nearbyint(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> rint(floatv<Abi> x); +template <class Abi> doublev<Abi> rint(doublev<Abi> x); +template <class Abi> ldoublev<Abi> rint(ldoublev<Abi> x); + +template <class Abi> samesize<long int, floatv<Abi>> lrint(floatv<Abi> x); +template <class Abi> samesize<long int, doublev<Abi>> lrint(doublev<Abi> x); +template <class Abi> samesize<long int, ldoublev<Abi>> lrint(ldoublev<Abi> x); +template <class Abi> samesize<long long int, floatv<Abi>> llrint(floatv<Abi> x); +template <class Abi> samesize<long long int, doublev<Abi>> llrint(doublev<Abi> x); +template <class Abi> samesize<long long int, ldoublev<Abi>> llrint(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> round(floatv<Abi> x); +template <class Abi> doublev<Abi> round(doublev<Abi> x); +template <class Abi> ldoublev<Abi> round(ldoublev<Abi> x); +template <class Abi> samesize<long int, floatv<Abi>> lround(floatv<Abi> x); +template <class Abi> samesize<long int, doublev<Abi>> lround(doublev<Abi> x); +template <class Abi> samesize<long int, ldoublev<Abi>> lround(ldoublev<Abi> x); +template <class Abi> samesize<long long int, floatv<Abi>> llround(floatv<Abi> x); +template <class Abi> samesize<long long int, doublev<Abi>> llround(doublev<Abi> x); +template <class Abi> samesize<long long int, ldoublev<Abi>> llround(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> trunc(floatv<Abi> x); +template <class Abi> doublev<Abi> trunc(doublev<Abi> x); +template <class Abi> ldoublev<Abi> trunc(ldoublev<Abi> x); + +template <class Abi> floatv<Abi> fmod(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> fmod(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> fmod(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> remainder(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> remainder(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> remainder(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> remquo(floatv<Abi> x, floatv<Abi> y, samesize<int, floatv<Abi>>* quo); +template <class Abi> doublev<Abi> remquo(doublev<Abi> x, doublev<Abi> y, samesize<int, doublev<Abi>>* quo); +template <class Abi> ldoublev<Abi> remquo(ldoublev<Abi> x, ldoublev<Abi> y, samesize<int, ldoublev<Abi>>* quo); + +template <class Abi> floatv<Abi> copysign(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> copysign(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> copysign(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> doublev<Abi> nan(const char* tagp); +template <class Abi> floatv<Abi> nanf(const char* tagp); +template <class Abi> ldoublev<Abi> nanl(const char* tagp); + +template <class Abi> floatv<Abi> nextafter(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> nextafter(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> nextafter(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> nexttoward(floatv<Abi> x, ldoublev<Abi> y); +template <class Abi> doublev<Abi> nexttoward(doublev<Abi> x, ldoublev<Abi> y); +template <class Abi> ldoublev<Abi> nexttoward(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> fdim(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> fdim(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> fdim(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> fmax(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> fmax(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> fmax(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> fmin(floatv<Abi> x, floatv<Abi> y); +template <class Abi> doublev<Abi> fmin(doublev<Abi> x, doublev<Abi> y); +template <class Abi> ldoublev<Abi> fmin(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> floatv<Abi> fma(floatv<Abi> x, floatv<Abi> y, floatv<Abi> z); +template <class Abi> doublev<Abi> fma(doublev<Abi> x, doublev<Abi> y, doublev<Abi> z); +template <class Abi> ldoublev<Abi> fma(ldoublev<Abi> x, ldoublev<Abi> y, ldoublev<Abi> z); + +template <class Abi> samesize<int, floatv<Abi>> fpclassify(floatv<Abi> x); +template <class Abi> samesize<int, doublev<Abi>> fpclassify(doublev<Abi> x); +template <class Abi> samesize<int, ldoublev<Abi>> fpclassify(ldoublev<Abi> x); + +template <class Abi> simd_mask<float, Abi> isfinite(floatv<Abi> x); +template <class Abi> simd_mask<double, Abi> isfinite(doublev<Abi> x); +template <class Abi> simd_mask<long double, Abi> isfinite(ldoublev<Abi> x); + +template <class Abi> simd_mask<float, Abi> isinf(floatv<Abi> x); +template <class Abi> simd_mask<double, Abi> isinf(doublev<Abi> x); +template <class Abi> simd_mask<long double, Abi> isinf(ldoublev<Abi> x); + +template <class Abi> simd_mask<float, Abi> isnan(floatv<Abi> x); +template <class Abi> simd_mask<double, Abi> isnan(doublev<Abi> x); +template <class Abi> simd_mask<long double, Abi> isnan(ldoublev<Abi> x); + +template <class Abi> simd_mask<float, Abi> isnormal(floatv<Abi> x); +template <class Abi> simd_mask<double, Abi> isnormal(doublev<Abi> x); +template <class Abi> simd_mask<long double, Abi> isnormal(ldoublev<Abi> x); + +template <class Abi> simd_mask<float, Abi> signbit(floatv<Abi> x); +template <class Abi> simd_mask<double, Abi> signbit(doublev<Abi> x); +template <class Abi> simd_mask<long double, Abi> signbit(ldoublev<Abi> x); + +template <class Abi> simd_mask<float, Abi> isgreater(floatv<Abi> x, floatv<Abi> y); +template <class Abi> simd_mask<double, Abi> isgreater(doublev<Abi> x, doublev<Abi> y); +template <class Abi> simd_mask<long double, Abi> isgreater(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> simd_mask<float, Abi> isgreaterequal(floatv<Abi> x, floatv<Abi> y); +template <class Abi> simd_mask<double, Abi> isgreaterequal(doublev<Abi> x, doublev<Abi> y); +template <class Abi> simd_mask<long double, Abi> isgreaterequal(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> simd_mask<float, Abi> isless(floatv<Abi> x, floatv<Abi> y); +template <class Abi> simd_mask<double, Abi> isless(doublev<Abi> x, doublev<Abi> y); +template <class Abi> simd_mask<long double, Abi> isless(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> simd_mask<float, Abi> islessequal(floatv<Abi> x, floatv<Abi> y); +template <class Abi> simd_mask<double, Abi> islessequal(doublev<Abi> x, doublev<Abi> y); +template <class Abi> simd_mask<long double, Abi> islessequal(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> simd_mask<float, Abi> islessgreater(floatv<Abi> x, floatv<Abi> y); +template <class Abi> simd_mask<double, Abi> islessgreater(doublev<Abi> x, doublev<Abi> y); +template <class Abi> simd_mask<long double, Abi> islessgreater(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class Abi> simd_mask<float, Abi> isunordered(floatv<Abi> x, floatv<Abi> y); +template <class Abi> simd_mask<double, Abi> isunordered(doublev<Abi> x, doublev<Abi> y); +template <class Abi> simd_mask<long double, Abi> isunordered(ldoublev<Abi> x, ldoublev<Abi> y); + +template <class V> struct simd_div_t { V quot, rem; }; +template <class Abi> simd_div_t<scharv<Abi>> div(scharv<Abi> numer, scharv<Abi> denom); +template <class Abi> simd_div_t<shortv<Abi>> div(shortv<Abi> numer, shortv<Abi> denom); +template <class Abi> simd_div_t<intv<Abi>> div(intv<Abi> numer, intv<Abi> denom); +template <class Abi> simd_div_t<longv<Abi>> div(longv<Abi> numer, longv<Abi> denom); +template <class Abi> simd_div_t<llongv<Abi>> div(llongv<Abi> numer, llongv<Abi> denom); + +// [simd.mask.class] +template <class T, class Abi> +class simd_mask { +public: + using value_type = bool; + using reference = see below; + using simd_type = simd<T, Abi>; + using abi_type = Abi; + static constexpr size_t size() noexcept; + simd_mask() = default; + + // broadcast constructor + explicit simd_mask(value_type) noexcept; + + // implicit type conversion constructor + template <class U> simd_mask(const simd_mask<U, simd_abi::fixed_size<size()>>&) noexcept; + + // load constructor + template <class Flags> simd_mask(const value_type* mem, Flags); + + // loads [simd.mask.copy] + template <class Flags> void copy_from(const value_type* mem, Flags); + template <class Flags> void copy_to(value_type* mem, Flags) const; + + // scalar access [simd.mask.subscr] + reference operator[](size_t); + value_type operator[](size_t) const; + + // unary operators [simd.mask.unary] + simd_mask operator!() const noexcept; + + // simd_mask binary operators [simd.mask.binary] + friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator& (const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator| (const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator^ (const simd_mask&, const simd_mask&) noexcept; + + // simd_mask compound assignment [simd.mask.cassign] + friend simd_mask& operator&=(simd_mask&, const simd_mask&) noexcept; + friend simd_mask& operator|=(simd_mask&, const simd_mask&) noexcept; + friend simd_mask& operator^=(simd_mask&, const simd_mask&) noexcept; + + // simd_mask compares [simd.mask.comparison] + friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept; +}; + +} // parallelism_v2 +} // std::experimental + +*/ + +#include <experimental/__config> +#include <algorithm> +#include <array> +#include <cstddef> +#include <functional> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD + +#if _LIBCPP_STD_VER >= 17 + +enum class _StorageKind { + _Scalar, + _Array, + _VecExt, +}; + +template <_StorageKind __kind, int _Np> +struct __simd_abi {}; + +template <class _Tp, class _Abi> +class __simd_storage {}; + +template <class _Tp, int __num_element> +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { + std::array<_Tp, __num_element> __storage_; + + template <class, class> + friend struct simd; + + template <class, class> + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { + __storage_[__index] = __val; + } +}; + +template <class _Tp> +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { + _Tp __storage_; + + template <class, class> + friend struct simd; + + template <class, class> + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { + (&__storage_)[__index] = __val; + } +}; + +#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION + +constexpr size_t __floor_pow_of_2(size_t __val) { + return ((__val - 1) & __val) == 0 ? __val + : __floor_pow_of_2((__val - 1) & __val); +} + +constexpr size_t __ceil_pow_of_2(size_t __val) { + return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1; +} + +template <class _Tp, size_t __bytes> +struct __vec_ext_traits { +#if !defined(_LIBCPP_COMPILER_CLANG_BASED) + typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes)))); +#endif +}; + +#if defined(_LIBCPP_COMPILER_CLANG_BASED) +#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT) \ + template <> \ + struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> { \ + using type = \ + _TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT))); \ + } + +#define _LIBCPP_SPECIALIZE_VEC_EXT_32(_TYPE) \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 1); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 2); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 3); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 4); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 5); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 6); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 7); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 8); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 9); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 10); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 11); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 12); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 13); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 14); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 15); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 16); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 17); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 18); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 19); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 20); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 21); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 22); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 23); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 24); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 25); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 26); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 27); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 28); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 29); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 30); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 31); \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32); + +_LIBCPP_SPECIALIZE_VEC_EXT_32(char); +_LIBCPP_SPECIALIZE_VEC_EXT_32(char16_t); +_LIBCPP_SPECIALIZE_VEC_EXT_32(char32_t); +_LIBCPP_SPECIALIZE_VEC_EXT_32(wchar_t); +_LIBCPP_SPECIALIZE_VEC_EXT_32(signed char); +_LIBCPP_SPECIALIZE_VEC_EXT_32(signed short); +_LIBCPP_SPECIALIZE_VEC_EXT_32(signed int); +_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long); +_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long long); +_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned char); +_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned short); +_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned int); +_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long); +_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long long); +_LIBCPP_SPECIALIZE_VEC_EXT_32(float); +_LIBCPP_SPECIALIZE_VEC_EXT_32(double); +_LIBCPP_SPECIALIZE_VEC_EXT_32(long double); + +#undef _LIBCPP_SPECIALIZE_VEC_EXT_32 +#undef _LIBCPP_SPECIALIZE_VEC_EXT +#endif + +template <class _Tp, int __num_element> +class __simd_storage<_Tp, __simd_abi<_StorageKind::_VecExt, __num_element>> { + using _StorageType = + typename __vec_ext_traits<_Tp, sizeof(_Tp) * __num_element>::type; + + _StorageType __storage_; + + template <class, class> + friend struct simd; + + template <class, class> + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { + __storage_[__index] = __val; + } +}; + +#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION + +template <class _Vp, class _Tp, class _Abi> +class __simd_reference { + static_assert(std::is_same<_Vp, _Tp>::value, ""); + + template <class, class> + friend struct simd; + + template <class, class> + friend struct simd_mask; + + __simd_storage<_Tp, _Abi>* __ptr_; + size_t __index_; + + __simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index) + : __ptr_(__ptr), __index_(__index) {} + + __simd_reference(const __simd_reference&) = default; + +public: + __simd_reference() = delete; + __simd_reference& operator=(const __simd_reference&) = delete; + + operator _Vp() const { return __ptr_->__get(__index_); } + + __simd_reference operator=(_Vp __value) && { + __ptr_->__set(__index_, __value); + return *this; + } + + __simd_reference operator++() && { + return std::move(*this) = __ptr_->__get(__index_) + 1; + } + + _Vp operator++(int) && { + auto __val = __ptr_->__get(__index_); + __ptr_->__set(__index_, __val + 1); + return __val; + } + + __simd_reference operator--() && { + return std::move(*this) = __ptr_->__get(__index_) - 1; + } + + _Vp operator--(int) && { + auto __val = __ptr_->__get(__index_); + __ptr_->__set(__index_, __val - 1); + return __val; + } + + __simd_reference operator+=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) + __value; + } + + __simd_reference operator-=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) - __value; + } + + __simd_reference operator*=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) * __value; + } + + __simd_reference operator/=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) / __value; + } + + __simd_reference operator%=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) % __value; + } + + __simd_reference operator>>=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) >> __value; + } + + __simd_reference operator<<=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) << __value; + } + + __simd_reference operator&=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) & __value; + } + + __simd_reference operator|=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) | __value; + } + + __simd_reference operator^=(_Vp __value) && { + return std::move(*this) = __ptr_->__get(__index_) ^ __value; + } +}; + +template <class _To, class _From> +constexpr decltype(_To{std::declval<_From>()}, true) +__is_non_narrowing_convertible_impl(_From) { + return true; +} + +template <class _To> +constexpr bool __is_non_narrowing_convertible_impl(...) { + return false; +} + +template <class _From, class _To> +constexpr typename std::enable_if<std::is_arithmetic<_To>::value && + std::is_arithmetic<_From>::value, + bool>::type +__is_non_narrowing_arithmetic_convertible() { + return __is_non_narrowing_convertible_impl<_To>(_From{}); +} + +template <class _From, class _To> +constexpr typename std::enable_if<!(std::is_arithmetic<_To>::value && + std::is_arithmetic<_From>::value), + bool>::type +__is_non_narrowing_arithmetic_convertible() { + return false; +} + +template <class _Tp> +constexpr _Tp __variadic_sum() { + return _Tp{}; +} + +template <class _Tp, class _Up, class... _Args> +constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) { + return static_cast<_Tp>(__first) + __variadic_sum<_Tp>(__rest...); +} + +template <class _Tp> +struct __nodeduce { + using type = _Tp; +}; + +template <class _Tp> +constexpr bool __vectorizable() { + return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value && + !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value; +} + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI + +using scalar = __simd_abi<_StorageKind::_Scalar, 1>; + +template <int _Np> +using fixed_size = __simd_abi<_StorageKind::_Array, _Np>; + +template <class _Tp> +inline constexpr size_t max_fixed_size = 32; + +template <class _Tp> +using compatible = fixed_size<16 / sizeof(_Tp)>; + +#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION +template <class _Tp> +using native = __simd_abi<_StorageKind::_VecExt, + _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>; +#else +template <class _Tp> +using native = + fixed_size<_Tp, _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>; +#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD + +template <class _Tp, class _Abi = simd_abi::compatible<_Tp>> +class simd; +template <class _Tp, class _Abi = simd_abi::compatible<_Tp>> +class simd_mask; + +struct element_aligned_tag {}; +struct vector_aligned_tag {}; +template <size_t> +struct overaligned_tag {}; +inline constexpr element_aligned_tag element_aligned{}; +inline constexpr vector_aligned_tag vector_aligned{}; +template <size_t _Np> +inline constexpr overaligned_tag<_Np> overaligned{}; + +// traits [simd.traits] +template <class _Tp> +struct is_abi_tag : std::integral_constant<bool, false> {}; + +template <_StorageKind __kind, int _Np> +struct is_abi_tag<__simd_abi<__kind, _Np>> + : std::integral_constant<bool, true> {}; + +template <class _Tp> +struct is_simd : std::integral_constant<bool, false> {}; + +template <class _Tp, class _Abi> +struct is_simd<simd<_Tp, _Abi>> : std::integral_constant<bool, true> {}; + +template <class _Tp> +struct is_simd_mask : std::integral_constant<bool, false> {}; + +template <class _Tp, class _Abi> +struct is_simd_mask<simd_mask<_Tp, _Abi>> : std::integral_constant<bool, true> { +}; + +template <class _Tp> +struct is_simd_flag_type : std::integral_constant<bool, false> {}; + +template <> +struct is_simd_flag_type<element_aligned_tag> + : std::integral_constant<bool, true> {}; + +template <> +struct is_simd_flag_type<vector_aligned_tag> + : std::integral_constant<bool, true> {}; + +template <size_t _Align> +struct is_simd_flag_type<overaligned_tag<_Align>> + : std::integral_constant<bool, true> {}; + +template <class _Tp> +inline constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value; +template <class _Tp> +inline constexpr bool is_simd_v = is_simd<_Tp>::value; +template <class _Tp> +inline constexpr bool is_simd_mask_v = is_simd_mask<_Tp>::value; +template <class _Tp> +inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<_Tp>::value; +template <class _Tp, size_t _Np> +struct abi_for_size { + using type = simd_abi::fixed_size<_Np>; +}; +template <class _Tp, size_t _Np> +using abi_for_size_t = typename abi_for_size<_Tp, _Np>::type; + +template <class _Tp, class _Abi = simd_abi::compatible<_Tp>> +struct simd_size; + +template <class _Tp, _StorageKind __kind, int _Np> +struct simd_size<_Tp, __simd_abi<__kind, _Np>> + : std::integral_constant<size_t, _Np> { + static_assert( + std::is_arithmetic<_Tp>::value && + !std::is_same<typename std::remove_const<_Tp>::type, bool>::value, + "Element type should be vectorizable"); +}; + +// TODO: implement it. +template <class _Tp, class _Up = typename _Tp::value_type> +struct memory_alignment; + +template <class _Tp, class _Abi = simd_abi::compatible<_Tp>> +inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value; + +template <class _Tp, class _Up = typename _Tp::value_type> +inline constexpr size_t memory_alignment_v = memory_alignment<_Tp, _Up>::value; + +// class template simd [simd.class] +template <class _Tp> +using native_simd = simd<_Tp, simd_abi::native<_Tp>>; +template <class _Tp, int _Np> +using fixed_size_simd = simd<_Tp, simd_abi::fixed_size<_Np>>; + +// class template simd_mask [simd.mask.class] +template <class _Tp> +using native_simd_mask = simd_mask<_Tp, simd_abi::native<_Tp>>; + +template <class _Tp, int _Np> +using fixed_size_simd_mask = simd_mask<_Tp, simd_abi::fixed_size<_Np>>; + +// casts [simd.casts] +template <class _Tp> +struct __static_simd_cast_traits { + template <class _Up, class _Abi> + static simd<_Tp, _Abi> __apply(const simd<_Up, _Abi>& __v); +}; + +template <class _Tp, class _NewAbi> +struct __static_simd_cast_traits<simd<_Tp, _NewAbi>> { + template <class _Up, class _Abi> + static typename std::enable_if<simd<_Up, _Abi>::size() == + simd<_Tp, _NewAbi>::size(), + simd<_Tp, _NewAbi>>::type + __apply(const simd<_Up, _Abi>& __v); +}; + +template <class _Tp> +struct __simd_cast_traits { + template <class _Up, class _Abi> + static typename std::enable_if< + __is_non_narrowing_arithmetic_convertible<_Up, _Tp>(), + simd<_Tp, _Abi>>::type + __apply(const simd<_Up, _Abi>& __v); +}; + +template <class _Tp, class _NewAbi> +struct __simd_cast_traits<simd<_Tp, _NewAbi>> { + template <class _Up, class _Abi> + static typename std::enable_if< + __is_non_narrowing_arithmetic_convertible<_Up, _Tp>() && + simd<_Up, _Abi>::size() == simd<_Tp, _NewAbi>::size(), + simd<_Tp, _NewAbi>>::type + __apply(const simd<_Up, _Abi>& __v); +}; + +template <class _Tp, class _Up, class _Abi> +auto simd_cast(const simd<_Up, _Abi>& __v) + -> decltype(__simd_cast_traits<_Tp>::__apply(__v)) { + return __simd_cast_traits<_Tp>::__apply(__v); +} + +template <class _Tp, class _Up, class _Abi> +auto static_simd_cast(const simd<_Up, _Abi>& __v) + -> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) { + return __static_simd_cast_traits<_Tp>::__apply(__v); +} + +template <class _Tp, class _Abi> +fixed_size_simd<_Tp, simd_size<_Tp, _Abi>::value> +to_fixed_size(const simd<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +fixed_size_simd_mask<_Tp, simd_size<_Tp, _Abi>::value> +to_fixed_size(const simd_mask<_Tp, _Abi>&) noexcept; + +template <class _Tp, size_t _Np> +native_simd<_Tp> to_native(const fixed_size_simd<_Tp, _Np>&) noexcept; + +template <class _Tp, size_t _Np> +native_simd_mask<_Tp> to_native(const fixed_size_simd_mask<_Tp, _Np>&) noexcept; + +template <class _Tp, size_t _Np> +simd<_Tp> to_compatible(const fixed_size_simd<_Tp, _Np>&) noexcept; + +template <class _Tp, size_t _Np> +simd_mask<_Tp> to_compatible(const fixed_size_simd_mask<_Tp, _Np>&) noexcept; + +template <size_t... __sizes, class _Tp, class _Abi> +tuple<simd<_Tp, abi_for_size_t<_Tp, __sizes>>...> split(const simd<_Tp, _Abi>&); + +template <size_t... __sizes, class _Tp, class _Abi> +tuple<simd_mask<_Tp, abi_for_size_t<_Tp, __sizes>>...> +split(const simd_mask<_Tp, _Abi>&); + +template <class _SimdType, class _Abi> +array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value / + _SimdType::size()> +split(const simd<typename _SimdType::value_type, _Abi>&); + +template <class _SimdType, class _Abi> +array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value / + _SimdType::size()> +split(const simd_mask<typename _SimdType::value_type, _Abi>&); + +template <class _Tp, class... _Abis> +simd<_Tp, abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>> +concat(const simd<_Tp, _Abis>&...); + +template <class _Tp, class... _Abis> +simd_mask<_Tp, + abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>> +concat(const simd_mask<_Tp, _Abis>&...); + +// reductions [simd.mask.reductions] +template <class _Tp, class _Abi> +bool all_of(const simd_mask<_Tp, _Abi>&) noexcept; +template <class _Tp, class _Abi> +bool any_of(const simd_mask<_Tp, _Abi>&) noexcept; +template <class _Tp, class _Abi> +bool none_of(const simd_mask<_Tp, _Abi>&) noexcept; +template <class _Tp, class _Abi> +bool some_of(const simd_mask<_Tp, _Abi>&) noexcept; +template <class _Tp, class _Abi> +int popcount(const simd_mask<_Tp, _Abi>&) noexcept; +template <class _Tp, class _Abi> +int find_first_set(const simd_mask<_Tp, _Abi>&); +template <class _Tp, class _Abi> +int find_last_set(const simd_mask<_Tp, _Abi>&); +bool all_of(bool) noexcept; +bool any_of(bool) noexcept; +bool none_of(bool) noexcept; +bool some_of(bool) noexcept; +int popcount(bool) noexcept; +int find_first_set(bool) noexcept; +int find_last_set(bool) noexcept; + +// masked assignment [simd.whereexpr] +template <class _MaskType, class _Tp> +class const_where_expression; +template <class _MaskType, class _Tp> +class where_expression; + +// masked assignment [simd.mask.where] +template <class _Tp, class _Abi> +where_expression<simd_mask<_Tp, _Abi>, simd<_Tp, _Abi>> +where(const typename simd<_Tp, _Abi>::mask_type&, simd<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +const_where_expression<simd_mask<_Tp, _Abi>, const simd<_Tp, _Abi>> +where(const typename simd<_Tp, _Abi>::mask_type&, + const simd<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +where_expression<simd_mask<_Tp, _Abi>, simd_mask<_Tp, _Abi>> +where(const typename __nodeduce<simd_mask<_Tp, _Abi>>::type&, + simd_mask<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +const_where_expression<simd_mask<_Tp, _Abi>, const simd_mask<_Tp, _Abi>> +where(const typename __nodeduce<simd_mask<_Tp, _Abi>>::type&, + const simd_mask<_Tp, _Abi>&) noexcept; + +template <class _Tp> +where_expression<bool, _Tp> where(bool, _Tp&) noexcept; + +template <class _Tp> +const_where_expression<bool, const _Tp> where(bool, const _Tp&) noexcept; + +// reductions [simd.reductions] +template <class _Tp, class _Abi, class _BinaryOp = std::plus<_Tp>> +_Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp()); + +template <class _MaskType, class _SimdType, class _BinaryOp> +typename _SimdType::value_type +reduce(const const_where_expression<_MaskType, _SimdType>&, + typename _SimdType::value_type neutral_element, _BinaryOp binary_op); + +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +reduce(const const_where_expression<_MaskType, _SimdType>&, + plus<typename _SimdType::value_type> binary_op = {}); + +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +reduce(const const_where_expression<_MaskType, _SimdType>&, + multiplies<typename _SimdType::value_type> binary_op); + +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +reduce(const const_where_expression<_MaskType, _SimdType>&, + bit_and<typename _SimdType::value_type> binary_op); + +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +reduce(const const_where_expression<_MaskType, _SimdType>&, + bit_or<typename _SimdType::value_type> binary_op); + +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +reduce(const const_where_expression<_MaskType, _SimdType>&, + bit_xor<typename _SimdType::value_type> binary_op); + +template <class _Tp, class _Abi> +_Tp hmin(const simd<_Tp, _Abi>&); +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +hmin(const const_where_expression<_MaskType, _SimdType>&); +template <class _Tp, class _Abi> +_Tp hmax(const simd<_Tp, _Abi>&); +template <class _MaskType, class _SimdType> +typename _SimdType::value_type +hmax(const const_where_expression<_MaskType, _SimdType>&); + +// algorithms [simd.alg] +template <class _Tp, class _Abi> +simd<_Tp, _Abi> min(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +simd<_Tp, _Abi> max(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +std::pair<simd<_Tp, _Abi>, simd<_Tp, _Abi>> +minmax(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept; + +template <class _Tp, class _Abi> +simd<_Tp, _Abi> clamp(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&, + const simd<_Tp, _Abi>&); + +// [simd.whereexpr] +// TODO implement where expressions. +template <class _MaskType, class _Tp> +class const_where_expression { +public: + const_where_expression(const const_where_expression&) = delete; + const_where_expression& operator=(const const_where_expression&) = delete; + typename remove_const<_Tp>::type operator-() const&&; + template <class _Up, class _Flags> + void copy_to(_Up*, _Flags) const&&; +}; + +template <class _MaskType, class _Tp> +class where_expression : public const_where_expression<_MaskType, _Tp> { +public: + where_expression(const where_expression&) = delete; + where_expression& operator=(const where_expression&) = delete; + template <class _Up> + void operator=(_Up&&); + template <class _Up> + void operator+=(_Up&&); + template <class _Up> + void operator-=(_Up&&); + template <class _Up> + void operator*=(_Up&&); + template <class _Up> + void operator/=(_Up&&); + template <class _Up> + void operator%=(_Up&&); + template <class _Up> + void operator&=(_Up&&); + template <class _Up> + void operator|=(_Up&&); + template <class _Up> + void operator^=(_Up&&); + template <class _Up> + void operator<<=(_Up&&); + template <class _Up> + void operator>>=(_Up&&); + void operator++(); + void operator++(int); + void operator--(); + void operator--(int); + template <class _Up, class _Flags> + void copy_from(const _Up*, _Flags); +}; + +// [simd.class] +// TODO: implement simd +template <class _Tp, class _Abi> +class simd { +public: + using value_type = _Tp; + using reference = __simd_reference<_Tp, _Tp, _Abi>; + using mask_type = simd_mask<_Tp, _Abi>; + using abi_type = _Abi; + + simd() = default; + simd(const simd&) = default; + simd& operator=(const simd&) = default; + + static constexpr size_t size() noexcept { + return simd_size<_Tp, _Abi>::value; + } + +private: + __simd_storage<_Tp, _Abi> __s_; + + template <class _Up> + static constexpr bool __can_broadcast() { + return (std::is_arithmetic<_Up>::value && + __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) || + (!std::is_arithmetic<_Up>::value && + std::is_convertible<_Up, _Tp>::value) || + std::is_same<typename std::remove_const<_Up>::type, int>::value || + (std::is_same<typename std::remove_const<_Up>::type, + unsigned int>::value && + std::is_unsigned<_Tp>::value); + } + + template <class _Generator, size_t... __indicies> + static constexpr decltype( + std::forward_as_tuple(std::declval<_Generator>()( + std::integral_constant<size_t, __indicies>())...), + bool()) + __can_generate(std::index_sequence<__indicies...>) { + return !__variadic_sum<bool>( + !__can_broadcast<decltype(std::declval<_Generator>()( + std::integral_constant<size_t, __indicies>()))>()...); + } + + template <class _Generator> + static bool __can_generate(...) { + return false; + } + + template <class _Generator, size_t... __indicies> + void __generator_init(_Generator&& __g, std::index_sequence<__indicies...>) { + int __not_used[]{((*this)[__indicies] = + __g(std::integral_constant<size_t, __indicies>()), + 0)...}; + (void)__not_used; + } + +public: + // implicit type conversion constructor + template <class _Up, + class = typename std::enable_if< + std::is_same<_Abi, simd_abi::fixed_size<size()>>::value && + __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()>::type> + simd(const simd<_Up, simd_abi::fixed_size<size()>>& __v) { + for (size_t __i = 0; __i < size(); __i++) { + (*this)[__i] = static_cast<_Tp>(__v[__i]); + } + } + + // implicit broadcast constructor + template <class _Up, + class = typename std::enable_if<__can_broadcast<_Up>()>::type> + simd(_Up&& __rv) { + auto __v = static_cast<_Tp>(__rv); + for (size_t __i = 0; __i < size(); __i++) { + (*this)[__i] = __v; + } + } + + // generator constructor + template <class _Generator, + int = typename std::enable_if< + __can_generate<_Generator>(std::make_index_sequence<size()>()), + int>::type()> + explicit simd(_Generator&& __g) { + __generator_init(std::forward<_Generator>(__g), + std::make_index_sequence<size()>()); + } + + // load constructor + template < + class _Up, class _Flags, + class = typename std::enable_if<__vectorizable<_Up>()>::type, + class = typename std::enable_if<is_simd_flag_type<_Flags>::value>::type> + simd(const _Up* __buffer, _Flags) { + // TODO: optimize for overaligned flags + for (size_t __i = 0; __i < size(); __i++) { + (*this)[__i] = static_cast<_Tp>(__buffer[__i]); + } + } + + // loads [simd.load] + template <class _Up, class _Flags> + typename std::enable_if<__vectorizable<_Up>() && + is_simd_flag_type<_Flags>::value>::type + copy_from(const _Up* __buffer, _Flags) { + *this = simd(__buffer, _Flags()); + } + + // stores [simd.store] + template <class _Up, class _Flags> + typename std::enable_if<__vectorizable<_Up>() && + is_simd_flag_type<_Flags>::value>::type + copy_to(_Up* __buffer, _Flags) const { + // TODO: optimize for overaligned flags + for (size_t __i = 0; __i < size(); __i++) { + __buffer[__i] = static_cast<_Up>((*this)[__i]); + } + } + + // scalar access [simd.subscr] + reference operator[](size_t __i) { return reference(&__s_, __i); } + + value_type operator[](size_t __i) const { return __s_.__get(__i); } + + // unary operators [simd.unary] + simd& operator++(); + simd operator++(int); + simd& operator--(); + simd operator--(int); + mask_type operator!() const; + simd operator~() const; + simd operator+() const; + simd operator-() const; + + // binary operators [simd.binary] + friend simd operator+(const simd&, const simd&); + friend simd operator-(const simd&, const simd&); + friend simd operator*(const simd&, const simd&); + friend simd operator/(const simd&, const simd&); + friend simd operator%(const simd&, const simd&); + friend simd operator&(const simd&, const simd&); + friend simd operator|(const simd&, const simd&); + friend simd operator^(const simd&, const simd&); + friend simd operator<<(const simd&, const simd&); + friend simd operator>>(const simd&, const simd&); + friend simd operator<<(const simd&, int); + friend simd operator>>(const simd&, int); + + // compound assignment [simd.cassign] + friend simd& operator+=(simd&, const simd&); + friend simd& operator-=(simd&, const simd&); + friend simd& operator*=(simd&, const simd&); + friend simd& operator/=(simd&, const simd&); + friend simd& operator%=(simd&, const simd&); + + friend simd& operator&=(simd&, const simd&); + friend simd& operator|=(simd&, const simd&); + friend simd& operator^=(simd&, const simd&); + friend simd& operator<<=(simd&, const simd&); + friend simd& operator>>=(simd&, const simd&); + friend simd& operator<<=(simd&, int); + friend simd& operator>>=(simd&, int); + + // compares [simd.comparison] + friend mask_type operator==(const simd&, const simd&); + friend mask_type operator!=(const simd&, const simd&); + friend mask_type operator>=(const simd&, const simd&); + friend mask_type operator<=(const simd&, const simd&); + friend mask_type operator>(const simd&, const simd&); + friend mask_type operator<(const simd&, const simd&); +}; + +// [simd.mask.class] +template <class _Tp, class _Abi> +// TODO: implement simd_mask +class simd_mask { +public: + using value_type = bool; + // TODO: this is strawman implementation. Turn it into a proxy type. + using reference = bool&; + using simd_type = simd<_Tp, _Abi>; + using abi_type = _Abi; + static constexpr size_t size() noexcept; + simd_mask() = default; + + // broadcast constructor + explicit simd_mask(value_type) noexcept; + + // implicit type conversion constructor + template <class _Up> + simd_mask(const simd_mask<_Up, simd_abi::fixed_size<size()>>&) noexcept; + + // load constructor + template <class _Flags> + simd_mask(const value_type*, _Flags); + + // loads [simd.mask.copy] + template <class _Flags> + void copy_from(const value_type*, _Flags); + template <class _Flags> + void copy_to(value_type*, _Flags) const; + + // scalar access [simd.mask.subscr] + reference operator[](size_t); + value_type operator[](size_t) const; + + // unary operators [simd.mask.unary] + simd_mask operator!() const noexcept; + + // simd_mask binary operators [simd.mask.binary] + friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator&(const simd_mask&, const simd_mask&)noexcept; + friend simd_mask operator|(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator^(const simd_mask&, const simd_mask&) noexcept; + + // simd_mask compound assignment [simd.mask.cassign] + friend simd_mask& operator&=(simd_mask&, const simd_mask&) noexcept; + friend simd_mask& operator|=(simd_mask&, const simd_mask&) noexcept; + friend simd_mask& operator^=(simd_mask&, const simd_mask&) noexcept; + + // simd_mask compares [simd.mask.comparison] + friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept; + friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept; +}; + +#endif // _LIBCPP_STD_VER >= 17 + +_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD + +_LIBCPP_POP_MACROS + +#endif /* _LIBCPP_EXPERIMENTAL_SIMD */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/string b/contrib/libs/cxxsupp/libcxx/include/experimental/string new file mode 100644 index 0000000000..63890ac51b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/string @@ -0,0 +1,63 @@ +// -*- C++ -*- +//===--------------------------- string ----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_string<wchar_t> wstring; +#endif + +_LIBCPP_END_NAMESPACE_LFTS_PMR + +#endif /* _LIBCPP_EXPERIMENTAL_STRING */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits b/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits new file mode 100644 index 0000000000..ea1335f96a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits @@ -0,0 +1,154 @@ +// -*- C++ -*- +//===-------------------------- type_traits -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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 { + + // 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; + + // 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 + + */ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <initializer_list> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +// 3.3.2, Other type transformations +/* +template <class> +class _LIBCPP_TEMPLATE_VIS raw_invocation_type; + +template <class _Fn, class ..._Args> +class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>; + +template <class> +class _LIBCPP_TEMPLATE_VIS invokation_type; + +template <class _Fn, class ..._Args> +class _LIBCPP_TEMPLATE_VIS 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; +*/ + +// 3.3.4, Detection idiom +template <class...> using void_t = void; + +struct nonesuch : private __nat { // make nonesuch "not an aggregate" + ~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 */ + +#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/unordered_map b/contrib/libs/cxxsupp/libcxx/include/experimental/unordered_map new file mode 100644 index 0000000000..eca9cea793 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/unordered_map @@ -0,0 +1,64 @@ +// -*- C++ -*- +//===------------------------- unordered_map ------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/unordered_set b/contrib/libs/cxxsupp/libcxx/include/experimental/unordered_set new file mode 100644 index 0000000000..323868f785 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/unordered_set @@ -0,0 +1,58 @@ +// -*- C++ -*- +//===------------------------- unordered_set ------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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/contrib/libs/cxxsupp/libcxx/include/experimental/utility b/contrib/libs/cxxsupp/libcxx/include/experimental/utility new file mode 100644 index 0000000000..0bca0f7c9c --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/utility @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===-------------------------- utility ----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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_TEMPLATE_VIS erased_type { }; + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */ diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/vector b/contrib/libs/cxxsupp/libcxx/include/experimental/vector new file mode 100644 index 0000000000..9b81012069 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/vector @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===--------------------------- vector ------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_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 */ |