diff options
author | armenqa <armenqa@yandex-team.com> | 2024-01-19 12:23:50 +0300 |
---|---|---|
committer | armenqa <armenqa@yandex-team.com> | 2024-01-19 13:10:03 +0300 |
commit | 2de0149d0151c514b22bca0760b95b26c9b0b578 (patch) | |
tree | 2bfed9f3bce7e643ddf048bb61ce3dc0a714bcc2 /contrib/libs/cxxsupp/libcxx/include/__ranges | |
parent | a8c06d218f12b2406fbce24d194885c5d7b68503 (diff) | |
download | ydb-2de0149d0151c514b22bca0760b95b26c9b0b578.tar.gz |
feat contrib: aiogram 3
Relates: https://st.yandex-team.ru/, https://st.yandex-team.ru/
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__ranges')
33 files changed, 555 insertions, 63 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/access.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/access.h index 0f1cca033a..87392a163e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/access.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/access.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_ACCESS_H #define _LIBCPP___RANGES_ACCESS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h index 181477419c..c30c9e32e4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_ALL_H #define _LIBCPP___RANGES_ALL_H @@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges::views { @@ -76,7 +77,7 @@ using all_t = decltype(views::all(declval<_Range>())); } // namespace ranges::views -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/common_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/common_view.h index 61b9b61f26..8d7ae58415 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/common_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/common_view.h @@ -6,9 +6,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_COMMON_VIEW_H #define _LIBCPP___RANGES_COMMON_VIEW_H +#include <__concepts/constructible.h> +#include <__concepts/copyable.h> #include <__config> #include <__iterator/common_iterator.h> #include <__iterator/iterator_traits.h> @@ -21,7 +24,6 @@ #include <__ranges/view_interface.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -30,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { @@ -128,7 +130,7 @@ inline namespace __cpo { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/concepts.h index 87df1d18ba..739e14184a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/concepts.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/concepts.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_CONCEPTS_H #define _LIBCPP___RANGES_CONCEPTS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/copyable_box.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/copyable_box.h index 6012497db5..fb3d6e409c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/copyable_box.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/copyable_box.h @@ -10,11 +10,13 @@ #ifndef _LIBCPP___RANGES_COPYABLE_BOX_H #define _LIBCPP___RANGES_COPYABLE_BOX_H +#include <__concepts/constructible.h> +#include <__concepts/copyable.h> +#include <__concepts/movable.h> #include <__config> #include <__memory/addressof.h> #include <__memory/construct_at.h> #include <__utility/move.h> -#include <concepts> #include <optional> #include <type_traits> @@ -24,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 // __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into // a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state @@ -171,7 +173,7 @@ namespace ranges { }; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/counted.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/counted.h index f45f1e8900..138aa0e1dd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/counted.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/counted.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_COUNTED_H #define _LIBCPP___RANGES_COUNTED_H @@ -29,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges::views { @@ -74,7 +75,7 @@ inline namespace __cpo { } // namespace ranges::views -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/data.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/data.h index 35d1af1e64..cadbfc8cf3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/data.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/data.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_DATA_H #define _LIBCPP___RANGES_DATA_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h index b2a8ee5814..8f3564a8c7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h @@ -6,11 +6,14 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_DROP_VIEW_H #define _LIBCPP___RANGES_DROP_VIEW_H #include <__algorithm/min.h> #include <__assert> +#include <__concepts/constructible.h> +#include <__concepts/convertible_to.h> #include <__config> #include <__functional/bind_back.h> #include <__fwd/span.h> @@ -33,7 +36,6 @@ #include <__utility/auto_cast.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -45,7 +47,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<view _View> @@ -297,7 +299,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_while_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_while_view.h new file mode 100644 index 0000000000..7c28992f18 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_while_view.h @@ -0,0 +1,129 @@ +// -*- 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___RANGES_DROP_WHILE_VIEW_H +#define _LIBCPP___RANGES_DROP_WHILE_VIEW_H + +#include <__algorithm/ranges_find_if_not.h> +#include <__assert> +#include <__concepts/constructible.h> +#include <__config> +#include <__functional/bind_back.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__ranges/access.h> +#include <__ranges/all.h> +#include <__ranges/concepts.h> +#include <__ranges/copyable_box.h> +#include <__ranges/enable_borrowed_range.h> +#include <__ranges/non_propagating_cache.h> +#include <__ranges/range_adaptor.h> +#include <__ranges/view_interface.h> +#include <__type_traits/conditional.h> +#include <__type_traits/decay.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_object.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 + +namespace ranges { + +template <view _View, class _Pred> + requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>> +class drop_while_view : public view_interface<drop_while_view<_View, _Pred>> { +public: + _LIBCPP_HIDE_FROM_ABI drop_while_view() + requires default_initializable<_View> && default_initializable<_Pred> + = default; + + _LIBCPP_HIDE_FROM_ABI constexpr drop_while_view(_View __base, _Pred __pred) + : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {} + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& + requires copy_constructible<_View> + { + return __base_; + } + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } + + _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { + _LIBCPP_ASSERT(__pred_.__has_value(), + "drop_while_view needs to have a non-empty predicate before calling begin() -- did a previous " + "assignment to this drop_while_view fail?"); + if constexpr (_UseCache) { + if (!__cached_begin_.__has_value()) { + __cached_begin_.__emplace(ranges::find_if_not(__base_, std::cref(*__pred_))); + } + return *__cached_begin_; + } else { + return ranges::find_if_not(__base_, std::cref(*__pred_)); + } + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto end() { return ranges::end(__base_); } + +private: + _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); + _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_; + + static constexpr bool _UseCache = forward_range<_View>; + using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; + _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); +}; + +template <class _View, class _Pred> +inline constexpr bool enable_borrowed_range<drop_while_view<_View, _Pred>> = enable_borrowed_range<_View>; + +template <class _Range, class _Pred> +drop_while_view(_Range&&, _Pred) -> drop_while_view<views::all_t<_Range>, _Pred>; + +namespace views { +namespace __drop_while { + +struct __fn { + template <class _Range, class _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const + noexcept(noexcept(/**/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))) + -> decltype(/*--*/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) { + return /*-------------*/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); + } + + template <class _Pred> + requires constructible_from<decay_t<_Pred>, _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const + noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { + return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); + } +}; + +} // namespace __drop_while + +inline namespace __cpo { +inline constexpr auto drop_while = __drop_while::__fn{}; +} // namespace __cpo +} // namespace views +} // namespace ranges + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___RANGES_DROP_WHILE_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/empty.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/empty.h index 46c97ca7e3..2370f1373c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/empty.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/empty.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_EMPTY_H #define _LIBCPP___RANGES_EMPTY_H @@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 // [range.prim.empty] @@ -75,7 +76,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/empty_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/empty_view.h index 3299fe825d..58e69ac19f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/empty_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/empty_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_EMPTY_VIEW_H #define _LIBCPP___RANGES_EMPTY_VIEW_H @@ -20,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<class _Tp> @@ -45,7 +46,7 @@ namespace ranges { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/enable_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/enable_view.h index a1e5721404..2dc4752ff4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/enable_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/enable_view.h @@ -10,8 +10,9 @@ #ifndef _LIBCPP___RANGES_ENABLE_VIEW_H #define _LIBCPP___RANGES_ENABLE_VIEW_H +#include <__concepts/derived_from.h> +#include <__concepts/same_as.h> #include <__config> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/filter_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/filter_view.h index b040ea57b7..0622da54ef 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/filter_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/filter_view.h @@ -6,10 +6,15 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_FILTER_VIEW_H #define _LIBCPP___RANGES_FILTER_VIEW_H #include <__algorithm/ranges_find_if.h> +#include <__concepts/constructible.h> +#include <__concepts/copyable.h> +#include <__concepts/derived_from.h> +#include <__concepts/equality_comparable.h> #include <__config> #include <__debug> #include <__functional/bind_back.h> @@ -30,7 +35,6 @@ #include <__utility/forward.h> #include <__utility/in_place.h> #include <__utility/move.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -39,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred> @@ -252,7 +256,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h index e1f03bafa0..8f9148a684 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_IOTA_VIEW_H #define _LIBCPP___RANGES_IOTA_VIEW_H @@ -39,7 +40,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<class _Int> @@ -221,6 +222,7 @@ namespace ranges { return !(__x < __y); } + _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) requires totally_ordered<_Start> && three_way_comparable<_Start> { @@ -401,7 +403,7 @@ inline namespace __cpo { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/istream_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/istream_view.h new file mode 100644 index 0000000000..4113b329b2 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/istream_view.h @@ -0,0 +1,140 @@ +// -*- 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___RANGES_ISTREAM_VIEW_H +#define _LIBCPP___RANGES_ISTREAM_VIEW_H + +#include <__concepts/constructible.h> +#include <__concepts/derived_from.h> +#include <__concepts/movable.h> +#include <__config> +#include <__iterator/default_sentinel.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__ranges/view_interface.h> +#include <__type_traits/remove_cvref.h> +#include <__utility/forward.h> +#include <cstddef> +#include <iosfwd> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 20 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { + +template <class _Val, class _CharT, class _Traits> +concept __stream_extractable = requires(basic_istream<_CharT, _Traits>& __is, _Val& __t) { __is >> __t; }; + +template <movable _Val, class _CharT, class _Traits = char_traits<_CharT>> + requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits> +class basic_istream_view : public view_interface<basic_istream_view<_Val, _CharT, _Traits>> { +public: + _LIBCPP_HIDE_FROM_ABI constexpr explicit basic_istream_view(basic_istream<_CharT, _Traits>& __stream) + : __stream_(std::addressof(__stream)) {} + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { + *__stream_ >> __value_; + return __iterator{*this}; + } + + _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; } + +private: + class __iterator; + + basic_istream<_CharT, _Traits>* __stream_; + _LIBCPP_NO_UNIQUE_ADDRESS _Val __value_ = _Val(); +}; + +template <movable _Val, class _CharT, class _Traits> + requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits> +class basic_istream_view<_Val, _CharT, _Traits>::__iterator { +public: + using iterator_concept = input_iterator_tag; + using difference_type = ptrdiff_t; + using value_type = _Val; + + _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(basic_istream_view& __parent) noexcept + : __parent_(std::addressof(__parent)) {} + + __iterator(const __iterator&) = delete; + _LIBCPP_HIDE_FROM_ABI __iterator(__iterator&&) = default; + + __iterator& operator=(const __iterator&) = delete; + _LIBCPP_HIDE_FROM_ABI __iterator& operator=(__iterator&&) = default; + + _LIBCPP_HIDE_FROM_ABI __iterator& operator++() { + *__parent_->__stream_ >> __parent_->__value_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI void operator++(int) { ++*this; } + + _LIBCPP_HIDE_FROM_ABI _Val& operator*() const { return __parent_->__value_; } + + _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __iterator& __x, default_sentinel_t) { + return !*__x.__get_parent_stream(); + } + +private: + basic_istream_view* __parent_; + + _LIBCPP_HIDE_FROM_ABI constexpr basic_istream<_CharT, _Traits>* __get_parent_stream() const { + return __parent_->__stream_; + } +}; + +template <class _Val> +using istream_view = basic_istream_view<_Val, char>; + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +template <class _Val> +using wistream_view = basic_istream_view<_Val, wchar_t>; +#endif + +namespace views { +namespace __istream { + +// clang-format off +template <class _Tp> +struct __fn { + template <class _Up, class _UnCVRef = remove_cvref_t<_Up>> + requires derived_from<_UnCVRef, basic_istream<typename _UnCVRef::char_type, + typename _UnCVRef::traits_type>> + _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Up&& __u) const + noexcept(noexcept(basic_istream_view<_Tp, typename _UnCVRef::char_type, + typename _UnCVRef::traits_type>(std::forward<_Up>(__u)))) + -> decltype( basic_istream_view<_Tp, typename _UnCVRef::char_type, + typename _UnCVRef::traits_type>(std::forward<_Up>(__u))) + { return basic_istream_view<_Tp, typename _UnCVRef::char_type, + typename _UnCVRef::traits_type>(std::forward<_Up>(__u)); + } +}; +// clang-format on + +} // namespace __istream + +inline namespace __cpo { +template <class _Tp> + inline constexpr auto istream = __istream::__fn<_Tp>{}; +} // namespace __cpo +} // namespace views + +} // namespace ranges + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER >= 20 + +#endif // _LIBCPP___RANGES_ISTREAM_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/join_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/join_view.h index 6c16b68268..293926cc12 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/join_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/join_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_JOIN_VIEW_H #define _LIBCPP___RANGES_JOIN_VIEW_H @@ -25,6 +26,7 @@ #include <__ranges/non_propagating_cache.h> #include <__ranges/range_adaptor.h> #include <__ranges/view_interface.h> +#include <__type_traits/maybe_const.h> #include <__utility/forward.h> #include <optional> #include <type_traits> @@ -35,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<class> @@ -363,7 +365,7 @@ inline namespace __cpo { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h index e559a76ef7..3a95075884 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h @@ -10,7 +10,6 @@ #ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H #define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H -#include <__algorithm/in_in_result.h> #include <__algorithm/ranges_find.h> #include <__algorithm/ranges_mismatch.h> #include <__concepts/constructible.h> @@ -35,6 +34,7 @@ #include <__ranges/single_view.h> #include <__ranges/subrange.h> #include <__ranges/view_interface.h> +#include <__type_traits/maybe_const.h> #include <__utility/forward.h> #include <__utility/move.h> #include <type_traits> @@ -45,7 +45,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { @@ -458,7 +458,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/non_propagating_cache.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/non_propagating_cache.h index 7255705256..d50c577fc3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/non_propagating_cache.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/non_propagating_cache.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H #define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H @@ -14,7 +15,6 @@ #include <__iterator/iterator_traits.h> // iter_reference_t #include <__memory/addressof.h> #include <__utility/forward.h> -#include <concepts> // constructible_from #include <optional> #include <type_traits> @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { // __non_propagating_cache is a helper type that allows storing an optional value in it, @@ -107,7 +107,7 @@ namespace ranges { struct __empty_cache { }; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/owning_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/owning_view.h index ac1ef08fec..e150f6d9f2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/owning_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/owning_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_OWNING_VIEW_H #define _LIBCPP___RANGES_OWNING_VIEW_H @@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<range _Rp> @@ -68,13 +69,14 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp> { return ranges::data(__r_); } }; + _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(owning_view); template<class _Tp> inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h index b65233b563..37e48179e3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h @@ -10,13 +10,16 @@ #ifndef _LIBCPP___RANGES_RANGE_ADAPTOR_H #define _LIBCPP___RANGES_RANGE_ADAPTOR_H +#include <__concepts/constructible.h> +#include <__concepts/derived_from.h> +#include <__concepts/invocable.h> +#include <__concepts/same_as.h> #include <__config> #include <__functional/compose.h> #include <__functional/invoke.h> #include <__ranges/concepts.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -25,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 // CRTP base that one can derive from in order to be considered a range adaptor closure // by the library. When deriving from this class, a pipe operator will be provided to @@ -41,6 +44,7 @@ template <class _Fn> struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> { constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { } }; +_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t); template <class _Tp> concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>; @@ -66,7 +70,7 @@ struct __range_adaptor_closure { { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); } }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/rbegin.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/rbegin.h index 9291359fdf..26b47321de 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/rbegin.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/rbegin.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_RBEGIN_H #define _LIBCPP___RANGES_RBEGIN_H @@ -25,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 // [ranges.access.rbegin] @@ -123,7 +124,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/ref_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/ref_view.h index e69c715fb9..e949f75344 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/ref_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/ref_view.h @@ -6,9 +6,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_REF_VIEW_H #define _LIBCPP___RANGES_REF_VIEW_H +#include <__concepts/convertible_to.h> +#include <__concepts/different_from.h> #include <__config> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> @@ -22,7 +25,6 @@ #include <__ranges/size.h> #include <__ranges/view_interface.h> #include <__utility/forward.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -31,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<range _Range> @@ -79,7 +81,7 @@ public: inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/rend.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/rend.h index e507b25872..d2987e9fa8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/rend.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/rend.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_REND_H #define _LIBCPP___RANGES_REND_H @@ -26,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 // [range.access.rend] @@ -127,7 +128,7 @@ inline namespace __cpo { } // namespace __cpo } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h index b1df8fbc33..d7b1378054 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_REVERSE_VIEW_H #define _LIBCPP___RANGES_REVERSE_VIEW_H @@ -33,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<view _View> @@ -183,7 +184,7 @@ namespace ranges { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h index 98ebe5f383..5c4b91869c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h @@ -6,9 +6,11 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_SINGLE_VIEW_H #define _LIBCPP___RANGES_SINGLE_VIEW_H +#include <__concepts/constructible.h> #include <__config> #include <__ranges/copyable_box.h> #include <__ranges/range_adaptor.h> @@ -16,7 +18,6 @@ #include <__utility/forward.h> #include <__utility/in_place.h> #include <__utility/move.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -25,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<copy_constructible _Tp> @@ -94,7 +95,7 @@ inline namespace __cpo { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h index 0e6d295651..720e3d4fd2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h @@ -6,16 +6,17 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_SIZE_H #define _LIBCPP___RANGES_SIZE_H +#include <__concepts/arithmetic.h> #include <__concepts/class_or_enum.h> #include <__config> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__ranges/access.h> #include <__utility/auto_cast.h> -#include <concepts> #include <cstddef> #include <type_traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h index 7e42da6ce7..3efcd9602a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_SUBRANGE_H #define _LIBCPP___RANGES_SUBRANGE_H @@ -16,6 +17,7 @@ #include <__concepts/derived_from.h> #include <__concepts/different_from.h> #include <__config> +#include <__fwd/get.h> #include <__iterator/advance.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> @@ -26,7 +28,8 @@ #include <__ranges/enable_borrowed_range.h> #include <__ranges/size.h> #include <__ranges/view_interface.h> -#include <__tuple> +#include <__tuple/tuple_element.h> +#include <__tuple/tuple_size.h> #include <__utility/move.h> #include <type_traits> @@ -36,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { template<class _From, class _To> @@ -285,7 +288,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> { using type = _Sp; }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h index 11d5c9fc36..546e898aec 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h @@ -6,11 +6,14 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_TAKE_VIEW_H #define _LIBCPP___RANGES_TAKE_VIEW_H #include <__algorithm/min.h> #include <__algorithm/ranges_min.h> +#include <__concepts/constructible.h> +#include <__concepts/convertible_to.h> #include <__config> #include <__functional/bind_back.h> #include <__fwd/span.h> @@ -30,10 +33,10 @@ #include <__ranges/size.h> #include <__ranges/subrange.h> #include <__ranges/view_interface.h> +#include <__type_traits/maybe_const.h> #include <__utility/auto_cast.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <concepts> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -45,7 +48,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { @@ -225,6 +228,7 @@ struct __passthrough_type<basic_string_view<_CharT, _Traits>> { }; template <class _Iter, class _Sent, subrange_kind _Kind> + requires requires{typename subrange<_Iter>;} struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { using type = subrange<_Iter>; }; @@ -328,7 +332,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h new file mode 100644 index 0000000000..77d7390dce --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h @@ -0,0 +1,177 @@ +// -*- 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___RANGES_TAKE_WHILE_VIEW_H +#define _LIBCPP___RANGES_TAKE_WHILE_VIEW_H + +#include <__concepts/constructible.h> +#include <__concepts/convertible_to.h> +#include <__config> +#include <__functional/bind_back.h> +#include <__functional/invoke.h> +#include <__iterator/concepts.h> +#include <__memory/addressof.h> +#include <__ranges/access.h> +#include <__ranges/all.h> +#include <__ranges/concepts.h> +#include <__ranges/copyable_box.h> +#include <__ranges/range_adaptor.h> +#include <__ranges/view_interface.h> +#include <__type_traits/decay.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_object.h> +#include <__type_traits/maybe_const.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 + +namespace ranges { + +// The spec uses the unnamed requirement inside the `begin` and `end` member functions: +// constexpr auto begin() const +// requires range<const V> && indirect_unary_predicate<const Pred, iterator_t<const V>> +// However, due to a clang-14 and clang-15 bug, the above produces a hard error when `const V` is not a range. +// The workaround is to create a named concept and use the concept instead. +// As of take_while_view is implemented, the clang-trunk has already fixed the bug. +// It is OK to remove the workaround once our CI no longer uses clang-14, clang-15 based compilers, +// because we don't actually expect a lot of vendors to ship a new libc++ with an old clang. +template <class _View, class _Pred> +concept __take_while_const_is_range = + range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>; + +template <view _View, class _Pred> + requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>> +class take_while_view : public view_interface<take_while_view<_View, _Pred>> { + template <bool> + class __sentinel; + + _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); + _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_; + +public: + _LIBCPP_HIDE_FROM_ABI take_while_view() + requires default_initializable<_View> && default_initializable<_Pred> + = default; + + _LIBCPP_HIDE_FROM_ABI constexpr take_while_view(_View __base, _Pred __pred) + : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {} + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& + requires copy_constructible<_View> + { + return __base_; + } + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } + + _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() + requires(!__simple_view<_View>) + { + return ranges::begin(__base_); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const + requires __take_while_const_is_range<_View, _Pred> + { + return ranges::begin(__base_); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto end() + requires(!__simple_view<_View>) + { + return __sentinel</*_Const=*/false>(ranges::end(__base_), std::addressof(*__pred_)); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto end() const + requires __take_while_const_is_range<_View, _Pred> + { + return __sentinel</*_Const=*/true>(ranges::end(__base_), std::addressof(*__pred_)); + } +}; + +template <class _Range, class _Pred> +take_while_view(_Range&&, _Pred) -> take_while_view<views::all_t<_Range>, _Pred>; + +template <view _View, class _Pred> + requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>> +template <bool _Const> +class take_while_view<_View, _Pred>::__sentinel { + using _Base = __maybe_const<_Const, _View>; + + sentinel_t<_Base> __end_ = sentinel_t<_Base>(); + const _Pred* __pred_ = nullptr; + + friend class __sentinel<!_Const>; + +public: + _LIBCPP_HIDE_FROM_ABI __sentinel() = default; + + _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(sentinel_t<_Base> __end, const _Pred* __pred) + : __end_(std::move(__end)), __pred_(__pred) {} + + _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __s) + requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> + : __end_(std::move(__s.__end_)), __pred_(__s.__pred_) {} + + _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const iterator_t<_Base>& __x, const __sentinel& __y) { + return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x); + } + + template <bool _OtherConst = !_Const> + requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator==(const iterator_t<__maybe_const<_OtherConst, _View>>& __x, const __sentinel& __y) { + return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x); + } +}; + +namespace views { +namespace __take_while { + +struct __fn { + template <class _Range, class _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const + noexcept(noexcept(/**/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))) + -> decltype(/*--*/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) { + return /*-------------*/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); + } + + template <class _Pred> + requires constructible_from<decay_t<_Pred>, _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const + noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { + return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); + } +}; + +} // namespace __take_while + +inline namespace __cpo { +inline constexpr auto take_while = __take_while::__fn{}; +} // namespace __cpo +} // namespace views +} // namespace ranges + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___RANGES_TAKE_WHILE_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h index c5a7128c36..0b5ced3df4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H #define _LIBCPP___RANGES_TRANSFORM_VIEW_H @@ -30,6 +31,7 @@ #include <__ranges/range_adaptor.h> #include <__ranges/size.h> #include <__ranges/view_interface.h> +#include <__type_traits/maybe_const.h> #include <__utility/forward.h> #include <__utility/in_place.h> #include <__utility/move.h> @@ -41,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { @@ -433,7 +435,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h index 4b36e02f7d..b89ee999f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H #define _LIBCPP___RANGES_VIEW_INTERFACE_H @@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { @@ -167,7 +168,7 @@ public: } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/views.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/views.h index 8cc5ba3d2a..d40c64ad8c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/views.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/views.h @@ -18,7 +18,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 17 namespace ranges { @@ -28,7 +28,7 @@ namespace views { } namespace views = ranges::views; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/zip_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/zip_view.h index a8035bc79e..6eb0ffdf84 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/zip_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/zip_view.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP___RANGES_ZIP_VIEW_H #define _LIBCPP___RANGES_ZIP_VIEW_H @@ -44,7 +45,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#if _LIBCPP_STD_VER > 20 namespace ranges { @@ -502,7 +503,7 @@ inline namespace __cpo { } // namespace views } // namespace ranges -#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // _LIBCPP_STD_VER > 20 _LIBCPP_END_NAMESPACE_STD |