diff options
author | Andrey Khalyavin <[email protected]> | 2022-02-10 16:46:30 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:30 +0300 |
commit | 4b839d0704ee9be1dabb0310a1f03af24963637b (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/cxxsupp/libcxx/include/__iterator | |
parent | f773626848a7c7456803654292e716b83d69cc12 (diff) |
Restoring authorship annotation for Andrey Khalyavin <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__iterator')
32 files changed, 3959 insertions, 3959 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/access.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/access.h index 7fa4beb1f5f..5e0d6b35153 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/access.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/access.h @@ -1,129 +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___ITERATOR_ACCESS_H -#define _LIBCPP___ITERATOR_ACCESS_H - -#include <__config> -#include <cstddef> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Tp, size_t _Np> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -_Tp* -begin(_Tp (&__array)[_Np]) -{ - return __array; -} - -template <class _Tp, size_t _Np> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -_Tp* -end(_Tp (&__array)[_Np]) -{ - return __array + _Np; -} - -#if !defined(_LIBCPP_CXX03_LANG) - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto -begin(_Cp& __c) -> decltype(__c.begin()) -{ - return __c.begin(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto -begin(const _Cp& __c) -> decltype(__c.begin()) -{ - return __c.begin(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto -end(_Cp& __c) -> decltype(__c.end()) -{ - return __c.end(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto -end(const _Cp& __c) -> decltype(__c.end()) -{ - return __c.end(); -} - -#if _LIBCPP_STD_VER > 11 - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c)) -{ - return _VSTD::begin(__c); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c)) -{ - return _VSTD::end(__c); -} - -#endif - - -#else // defined(_LIBCPP_CXX03_LANG) - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY -typename _Cp::iterator -begin(_Cp& __c) -{ - return __c.begin(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY -typename _Cp::const_iterator -begin(const _Cp& __c) -{ - return __c.begin(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY -typename _Cp::iterator -end(_Cp& __c) -{ - return __c.end(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY -typename _Cp::const_iterator -end(const _Cp& __c) -{ - return __c.end(); -} - -#endif // !defined(_LIBCPP_CXX03_LANG) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ACCESS_H +// -*- 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___ITERATOR_ACCESS_H +#define _LIBCPP___ITERATOR_ACCESS_H + +#include <__config> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp, size_t _Np> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp* +begin(_Tp (&__array)[_Np]) +{ + return __array; +} + +template <class _Tp, size_t _Np> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp* +end(_Tp (&__array)[_Np]) +{ + return __array + _Np; +} + +#if !defined(_LIBCPP_CXX03_LANG) + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +begin(_Cp& __c) -> decltype(__c.begin()) +{ + return __c.begin(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +begin(const _Cp& __c) -> decltype(__c.begin()) +{ + return __c.begin(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +end(_Cp& __c) -> decltype(__c.end()) +{ + return __c.end(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +end(const _Cp& __c) -> decltype(__c.end()) +{ + return __c.end(); +} + +#if _LIBCPP_STD_VER > 11 + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c)) +{ + return _VSTD::begin(__c); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c)) +{ + return _VSTD::end(__c); +} + +#endif + + +#else // defined(_LIBCPP_CXX03_LANG) + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY +typename _Cp::iterator +begin(_Cp& __c) +{ + return __c.begin(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY +typename _Cp::const_iterator +begin(const _Cp& __c) +{ + return __c.begin(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY +typename _Cp::iterator +end(_Cp& __c) +{ + return __c.end(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY +typename _Cp::const_iterator +end(const _Cp& __c) +{ + return __c.end(); +} + +#endif // !defined(_LIBCPP_CXX03_LANG) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ACCESS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h index 66ced9e1a50..b38540fbe39 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h @@ -1,195 +1,195 @@ -// -*- 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___ITERATOR_ADVANCE_H -#define _LIBCPP___ITERATOR_ADVANCE_H - -#include <__config> -#include <__debug> -#include <__function_like.h> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/iterator_traits.h> -#include <__utility/move.h> -#include <cstdlib> -#include <concepts> -#include <limits> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _InputIter> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) { - for (; __n > 0; --__n) - ++__i; -} - -template <class _BiDirIter> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) { - if (__n >= 0) - for (; __n > 0; --__n) - ++__i; - else - for (; __n < 0; ++__n) - --__i; -} - -template <class _RandIter> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) { - __i += __n; -} - -template < - class _InputIter, class _Distance, - class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())), - class = __enable_if_t<is_integral<_IntegralDistance>::value> > -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -void advance(_InputIter& __i, _Distance __orig_n) { - typedef typename iterator_traits<_InputIter>::difference_type _Difference; - _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n)); - _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, - "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); - _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); -} - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -namespace ranges { -// [range.iter.op.advance] -struct __advance_fn final : private __function_like { -private: - template <class _Tp> - _LIBCPP_HIDE_FROM_ABI - static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept { - return __a < 0 ? (__a <= __b) : (__a >= __b); - } - - template <class _Ip> - _LIBCPP_HIDE_FROM_ABI - static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { - while (__n > 0) { - --__n; - ++__i; - } - } - - template <class _Ip> - _LIBCPP_HIDE_FROM_ABI - static constexpr void __advance_backward(_Ip& __i, iter_difference_t<_Ip> __n) { - while (__n < 0) { - ++__n; - --__i; - } - } - -public: - constexpr explicit __advance_fn(__tag __x) noexcept : __function_like(__x) {} - - // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. - template <input_or_output_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI - constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const { - _LIBCPP_ASSERT(__n >= 0 || bidirectional_iterator<_Ip>, - "If `n < 0`, then `bidirectional_iterator<I>` must be true."); - - // If `I` models `random_access_iterator`, equivalent to `i += n`. - if constexpr (random_access_iterator<_Ip>) { - __i += __n; - return; - } else if constexpr (bidirectional_iterator<_Ip>) { - // Otherwise, if `n` is non-negative, increments `i` by `n`. - __advance_forward(__i, __n); - // Otherwise, decrements `i` by `-n`. - __advance_backward(__i, __n); - return; - } else { - // Otherwise, if `n` is non-negative, increments `i` by `n`. - __advance_forward(__i, __n); - return; - } - } - - // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range. - template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI - constexpr void operator()(_Ip& __i, _Sp ___bound) const { - // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`. - if constexpr (assignable_from<_Ip&, _Sp>) { - __i = _VSTD::move(___bound); - } - // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`. - else if constexpr (sized_sentinel_for<_Sp, _Ip>) { - (*this)(__i, ___bound - __i); - } - // Otherwise, while `bool(i != bound)` is true, increments `i`. - else { - while (__i != ___bound) { - ++__i; - } - } - } - - // Preconditions: - // * If `n > 0`, [i, bound) denotes a range. - // * If `n == 0`, [i, bound) or [bound, i) denotes a range. - // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`. - // Returns: `n - M`, where `M` is the difference between the the ending and starting position. - template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI - constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp ___bound) const { - _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), - "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true."); - // If `S` and `I` model `sized_sentinel_for<S, I>`: - if constexpr (sized_sentinel_for<_Sp, _Ip>) { - // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. - if (const auto __M = ___bound - __i; __magnitude_geq(__n, __M)) { - (*this)(__i, ___bound); - return __n - __M; - } - - // Otherwise, equivalent to `ranges::advance(i, n)`. - (*this)(__i, __n); - return 0; - } else { - // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at - // most `n` times. - while (__i != ___bound && __n > 0) { - ++__i; - --__n; - } - - // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times. - if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { - while (__i != ___bound && __n < 0) { - --__i; - ++__n; - } - } - return __n; - } - - _LIBCPP_UNREACHABLE(); - } -}; - -inline constexpr auto advance = __advance_fn(__function_like::__tag()); -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ADVANCE_H +// -*- 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___ITERATOR_ADVANCE_H +#define _LIBCPP___ITERATOR_ADVANCE_H + +#include <__config> +#include <__debug> +#include <__function_like.h> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <__utility/move.h> +#include <cstdlib> +#include <concepts> +#include <limits> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _InputIter> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) { + for (; __n > 0; --__n) + ++__i; +} + +template <class _BiDirIter> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) { + if (__n >= 0) + for (; __n > 0; --__n) + ++__i; + else + for (; __n < 0; ++__n) + --__i; +} + +template <class _RandIter> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) { + __i += __n; +} + +template < + class _InputIter, class _Distance, + class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())), + class = __enable_if_t<is_integral<_IntegralDistance>::value> > +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void advance(_InputIter& __i, _Distance __orig_n) { + typedef typename iterator_traits<_InputIter>::difference_type _Difference; + _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n)); + _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); + _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); +} + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +// [range.iter.op.advance] +struct __advance_fn final : private __function_like { +private: + template <class _Tp> + _LIBCPP_HIDE_FROM_ABI + static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept { + return __a < 0 ? (__a <= __b) : (__a >= __b); + } + + template <class _Ip> + _LIBCPP_HIDE_FROM_ABI + static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { + while (__n > 0) { + --__n; + ++__i; + } + } + + template <class _Ip> + _LIBCPP_HIDE_FROM_ABI + static constexpr void __advance_backward(_Ip& __i, iter_difference_t<_Ip> __n) { + while (__n < 0) { + ++__n; + --__i; + } + } + +public: + constexpr explicit __advance_fn(__tag __x) noexcept : __function_like(__x) {} + + // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. + template <input_or_output_iterator _Ip> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const { + _LIBCPP_ASSERT(__n >= 0 || bidirectional_iterator<_Ip>, + "If `n < 0`, then `bidirectional_iterator<I>` must be true."); + + // If `I` models `random_access_iterator`, equivalent to `i += n`. + if constexpr (random_access_iterator<_Ip>) { + __i += __n; + return; + } else if constexpr (bidirectional_iterator<_Ip>) { + // Otherwise, if `n` is non-negative, increments `i` by `n`. + __advance_forward(__i, __n); + // Otherwise, decrements `i` by `-n`. + __advance_backward(__i, __n); + return; + } else { + // Otherwise, if `n` is non-negative, increments `i` by `n`. + __advance_forward(__i, __n); + return; + } + } + + // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range. + template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_Ip& __i, _Sp ___bound) const { + // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`. + if constexpr (assignable_from<_Ip&, _Sp>) { + __i = _VSTD::move(___bound); + } + // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`. + else if constexpr (sized_sentinel_for<_Sp, _Ip>) { + (*this)(__i, ___bound - __i); + } + // Otherwise, while `bool(i != bound)` is true, increments `i`. + else { + while (__i != ___bound) { + ++__i; + } + } + } + + // Preconditions: + // * If `n > 0`, [i, bound) denotes a range. + // * If `n == 0`, [i, bound) or [bound, i) denotes a range. + // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`. + // Returns: `n - M`, where `M` is the difference between the the ending and starting position. + template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp ___bound) const { + _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), + "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true."); + // If `S` and `I` model `sized_sentinel_for<S, I>`: + if constexpr (sized_sentinel_for<_Sp, _Ip>) { + // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. + if (const auto __M = ___bound - __i; __magnitude_geq(__n, __M)) { + (*this)(__i, ___bound); + return __n - __M; + } + + // Otherwise, equivalent to `ranges::advance(i, n)`. + (*this)(__i, __n); + return 0; + } else { + // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at + // most `n` times. + while (__i != ___bound && __n > 0) { + ++__i; + --__n; + } + + // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times. + if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { + while (__i != ___bound && __n < 0) { + --__i; + ++__n; + } + } + return __n; + } + + _LIBCPP_UNREACHABLE(); + } +}; + +inline constexpr auto advance = __advance_fn(__function_like::__tag()); +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ADVANCE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/back_insert_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/back_insert_iterator.h index dffe2215683..844babe5c5e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/back_insert_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/back_insert_iterator.h @@ -1,70 +1,70 @@ -// -*- 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___ITERATOR_BACK_INSERT_ITERATOR_H -#define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <__utility/move.h> -#include <cstddef> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _Container> -class _LIBCPP_TEMPLATE_VIS back_insert_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<output_iterator_tag, void, void, void, void> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -protected: - _Container* container; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; -#if _LIBCPP_STD_VER > 17 - typedef ptrdiff_t difference_type; -#else - typedef void difference_type; -#endif - typedef void pointer; - typedef void reference; - typedef _Container container_type; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) - {container->push_back(__value_); return *this;} -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) - {container->push_back(_VSTD::move(__value_)); return *this;} -#endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} -}; - -template <class _Container> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -back_insert_iterator<_Container> -back_inserter(_Container& __x) -{ - return back_insert_iterator<_Container>(__x); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H +// -*- 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___ITERATOR_BACK_INSERT_ITERATOR_H +#define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__utility/move.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _Container> +class _LIBCPP_TEMPLATE_VIS back_insert_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<output_iterator_tag, void, void, void, void> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +protected: + _Container* container; +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _Container container_type; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_back(__value_); return *this;} +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_back(_VSTD::move(__value_)); return *this;} +#endif // _LIBCPP_CXX03_LANG + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} +}; + +template <class _Container> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 +back_insert_iterator<_Container> +back_inserter(_Container& __x) +{ + return back_insert_iterator<_Container>(__x); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h index eef14c5cdad..9a142769e55 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h @@ -1,296 +1,296 @@ -// -*- 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___ITERATOR_COMMON_ITERATOR_H -#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H - -#include <__config> -#include <__debug> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/iter_move.h> -#include <__iterator/iter_swap.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/readable_traits.h> -#include <concepts> -#include <variant> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent> - requires (!same_as<_Iter, _Sent> && copyable<_Iter>) -class common_iterator { - class __proxy { - friend common_iterator; - - iter_value_t<_Iter> __value; - // We can move __x because the only caller verifies that __x is not a reference. - constexpr __proxy(iter_reference_t<_Iter>&& __x) - : __value(_VSTD::move(__x)) {} - - public: - const iter_value_t<_Iter>* operator->() const { - return _VSTD::addressof(__value); - } - }; - - class __postfix_proxy { - friend common_iterator; - - iter_value_t<_Iter> __value; - constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x) - : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {} - - public: - constexpr static bool __valid_for_iter = - constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>> && - move_constructible<iter_value_t<_Iter>>; - - const iter_value_t<_Iter>& operator*() const { - return __value; - } - }; - -public: - variant<_Iter, _Sent> __hold_; - - common_iterator() requires default_initializable<_Iter> = default; - - constexpr common_iterator(_Iter __i) : __hold_(in_place_type<_Iter>, _VSTD::move(__i)) {} - constexpr common_iterator(_Sent __s) : __hold_(in_place_type<_Sent>, _VSTD::move(__s)) {} - - template<class _I2, class _S2> - requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> - constexpr common_iterator(const common_iterator<_I2, _S2>& __other) - : __hold_([&]() -> variant<_Iter, _Sent> { - _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Constructed from valueless iterator."); - if (__other.__hold_.index() == 0) - return variant<_Iter, _Sent>{in_place_index<0>, _VSTD::__unchecked_get<0>(__other.__hold_)}; - return variant<_Iter, _Sent>{in_place_index<1>, _VSTD::__unchecked_get<1>(__other.__hold_)}; - }()) {} - - template<class _I2, class _S2> - requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> && - assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&> - common_iterator& operator=(const common_iterator<_I2, _S2>& __other) { - _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Assigned from valueless iterator."); - - auto __idx = __hold_.index(); - auto __other_idx = __other.__hold_.index(); - - // If they're the same index, just assign. - if (__idx == 0 && __other_idx == 0) - _VSTD::__unchecked_get<0>(__hold_) = _VSTD::__unchecked_get<0>(__other.__hold_); - else if (__idx == 1 && __other_idx == 1) - _VSTD::__unchecked_get<1>(__hold_) = _VSTD::__unchecked_get<1>(__other.__hold_); - - // Otherwise replace with the oposite element. - else if (__other_idx == 1) - __hold_.template emplace<1>(_VSTD::__unchecked_get<1>(__other.__hold_)); - else if (__other_idx == 0) - __hold_.template emplace<0>(_VSTD::__unchecked_get<0>(__other.__hold_)); - - return *this; - } - - decltype(auto) operator*() - { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), - "Cannot dereference sentinel. Common iterator not holding an iterator."); - return *_VSTD::__unchecked_get<_Iter>(__hold_); - } - - decltype(auto) operator*() const - requires __dereferenceable<const _Iter> - { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), - "Cannot dereference sentinel. Common iterator not holding an iterator."); - return *_VSTD::__unchecked_get<_Iter>(__hold_); - } - - template<class _I2 = _Iter> - decltype(auto) operator->() const - requires indirectly_readable<const _I2> && - (requires(const _I2& __i) { __i.operator->(); } || - is_reference_v<iter_reference_t<_I2>> || - constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>) - { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), - "Cannot dereference sentinel. Common iterator not holding an iterator."); - - if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) { - return _VSTD::__unchecked_get<_Iter>(__hold_); - } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) { - auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_); - return _VSTD::addressof(__tmp); - } else { - return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_)); - } - } - - common_iterator& operator++() { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), - "Cannot increment sentinel. Common iterator not holding an iterator."); - ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this; - } - - decltype(auto) operator++(int) { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), - "Cannot increment sentinel. Common iterator not holding an iterator."); - - if constexpr (forward_iterator<_Iter>) { - auto __tmp = *this; - ++*this; - return __tmp; - } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } || - !__postfix_proxy::__valid_for_iter) { - return _VSTD::__unchecked_get<_Iter>(__hold_)++; - } else { - __postfix_proxy __p(**this); - ++*this; - return __p; - } - } - - template<class _I2, sentinel_for<_Iter> _S2> - requires sentinel_for<_Sent, _I2> - friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { - _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && - !__y.__hold_.valueless_by_exception(), - "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); - - auto __x_index = __x.__hold_.index(); - auto __y_index = __y.__hold_.index(); - - if (__x_index == __y_index) - return true; - - if (__x_index == 0) - return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_); - - return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); - } - - template<class _I2, sentinel_for<_Iter> _S2> - requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2> - friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { - _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && - !__y.__hold_.valueless_by_exception(), - "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); - - auto __x_index = __x.__hold_.index(); - auto __y_index = __y.__hold_.index(); - - if (__x_index == 1 && __y_index == 1) - return true; - - if (__x_index == 0 && __y_index == 0) - return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); - - if (__x_index == 0) - return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_); - - return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); - } - - template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2> - requires sized_sentinel_for<_Sent, _I2> - friend iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { - _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && - !__y.__hold_.valueless_by_exception(), - "One or both common_iterators are valueless. (Cannot subtract valueless iterators.)"); - - auto __x_index = __x.__hold_.index(); - auto __y_index = __y.__hold_.index(); - - if (__x_index == 1 && __y_index == 1) - return 0; - - if (__x_index == 0 && __y_index == 0) - return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); - - if (__x_index == 0) - return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_S2>(__y.__hold_); - - return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); - } - - friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) - noexcept(noexcept(ranges::iter_move(declval<const _Iter&>()))) - requires input_iterator<_Iter> - { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), - "Cannot iter_move a sentinel. Common iterator not holding an iterator."); - return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_)); - } - - template<indirectly_swappable<_Iter> _I2, class _S2> - friend void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) - noexcept(noexcept(ranges::iter_swap(declval<const _Iter&>(), declval<const _I2&>()))) - { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), - "Cannot swap __y with a sentinel. Common iterator (__x) not holding an iterator."); - _LIBCPP_ASSERT(holds_alternative<_Iter>(__y.__hold_), - "Cannot swap __x with a sentinel. Common iterator (__y) not holding an iterator."); - return ranges::iter_swap( _VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_Iter>(__y.__hold_)); - } -}; - -template<class _Iter, class _Sent> -struct incrementable_traits<common_iterator<_Iter, _Sent>> { - using difference_type = iter_difference_t<_Iter>; -}; - -template<class _Iter> -concept __denotes_forward_iter = - requires { typename iterator_traits<_Iter>::iterator_category; } && - derived_from<typename iterator_traits<_Iter>::iterator_category, forward_iterator_tag>; - -template<class _Iter, class _Sent> -concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>& __a) { - __a.operator->(); -}; - -template<class, class> -struct __arrow_type_or_void { - using type = void; -}; - -template<class _Iter, class _Sent> - requires __common_iter_has_ptr_op<_Iter, _Sent> -struct __arrow_type_or_void<_Iter, _Sent> { - using type = decltype(declval<const common_iterator<_Iter, _Sent>>().operator->()); -}; - -template<class _Iter, class _Sent> -struct iterator_traits<common_iterator<_Iter, _Sent>> { - using iterator_concept = _If<forward_iterator<_Iter>, - forward_iterator_tag, - input_iterator_tag>; - using iterator_category = _If<__denotes_forward_iter<_Iter>, - forward_iterator_tag, - input_iterator_tag>; - using pointer = typename __arrow_type_or_void<_Iter, _Sent>::type; - using value_type = iter_value_t<_Iter>; - using difference_type = iter_difference_t<_Iter>; - using reference = iter_reference_t<_Iter>; -}; - - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H +// -*- 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___ITERATOR_COMMON_ITERATOR_H +#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H + +#include <__config> +#include <__debug> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iter_move.h> +#include <__iterator/iter_swap.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <concepts> +#include <variant> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent> + requires (!same_as<_Iter, _Sent> && copyable<_Iter>) +class common_iterator { + class __proxy { + friend common_iterator; + + iter_value_t<_Iter> __value; + // We can move __x because the only caller verifies that __x is not a reference. + constexpr __proxy(iter_reference_t<_Iter>&& __x) + : __value(_VSTD::move(__x)) {} + + public: + const iter_value_t<_Iter>* operator->() const { + return _VSTD::addressof(__value); + } + }; + + class __postfix_proxy { + friend common_iterator; + + iter_value_t<_Iter> __value; + constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x) + : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {} + + public: + constexpr static bool __valid_for_iter = + constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>> && + move_constructible<iter_value_t<_Iter>>; + + const iter_value_t<_Iter>& operator*() const { + return __value; + } + }; + +public: + variant<_Iter, _Sent> __hold_; + + common_iterator() requires default_initializable<_Iter> = default; + + constexpr common_iterator(_Iter __i) : __hold_(in_place_type<_Iter>, _VSTD::move(__i)) {} + constexpr common_iterator(_Sent __s) : __hold_(in_place_type<_Sent>, _VSTD::move(__s)) {} + + template<class _I2, class _S2> + requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> + constexpr common_iterator(const common_iterator<_I2, _S2>& __other) + : __hold_([&]() -> variant<_Iter, _Sent> { + _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Constructed from valueless iterator."); + if (__other.__hold_.index() == 0) + return variant<_Iter, _Sent>{in_place_index<0>, _VSTD::__unchecked_get<0>(__other.__hold_)}; + return variant<_Iter, _Sent>{in_place_index<1>, _VSTD::__unchecked_get<1>(__other.__hold_)}; + }()) {} + + template<class _I2, class _S2> + requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> && + assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&> + common_iterator& operator=(const common_iterator<_I2, _S2>& __other) { + _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Assigned from valueless iterator."); + + auto __idx = __hold_.index(); + auto __other_idx = __other.__hold_.index(); + + // If they're the same index, just assign. + if (__idx == 0 && __other_idx == 0) + _VSTD::__unchecked_get<0>(__hold_) = _VSTD::__unchecked_get<0>(__other.__hold_); + else if (__idx == 1 && __other_idx == 1) + _VSTD::__unchecked_get<1>(__hold_) = _VSTD::__unchecked_get<1>(__other.__hold_); + + // Otherwise replace with the oposite element. + else if (__other_idx == 1) + __hold_.template emplace<1>(_VSTD::__unchecked_get<1>(__other.__hold_)); + else if (__other_idx == 0) + __hold_.template emplace<0>(_VSTD::__unchecked_get<0>(__other.__hold_)); + + return *this; + } + + decltype(auto) operator*() + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + return *_VSTD::__unchecked_get<_Iter>(__hold_); + } + + decltype(auto) operator*() const + requires __dereferenceable<const _Iter> + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + return *_VSTD::__unchecked_get<_Iter>(__hold_); + } + + template<class _I2 = _Iter> + decltype(auto) operator->() const + requires indirectly_readable<const _I2> && + (requires(const _I2& __i) { __i.operator->(); } || + is_reference_v<iter_reference_t<_I2>> || + constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>) + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + + if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) { + return _VSTD::__unchecked_get<_Iter>(__hold_); + } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) { + auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_); + return _VSTD::addressof(__tmp); + } else { + return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_)); + } + } + + common_iterator& operator++() { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot increment sentinel. Common iterator not holding an iterator."); + ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this; + } + + decltype(auto) operator++(int) { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot increment sentinel. Common iterator not holding an iterator."); + + if constexpr (forward_iterator<_Iter>) { + auto __tmp = *this; + ++*this; + return __tmp; + } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } || + !__postfix_proxy::__valid_for_iter) { + return _VSTD::__unchecked_get<_Iter>(__hold_)++; + } else { + __postfix_proxy __p(**this); + ++*this; + return __p; + } + } + + template<class _I2, sentinel_for<_Iter> _S2> + requires sentinel_for<_Sent, _I2> + friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); + + auto __x_index = __x.__hold_.index(); + auto __y_index = __y.__hold_.index(); + + if (__x_index == __y_index) + return true; + + if (__x_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_); + + return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); + } + + template<class _I2, sentinel_for<_Iter> _S2> + requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2> + friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); + + auto __x_index = __x.__hold_.index(); + auto __y_index = __y.__hold_.index(); + + if (__x_index == 1 && __y_index == 1) + return true; + + if (__x_index == 0 && __y_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); + + if (__x_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_); + + return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); + } + + template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2> + requires sized_sentinel_for<_Sent, _I2> + friend iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot subtract valueless iterators.)"); + + auto __x_index = __x.__hold_.index(); + auto __y_index = __y.__hold_.index(); + + if (__x_index == 1 && __y_index == 1) + return 0; + + if (__x_index == 0 && __y_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); + + if (__x_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_S2>(__y.__hold_); + + return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); + } + + friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) + noexcept(noexcept(ranges::iter_move(declval<const _Iter&>()))) + requires input_iterator<_Iter> + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), + "Cannot iter_move a sentinel. Common iterator not holding an iterator."); + return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_)); + } + + template<indirectly_swappable<_Iter> _I2, class _S2> + friend void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) + noexcept(noexcept(ranges::iter_swap(declval<const _Iter&>(), declval<const _I2&>()))) + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), + "Cannot swap __y with a sentinel. Common iterator (__x) not holding an iterator."); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__y.__hold_), + "Cannot swap __x with a sentinel. Common iterator (__y) not holding an iterator."); + return ranges::iter_swap( _VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_Iter>(__y.__hold_)); + } +}; + +template<class _Iter, class _Sent> +struct incrementable_traits<common_iterator<_Iter, _Sent>> { + using difference_type = iter_difference_t<_Iter>; +}; + +template<class _Iter> +concept __denotes_forward_iter = + requires { typename iterator_traits<_Iter>::iterator_category; } && + derived_from<typename iterator_traits<_Iter>::iterator_category, forward_iterator_tag>; + +template<class _Iter, class _Sent> +concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>& __a) { + __a.operator->(); +}; + +template<class, class> +struct __arrow_type_or_void { + using type = void; +}; + +template<class _Iter, class _Sent> + requires __common_iter_has_ptr_op<_Iter, _Sent> +struct __arrow_type_or_void<_Iter, _Sent> { + using type = decltype(declval<const common_iterator<_Iter, _Sent>>().operator->()); +}; + +template<class _Iter, class _Sent> +struct iterator_traits<common_iterator<_Iter, _Sent>> { + using iterator_concept = _If<forward_iterator<_Iter>, + forward_iterator_tag, + input_iterator_tag>; + using iterator_category = _If<__denotes_forward_iter<_Iter>, + forward_iterator_tag, + input_iterator_tag>; + using pointer = typename __arrow_type_or_void<_Iter, _Sent>::type; + using value_type = iter_value_t<_Iter>; + using difference_type = iter_difference_t<_Iter>; + using reference = iter_reference_t<_Iter>; +}; + + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h index 222f64354d9..531acdf0a5b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h @@ -1,268 +1,268 @@ -// -*- 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___ITERATOR_CONCEPTS_H -#define _LIBCPP___ITERATOR_CONCEPTS_H - -#include <__config> -#include <__iterator/incrementable_traits.h> -#include <__iterator/iter_move.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/readable_traits.h> -#include <__memory/pointer_traits.h> -#include <__utility/forward.h> -#include <concepts> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -// clang-format off - -// [iterator.concept.readable] -template<class _In> -concept __indirectly_readable_impl = - requires(const _In __i) { - typename iter_value_t<_In>; - typename iter_reference_t<_In>; - typename iter_rvalue_reference_t<_In>; - { *__i } -> same_as<iter_reference_t<_In>>; - { ranges::iter_move(__i) } -> same_as<iter_rvalue_reference_t<_In>>; - } && - common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&> && - common_reference_with<iter_reference_t<_In>&&, iter_rvalue_reference_t<_In>&&> && - common_reference_with<iter_rvalue_reference_t<_In>&&, const iter_value_t<_In>&>; - -template<class _In> -concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>; - -template<indirectly_readable _Tp> -using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>; - -// [iterator.concept.writable] -template<class _Out, class _Tp> -concept indirectly_writable = - requires(_Out&& __o, _Tp&& __t) { - *__o = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving - *_VSTD::forward<_Out>(__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving - const_cast<const iter_reference_t<_Out>&&>(*__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving - const_cast<const iter_reference_t<_Out>&&>(*_VSTD::forward<_Out>(__o)) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving - }; - -// [iterator.concept.winc] -template<class _Tp> -concept __integer_like = integral<_Tp> && !same_as<_Tp, bool>; - -template<class _Tp> -concept __signed_integer_like = signed_integral<_Tp>; - -template<class _Ip> -concept weakly_incrementable = - // TODO: remove this once the clang bug is fixed (bugs.llvm.org/PR48173). - !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. - movable<_Ip> && - requires(_Ip __i) { - typename iter_difference_t<_Ip>; - requires __signed_integer_like<iter_difference_t<_Ip>>; - { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving - __i++; // not required to be equality-preserving - }; - -// [iterator.concept.inc] -template<class _Ip> -concept incrementable = - regular<_Ip> && - weakly_incrementable<_Ip> && - requires(_Ip __i) { - { __i++ } -> same_as<_Ip>; - }; - -// [iterator.concept.iterator] -template<class _Ip> -concept input_or_output_iterator = - requires(_Ip __i) { - { *__i } -> __referenceable; - } && - weakly_incrementable<_Ip>; - -// [iterator.concept.sentinel] -template<class _Sp, class _Ip> -concept sentinel_for = - semiregular<_Sp> && - input_or_output_iterator<_Ip> && - __weakly_equality_comparable_with<_Sp, _Ip>; - -template<class, class> -inline constexpr bool disable_sized_sentinel_for = false; - -template<class _Sp, class _Ip> -concept sized_sentinel_for = - sentinel_for<_Sp, _Ip> && - !disable_sized_sentinel_for<remove_cv_t<_Sp>, remove_cv_t<_Ip>> && - requires(const _Ip& __i, const _Sp& __s) { - { __s - __i } -> same_as<iter_difference_t<_Ip>>; - { __i - __s } -> same_as<iter_difference_t<_Ip>>; - }; - -// [iterator.concept.input] -template<class _Ip> -concept input_iterator = - input_or_output_iterator<_Ip> && - indirectly_readable<_Ip> && - requires { typename _ITER_CONCEPT<_Ip>; } && - derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>; - -// [iterator.concept.output] -template<class _Ip, class _Tp> -concept output_iterator = - input_or_output_iterator<_Ip> && - indirectly_writable<_Ip, _Tp> && - requires (_Ip __it, _Tp&& __t) { - *__it++ = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving - }; - -// [iterator.concept.forward] -template<class _Ip> -concept forward_iterator = - input_iterator<_Ip> && - derived_from<_ITER_CONCEPT<_Ip>, forward_iterator_tag> && - incrementable<_Ip> && - sentinel_for<_Ip, _Ip>; - -// [iterator.concept.bidir] -template<class _Ip> -concept bidirectional_iterator = - forward_iterator<_Ip> && - derived_from<_ITER_CONCEPT<_Ip>, bidirectional_iterator_tag> && - requires(_Ip __i) { - { --__i } -> same_as<_Ip&>; - { __i-- } -> same_as<_Ip>; - }; - -template<class _Ip> -concept random_access_iterator = - bidirectional_iterator<_Ip> && - derived_from<_ITER_CONCEPT<_Ip>, random_access_iterator_tag> && - totally_ordered<_Ip> && - sized_sentinel_for<_Ip, _Ip> && - requires(_Ip __i, const _Ip __j, const iter_difference_t<_Ip> __n) { - { __i += __n } -> same_as<_Ip&>; - { __j + __n } -> same_as<_Ip>; - { __n + __j } -> same_as<_Ip>; - { __i -= __n } -> same_as<_Ip&>; - { __j - __n } -> same_as<_Ip>; - { __j[__n] } -> same_as<iter_reference_t<_Ip>>; - }; - -template<class _Ip> -concept contiguous_iterator = - random_access_iterator<_Ip> && - derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> && - is_lvalue_reference_v<iter_reference_t<_Ip>> && - same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>> && - requires(const _Ip& __i) { - { _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>; - }; - -template<class _Ip> -concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip __i) { __i.operator->(); }); - -// [indirectcallable.indirectinvocable] -template<class _Fp, class _It> -concept indirectly_unary_invocable = - indirectly_readable<_It> && - copy_constructible<_Fp> && - invocable<_Fp&, iter_value_t<_It>&> && - invocable<_Fp&, iter_reference_t<_It>> && - invocable<_Fp&, iter_common_reference_t<_It>> && - common_reference_with< - invoke_result_t<_Fp&, iter_value_t<_It>&>, - invoke_result_t<_Fp&, iter_reference_t<_It>>>; - -template<class _Fp, class _It> -concept indirectly_regular_unary_invocable = - indirectly_readable<_It> && - copy_constructible<_Fp> && - regular_invocable<_Fp&, iter_value_t<_It>&> && - regular_invocable<_Fp&, iter_reference_t<_It>> && - regular_invocable<_Fp&, iter_common_reference_t<_It>> && - common_reference_with< - invoke_result_t<_Fp&, iter_value_t<_It>&>, - invoke_result_t<_Fp&, iter_reference_t<_It>>>; - -template<class _Fp, class _It> -concept indirect_unary_predicate = - indirectly_readable<_It> && - copy_constructible<_Fp> && - predicate<_Fp&, iter_value_t<_It>&> && - predicate<_Fp&, iter_reference_t<_It>> && - predicate<_Fp&, iter_common_reference_t<_It>>; - -template<class _Fp, class _It1, class _It2> -concept indirect_binary_predicate = - indirectly_readable<_It1> && indirectly_readable<_It2> && - copy_constructible<_Fp> && - predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && - predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && - predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && - predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && - predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; - -template<class _Fp, class _It1, class _It2 = _It1> -concept indirect_equivalence_relation = - indirectly_readable<_It1> && indirectly_readable<_It2> && - copy_constructible<_Fp> && - equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && - equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && - equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && - equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && - equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; - -template<class _Fp, class _It1, class _It2 = _It1> -concept indirect_strict_weak_order = - indirectly_readable<_It1> && indirectly_readable<_It2> && - copy_constructible<_Fp> && - strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && - strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && - strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && - strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && - strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; - -template<class _Fp, class... _Its> - requires (indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> -using indirect_result_t = invoke_result_t<_Fp, iter_reference_t<_Its>...>; - -template<class _In, class _Out> -concept indirectly_movable = - indirectly_readable<_In> && - indirectly_writable<_Out, iter_rvalue_reference_t<_In>>; - -template<class _In, class _Out> -concept indirectly_movable_storable = - indirectly_movable<_In, _Out> && - indirectly_writable<_Out, iter_value_t<_In>> && - movable<iter_value_t<_In>> && - constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> && - assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>; - -// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle -// (both iter_swap and indirectly_swappable require indirectly_readable). - -// clang-format on - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_CONCEPTS_H +// -*- 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___ITERATOR_CONCEPTS_H +#define _LIBCPP___ITERATOR_CONCEPTS_H + +#include <__config> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iter_move.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <__memory/pointer_traits.h> +#include <__utility/forward.h> +#include <concepts> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// clang-format off + +// [iterator.concept.readable] +template<class _In> +concept __indirectly_readable_impl = + requires(const _In __i) { + typename iter_value_t<_In>; + typename iter_reference_t<_In>; + typename iter_rvalue_reference_t<_In>; + { *__i } -> same_as<iter_reference_t<_In>>; + { ranges::iter_move(__i) } -> same_as<iter_rvalue_reference_t<_In>>; + } && + common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&> && + common_reference_with<iter_reference_t<_In>&&, iter_rvalue_reference_t<_In>&&> && + common_reference_with<iter_rvalue_reference_t<_In>&&, const iter_value_t<_In>&>; + +template<class _In> +concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>; + +template<indirectly_readable _Tp> +using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>; + +// [iterator.concept.writable] +template<class _Out, class _Tp> +concept indirectly_writable = + requires(_Out&& __o, _Tp&& __t) { + *__o = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + *_VSTD::forward<_Out>(__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + const_cast<const iter_reference_t<_Out>&&>(*__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + const_cast<const iter_reference_t<_Out>&&>(*_VSTD::forward<_Out>(__o)) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + }; + +// [iterator.concept.winc] +template<class _Tp> +concept __integer_like = integral<_Tp> && !same_as<_Tp, bool>; + +template<class _Tp> +concept __signed_integer_like = signed_integral<_Tp>; + +template<class _Ip> +concept weakly_incrementable = + // TODO: remove this once the clang bug is fixed (bugs.llvm.org/PR48173). + !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. + movable<_Ip> && + requires(_Ip __i) { + typename iter_difference_t<_Ip>; + requires __signed_integer_like<iter_difference_t<_Ip>>; + { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving + __i++; // not required to be equality-preserving + }; + +// [iterator.concept.inc] +template<class _Ip> +concept incrementable = + regular<_Ip> && + weakly_incrementable<_Ip> && + requires(_Ip __i) { + { __i++ } -> same_as<_Ip>; + }; + +// [iterator.concept.iterator] +template<class _Ip> +concept input_or_output_iterator = + requires(_Ip __i) { + { *__i } -> __referenceable; + } && + weakly_incrementable<_Ip>; + +// [iterator.concept.sentinel] +template<class _Sp, class _Ip> +concept sentinel_for = + semiregular<_Sp> && + input_or_output_iterator<_Ip> && + __weakly_equality_comparable_with<_Sp, _Ip>; + +template<class, class> +inline constexpr bool disable_sized_sentinel_for = false; + +template<class _Sp, class _Ip> +concept sized_sentinel_for = + sentinel_for<_Sp, _Ip> && + !disable_sized_sentinel_for<remove_cv_t<_Sp>, remove_cv_t<_Ip>> && + requires(const _Ip& __i, const _Sp& __s) { + { __s - __i } -> same_as<iter_difference_t<_Ip>>; + { __i - __s } -> same_as<iter_difference_t<_Ip>>; + }; + +// [iterator.concept.input] +template<class _Ip> +concept input_iterator = + input_or_output_iterator<_Ip> && + indirectly_readable<_Ip> && + requires { typename _ITER_CONCEPT<_Ip>; } && + derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>; + +// [iterator.concept.output] +template<class _Ip, class _Tp> +concept output_iterator = + input_or_output_iterator<_Ip> && + indirectly_writable<_Ip, _Tp> && + requires (_Ip __it, _Tp&& __t) { + *__it++ = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + }; + +// [iterator.concept.forward] +template<class _Ip> +concept forward_iterator = + input_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, forward_iterator_tag> && + incrementable<_Ip> && + sentinel_for<_Ip, _Ip>; + +// [iterator.concept.bidir] +template<class _Ip> +concept bidirectional_iterator = + forward_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, bidirectional_iterator_tag> && + requires(_Ip __i) { + { --__i } -> same_as<_Ip&>; + { __i-- } -> same_as<_Ip>; + }; + +template<class _Ip> +concept random_access_iterator = + bidirectional_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, random_access_iterator_tag> && + totally_ordered<_Ip> && + sized_sentinel_for<_Ip, _Ip> && + requires(_Ip __i, const _Ip __j, const iter_difference_t<_Ip> __n) { + { __i += __n } -> same_as<_Ip&>; + { __j + __n } -> same_as<_Ip>; + { __n + __j } -> same_as<_Ip>; + { __i -= __n } -> same_as<_Ip&>; + { __j - __n } -> same_as<_Ip>; + { __j[__n] } -> same_as<iter_reference_t<_Ip>>; + }; + +template<class _Ip> +concept contiguous_iterator = + random_access_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> && + is_lvalue_reference_v<iter_reference_t<_Ip>> && + same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>> && + requires(const _Ip& __i) { + { _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>; + }; + +template<class _Ip> +concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip __i) { __i.operator->(); }); + +// [indirectcallable.indirectinvocable] +template<class _Fp, class _It> +concept indirectly_unary_invocable = + indirectly_readable<_It> && + copy_constructible<_Fp> && + invocable<_Fp&, iter_value_t<_It>&> && + invocable<_Fp&, iter_reference_t<_It>> && + invocable<_Fp&, iter_common_reference_t<_It>> && + common_reference_with< + invoke_result_t<_Fp&, iter_value_t<_It>&>, + invoke_result_t<_Fp&, iter_reference_t<_It>>>; + +template<class _Fp, class _It> +concept indirectly_regular_unary_invocable = + indirectly_readable<_It> && + copy_constructible<_Fp> && + regular_invocable<_Fp&, iter_value_t<_It>&> && + regular_invocable<_Fp&, iter_reference_t<_It>> && + regular_invocable<_Fp&, iter_common_reference_t<_It>> && + common_reference_with< + invoke_result_t<_Fp&, iter_value_t<_It>&>, + invoke_result_t<_Fp&, iter_reference_t<_It>>>; + +template<class _Fp, class _It> +concept indirect_unary_predicate = + indirectly_readable<_It> && + copy_constructible<_Fp> && + predicate<_Fp&, iter_value_t<_It>&> && + predicate<_Fp&, iter_reference_t<_It>> && + predicate<_Fp&, iter_common_reference_t<_It>>; + +template<class _Fp, class _It1, class _It2> +concept indirect_binary_predicate = + indirectly_readable<_It1> && indirectly_readable<_It2> && + copy_constructible<_Fp> && + predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && + predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && + predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && + predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && + predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + +template<class _Fp, class _It1, class _It2 = _It1> +concept indirect_equivalence_relation = + indirectly_readable<_It1> && indirectly_readable<_It2> && + copy_constructible<_Fp> && + equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && + equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && + equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && + equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && + equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + +template<class _Fp, class _It1, class _It2 = _It1> +concept indirect_strict_weak_order = + indirectly_readable<_It1> && indirectly_readable<_It2> && + copy_constructible<_Fp> && + strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && + strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && + strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && + strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && + strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + +template<class _Fp, class... _Its> + requires (indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> +using indirect_result_t = invoke_result_t<_Fp, iter_reference_t<_Its>...>; + +template<class _In, class _Out> +concept indirectly_movable = + indirectly_readable<_In> && + indirectly_writable<_Out, iter_rvalue_reference_t<_In>>; + +template<class _In, class _Out> +concept indirectly_movable_storable = + indirectly_movable<_In, _Out> && + indirectly_writable<_Out, iter_value_t<_In>> && + movable<iter_value_t<_In>> && + constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> && + assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>; + +// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle +// (both iter_swap and indirectly_swappable require indirectly_readable). + +// clang-format on + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_CONCEPTS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h index dc4aad8ef7a..55979fe5571 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h @@ -1,303 +1,303 @@ -// -*- 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___ITERATOR_COUNTED_ITERATOR_H -#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H - -#include <__config> -#include <__debug> -#include <__iterator/concepts.h> -#include <__iterator/default_sentinel.h> -#include <__iterator/iter_move.h> -#include <__iterator/iter_swap.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/readable_traits.h> -#include <__memory/pointer_traits.h> -#include <__utility/move.h> -#include <compare> -#include <concepts> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -template<class> -struct __counted_iterator_concept {}; - -template<class _Iter> - requires requires { typename _Iter::iterator_concept; } -struct __counted_iterator_concept<_Iter> { - using iterator_concept = typename _Iter::iterator_concept; -}; - -template<class> -struct __counted_iterator_category {}; - -template<class _Iter> - requires requires { typename _Iter::iterator_category; } -struct __counted_iterator_category<_Iter> { - using iterator_category = typename _Iter::iterator_category; -}; - -template<class> -struct __counted_iterator_value_type {}; - -template<indirectly_readable _Iter> -struct __counted_iterator_value_type<_Iter> { - using value_type = iter_value_t<_Iter>; -}; - -template<input_or_output_iterator _Iter> -class counted_iterator - : public __counted_iterator_concept<_Iter> - , public __counted_iterator_category<_Iter> - , public __counted_iterator_value_type<_Iter> -{ -public: - [[no_unique_address]] _Iter __current_ = _Iter(); - iter_difference_t<_Iter> __count_ = 0; - - using iterator_type = _Iter; - using difference_type = iter_difference_t<_Iter>; - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator() requires default_initializable<_Iter> = default; - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator(_Iter __iter, iter_difference_t<_Iter> __n) - : __current_(_VSTD::move(__iter)), __count_(__n) { - _LIBCPP_ASSERT(__n >= 0, "__n must not be negative."); - } - - template<class _I2> - requires convertible_to<const _I2&, _Iter> - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator(const counted_iterator<_I2>& __other) - : __current_(__other.__current_), __count_(__other.__count_) {} - - template<class _I2> - requires assignable_from<_Iter&, const _I2&> - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator& operator=(const counted_iterator<_I2>& __other) { - __current_ = __other.__current_; - __count_ = __other.__count_; - return *this; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr const _Iter& base() const& { return __current_; } - - _LIBCPP_HIDE_FROM_ABI - constexpr _Iter base() && { return _VSTD::move(__current_); } - - _LIBCPP_HIDE_FROM_ABI - constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; } - - _LIBCPP_HIDE_FROM_ABI - constexpr decltype(auto) operator*() { - _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end."); - return *__current_; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr decltype(auto) operator*() const - requires __dereferenceable<const _Iter> - { - _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end."); - return *__current_; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr auto operator->() const noexcept - requires contiguous_iterator<_Iter> - { - return _VSTD::to_address(__current_); - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator& operator++() { - _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); - ++__current_; - --__count_; - return *this; - } - - _LIBCPP_HIDE_FROM_ABI - decltype(auto) operator++(int) { - _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); - --__count_; -#ifndef _LIBCPP_NO_EXCEPTIONS - try { return __current_++; } - catch(...) { ++__count_; throw; } -#else - return __current_++; -#endif // _LIBCPP_NO_EXCEPTIONS - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator operator++(int) - requires forward_iterator<_Iter> - { - _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); - counted_iterator __tmp = *this; - ++*this; - return __tmp; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator& operator--() - requires bidirectional_iterator<_Iter> - { - --__current_; - ++__count_; - return *this; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator operator--(int) - requires bidirectional_iterator<_Iter> - { - counted_iterator __tmp = *this; - --*this; - return __tmp; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator operator+(iter_difference_t<_Iter> __n) const - requires random_access_iterator<_Iter> - { - return counted_iterator(__current_ + __n, __count_ - __n); - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr counted_iterator operator+( - iter_difference_t<_Iter> __n, const counted_iterator& __x) - requires random_access_iterator<_Iter> - { - return __x + __n; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator& operator+=(iter_difference_t<_Iter> __n) - requires random_access_iterator<_Iter> - { - _LIBCPP_ASSERT(__n <= __count_, "Cannot advance iterator past end."); - __current_ += __n; - __count_ -= __n; - return *this; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator operator-(iter_difference_t<_Iter> __n) const - requires random_access_iterator<_Iter> - { - return counted_iterator(__current_ - __n, __count_ + __n); - } - - template<common_with<_Iter> _I2> - _LIBCPP_HIDE_FROM_ABI - friend constexpr iter_difference_t<_I2> operator-( - const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) - { - return __rhs.__count_ - __lhs.__count_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr iter_difference_t<_Iter> operator-( - const counted_iterator& __lhs, default_sentinel_t) - { - return -__lhs.__count_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr iter_difference_t<_Iter> operator-( - default_sentinel_t, const counted_iterator& __rhs) - { - return __rhs.__count_; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr counted_iterator& operator-=(iter_difference_t<_Iter> __n) - requires random_access_iterator<_Iter> - { - _LIBCPP_ASSERT(-__n <= __count_, "Attempt to subtract too large of a size: " - "counted_iterator would be decremented before the " - "first element of its range."); - __current_ -= __n; - __count_ += __n; - return *this; - } - - _LIBCPP_HIDE_FROM_ABI - constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const - requires random_access_iterator<_Iter> - { - _LIBCPP_ASSERT(__n < __count_, "Subscript argument must be less than size."); - return __current_[__n]; - } - - template<common_with<_Iter> _I2> - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==( - const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) - { - return __lhs.__count_ == __rhs.__count_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==( - const counted_iterator& __lhs, default_sentinel_t) - { - return __lhs.__count_ == 0; - } - - template<common_with<_Iter> _I2> - friend constexpr strong_ordering operator<=>( - const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) - { - return __rhs.__count_ <=> __lhs.__count_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const counted_iterator& __i) - noexcept(noexcept(ranges::iter_move(__i.__current_))) - requires input_iterator<_Iter> - { - _LIBCPP_ASSERT(__i.__count_ > 0, "Iterator must not be past end of range."); - return ranges::iter_move(__i.__current_); - } - - template<indirectly_swappable<_Iter> _I2> - _LIBCPP_HIDE_FROM_ABI - friend constexpr void iter_swap(const counted_iterator& __x, const counted_iterator<_I2>& __y) - noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) - { - _LIBCPP_ASSERT(__x.__count_ > 0 && __y.__count_ > 0, - "Iterators must not be past end of range."); - return ranges::iter_swap(__x.__current_, __y.__current_); - } -}; - -template<input_iterator _Iter> - requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>> -struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> { - using pointer = conditional_t<contiguous_iterator<_Iter>, - add_pointer_t<iter_reference_t<_Iter>>, void>; -}; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H +// -*- 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___ITERATOR_COUNTED_ITERATOR_H +#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H + +#include <__config> +#include <__debug> +#include <__iterator/concepts.h> +#include <__iterator/default_sentinel.h> +#include <__iterator/iter_move.h> +#include <__iterator/iter_swap.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <__memory/pointer_traits.h> +#include <__utility/move.h> +#include <compare> +#include <concepts> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template<class> +struct __counted_iterator_concept {}; + +template<class _Iter> + requires requires { typename _Iter::iterator_concept; } +struct __counted_iterator_concept<_Iter> { + using iterator_concept = typename _Iter::iterator_concept; +}; + +template<class> +struct __counted_iterator_category {}; + +template<class _Iter> + requires requires { typename _Iter::iterator_category; } +struct __counted_iterator_category<_Iter> { + using iterator_category = typename _Iter::iterator_category; +}; + +template<class> +struct __counted_iterator_value_type {}; + +template<indirectly_readable _Iter> +struct __counted_iterator_value_type<_Iter> { + using value_type = iter_value_t<_Iter>; +}; + +template<input_or_output_iterator _Iter> +class counted_iterator + : public __counted_iterator_concept<_Iter> + , public __counted_iterator_category<_Iter> + , public __counted_iterator_value_type<_Iter> +{ +public: + [[no_unique_address]] _Iter __current_ = _Iter(); + iter_difference_t<_Iter> __count_ = 0; + + using iterator_type = _Iter; + using difference_type = iter_difference_t<_Iter>; + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator() requires default_initializable<_Iter> = default; + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator(_Iter __iter, iter_difference_t<_Iter> __n) + : __current_(_VSTD::move(__iter)), __count_(__n) { + _LIBCPP_ASSERT(__n >= 0, "__n must not be negative."); + } + + template<class _I2> + requires convertible_to<const _I2&, _Iter> + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator(const counted_iterator<_I2>& __other) + : __current_(__other.__current_), __count_(__other.__count_) {} + + template<class _I2> + requires assignable_from<_Iter&, const _I2&> + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator=(const counted_iterator<_I2>& __other) { + __current_ = __other.__current_; + __count_ = __other.__count_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr const _Iter& base() const& { return __current_; } + + _LIBCPP_HIDE_FROM_ABI + constexpr _Iter base() && { return _VSTD::move(__current_); } + + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; } + + _LIBCPP_HIDE_FROM_ABI + constexpr decltype(auto) operator*() { + _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end."); + return *__current_; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr decltype(auto) operator*() const + requires __dereferenceable<const _Iter> + { + _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end."); + return *__current_; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr auto operator->() const noexcept + requires contiguous_iterator<_Iter> + { + return _VSTD::to_address(__current_); + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator++() { + _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); + ++__current_; + --__count_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + decltype(auto) operator++(int) { + _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); + --__count_; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { return __current_++; } + catch(...) { ++__count_; throw; } +#else + return __current_++; +#endif // _LIBCPP_NO_EXCEPTIONS + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator++(int) + requires forward_iterator<_Iter> + { + _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); + counted_iterator __tmp = *this; + ++*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator--() + requires bidirectional_iterator<_Iter> + { + --__current_; + ++__count_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator--(int) + requires bidirectional_iterator<_Iter> + { + counted_iterator __tmp = *this; + --*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator+(iter_difference_t<_Iter> __n) const + requires random_access_iterator<_Iter> + { + return counted_iterator(__current_ + __n, __count_ - __n); + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr counted_iterator operator+( + iter_difference_t<_Iter> __n, const counted_iterator& __x) + requires random_access_iterator<_Iter> + { + return __x + __n; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator+=(iter_difference_t<_Iter> __n) + requires random_access_iterator<_Iter> + { + _LIBCPP_ASSERT(__n <= __count_, "Cannot advance iterator past end."); + __current_ += __n; + __count_ -= __n; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator-(iter_difference_t<_Iter> __n) const + requires random_access_iterator<_Iter> + { + return counted_iterator(__current_ - __n, __count_ + __n); + } + + template<common_with<_Iter> _I2> + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_difference_t<_I2> operator-( + const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) + { + return __rhs.__count_ - __lhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_difference_t<_Iter> operator-( + const counted_iterator& __lhs, default_sentinel_t) + { + return -__lhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_difference_t<_Iter> operator-( + default_sentinel_t, const counted_iterator& __rhs) + { + return __rhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator-=(iter_difference_t<_Iter> __n) + requires random_access_iterator<_Iter> + { + _LIBCPP_ASSERT(-__n <= __count_, "Attempt to subtract too large of a size: " + "counted_iterator would be decremented before the " + "first element of its range."); + __current_ -= __n; + __count_ += __n; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const + requires random_access_iterator<_Iter> + { + _LIBCPP_ASSERT(__n < __count_, "Subscript argument must be less than size."); + return __current_[__n]; + } + + template<common_with<_Iter> _I2> + _LIBCPP_HIDE_FROM_ABI + friend constexpr bool operator==( + const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) + { + return __lhs.__count_ == __rhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr bool operator==( + const counted_iterator& __lhs, default_sentinel_t) + { + return __lhs.__count_ == 0; + } + + template<common_with<_Iter> _I2> + friend constexpr strong_ordering operator<=>( + const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) + { + return __rhs.__count_ <=> __lhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const counted_iterator& __i) + noexcept(noexcept(ranges::iter_move(__i.__current_))) + requires input_iterator<_Iter> + { + _LIBCPP_ASSERT(__i.__count_ > 0, "Iterator must not be past end of range."); + return ranges::iter_move(__i.__current_); + } + + template<indirectly_swappable<_Iter> _I2> + _LIBCPP_HIDE_FROM_ABI + friend constexpr void iter_swap(const counted_iterator& __x, const counted_iterator<_I2>& __y) + noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) + { + _LIBCPP_ASSERT(__x.__count_ > 0 && __y.__count_ > 0, + "Iterators must not be past end of range."); + return ranges::iter_swap(__x.__current_, __y.__current_); + } +}; + +template<input_iterator _Iter> + requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>> +struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> { + using pointer = conditional_t<contiguous_iterator<_Iter>, + add_pointer_t<iter_reference_t<_Iter>>, void>; +}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/data.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/data.h index 6f80a0b565f..5e4946cc10b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/data.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/data.h @@ -1,51 +1,51 @@ -// -*- 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___ITERATOR_DATA_H -#define _LIBCPP___ITERATOR_DATA_H - -#include <__config> -#include <cstddef> -#include <initializer_list> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 14 - -template <class _Cont> constexpr -_LIBCPP_INLINE_VISIBILITY -auto data(_Cont& __c) -_NOEXCEPT_(noexcept(__c.data())) --> decltype (__c.data()) -{ return __c.data(); } - -template <class _Cont> constexpr -_LIBCPP_INLINE_VISIBILITY -auto data(const _Cont& __c) -_NOEXCEPT_(noexcept(__c.data())) --> decltype (__c.data()) -{ return __c.data(); } - -template <class _Tp, size_t _Sz> -_LIBCPP_INLINE_VISIBILITY -constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; } - -template <class _Ep> -_LIBCPP_INLINE_VISIBILITY -constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } - -#endif - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_DATA_H +// -*- 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___ITERATOR_DATA_H +#define _LIBCPP___ITERATOR_DATA_H + +#include <__config> +#include <cstddef> +#include <initializer_list> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template <class _Cont> constexpr +_LIBCPP_INLINE_VISIBILITY +auto data(_Cont& __c) +_NOEXCEPT_(noexcept(__c.data())) +-> decltype (__c.data()) +{ return __c.data(); } + +template <class _Cont> constexpr +_LIBCPP_INLINE_VISIBILITY +auto data(const _Cont& __c) +_NOEXCEPT_(noexcept(__c.data())) +-> decltype (__c.data()) +{ return __c.data(); } + +template <class _Tp, size_t _Sz> +_LIBCPP_INLINE_VISIBILITY +constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; } + +template <class _Ep> +_LIBCPP_INLINE_VISIBILITY +constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_DATA_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/default_sentinel.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/default_sentinel.h index ffda6a8d3d6..7172a748feb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/default_sentinel.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/default_sentinel.h @@ -1,30 +1,30 @@ -// -*- 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___ITERATOR_DEFAULT_SENTINEL_H -#define _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -struct default_sentinel_t { }; -inline constexpr default_sentinel_t default_sentinel{}; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H +// -*- 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___ITERATOR_DEFAULT_SENTINEL_H +#define _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +struct default_sentinel_t { }; +inline constexpr default_sentinel_t default_sentinel{}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h index 2fe6597ffb2..70e8e52398f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h @@ -1,51 +1,51 @@ -// -*- 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___ITERATOR_DISTANCE_H -#define _LIBCPP___ITERATOR_DISTANCE_H - -#include <__config> -#include <__iterator/iterator_traits.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _InputIter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -typename iterator_traits<_InputIter>::difference_type -__distance(_InputIter __first, _InputIter __last, input_iterator_tag) -{ - typename iterator_traits<_InputIter>::difference_type __r(0); - for (; __first != __last; ++__first) - ++__r; - return __r; -} - -template <class _RandIter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -typename iterator_traits<_RandIter>::difference_type -__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) -{ - return __last - __first; -} - -template <class _InputIter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -typename iterator_traits<_InputIter>::difference_type -distance(_InputIter __first, _InputIter __last) -{ - return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_DISTANCE_H +// -*- 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___ITERATOR_DISTANCE_H +#define _LIBCPP___ITERATOR_DISTANCE_H + +#include <__config> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _InputIter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename iterator_traits<_InputIter>::difference_type +__distance(_InputIter __first, _InputIter __last, input_iterator_tag) +{ + typename iterator_traits<_InputIter>::difference_type __r(0); + for (; __first != __last; ++__first) + ++__r; + return __r; +} + +template <class _RandIter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename iterator_traits<_RandIter>::difference_type +__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) +{ + return __last - __first; +} + +template <class _InputIter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename iterator_traits<_InputIter>::difference_type +distance(_InputIter __first, _InputIter __last) +{ + return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_DISTANCE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/empty.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/empty.h index f647b0d8fa4..39cd560a276 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/empty.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/empty.h @@ -1,44 +1,44 @@ -// -*- 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___ITERATOR_EMPTY_H -#define _LIBCPP___ITERATOR_EMPTY_H - -#include <__config> -#include <cstddef> -#include <initializer_list> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 14 - -template <class _Cont> -_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY -constexpr auto empty(const _Cont& __c) -_NOEXCEPT_(noexcept(__c.empty())) --> decltype (__c.empty()) -{ return __c.empty(); } - -template <class _Tp, size_t _Sz> -_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY -constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; } - -template <class _Ep> -_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY -constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } - -#endif // _LIBCPP_STD_VER > 14 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_EMPTY_H +// -*- 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___ITERATOR_EMPTY_H +#define _LIBCPP___ITERATOR_EMPTY_H + +#include <__config> +#include <cstddef> +#include <initializer_list> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template <class _Cont> +_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY +constexpr auto empty(const _Cont& __c) +_NOEXCEPT_(noexcept(__c.empty())) +-> decltype (__c.empty()) +{ return __c.empty(); } + +template <class _Tp, size_t _Sz> +_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY +constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; } + +template <class _Ep> +_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY +constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_EMPTY_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/erase_if_container.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/erase_if_container.h index 7afabd19be0..08f6e224823 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/erase_if_container.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/erase_if_container.h @@ -1,40 +1,40 @@ -// -*- 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___ITERATOR_ERASE_IF_CONTAINER_H -#define _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Container, class _Predicate> -_LIBCPP_HIDE_FROM_ABI -typename _Container::size_type -__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) { - typename _Container::size_type __old_size = __c.size(); - - const typename _Container::iterator __last = __c.end(); - for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) { - if (__pred(*__iter)) - __iter = __c.erase(__iter); - else - ++__iter; - } - - return __old_size - __c.size(); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H +// -*- 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___ITERATOR_ERASE_IF_CONTAINER_H +#define _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Container, class _Predicate> +_LIBCPP_HIDE_FROM_ABI +typename _Container::size_type +__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) { + typename _Container::size_type __old_size = __c.size(); + + const typename _Container::iterator __last = __c.end(); + for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) { + if (__pred(*__iter)) + __iter = __c.erase(__iter); + else + ++__iter; + } + + return __old_size - __c.size(); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/front_insert_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/front_insert_iterator.h index db896d7e9ad..b229a99f110 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/front_insert_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/front_insert_iterator.h @@ -1,70 +1,70 @@ -// -*- 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___ITERATOR_FRONT_INSERT_ITERATOR_H -#define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <__utility/move.h> -#include <cstddef> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _Container> -class _LIBCPP_TEMPLATE_VIS front_insert_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<output_iterator_tag, void, void, void, void> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -protected: - _Container* container; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; -#if _LIBCPP_STD_VER > 17 - typedef ptrdiff_t difference_type; -#else - typedef void difference_type; -#endif - typedef void pointer; - typedef void reference; - typedef _Container container_type; - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_) - {container->push_front(__value_); return *this;} -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_) - {container->push_front(_VSTD::move(__value_)); return *this;} -#endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;} -}; - -template <class _Container> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 -front_insert_iterator<_Container> -front_inserter(_Container& __x) -{ - return front_insert_iterator<_Container>(__x); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H +// -*- 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___ITERATOR_FRONT_INSERT_ITERATOR_H +#define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__utility/move.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _Container> +class _LIBCPP_TEMPLATE_VIS front_insert_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<output_iterator_tag, void, void, void, void> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +protected: + _Container* container; +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _Container container_type; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_front(__value_); return *this;} +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_front(_VSTD::move(__value_)); return *this;} +#endif // _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;} +}; + +template <class _Container> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +front_insert_iterator<_Container> +front_inserter(_Container& __x) +{ + return front_insert_iterator<_Container>(__x); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/incrementable_traits.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/incrementable_traits.h index 90355b2893c..fd5015ddf1b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/incrementable_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/incrementable_traits.h @@ -1,72 +1,72 @@ -// -*- 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___ITERATOR_INCREMENTABLE_TRAITS_H -#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H - -#include <__config> -#include <concepts> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -// [incrementable.traits] -template<class> struct incrementable_traits {}; - -template<class _Tp> -requires is_object_v<_Tp> -struct incrementable_traits<_Tp*> { - using difference_type = ptrdiff_t; -}; - -template<class _Ip> -struct incrementable_traits<const _Ip> : incrementable_traits<_Ip> {}; - -template<class _Tp> -concept __has_member_difference_type = requires { typename _Tp::difference_type; }; - -template<__has_member_difference_type _Tp> -struct incrementable_traits<_Tp> { - using difference_type = typename _Tp::difference_type; -}; - -template<class _Tp> -concept __has_integral_minus = - requires(const _Tp& __x, const _Tp& __y) { - { __x - __y } -> integral; - }; - -template<__has_integral_minus _Tp> -requires (!__has_member_difference_type<_Tp>) -struct incrementable_traits<_Tp> { - using difference_type = make_signed_t<decltype(declval<_Tp>() - declval<_Tp>())>; -}; - -template <class> -struct iterator_traits; - -// Let `RI` be `remove_cvref_t<I>`. The type `iter_difference_t<I>` denotes -// `incrementable_traits<RI>::difference_type` if `iterator_traits<RI>` names a specialization -// generated from the primary template, and `iterator_traits<RI>::difference_type` otherwise. -template <class _Ip> -using iter_difference_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value, - incrementable_traits<remove_cvref_t<_Ip> >, - iterator_traits<remove_cvref_t<_Ip> > >::difference_type; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H +// -*- 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___ITERATOR_INCREMENTABLE_TRAITS_H +#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H + +#include <__config> +#include <concepts> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// [incrementable.traits] +template<class> struct incrementable_traits {}; + +template<class _Tp> +requires is_object_v<_Tp> +struct incrementable_traits<_Tp*> { + using difference_type = ptrdiff_t; +}; + +template<class _Ip> +struct incrementable_traits<const _Ip> : incrementable_traits<_Ip> {}; + +template<class _Tp> +concept __has_member_difference_type = requires { typename _Tp::difference_type; }; + +template<__has_member_difference_type _Tp> +struct incrementable_traits<_Tp> { + using difference_type = typename _Tp::difference_type; +}; + +template<class _Tp> +concept __has_integral_minus = + requires(const _Tp& __x, const _Tp& __y) { + { __x - __y } -> integral; + }; + +template<__has_integral_minus _Tp> +requires (!__has_member_difference_type<_Tp>) +struct incrementable_traits<_Tp> { + using difference_type = make_signed_t<decltype(declval<_Tp>() - declval<_Tp>())>; +}; + +template <class> +struct iterator_traits; + +// Let `RI` be `remove_cvref_t<I>`. The type `iter_difference_t<I>` denotes +// `incrementable_traits<RI>::difference_type` if `iterator_traits<RI>` names a specialization +// generated from the primary template, and `iterator_traits<RI>::difference_type` otherwise. +template <class _Ip> +using iter_difference_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value, + incrementable_traits<remove_cvref_t<_Ip> >, + iterator_traits<remove_cvref_t<_Ip> > >::difference_type; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/insert_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/insert_iterator.h index e840c091fdd..33117419881 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/insert_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/insert_iterator.h @@ -1,81 +1,81 @@ -// -*- 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___ITERATOR_INSERT_ITERATOR_H -#define _LIBCPP___ITERATOR_INSERT_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <__ranges/access.h> -#include <__utility/move.h> -#include <cstddef> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) -template <class _Container> -using __insert_iterator_iter_t = ranges::iterator_t<_Container>; -#else -template <class _Container> -using __insert_iterator_iter_t = typename _Container::iterator; -#endif - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _Container> -class _LIBCPP_TEMPLATE_VIS insert_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<output_iterator_tag, void, void, void, void> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -protected: - _Container* container; - __insert_iterator_iter_t<_Container> iter; -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; -#if _LIBCPP_STD_VER > 17 - typedef ptrdiff_t difference_type; -#else - typedef void difference_type; -#endif - typedef void pointer; - typedef void reference; - typedef _Container container_type; - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) - : container(_VSTD::addressof(__x)), iter(__i) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) - {iter = container->insert(iter, __value_); ++iter; return *this;} -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) - {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} -#endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;} -}; - -template <class _Container> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 -insert_iterator<_Container> -inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) -{ - return insert_iterator<_Container>(__x, __i); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H +// -*- 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___ITERATOR_INSERT_ITERATOR_H +#define _LIBCPP___ITERATOR_INSERT_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__ranges/access.h> +#include <__utility/move.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) +template <class _Container> +using __insert_iterator_iter_t = ranges::iterator_t<_Container>; +#else +template <class _Container> +using __insert_iterator_iter_t = typename _Container::iterator; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _Container> +class _LIBCPP_TEMPLATE_VIS insert_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<output_iterator_tag, void, void, void, void> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +protected: + _Container* container; + __insert_iterator_iter_t<_Container> iter; +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _Container container_type; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) + : container(_VSTD::addressof(__x)), iter(__i) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) + {iter = container->insert(iter, __value_); ++iter; return *this;} +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) + {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} +#endif // _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;} +}; + +template <class _Container> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +insert_iterator<_Container> +inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) +{ + return insert_iterator<_Container>(__x, __i); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/istream_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/istream_iterator.h index 346d400f138..979d714edf5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/istream_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/istream_iterator.h @@ -1,92 +1,92 @@ -// -*- 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___ITERATOR_ISTREAM_ITERATOR_H -#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <iosfwd> // for forward declarations of char_traits and basic_istream - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _Tp, class _CharT = char, - class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> -class _LIBCPP_TEMPLATE_VIS istream_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -public: - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; - typedef _CharT char_type; - typedef _Traits traits_type; - typedef basic_istream<_CharT,_Traits> istream_type; -private: - istream_type* __in_stream_; - _Tp __value_; -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {} - _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s)) - { - if (!(*__in_stream_ >> __value_)) - __in_stream_ = nullptr; - } - - _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;} - _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));} - _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++() - { - if (!(*__in_stream_ >> __value_)) - __in_stream_ = nullptr; - return *this; - } - _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int) - {istream_iterator __t(*this); ++(*this); return __t;} - - template <class _Up, class _CharU, class _TraitsU, class _DistanceU> - friend _LIBCPP_INLINE_VISIBILITY - bool - operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, - const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); -}; - -template <class _Tp, class _CharT, class _Traits, class _Distance> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, - const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) -{ - return __x.__in_stream_ == __y.__in_stream_; -} - -template <class _Tp, class _CharT, class _Traits, class _Distance> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, - const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) -{ - return !(__x == __y); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H +// -*- 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___ITERATOR_ISTREAM_ITERATOR_H +#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <iosfwd> // for forward declarations of char_traits and basic_istream + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _Tp, class _CharT = char, + class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> +class _LIBCPP_TEMPLATE_VIS istream_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef input_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_istream<_CharT,_Traits> istream_type; +private: + istream_type* __in_stream_; + _Tp __value_; +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {} + _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s)) + { + if (!(*__in_stream_ >> __value_)) + __in_stream_ = nullptr; + } + + _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;} + _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));} + _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++() + { + if (!(*__in_stream_ >> __value_)) + __in_stream_ = nullptr; + return *this; + } + _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int) + {istream_iterator __t(*this); ++(*this); return __t;} + + template <class _Up, class _CharU, class _TraitsU, class _DistanceU> + friend _LIBCPP_INLINE_VISIBILITY + bool + operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, + const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); +}; + +template <class _Tp, class _CharT, class _Traits, class _Distance> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, + const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) +{ + return __x.__in_stream_ == __y.__in_stream_; +} + +template <class _Tp, class _CharT, class _Traits, class _Distance> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, + const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) +{ + return !(__x == __y); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/istreambuf_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/istreambuf_iterator.h index 76e7046837c..0c7676f1690 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/istreambuf_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/istreambuf_iterator.h @@ -1,105 +1,105 @@ -// -*- 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___ITERATOR_ISTREAMBUF_ITERATOR_H -#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <iosfwd> // for forward declaration of basic_streambuf - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template<class _CharT, class _Traits> -class _LIBCPP_TEMPLATE_VIS istreambuf_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<input_iterator_tag, _CharT, - typename _Traits::off_type, _CharT*, - _CharT> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -public: - typedef input_iterator_tag iterator_category; - typedef _CharT value_type; - typedef typename _Traits::off_type difference_type; - typedef _CharT* pointer; - typedef _CharT reference; - typedef _CharT char_type; - typedef _Traits traits_type; - typedef typename _Traits::int_type int_type; - typedef basic_streambuf<_CharT,_Traits> streambuf_type; - typedef basic_istream<_CharT,_Traits> istream_type; -private: - mutable streambuf_type* __sbuf_; - - class __proxy - { - char_type __keep_; - streambuf_type* __sbuf_; - _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s) - : __keep_(__c), __sbuf_(__s) {} - friend class istreambuf_iterator; - public: - _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;} - }; - - _LIBCPP_INLINE_VISIBILITY - bool __test_for_eof() const - { - if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof())) - __sbuf_ = nullptr; - return __sbuf_ == nullptr; - } -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT - : __sbuf_(__s.rdbuf()) {} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT - : __sbuf_(__s) {} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT - : __sbuf_(__p.__sbuf_) {} - - _LIBCPP_INLINE_VISIBILITY char_type operator*() const - {return static_cast<char_type>(__sbuf_->sgetc());} - _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++() - { - __sbuf_->sbumpc(); - return *this; - } - _LIBCPP_INLINE_VISIBILITY __proxy operator++(int) - { - return __proxy(__sbuf_->sbumpc(), __sbuf_); - } - - _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const - {return __test_for_eof() == __b.__test_for_eof();} -}; - -template <class _CharT, class _Traits> -inline _LIBCPP_INLINE_VISIBILITY -bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a, - const istreambuf_iterator<_CharT,_Traits>& __b) - {return __a.equal(__b);} - -template <class _CharT, class _Traits> -inline _LIBCPP_INLINE_VISIBILITY -bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, - const istreambuf_iterator<_CharT,_Traits>& __b) - {return !__a.equal(__b);} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H +// -*- 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___ITERATOR_ISTREAMBUF_ITERATOR_H +#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <iosfwd> // for forward declaration of basic_streambuf + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template<class _CharT, class _Traits> +class _LIBCPP_TEMPLATE_VIS istreambuf_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<input_iterator_tag, _CharT, + typename _Traits::off_type, _CharT*, + _CharT> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef input_iterator_tag iterator_category; + typedef _CharT value_type; + typedef typename _Traits::off_type difference_type; + typedef _CharT* pointer; + typedef _CharT reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename _Traits::int_type int_type; + typedef basic_streambuf<_CharT,_Traits> streambuf_type; + typedef basic_istream<_CharT,_Traits> istream_type; +private: + mutable streambuf_type* __sbuf_; + + class __proxy + { + char_type __keep_; + streambuf_type* __sbuf_; + _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s) + : __keep_(__c), __sbuf_(__s) {} + friend class istreambuf_iterator; + public: + _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;} + }; + + _LIBCPP_INLINE_VISIBILITY + bool __test_for_eof() const + { + if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof())) + __sbuf_ = nullptr; + return __sbuf_ == nullptr; + } +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT + : __sbuf_(__s.rdbuf()) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT + : __sbuf_(__s) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT + : __sbuf_(__p.__sbuf_) {} + + _LIBCPP_INLINE_VISIBILITY char_type operator*() const + {return static_cast<char_type>(__sbuf_->sgetc());} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++() + { + __sbuf_->sbumpc(); + return *this; + } + _LIBCPP_INLINE_VISIBILITY __proxy operator++(int) + { + return __proxy(__sbuf_->sbumpc(), __sbuf_); + } + + _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const + {return __test_for_eof() == __b.__test_for_eof();} +}; + +template <class _CharT, class _Traits> +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a, + const istreambuf_iterator<_CharT,_Traits>& __b) + {return __a.equal(__b);} + +template <class _CharT, class _Traits> +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, + const istreambuf_iterator<_CharT,_Traits>& __b) + {return !__a.equal(__b);} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_move.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_move.h index 600222ef900..a2951f764b0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_move.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_move.h @@ -1,86 +1,86 @@ -// -*- 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___ITERATOR_ITER_MOVE_H -#define _LIBCPP___ITERATOR_ITER_MOVE_H - -#include <__config> -#include <__iterator/iterator_traits.h> -#include <__utility/forward.h> -#include <concepts> // __class_or_enum -#include <type_traits> -#include <utility> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -namespace ranges::__iter_move { -void iter_move(); - -template<class _Ip> -concept __unqualified_iter_move = requires(_Ip&& __i) { - iter_move(_VSTD::forward<_Ip>(__i)); -}; - -// [iterator.cust.move]/1 -// The name ranges::iter_move denotes a customization point object. -// The expression ranges::iter_move(E) for a subexpression E is -// expression-equivalent to: -struct __fn { - // [iterator.cust.move]/1.1 - // iter_move(E), if E has class or enumeration type and iter_move(E) is a - // well-formed expression when treated as an unevaluated operand, [...] - template<class _Ip> - requires __class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const - noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i)))) - { - return iter_move(_VSTD::forward<_Ip>(__i)); - } - - // [iterator.cust.move]/1.2 - // Otherwise, if the expression *E is well-formed: - // 1.2.1 if *E is an lvalue, std::move(*E); - // 1.2.2 otherwise, *E. - template<class _Ip> - requires (!(__class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>)) && - requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); } - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const - noexcept(noexcept(*_VSTD::forward<_Ip>(__i))) - { - if constexpr (is_lvalue_reference_v<decltype(*_VSTD::forward<_Ip>(__i))>) { - return _VSTD::move(*_VSTD::forward<_Ip>(__i)); - } else { - return *_VSTD::forward<_Ip>(__i); - } - } - - // [iterator.cust.move]/1.3 - // Otherwise, ranges::iter_move(E) is ill-formed. -}; -} // namespace ranges::__iter_move - -namespace ranges::inline __cpo { - inline constexpr auto iter_move = __iter_move::__fn{}; -} - -template<__dereferenceable _Tp> -requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } -using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); - -#endif // !_LIBCPP_HAS_NO_RANGES - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ITER_MOVE_H +// -*- 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___ITERATOR_ITER_MOVE_H +#define _LIBCPP___ITERATOR_ITER_MOVE_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__utility/forward.h> +#include <concepts> // __class_or_enum +#include <type_traits> +#include <utility> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges::__iter_move { +void iter_move(); + +template<class _Ip> +concept __unqualified_iter_move = requires(_Ip&& __i) { + iter_move(_VSTD::forward<_Ip>(__i)); +}; + +// [iterator.cust.move]/1 +// The name ranges::iter_move denotes a customization point object. +// The expression ranges::iter_move(E) for a subexpression E is +// expression-equivalent to: +struct __fn { + // [iterator.cust.move]/1.1 + // iter_move(E), if E has class or enumeration type and iter_move(E) is a + // well-formed expression when treated as an unevaluated operand, [...] + template<class _Ip> + requires __class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const + noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i)))) + { + return iter_move(_VSTD::forward<_Ip>(__i)); + } + + // [iterator.cust.move]/1.2 + // Otherwise, if the expression *E is well-formed: + // 1.2.1 if *E is an lvalue, std::move(*E); + // 1.2.2 otherwise, *E. + template<class _Ip> + requires (!(__class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>)) && + requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const + noexcept(noexcept(*_VSTD::forward<_Ip>(__i))) + { + if constexpr (is_lvalue_reference_v<decltype(*_VSTD::forward<_Ip>(__i))>) { + return _VSTD::move(*_VSTD::forward<_Ip>(__i)); + } else { + return *_VSTD::forward<_Ip>(__i); + } + } + + // [iterator.cust.move]/1.3 + // Otherwise, ranges::iter_move(E) is ill-formed. +}; +} // namespace ranges::__iter_move + +namespace ranges::inline __cpo { + inline constexpr auto iter_move = __iter_move::__fn{}; +} + +template<__dereferenceable _Tp> +requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } +using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); + +#endif // !_LIBCPP_HAS_NO_RANGES + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ITER_MOVE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_swap.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_swap.h index 8032557b98d..a6c3bc8c663 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_swap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/iter_swap.h @@ -1,104 +1,104 @@ -// -*- 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___ITERATOR_ITER_SWAP_H -#define _LIBCPP___ITERATOR_ITER_SWAP_H - -#include <__config> -#include <__iterator/concepts.h> -#include <__iterator/iter_move.h> -#include <__iterator/iterator_traits.h> -#include <__iterator/readable_traits.h> -#include <__ranges/access.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <concepts> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -namespace ranges { -namespace __iter_swap { - template<class _I1, class _I2> - void iter_swap(_I1, _I2) = delete; - - template<class _T1, class _T2> - concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) { - iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); - }; - - template<class _T1, class _T2> - concept __readable_swappable = - indirectly_readable<_T1> && indirectly_readable<_T2> && - swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>; - - struct __fn { - template <class _T1, class _T2> - requires __unqualified_iter_swap<_T1, _T2> - _LIBCPP_HIDE_FROM_ABI - constexpr void operator()(_T1&& __x, _T2&& __y) const - noexcept(noexcept(iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)))) - { - (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); - } - - template <class _T1, class _T2> - requires (!__unqualified_iter_swap<_T1, _T2>) && - __readable_swappable<_T1, _T2> - _LIBCPP_HIDE_FROM_ABI - constexpr void operator()(_T1&& __x, _T2&& __y) const - noexcept(noexcept(ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y)))) - { - ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y)); - } - - template <class _T1, class _T2> - requires (!__unqualified_iter_swap<_T1, _T2> && - !__readable_swappable<_T1, _T2>) && - indirectly_movable_storable<_T1, _T2> && - indirectly_movable_storable<_T2, _T1> - _LIBCPP_HIDE_FROM_ABI - constexpr void operator()(_T1&& __x, _T2&& __y) const - noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) && - noexcept(*__y = ranges::iter_move(__x)) && - noexcept(*_VSTD::forward<_T1>(__x) = declval<iter_value_t<_T2>>())) - { - iter_value_t<_T2> __old(ranges::iter_move(__y)); - *__y = ranges::iter_move(__x); - *_VSTD::forward<_T1>(__x) = _VSTD::move(__old); - } - }; -} // end namespace __iter_swap - -inline namespace __cpo { - inline constexpr auto iter_swap = __iter_swap::__fn{}; -} // namespace __cpo - -} // namespace ranges - -template<class _I1, class _I2 = _I1> -concept indirectly_swappable = - indirectly_readable<_I1> && indirectly_readable<_I2> && - requires(const _I1 __i1, const _I2 __i2) { - ranges::iter_swap(__i1, __i1); - ranges::iter_swap(__i2, __i2); - ranges::iter_swap(__i1, __i2); - ranges::iter_swap(__i2, __i1); - }; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ITER_SWAP_H +// -*- 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___ITERATOR_ITER_SWAP_H +#define _LIBCPP___ITERATOR_ITER_SWAP_H + +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/iter_move.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <__ranges/access.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include <concepts> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +namespace __iter_swap { + template<class _I1, class _I2> + void iter_swap(_I1, _I2) = delete; + + template<class _T1, class _T2> + concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) { + iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); + }; + + template<class _T1, class _T2> + concept __readable_swappable = + indirectly_readable<_T1> && indirectly_readable<_T2> && + swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>; + + struct __fn { + template <class _T1, class _T2> + requires __unqualified_iter_swap<_T1, _T2> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_T1&& __x, _T2&& __y) const + noexcept(noexcept(iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)))) + { + (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); + } + + template <class _T1, class _T2> + requires (!__unqualified_iter_swap<_T1, _T2>) && + __readable_swappable<_T1, _T2> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_T1&& __x, _T2&& __y) const + noexcept(noexcept(ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y)))) + { + ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y)); + } + + template <class _T1, class _T2> + requires (!__unqualified_iter_swap<_T1, _T2> && + !__readable_swappable<_T1, _T2>) && + indirectly_movable_storable<_T1, _T2> && + indirectly_movable_storable<_T2, _T1> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_T1&& __x, _T2&& __y) const + noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) && + noexcept(*__y = ranges::iter_move(__x)) && + noexcept(*_VSTD::forward<_T1>(__x) = declval<iter_value_t<_T2>>())) + { + iter_value_t<_T2> __old(ranges::iter_move(__y)); + *__y = ranges::iter_move(__x); + *_VSTD::forward<_T1>(__x) = _VSTD::move(__old); + } + }; +} // end namespace __iter_swap + +inline namespace __cpo { + inline constexpr auto iter_swap = __iter_swap::__fn{}; +} // namespace __cpo + +} // namespace ranges + +template<class _I1, class _I2 = _I1> +concept indirectly_swappable = + indirectly_readable<_I1> && indirectly_readable<_I2> && + requires(const _I1 __i1, const _I2 __i2) { + ranges::iter_swap(__i1, __i1); + ranges::iter_swap(__i2, __i2); + ranges::iter_swap(__i1, __i2); + ranges::iter_swap(__i2, __i1); + }; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ITER_SWAP_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator.h index 755f8bc6578..be298ee5228 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator.h @@ -1,35 +1,35 @@ -// -*- 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___ITERATOR_ITERATOR_H -#define _LIBCPP___ITERATOR_ITERATOR_H - -#include <__config> -#include <cstddef> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template<class _Category, class _Tp, class _Distance = ptrdiff_t, - class _Pointer = _Tp*, class _Reference = _Tp&> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator -{ - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Pointer pointer; - typedef _Reference reference; - typedef _Category iterator_category; -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ITERATOR_H +// -*- 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___ITERATOR_ITERATOR_H +#define _LIBCPP___ITERATOR_ITERATOR_H + +#include <__config> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template<class _Category, class _Tp, class _Distance = ptrdiff_t, + class _Pointer = _Tp*, class _Reference = _Tp&> +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator +{ + typedef _Tp value_type; + typedef _Distance difference_type; + typedef _Pointer pointer; + typedef _Reference reference; + typedef _Category iterator_category; +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h index d4bbd584dfc..54c3e11e673 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h @@ -1,495 +1,495 @@ -// -*- 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___ITERATOR_ITERATOR_TRAITS_H -#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H - -#include <__config> -#include <__iterator/incrementable_traits.h> -#include <__iterator/readable_traits.h> -#include <concepts> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -template <class _Tp> -using __with_reference = _Tp&; - -template <class _Tp> -concept __referenceable = requires { - typename __with_reference<_Tp>; -}; - -template <class _Tp> -concept __dereferenceable = requires(_Tp& __t) { - { *__t } -> __referenceable; // not required to be equality-preserving -}; - -// [iterator.traits] -template<__dereferenceable _Tp> -using iter_reference_t = decltype(*declval<_Tp&>()); - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -template <class _Iter> -struct _LIBCPP_TEMPLATE_VIS iterator_traits; - -struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {}; -struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {}; -struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {}; -struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; -struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; -#if _LIBCPP_STD_VER > 17 -struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {}; -#endif - -template <class _Iter> -struct __iter_traits_cache { - using type = _If< - __is_primary_template<iterator_traits<_Iter> >::value, - _Iter, - iterator_traits<_Iter> - >; -}; -template <class _Iter> -using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type; - -struct __iter_concept_concept_test { - template <class _Iter> - using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept; -}; -struct __iter_concept_category_test { - template <class _Iter> - using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category; -}; -struct __iter_concept_random_fallback { - template <class _Iter> - using _Apply = __enable_if_t< - __is_primary_template<iterator_traits<_Iter> >::value, - random_access_iterator_tag - >; -}; - -template <class _Iter, class _Tester> struct __test_iter_concept - : _IsValidExpansion<_Tester::template _Apply, _Iter>, - _Tester -{ -}; - -template <class _Iter> -struct __iter_concept_cache { - using type = _Or< - __test_iter_concept<_Iter, __iter_concept_concept_test>, - __test_iter_concept<_Iter, __iter_concept_category_test>, - __test_iter_concept<_Iter, __iter_concept_random_fallback> - >; -}; - -template <class _Iter> -using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; - - -template <class _Tp> -struct __has_iterator_typedefs -{ -private: - struct __two {char __lx; char __lxx;}; - template <class _Up> static __two __test(...); - template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0, - typename __void_t<typename _Up::difference_type>::type* = 0, - typename __void_t<typename _Up::value_type>::type* = 0, - typename __void_t<typename _Up::reference>::type* = 0, - typename __void_t<typename _Up::pointer>::type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1; -}; - - -template <class _Tp> -struct __has_iterator_category -{ -private: - struct __two {char __lx; char __lxx;}; - template <class _Up> static __two __test(...); - template <class _Up> static char __test(typename _Up::iterator_category* = nullptr); -public: - static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; -}; - -template <class _Tp> -struct __has_iterator_concept -{ -private: - struct __two {char __lx; char __lxx;}; - template <class _Up> static __two __test(...); - template <class _Up> static char __test(typename _Up::iterator_concept* = nullptr); -public: - static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; -}; - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -// The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, -// so they've been banished to a namespace that makes it obvious they have a niche use-case. -namespace __iterator_traits_detail { -template<class _Ip> -concept __cpp17_iterator = - requires(_Ip __i) { - { *__i } -> __referenceable; - { ++__i } -> same_as<_Ip&>; - { *__i++ } -> __referenceable; - } && - copyable<_Ip>; - -template<class _Ip> -concept __cpp17_input_iterator = - __cpp17_iterator<_Ip> && - equality_comparable<_Ip> && - requires(_Ip __i) { - typename incrementable_traits<_Ip>::difference_type; - typename indirectly_readable_traits<_Ip>::value_type; - typename common_reference_t<iter_reference_t<_Ip>&&, - typename indirectly_readable_traits<_Ip>::value_type&>; - typename common_reference_t<decltype(*__i++)&&, - typename indirectly_readable_traits<_Ip>::value_type&>; - requires signed_integral<typename incrementable_traits<_Ip>::difference_type>; - }; - -template<class _Ip> -concept __cpp17_forward_iterator = - __cpp17_input_iterator<_Ip> && - constructible_from<_Ip> && - is_lvalue_reference_v<iter_reference_t<_Ip>> && - same_as<remove_cvref_t<iter_reference_t<_Ip>>, - typename indirectly_readable_traits<_Ip>::value_type> && - requires(_Ip __i) { - { __i++ } -> convertible_to<_Ip const&>; - { *__i++ } -> same_as<iter_reference_t<_Ip>>; - }; - -template<class _Ip> -concept __cpp17_bidirectional_iterator = - __cpp17_forward_iterator<_Ip> && - requires(_Ip __i) { - { --__i } -> same_as<_Ip&>; - { __i-- } -> convertible_to<_Ip const&>; - { *__i-- } -> same_as<iter_reference_t<_Ip>>; - }; - -template<class _Ip> -concept __cpp17_random_access_iterator = - __cpp17_bidirectional_iterator<_Ip> && - totally_ordered<_Ip> && - requires(_Ip __i, typename incrementable_traits<_Ip>::difference_type __n) { - { __i += __n } -> same_as<_Ip&>; - { __i -= __n } -> same_as<_Ip&>; - { __i + __n } -> same_as<_Ip>; - { __n + __i } -> same_as<_Ip>; - { __i - __n } -> same_as<_Ip>; - { __i - __i } -> same_as<decltype(__n)>; - { __i[__n] } -> convertible_to<iter_reference_t<_Ip>>; - }; -} // namespace __iterator_traits_detail - -template<class _Ip> -concept __has_member_reference = requires { typename _Ip::reference; }; - -template<class _Ip> -concept __has_member_pointer = requires { typename _Ip::pointer; }; - -template<class _Ip> -concept __has_member_iterator_category = requires { typename _Ip::iterator_category; }; - -template<class _Ip> -concept __specifies_members = requires { - typename _Ip::value_type; - typename _Ip::difference_type; - requires __has_member_reference<_Ip>; - requires __has_member_iterator_category<_Ip>; - }; - -template<class> -struct __iterator_traits_member_pointer_or_void { - using type = void; -}; - -template<__has_member_pointer _Tp> -struct __iterator_traits_member_pointer_or_void<_Tp> { - using type = typename _Tp::pointer; -}; - -template<class _Tp> -concept __cpp17_iterator_missing_members = - !__specifies_members<_Tp> && - __iterator_traits_detail::__cpp17_iterator<_Tp>; - -template<class _Tp> -concept __cpp17_input_iterator_missing_members = - __cpp17_iterator_missing_members<_Tp> && - __iterator_traits_detail::__cpp17_input_iterator<_Tp>; - -// Otherwise, `pointer` names `void`. -template<class> -struct __iterator_traits_member_pointer_or_arrow_or_void { using type = void; }; - -// [iterator.traits]/3.2.1 -// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type. -template<__has_member_pointer _Ip> -struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typename _Ip::pointer; }; - -// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that -// type. -template<class _Ip> - requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) -struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { - using type = decltype(declval<_Ip&>().operator->()); -}; - -// Otherwise, `reference` names `iter-reference-t<I>`. -template<class _Ip> -struct __iterator_traits_member_reference { using type = iter_reference_t<_Ip>; }; - -// [iterator.traits]/3.2.2 -// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type. -template<__has_member_reference _Ip> -struct __iterator_traits_member_reference<_Ip> { using type = typename _Ip::reference; }; - -// [iterator.traits]/3.2.3.4 -// input_iterator_tag -template<class _Ip> -struct __deduce_iterator_category { - using type = input_iterator_tag; -}; - -// [iterator.traits]/3.2.3.1 -// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise -template<__iterator_traits_detail::__cpp17_random_access_iterator _Ip> -struct __deduce_iterator_category<_Ip> { - using type = random_access_iterator_tag; -}; - -// [iterator.traits]/3.2.3.2 -// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise -template<__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip> -struct __deduce_iterator_category<_Ip> { - using type = bidirectional_iterator_tag; -}; - -// [iterator.traits]/3.2.3.3 -// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise -template<__iterator_traits_detail::__cpp17_forward_iterator _Ip> -struct __deduce_iterator_category<_Ip> { - using type = forward_iterator_tag; -}; - -template<class _Ip> -struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {}; - -// [iterator.traits]/3.2.3 -// If the qualified-id `I::iterator-category` is valid and denotes a type, `iterator-category` names -// that type. -template<__has_member_iterator_category _Ip> -struct __iterator_traits_iterator_category<_Ip> { - using type = typename _Ip::iterator_category; -}; - -// otherwise, it names void. -template<class> -struct __iterator_traits_difference_type { using type = void; }; - -// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then -// `difference_type` names that type; -template<class _Ip> -requires requires { typename incrementable_traits<_Ip>::difference_type; } -struct __iterator_traits_difference_type<_Ip> { - using type = typename incrementable_traits<_Ip>::difference_type; -}; - -// [iterator.traits]/3.4 -// Otherwise, `iterator_traits<I>` has no members by any of the above names. -template<class> -struct __iterator_traits {}; - -// [iterator.traits]/3.1 -// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and -// `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members: -template<__specifies_members _Ip> -struct __iterator_traits<_Ip> { - using iterator_category = typename _Ip::iterator_category; - using value_type = typename _Ip::value_type; - using difference_type = typename _Ip::difference_type; - using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type; - using reference = typename _Ip::reference; -}; - -// [iterator.traits]/3.2 -// Otherwise, if `I` satisfies the exposition-only concept `cpp17-input-iterator`, -// `iterator-traits<I>` has the following publicly accessible members: -template<__cpp17_input_iterator_missing_members _Ip> -struct __iterator_traits<_Ip> { - using iterator_category = typename __iterator_traits_iterator_category<_Ip>::type; - using value_type = typename indirectly_readable_traits<_Ip>::value_type; - using difference_type = typename incrementable_traits<_Ip>::difference_type; - using pointer = typename __iterator_traits_member_pointer_or_arrow_or_void<_Ip>::type; - using reference = typename __iterator_traits_member_reference<_Ip>::type; -}; - -// Otherwise, if `I` satisfies the exposition-only concept `cpp17-iterator`, then -// `iterator_traits<I>` has the following publicly accessible members: -template<__cpp17_iterator_missing_members _Ip> -struct __iterator_traits<_Ip> { - using iterator_category = output_iterator_tag; - using value_type = void; - using difference_type = typename __iterator_traits_difference_type<_Ip>::type; - using pointer = void; - using reference = void; -}; - -template<class _Ip> -struct iterator_traits : __iterator_traits<_Ip> { - using __primary_template = iterator_traits; -}; - -#else // !defined(_LIBCPP_HAS_NO_RANGES) - -template <class _Iter, bool> struct __iterator_traits {}; - -template <class _Iter, bool> struct __iterator_traits_impl {}; - -template <class _Iter> -struct __iterator_traits_impl<_Iter, true> -{ - typedef typename _Iter::difference_type difference_type; - typedef typename _Iter::value_type value_type; - typedef typename _Iter::pointer pointer; - typedef typename _Iter::reference reference; - typedef typename _Iter::iterator_category iterator_category; -}; - -template <class _Iter> -struct __iterator_traits<_Iter, true> - : __iterator_traits_impl - < - _Iter, - is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value || - is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value - > -{}; - -// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category -// exists. Else iterator_traits<Iterator> will be an empty class. This is a -// conforming extension which allows some programs to compile and behave as -// the client expects instead of failing at compile time. - -template <class _Iter> -struct _LIBCPP_TEMPLATE_VIS iterator_traits - : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> { - - using __primary_template = iterator_traits; -}; -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -template<class _Tp> -#if !defined(_LIBCPP_HAS_NO_RANGES) -requires is_object_v<_Tp> -#endif -struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> -{ - typedef ptrdiff_t difference_type; - typedef typename remove_cv<_Tp>::type value_type; - typedef _Tp* pointer; - typedef _Tp& reference; - typedef random_access_iterator_tag iterator_category; -#if _LIBCPP_STD_VER > 17 - typedef contiguous_iterator_tag iterator_concept; -#endif -}; - -template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value> -struct __has_iterator_category_convertible_to - : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up> -{}; - -template <class _Tp, class _Up> -struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {}; - -template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value> -struct __has_iterator_concept_convertible_to - : is_convertible<typename _Tp::iterator_concept, _Up> -{}; - -template <class _Tp, class _Up> -struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {}; - -template <class _Tp> -struct __is_cpp17_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {}; - -template <class _Tp> -struct __is_cpp17_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {}; - -template <class _Tp> -struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {}; - -template <class _Tp> -struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; - -// __is_cpp17_contiguous_iterator determines if an iterator is known by -// libc++ to be contiguous, either because it advertises itself as such -// (in C++20) or because it is a pointer type or a known trivial wrapper -// around a (possibly fancy) pointer type, such as __wrap_iter<T*>. -// Such iterators receive special "contiguous" optimizations in -// std::copy and std::sort. -// -#if _LIBCPP_STD_VER > 17 -template <class _Tp> -struct __is_cpp17_contiguous_iterator : _Or< - __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag>, - __has_iterator_concept_convertible_to<_Tp, contiguous_iterator_tag> -> {}; -#else -template <class _Tp> -struct __is_cpp17_contiguous_iterator : false_type {}; -#endif - -// Any native pointer which is an iterator is also a contiguous iterator. -template <class _Up> -struct __is_cpp17_contiguous_iterator<_Up*> : true_type {}; - - -template <class _Tp> -struct __is_exactly_cpp17_input_iterator - : public integral_constant<bool, - __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && - !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; - -#if _LIBCPP_STD_VER >= 17 -template<class _InputIterator> -using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; - -template<class _InputIterator> -using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; - -template<class _InputIterator> -using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type; - -template<class _InputIterator> -using __iter_to_alloc_type = pair< - add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>, - typename iterator_traits<_InputIterator>::value_type::second_type>; -#endif // _LIBCPP_STD_VER >= 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H +// -*- 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___ITERATOR_ITERATOR_TRAITS_H +#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H + +#include <__config> +#include <__iterator/incrementable_traits.h> +#include <__iterator/readable_traits.h> +#include <concepts> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template <class _Tp> +using __with_reference = _Tp&; + +template <class _Tp> +concept __referenceable = requires { + typename __with_reference<_Tp>; +}; + +template <class _Tp> +concept __dereferenceable = requires(_Tp& __t) { + { *__t } -> __referenceable; // not required to be equality-preserving +}; + +// [iterator.traits] +template<__dereferenceable _Tp> +using iter_reference_t = decltype(*declval<_Tp&>()); + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +template <class _Iter> +struct _LIBCPP_TEMPLATE_VIS iterator_traits; + +struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; +#if _LIBCPP_STD_VER > 17 +struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {}; +#endif + +template <class _Iter> +struct __iter_traits_cache { + using type = _If< + __is_primary_template<iterator_traits<_Iter> >::value, + _Iter, + iterator_traits<_Iter> + >; +}; +template <class _Iter> +using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type; + +struct __iter_concept_concept_test { + template <class _Iter> + using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept; +}; +struct __iter_concept_category_test { + template <class _Iter> + using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category; +}; +struct __iter_concept_random_fallback { + template <class _Iter> + using _Apply = __enable_if_t< + __is_primary_template<iterator_traits<_Iter> >::value, + random_access_iterator_tag + >; +}; + +template <class _Iter, class _Tester> struct __test_iter_concept + : _IsValidExpansion<_Tester::template _Apply, _Iter>, + _Tester +{ +}; + +template <class _Iter> +struct __iter_concept_cache { + using type = _Or< + __test_iter_concept<_Iter, __iter_concept_concept_test>, + __test_iter_concept<_Iter, __iter_concept_category_test>, + __test_iter_concept<_Iter, __iter_concept_random_fallback> + >; +}; + +template <class _Iter> +using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; + + +template <class _Tp> +struct __has_iterator_typedefs +{ +private: + struct __two {char __lx; char __lxx;}; + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0, + typename __void_t<typename _Up::difference_type>::type* = 0, + typename __void_t<typename _Up::value_type>::type* = 0, + typename __void_t<typename _Up::reference>::type* = 0, + typename __void_t<typename _Up::pointer>::type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1; +}; + + +template <class _Tp> +struct __has_iterator_category +{ +private: + struct __two {char __lx; char __lxx;}; + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::iterator_category* = nullptr); +public: + static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; +}; + +template <class _Tp> +struct __has_iterator_concept +{ +private: + struct __two {char __lx; char __lxx;}; + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::iterator_concept* = nullptr); +public: + static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; +}; + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, +// so they've been banished to a namespace that makes it obvious they have a niche use-case. +namespace __iterator_traits_detail { +template<class _Ip> +concept __cpp17_iterator = + requires(_Ip __i) { + { *__i } -> __referenceable; + { ++__i } -> same_as<_Ip&>; + { *__i++ } -> __referenceable; + } && + copyable<_Ip>; + +template<class _Ip> +concept __cpp17_input_iterator = + __cpp17_iterator<_Ip> && + equality_comparable<_Ip> && + requires(_Ip __i) { + typename incrementable_traits<_Ip>::difference_type; + typename indirectly_readable_traits<_Ip>::value_type; + typename common_reference_t<iter_reference_t<_Ip>&&, + typename indirectly_readable_traits<_Ip>::value_type&>; + typename common_reference_t<decltype(*__i++)&&, + typename indirectly_readable_traits<_Ip>::value_type&>; + requires signed_integral<typename incrementable_traits<_Ip>::difference_type>; + }; + +template<class _Ip> +concept __cpp17_forward_iterator = + __cpp17_input_iterator<_Ip> && + constructible_from<_Ip> && + is_lvalue_reference_v<iter_reference_t<_Ip>> && + same_as<remove_cvref_t<iter_reference_t<_Ip>>, + typename indirectly_readable_traits<_Ip>::value_type> && + requires(_Ip __i) { + { __i++ } -> convertible_to<_Ip const&>; + { *__i++ } -> same_as<iter_reference_t<_Ip>>; + }; + +template<class _Ip> +concept __cpp17_bidirectional_iterator = + __cpp17_forward_iterator<_Ip> && + requires(_Ip __i) { + { --__i } -> same_as<_Ip&>; + { __i-- } -> convertible_to<_Ip const&>; + { *__i-- } -> same_as<iter_reference_t<_Ip>>; + }; + +template<class _Ip> +concept __cpp17_random_access_iterator = + __cpp17_bidirectional_iterator<_Ip> && + totally_ordered<_Ip> && + requires(_Ip __i, typename incrementable_traits<_Ip>::difference_type __n) { + { __i += __n } -> same_as<_Ip&>; + { __i -= __n } -> same_as<_Ip&>; + { __i + __n } -> same_as<_Ip>; + { __n + __i } -> same_as<_Ip>; + { __i - __n } -> same_as<_Ip>; + { __i - __i } -> same_as<decltype(__n)>; + { __i[__n] } -> convertible_to<iter_reference_t<_Ip>>; + }; +} // namespace __iterator_traits_detail + +template<class _Ip> +concept __has_member_reference = requires { typename _Ip::reference; }; + +template<class _Ip> +concept __has_member_pointer = requires { typename _Ip::pointer; }; + +template<class _Ip> +concept __has_member_iterator_category = requires { typename _Ip::iterator_category; }; + +template<class _Ip> +concept __specifies_members = requires { + typename _Ip::value_type; + typename _Ip::difference_type; + requires __has_member_reference<_Ip>; + requires __has_member_iterator_category<_Ip>; + }; + +template<class> +struct __iterator_traits_member_pointer_or_void { + using type = void; +}; + +template<__has_member_pointer _Tp> +struct __iterator_traits_member_pointer_or_void<_Tp> { + using type = typename _Tp::pointer; +}; + +template<class _Tp> +concept __cpp17_iterator_missing_members = + !__specifies_members<_Tp> && + __iterator_traits_detail::__cpp17_iterator<_Tp>; + +template<class _Tp> +concept __cpp17_input_iterator_missing_members = + __cpp17_iterator_missing_members<_Tp> && + __iterator_traits_detail::__cpp17_input_iterator<_Tp>; + +// Otherwise, `pointer` names `void`. +template<class> +struct __iterator_traits_member_pointer_or_arrow_or_void { using type = void; }; + +// [iterator.traits]/3.2.1 +// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type. +template<__has_member_pointer _Ip> +struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typename _Ip::pointer; }; + +// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that +// type. +template<class _Ip> + requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) +struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { + using type = decltype(declval<_Ip&>().operator->()); +}; + +// Otherwise, `reference` names `iter-reference-t<I>`. +template<class _Ip> +struct __iterator_traits_member_reference { using type = iter_reference_t<_Ip>; }; + +// [iterator.traits]/3.2.2 +// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type. +template<__has_member_reference _Ip> +struct __iterator_traits_member_reference<_Ip> { using type = typename _Ip::reference; }; + +// [iterator.traits]/3.2.3.4 +// input_iterator_tag +template<class _Ip> +struct __deduce_iterator_category { + using type = input_iterator_tag; +}; + +// [iterator.traits]/3.2.3.1 +// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise +template<__iterator_traits_detail::__cpp17_random_access_iterator _Ip> +struct __deduce_iterator_category<_Ip> { + using type = random_access_iterator_tag; +}; + +// [iterator.traits]/3.2.3.2 +// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise +template<__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip> +struct __deduce_iterator_category<_Ip> { + using type = bidirectional_iterator_tag; +}; + +// [iterator.traits]/3.2.3.3 +// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise +template<__iterator_traits_detail::__cpp17_forward_iterator _Ip> +struct __deduce_iterator_category<_Ip> { + using type = forward_iterator_tag; +}; + +template<class _Ip> +struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {}; + +// [iterator.traits]/3.2.3 +// If the qualified-id `I::iterator-category` is valid and denotes a type, `iterator-category` names +// that type. +template<__has_member_iterator_category _Ip> +struct __iterator_traits_iterator_category<_Ip> { + using type = typename _Ip::iterator_category; +}; + +// otherwise, it names void. +template<class> +struct __iterator_traits_difference_type { using type = void; }; + +// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then +// `difference_type` names that type; +template<class _Ip> +requires requires { typename incrementable_traits<_Ip>::difference_type; } +struct __iterator_traits_difference_type<_Ip> { + using type = typename incrementable_traits<_Ip>::difference_type; +}; + +// [iterator.traits]/3.4 +// Otherwise, `iterator_traits<I>` has no members by any of the above names. +template<class> +struct __iterator_traits {}; + +// [iterator.traits]/3.1 +// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and +// `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members: +template<__specifies_members _Ip> +struct __iterator_traits<_Ip> { + using iterator_category = typename _Ip::iterator_category; + using value_type = typename _Ip::value_type; + using difference_type = typename _Ip::difference_type; + using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type; + using reference = typename _Ip::reference; +}; + +// [iterator.traits]/3.2 +// Otherwise, if `I` satisfies the exposition-only concept `cpp17-input-iterator`, +// `iterator-traits<I>` has the following publicly accessible members: +template<__cpp17_input_iterator_missing_members _Ip> +struct __iterator_traits<_Ip> { + using iterator_category = typename __iterator_traits_iterator_category<_Ip>::type; + using value_type = typename indirectly_readable_traits<_Ip>::value_type; + using difference_type = typename incrementable_traits<_Ip>::difference_type; + using pointer = typename __iterator_traits_member_pointer_or_arrow_or_void<_Ip>::type; + using reference = typename __iterator_traits_member_reference<_Ip>::type; +}; + +// Otherwise, if `I` satisfies the exposition-only concept `cpp17-iterator`, then +// `iterator_traits<I>` has the following publicly accessible members: +template<__cpp17_iterator_missing_members _Ip> +struct __iterator_traits<_Ip> { + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = typename __iterator_traits_difference_type<_Ip>::type; + using pointer = void; + using reference = void; +}; + +template<class _Ip> +struct iterator_traits : __iterator_traits<_Ip> { + using __primary_template = iterator_traits; +}; + +#else // !defined(_LIBCPP_HAS_NO_RANGES) + +template <class _Iter, bool> struct __iterator_traits {}; + +template <class _Iter, bool> struct __iterator_traits_impl {}; + +template <class _Iter> +struct __iterator_traits_impl<_Iter, true> +{ + typedef typename _Iter::difference_type difference_type; + typedef typename _Iter::value_type value_type; + typedef typename _Iter::pointer pointer; + typedef typename _Iter::reference reference; + typedef typename _Iter::iterator_category iterator_category; +}; + +template <class _Iter> +struct __iterator_traits<_Iter, true> + : __iterator_traits_impl + < + _Iter, + is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value || + is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value + > +{}; + +// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category +// exists. Else iterator_traits<Iterator> will be an empty class. This is a +// conforming extension which allows some programs to compile and behave as +// the client expects instead of failing at compile time. + +template <class _Iter> +struct _LIBCPP_TEMPLATE_VIS iterator_traits + : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> { + + using __primary_template = iterator_traits; +}; +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +template<class _Tp> +#if !defined(_LIBCPP_HAS_NO_RANGES) +requires is_object_v<_Tp> +#endif +struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> +{ + typedef ptrdiff_t difference_type; + typedef typename remove_cv<_Tp>::type value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + typedef random_access_iterator_tag iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef contiguous_iterator_tag iterator_concept; +#endif +}; + +template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value> +struct __has_iterator_category_convertible_to + : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up> +{}; + +template <class _Tp, class _Up> +struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {}; + +template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value> +struct __has_iterator_concept_convertible_to + : is_convertible<typename _Tp::iterator_concept, _Up> +{}; + +template <class _Tp, class _Up> +struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {}; + +template <class _Tp> +struct __is_cpp17_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {}; + +template <class _Tp> +struct __is_cpp17_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {}; + +template <class _Tp> +struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {}; + +template <class _Tp> +struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; + +// __is_cpp17_contiguous_iterator determines if an iterator is known by +// libc++ to be contiguous, either because it advertises itself as such +// (in C++20) or because it is a pointer type or a known trivial wrapper +// around a (possibly fancy) pointer type, such as __wrap_iter<T*>. +// Such iterators receive special "contiguous" optimizations in +// std::copy and std::sort. +// +#if _LIBCPP_STD_VER > 17 +template <class _Tp> +struct __is_cpp17_contiguous_iterator : _Or< + __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag>, + __has_iterator_concept_convertible_to<_Tp, contiguous_iterator_tag> +> {}; +#else +template <class _Tp> +struct __is_cpp17_contiguous_iterator : false_type {}; +#endif + +// Any native pointer which is an iterator is also a contiguous iterator. +template <class _Up> +struct __is_cpp17_contiguous_iterator<_Up*> : true_type {}; + + +template <class _Tp> +struct __is_exactly_cpp17_input_iterator + : public integral_constant<bool, + __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && + !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; + +#if _LIBCPP_STD_VER >= 17 +template<class _InputIterator> +using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; + +template<class _InputIterator> +using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; + +template<class _InputIterator> +using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type; + +template<class _InputIterator> +using __iter_to_alloc_type = pair< + add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>, + typename iterator_traits<_InputIterator>::value_type::second_type>; +#endif // _LIBCPP_STD_VER >= 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/move_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/move_iterator.h index ef74867c02d..eac9264df30 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/move_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/move_iterator.h @@ -1,184 +1,184 @@ -// -*- 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___ITERATOR_MOVE_ITERATOR_H -#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H - -#include <__config> -#include <__iterator/iterator_traits.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Iter> -class _LIBCPP_TEMPLATE_VIS move_iterator -{ -private: - _Iter __i; -public: - typedef _Iter iterator_type; - typedef typename iterator_traits<iterator_type>::value_type value_type; - typedef typename iterator_traits<iterator_type>::difference_type difference_type; - typedef iterator_type pointer; - typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, - random_access_iterator_tag, - typename iterator_traits<_Iter>::iterator_category> iterator_category; -#if _LIBCPP_STD_VER > 17 - typedef input_iterator_tag iterator_concept; -#endif - -#ifndef _LIBCPP_CXX03_LANG - typedef typename iterator_traits<iterator_type>::reference __reference; - typedef typename conditional< - is_reference<__reference>::value, - typename remove_reference<__reference>::type&&, - __reference - >::type reference; -#else - typedef typename iterator_traits<iterator_type>::reference reference; -#endif - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator() : __i() {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - explicit move_iterator(_Iter __x) : __i(__x) {} - - template <class _Up, class = __enable_if_t< - !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value - > > - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} - - template <class _Up, class = __enable_if_t< - !is_same<_Up, _Iter>::value && - is_convertible<_Up const&, _Iter>::value && - is_assignable<_Iter&, _Up const&>::value - > > - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator=(const move_iterator<_Up>& __u) { - __i = __u.base(); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reference operator*() const { return static_cast<reference>(*__i); } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - pointer operator->() const { return __i;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator++() {++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator--() {--__i; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); } -}; - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() == __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() < __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() != __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() > __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() >= __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() <= __y.base(); -} - -#ifndef _LIBCPP_CXX03_LANG -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto -operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) --> decltype(__x.base() - __y.base()) -{ - return __x.base() - __y.base(); -} -#else -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -typename move_iterator<_Iter1>::difference_type -operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() - __y.base(); -} -#endif - -template <class _Iter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -move_iterator<_Iter> -operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) -{ - return move_iterator<_Iter>(__x.base() + __n); -} - -template <class _Iter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -move_iterator<_Iter> -make_move_iterator(_Iter __i) -{ - return move_iterator<_Iter>(__i); -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H +// -*- 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___ITERATOR_MOVE_ITERATOR_H +#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Iter> +class _LIBCPP_TEMPLATE_VIS move_iterator +{ +private: + _Iter __i; +public: + typedef _Iter iterator_type; + typedef typename iterator_traits<iterator_type>::value_type value_type; + typedef typename iterator_traits<iterator_type>::difference_type difference_type; + typedef iterator_type pointer; + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + typename iterator_traits<_Iter>::iterator_category> iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef input_iterator_tag iterator_concept; +#endif + +#ifndef _LIBCPP_CXX03_LANG + typedef typename iterator_traits<iterator_type>::reference __reference; + typedef typename conditional< + is_reference<__reference>::value, + typename remove_reference<__reference>::type&&, + __reference + >::type reference; +#else + typedef typename iterator_traits<iterator_type>::reference reference; +#endif + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator() : __i() {} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit move_iterator(_Iter __x) : __i(__x) {} + + template <class _Up, class = __enable_if_t< + !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} + + template <class _Up, class = __enable_if_t< + !is_same<_Up, _Iter>::value && + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Iter&, _Up const&>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator=(const move_iterator<_Up>& __u) { + __i = __u.base(); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator*() const { return static_cast<reference>(*__i); } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + pointer operator->() const { return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator++() {++__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator--() {--__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); } +}; + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() == __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() < __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() != __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() > __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() >= __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() <= __y.base(); +} + +#ifndef _LIBCPP_CXX03_LANG +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +-> decltype(__x.base() - __y.base()) +{ + return __x.base() - __y.base(); +} +#else +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY +typename move_iterator<_Iter1>::difference_type +operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() - __y.base(); +} +#endif + +template <class _Iter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +move_iterator<_Iter> +operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) +{ + return move_iterator<_Iter>(__x.base() + __n); +} + +template <class _Iter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +move_iterator<_Iter> +make_move_iterator(_Iter __i) +{ + return move_iterator<_Iter>(__i); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h index 3c0dc3b725f..d764bd6f71f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h @@ -1,82 +1,82 @@ -// -*- 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___ITERATOR_NEXT_H -#define _LIBCPP___ITERATOR_NEXT_H - -#include <__config> -#include <__debug> -#include <__function_like.h> -#include <__iterator/advance.h> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/iterator_traits.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _InputIter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type - next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { - _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, - "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); - - _VSTD::advance(__x, __n); - return __x; -} - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -namespace ranges { -struct __next_fn final : private __function_like { - _LIBCPP_HIDE_FROM_ABI - constexpr explicit __next_fn(__tag __x) noexcept : __function_like(__x) {} - - template <input_or_output_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x) const { - ++__x; - return __x; - } - - template <input_or_output_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { - ranges::advance(__x, __n); - return __x; - } - - template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x, _Sp ___bound) const { - ranges::advance(__x, ___bound); - return __x; - } - - template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp ___bound) const { - ranges::advance(__x, __n, ___bound); - return __x; - } -}; - -inline constexpr auto next = __next_fn(__function_like::__tag()); -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_PRIMITIVES_H +// -*- 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___ITERATOR_NEXT_H +#define _LIBCPP___ITERATOR_NEXT_H + +#include <__config> +#include <__debug> +#include <__function_like.h> +#include <__iterator/advance.h> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _InputIter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type + next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { + _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); + + _VSTD::advance(__x, __n); + return __x; +} + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +struct __next_fn final : private __function_like { + _LIBCPP_HIDE_FROM_ABI + constexpr explicit __next_fn(__tag __x) noexcept : __function_like(__x) {} + + template <input_or_output_iterator _Ip> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x) const { + ++__x; + return __x; + } + + template <input_or_output_iterator _Ip> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { + ranges::advance(__x, __n); + return __x; + } + + template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, _Sp ___bound) const { + ranges::advance(__x, ___bound); + return __x; + } + + template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp ___bound) const { + ranges::advance(__x, __n, ___bound); + return __x; + } +}; + +inline constexpr auto next = __next_fn(__function_like::__tag()); +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_PRIMITIVES_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/ostream_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/ostream_iterator.h index 41c662ad6a3..20a36742cca 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/ostream_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/ostream_iterator.h @@ -1,70 +1,70 @@ -// -*- 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___ITERATOR_OSTREAM_ITERATOR_H -#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <iosfwd> // for forward declarations of char_traits and basic_ostream - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > -class _LIBCPP_TEMPLATE_VIS ostream_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<output_iterator_tag, void, void, void, void> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; -#if _LIBCPP_STD_VER > 17 - typedef ptrdiff_t difference_type; -#else - typedef void difference_type; -#endif - typedef void pointer; - typedef void reference; - typedef _CharT char_type; - typedef _Traits traits_type; - typedef basic_ostream<_CharT, _Traits> ostream_type; - -private: - ostream_type* __out_stream_; - const char_type* __delim_; -public: - _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT - : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {} - _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT - : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {} - _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) - { - *__out_stream_ << __value_; - if (__delim_) - *__out_stream_ << __delim_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;} -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H +// -*- 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___ITERATOR_OSTREAM_ITERATOR_H +#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <iosfwd> // for forward declarations of char_traits and basic_ostream + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > +class _LIBCPP_TEMPLATE_VIS ostream_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<output_iterator_tag, void, void, void, void> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + +private: + ostream_type* __out_stream_; + const char_type* __delim_; +public: + _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT + : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {} + _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT + : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {} + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) + { + *__out_stream_ << __value_; + if (__delim_) + *__out_stream_ << __delim_; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;} +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h index e5d615e31df..3272f6c99d7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h @@ -1,76 +1,76 @@ -// -*- 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___ITERATOR_OSTREAMBUF_ITERATOR_H -#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <iosfwd> // for forward declaration of basic_streambuf - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _CharT, class _Traits> -class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<output_iterator_tag, void, void, void, void> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -public: - typedef output_iterator_tag iterator_category; - typedef void value_type; -#if _LIBCPP_STD_VER > 17 - typedef ptrdiff_t difference_type; -#else - typedef void difference_type; -#endif - typedef void pointer; - typedef void reference; - typedef _CharT char_type; - typedef _Traits traits_type; - typedef basic_streambuf<_CharT, _Traits> streambuf_type; - typedef basic_ostream<_CharT, _Traits> ostream_type; - -private: - streambuf_type* __sbuf_; -public: - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT - : __sbuf_(__s.rdbuf()) {} - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT - : __sbuf_(__s) {} - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c) - { - if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof())) - __sbuf_ = nullptr; - return *this; - } - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;} - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;} - _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;} - _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;} - - template <class _Ch, class _Tr> - friend - _LIBCPP_HIDDEN - ostreambuf_iterator<_Ch, _Tr> - __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s, - const _Ch* __ob, const _Ch* __op, const _Ch* __oe, - ios_base& __iob, _Ch __fl); -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H +// -*- 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___ITERATOR_OSTREAMBUF_ITERATOR_H +#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <iosfwd> // for forward declaration of basic_streambuf + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _CharT, class _Traits> +class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<output_iterator_tag, void, void, void, void> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + +private: + streambuf_type* __sbuf_; +public: + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT + : __sbuf_(__s.rdbuf()) {} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT + : __sbuf_(__s) {} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c) + { + if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof())) + __sbuf_ = nullptr; + return *this; + } + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;} + _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;} + + template <class _Ch, class _Tr> + friend + _LIBCPP_HIDDEN + ostreambuf_iterator<_Ch, _Tr> + __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s, + const _Ch* __ob, const _Ch* __op, const _Ch* __oe, + ios_base& __iob, _Ch __fl); +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h index 6df53ca2f34..42d836cc1db 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h @@ -1,74 +1,74 @@ -// -*- 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___ITERATOR_PREV_H -#define _LIBCPP___ITERATOR_PREV_H - -#include <__config> -#include <__debug> -#include <__function_like.h> -#include <__iterator/advance.h> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/iterator_traits.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _InputIter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type - prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { - _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, - "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); - _VSTD::advance(__x, -__n); - return __x; -} - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -namespace ranges { -struct __prev_fn final : private __function_like { - _LIBCPP_HIDE_FROM_ABI - constexpr explicit __prev_fn(__tag __x) noexcept : __function_like(__x) {} - - template <bidirectional_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x) const { - --__x; - return __x; - } - - template <bidirectional_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { - ranges::advance(__x, -__n); - return __x; - } - - template <bidirectional_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI - constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip ___bound) const { - ranges::advance(__x, -__n, ___bound); - return __x; - } -}; - -inline constexpr auto prev = __prev_fn(__function_like::__tag()); -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_PREV_H +// -*- 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___ITERATOR_PREV_H +#define _LIBCPP___ITERATOR_PREV_H + +#include <__config> +#include <__debug> +#include <__function_like.h> +#include <__iterator/advance.h> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _InputIter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type + prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { + _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); + _VSTD::advance(__x, -__n); + return __x; +} + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +struct __prev_fn final : private __function_like { + _LIBCPP_HIDE_FROM_ABI + constexpr explicit __prev_fn(__tag __x) noexcept : __function_like(__x) {} + + template <bidirectional_iterator _Ip> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x) const { + --__x; + return __x; + } + + template <bidirectional_iterator _Ip> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { + ranges::advance(__x, -__n); + return __x; + } + + template <bidirectional_iterator _Ip> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip ___bound) const { + ranges::advance(__x, -__n, ___bound); + return __x; + } +}; + +inline constexpr auto prev = __prev_fn(__function_like::__tag()); +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_PREV_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h index 0cf50e76116..c24c86b4e06 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h @@ -1,40 +1,40 @@ -// -*- 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___ITERATOR_PROJECTED_H -#define _LIBCPP___ITERATOR_PROJECTED_H - -#include <__config> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> -struct projected { - using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; - indirect_result_t<_Proj&, _It> operator*() const; // not defined -}; - -template<weakly_incrementable _It, class _Proj> -struct incrementable_traits<projected<_It, _Proj>> { - using difference_type = iter_difference_t<_It>; -}; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_PROJECTED_H +// -*- 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___ITERATOR_PROJECTED_H +#define _LIBCPP___ITERATOR_PROJECTED_H + +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> +struct projected { + using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; + indirect_result_t<_Proj&, _It> operator*() const; // not defined +}; + +template<weakly_incrementable _It, class _Proj> +struct incrementable_traits<projected<_It, _Proj>> { + using difference_type = iter_difference_t<_It>; +}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_PROJECTED_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/readable_traits.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/readable_traits.h index 5a16d68b395..90121bea807 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/readable_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/readable_traits.h @@ -1,86 +1,86 @@ -// -*- 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___ITERATOR_READABLE_TRAITS_H -#define _LIBCPP___ITERATOR_READABLE_TRAITS_H - -#include <__config> -#include <concepts> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -// [readable.traits] -template<class> struct __cond_value_type {}; - -template<class _Tp> -requires is_object_v<_Tp> -struct __cond_value_type<_Tp> { using value_type = remove_cv_t<_Tp>; }; - -template<class _Tp> -concept __has_member_value_type = requires { typename _Tp::value_type; }; - -template<class _Tp> -concept __has_member_element_type = requires { typename _Tp::element_type; }; - -template<class> struct indirectly_readable_traits {}; - -template<class _Ip> -requires is_array_v<_Ip> -struct indirectly_readable_traits<_Ip> { - using value_type = remove_cv_t<remove_extent_t<_Ip>>; -}; - -template<class _Ip> -struct indirectly_readable_traits<const _Ip> : indirectly_readable_traits<_Ip> {}; - -template<class _Tp> -struct indirectly_readable_traits<_Tp*> : __cond_value_type<_Tp> {}; - -template<__has_member_value_type _Tp> -struct indirectly_readable_traits<_Tp> - : __cond_value_type<typename _Tp::value_type> {}; - -template<__has_member_element_type _Tp> -struct indirectly_readable_traits<_Tp> - : __cond_value_type<typename _Tp::element_type> {}; - -// Pre-emptively applies LWG3541 -template<__has_member_value_type _Tp> -requires __has_member_element_type<_Tp> -struct indirectly_readable_traits<_Tp> {}; -template<__has_member_value_type _Tp> -requires __has_member_element_type<_Tp> && - same_as<remove_cv_t<typename _Tp::element_type>, - remove_cv_t<typename _Tp::value_type>> -struct indirectly_readable_traits<_Tp> - : __cond_value_type<typename _Tp::value_type> {}; - -template <class> -struct iterator_traits; - -// Let `RI` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes -// `indirectly_readable_traits<RI>::value_type` if `iterator_traits<RI>` names a specialization -// generated from the primary template, and `iterator_traits<RI>::value_type` otherwise. -template <class _Ip> -using iter_value_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value, - indirectly_readable_traits<remove_cvref_t<_Ip> >, - iterator_traits<remove_cvref_t<_Ip> > >::value_type; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H +// -*- 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___ITERATOR_READABLE_TRAITS_H +#define _LIBCPP___ITERATOR_READABLE_TRAITS_H + +#include <__config> +#include <concepts> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// [readable.traits] +template<class> struct __cond_value_type {}; + +template<class _Tp> +requires is_object_v<_Tp> +struct __cond_value_type<_Tp> { using value_type = remove_cv_t<_Tp>; }; + +template<class _Tp> +concept __has_member_value_type = requires { typename _Tp::value_type; }; + +template<class _Tp> +concept __has_member_element_type = requires { typename _Tp::element_type; }; + +template<class> struct indirectly_readable_traits {}; + +template<class _Ip> +requires is_array_v<_Ip> +struct indirectly_readable_traits<_Ip> { + using value_type = remove_cv_t<remove_extent_t<_Ip>>; +}; + +template<class _Ip> +struct indirectly_readable_traits<const _Ip> : indirectly_readable_traits<_Ip> {}; + +template<class _Tp> +struct indirectly_readable_traits<_Tp*> : __cond_value_type<_Tp> {}; + +template<__has_member_value_type _Tp> +struct indirectly_readable_traits<_Tp> + : __cond_value_type<typename _Tp::value_type> {}; + +template<__has_member_element_type _Tp> +struct indirectly_readable_traits<_Tp> + : __cond_value_type<typename _Tp::element_type> {}; + +// Pre-emptively applies LWG3541 +template<__has_member_value_type _Tp> +requires __has_member_element_type<_Tp> +struct indirectly_readable_traits<_Tp> {}; +template<__has_member_value_type _Tp> +requires __has_member_element_type<_Tp> && + same_as<remove_cv_t<typename _Tp::element_type>, + remove_cv_t<typename _Tp::value_type>> +struct indirectly_readable_traits<_Tp> + : __cond_value_type<typename _Tp::value_type> {}; + +template <class> +struct iterator_traits; + +// Let `RI` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes +// `indirectly_readable_traits<RI>::value_type` if `iterator_traits<RI>` names a specialization +// generated from the primary template, and `iterator_traits<RI>::value_type` otherwise. +template <class _Ip> +using iter_value_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value, + indirectly_readable_traits<remove_cvref_t<_Ip> >, + iterator_traits<remove_cvref_t<_Ip> > >::value_type; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_access.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_access.h index 667cd7bc308..643aede01c7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_access.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_access.h @@ -1,104 +1,104 @@ -// -*- 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___ITERATOR_REVERSE_ACCESS_H -#define _LIBCPP___ITERATOR_REVERSE_ACCESS_H - -#include <__config> -#include <__iterator/reverse_iterator.h> -#include <cstddef> -#include <initializer_list> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_CXX03_LANG) - -#if _LIBCPP_STD_VER > 11 - -template <class _Tp, size_t _Np> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) -{ - return reverse_iterator<_Tp*>(__array + _Np); -} - -template <class _Tp, size_t _Np> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) -{ - return reverse_iterator<_Tp*>(__array); -} - -template <class _Ep> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) -{ - return reverse_iterator<const _Ep*>(__il.end()); -} - -template <class _Ep> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) -{ - return reverse_iterator<const _Ep*>(__il.begin()); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) -{ - return __c.rbegin(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) -{ - return __c.rbegin(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto rend(_Cp& __c) -> decltype(__c.rend()) -{ - return __c.rend(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto rend(const _Cp& __c) -> decltype(__c.rend()) -{ - return __c.rend(); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c)) -{ - return _VSTD::rbegin(__c); -} - -template <class _Cp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) -{ - return _VSTD::rend(__c); -} - -#endif - -#endif // !defined(_LIBCPP_CXX03_LANG) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H +// -*- 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___ITERATOR_REVERSE_ACCESS_H +#define _LIBCPP___ITERATOR_REVERSE_ACCESS_H + +#include <__config> +#include <__iterator/reverse_iterator.h> +#include <cstddef> +#include <initializer_list> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_CXX03_LANG) + +#if _LIBCPP_STD_VER > 11 + +template <class _Tp, size_t _Np> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array + _Np); +} + +template <class _Tp, size_t _Np> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array); +} + +template <class _Ep> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.end()); +} + +template <class _Ep> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.begin()); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) +{ + return __c.rbegin(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) +{ + return __c.rbegin(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rend(_Cp& __c) -> decltype(__c.rend()) +{ + return __c.rend(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rend(const _Cp& __c) -> decltype(__c.rend()) +{ + return __c.rend(); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c)) +{ + return _VSTD::rbegin(__c); +} + +template <class _Cp> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) +{ + return _VSTD::rend(__c); +} + +#endif + +#endif // !defined(_LIBCPP_CXX03_LANG) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h index c6062c4e0be..fad9bc175b0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h @@ -1,234 +1,234 @@ -// -*- 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___ITERATOR_REVERSE_ITERATOR_H -#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H - -#include <__config> -#include <__iterator/iterator.h> -#include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Tp, class = void> -struct __is_stashing_iterator : false_type {}; - -template <class _Tp> -struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type> - : true_type {}; - -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -template <class _Iter> -class _LIBCPP_TEMPLATE_VIS reverse_iterator -#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) - : public iterator<typename iterator_traits<_Iter>::iterator_category, - typename iterator_traits<_Iter>::value_type, - typename iterator_traits<_Iter>::difference_type, - typename iterator_traits<_Iter>::pointer, - typename iterator_traits<_Iter>::reference> -#endif -{ -_LIBCPP_SUPPRESS_DEPRECATED_POP -private: -#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES - _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break -#endif - - static_assert(!__is_stashing_iterator<_Iter>::value, - "The specified iterator type cannot be used with reverse_iterator; " - "Using stashing iterators with reverse_iterator causes undefined behavior"); - -protected: - _Iter current; -public: - typedef _Iter iterator_type; - typedef typename iterator_traits<_Iter>::difference_type difference_type; - typedef typename iterator_traits<_Iter>::reference reference; - typedef typename iterator_traits<_Iter>::pointer pointer; - typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, - random_access_iterator_tag, - typename iterator_traits<_Iter>::iterator_category> iterator_category; - typedef typename iterator_traits<_Iter>::value_type value_type; - -#if _LIBCPP_STD_VER > 17 - typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, - random_access_iterator_tag, - bidirectional_iterator_tag> iterator_concept; -#endif - -#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator() : __t(), current() {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} - - template <class _Up, class = __enable_if_t< - !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value - > > - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator(const reverse_iterator<_Up>& __u) - : __t(__u.base()), current(__u.base()) - { } - - template <class _Up, class = __enable_if_t< - !is_same<_Up, _Iter>::value && - is_convertible<_Up const&, _Iter>::value && - is_assignable<_Up const&, _Iter>::value - > > - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { - __t = current = __u.base(); - return *this; - } -#else - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator() : current() {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - explicit reverse_iterator(_Iter __x) : current(__x) {} - - template <class _Up, class = __enable_if_t< - !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value - > > - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator(const reverse_iterator<_Up>& __u) - : current(__u.base()) - { } - - template <class _Up, class = __enable_if_t< - !is_same<_Up, _Iter>::value && - is_convertible<_Up const&, _Iter>::value && - is_assignable<_Up const&, _Iter>::value - > > - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { - current = __u.base(); - return *this; - } -#endif - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - _Iter base() const {return current;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reference operator*() const {_Iter __tmp = current; return *--__tmp;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - pointer operator->() const {return _VSTD::addressof(operator*());} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator& operator++() {--current; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator& operator--() {++current; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 - reference operator[](difference_type __n) const {return *(*this + __n);} -}; - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __x.base() == __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __x.base() > __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __x.base() != __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __x.base() < __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __x.base() <= __y.base(); -} - -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool -operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __x.base() >= __y.base(); -} - -#ifndef _LIBCPP_CXX03_LANG -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto -operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) --> decltype(__y.base() - __x.base()) -{ - return __y.base() - __x.base(); -} -#else -template <class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -typename reverse_iterator<_Iter1>::difference_type -operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __y.base() - __x.base(); -} -#endif - -template <class _Iter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -reverse_iterator<_Iter> -operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) -{ - return reverse_iterator<_Iter>(__x.base() - __n); -} - -#if _LIBCPP_STD_VER > 11 -template <class _Iter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) -{ - return reverse_iterator<_Iter>(__i); -} -#endif - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H +// -*- 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___ITERATOR_REVERSE_ITERATOR_H +#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp, class = void> +struct __is_stashing_iterator : false_type {}; + +template <class _Tp> +struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type> + : true_type {}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <class _Iter> +class _LIBCPP_TEMPLATE_VIS reverse_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator<typename iterator_traits<_Iter>::iterator_category, + typename iterator_traits<_Iter>::value_type, + typename iterator_traits<_Iter>::difference_type, + typename iterator_traits<_Iter>::pointer, + typename iterator_traits<_Iter>::reference> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +private: +#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES + _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break +#endif + + static_assert(!__is_stashing_iterator<_Iter>::value, + "The specified iterator type cannot be used with reverse_iterator; " + "Using stashing iterators with reverse_iterator causes undefined behavior"); + +protected: + _Iter current; +public: + typedef _Iter iterator_type; + typedef typename iterator_traits<_Iter>::difference_type difference_type; + typedef typename iterator_traits<_Iter>::reference reference; + typedef typename iterator_traits<_Iter>::pointer pointer; + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + typename iterator_traits<_Iter>::iterator_category> iterator_category; + typedef typename iterator_traits<_Iter>::value_type value_type; + +#if _LIBCPP_STD_VER > 17 + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + bidirectional_iterator_tag> iterator_concept; +#endif + +#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator() : __t(), current() {} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} + + template <class _Up, class = __enable_if_t< + !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator(const reverse_iterator<_Up>& __u) + : __t(__u.base()), current(__u.base()) + { } + + template <class _Up, class = __enable_if_t< + !is_same<_Up, _Iter>::value && + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { + __t = current = __u.base(); + return *this; + } +#else + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator() : current() {} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit reverse_iterator(_Iter __x) : current(__x) {} + + template <class _Up, class = __enable_if_t< + !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator(const reverse_iterator<_Up>& __u) + : current(__u.base()) + { } + + template <class _Up, class = __enable_if_t< + !is_same<_Up, _Iter>::value && + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { + current = __u.base(); + return *this; + } +#endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + _Iter base() const {return current;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator*() const {_Iter __tmp = current; return *--__tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + pointer operator->() const {return _VSTD::addressof(operator*());} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator++() {--current; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator--() {++current; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator[](difference_type __n) const {return *(*this + __n);} +}; + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() == __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() > __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() != __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() < __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() <= __y.base(); +} + +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() >= __y.base(); +} + +#ifndef _LIBCPP_CXX03_LANG +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +-> decltype(__y.base() - __x.base()) +{ + return __y.base() - __x.base(); +} +#else +template <class _Iter1, class _Iter2> +inline _LIBCPP_INLINE_VISIBILITY +typename reverse_iterator<_Iter1>::difference_type +operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __y.base() - __x.base(); +} +#endif + +template <class _Iter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Iter> +operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) +{ + return reverse_iterator<_Iter>(__x.base() - __n); +} + +#if _LIBCPP_STD_VER > 11 +template <class _Iter> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) +{ + return reverse_iterator<_Iter>(__i); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/size.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/size.h index ace94a3f323..2e6a7d386cb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/size.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/size.h @@ -1,53 +1,53 @@ -// -*- 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___ITERATOR_SIZE_H -#define _LIBCPP___ITERATOR_SIZE_H - -#include <__config> -#include <cstddef> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 14 - -template <class _Cont> -_LIBCPP_INLINE_VISIBILITY -constexpr auto size(const _Cont& __c) -_NOEXCEPT_(noexcept(__c.size())) --> decltype (__c.size()) -{ return __c.size(); } - -template <class _Tp, size_t _Sz> -_LIBCPP_INLINE_VISIBILITY -constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; } - -#if _LIBCPP_STD_VER > 17 -template <class _Cont> -_LIBCPP_INLINE_VISIBILITY -constexpr auto ssize(const _Cont& __c) -_NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()))) --> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> -{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); } - -template <class _Tp, ptrdiff_t _Sz> -_LIBCPP_INLINE_VISIBILITY -constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } -#endif - -#endif // _LIBCPP_STD_VER > 14 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_SIZE_H +// -*- 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___ITERATOR_SIZE_H +#define _LIBCPP___ITERATOR_SIZE_H + +#include <__config> +#include <cstddef> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template <class _Cont> +_LIBCPP_INLINE_VISIBILITY +constexpr auto size(const _Cont& __c) +_NOEXCEPT_(noexcept(__c.size())) +-> decltype (__c.size()) +{ return __c.size(); } + +template <class _Tp, size_t _Sz> +_LIBCPP_INLINE_VISIBILITY +constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; } + +#if _LIBCPP_STD_VER > 17 +template <class _Cont> +_LIBCPP_INLINE_VISIBILITY +constexpr auto ssize(const _Cont& __c) +_NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()))) +-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> +{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); } + +template <class _Tp, ptrdiff_t _Sz> +_LIBCPP_INLINE_VISIBILITY +constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } +#endif + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_SIZE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/unreachable_sentinel.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/unreachable_sentinel.h index d0d2f7bbd64..cbbccd7bb28 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/unreachable_sentinel.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/unreachable_sentinel.h @@ -1,38 +1,38 @@ -// -*- 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___ITERATOR_UNREACHABLE_SENTINEL_H -#define _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H - -#include <__config> -#include <__iterator/concepts.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_RANGES) - -struct unreachable_sentinel_t { - template<weakly_incrementable _Iter> - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&) noexcept { - return false; - } -}; - -inline constexpr unreachable_sentinel_t unreachable_sentinel{}; - -#endif // !defined(_LIBCPP_HAS_NO_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H +// -*- 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___ITERATOR_UNREACHABLE_SENTINEL_H +#define _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H + +#include <__config> +#include <__iterator/concepts.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +struct unreachable_sentinel_t { + template<weakly_incrementable _Iter> + _LIBCPP_HIDE_FROM_ABI + friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&) noexcept { + return false; + } +}; + +inline constexpr unreachable_sentinel_t unreachable_sentinel{}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h index c98f6dc959f..0a978914b1a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h @@ -1,301 +1,301 @@ -// -*- 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___ITERATOR_WRAP_ITER_H -#define _LIBCPP___ITERATOR_WRAP_ITER_H - -#include <__config> -#include <__debug> -#include <__iterator/iterator_traits.h> -#include <__memory/pointer_traits.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Iter> -class __wrap_iter -{ -public: - typedef _Iter iterator_type; - typedef typename iterator_traits<iterator_type>::value_type value_type; - typedef typename iterator_traits<iterator_type>::difference_type difference_type; - typedef typename iterator_traits<iterator_type>::pointer pointer; - typedef typename iterator_traits<iterator_type>::reference reference; - typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; -#if _LIBCPP_STD_VER > 17 - typedef contiguous_iterator_tag iterator_concept; -#endif - -private: - iterator_type __i; -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __i{} -#endif - { -#if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->__insert_i(this); -#endif - } - template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG - __wrap_iter(const __wrap_iter<_Up>& __u, - typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT - : __i(__u.base()) - { -#if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->__iterator_copy(this, &__u); -#endif - } -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG - __wrap_iter(const __wrap_iter& __x) - : __i(__x.base()) - { - __get_db()->__iterator_copy(this, &__x); - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG - __wrap_iter& operator=(const __wrap_iter& __x) - { - if (this != &__x) - { - __get_db()->__iterator_copy(this, &__x); - __i = __x.__i; - } - return *this; - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG - ~__wrap_iter() - { - __get_db()->__erase_i(this); - } -#endif - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT - { -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable iterator"); -#endif - return *__i; - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT - { -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable iterator"); -#endif - return _VSTD::__to_address(__i); - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT - { -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment a non-incrementable iterator"); -#endif - ++__i; - return *this; - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT - {__wrap_iter __tmp(*this); ++(*this); return __tmp;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT - { -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), - "Attempted to decrement a non-decrementable iterator"); -#endif - --__i; - return *this; - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT - {__wrap_iter __tmp(*this); --(*this); return __tmp;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT - {__wrap_iter __w(*this); __w += __n; return __w;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT - { -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n), - "Attempted to add/subtract an iterator outside its valid range"); -#endif - __i += __n; - return *this; - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT - {return *this + (-__n);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT - {*this += -__n; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT - { -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n), - "Attempted to subscript an iterator outside its valid range"); -#endif - return __i[__n]; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;} - -private: -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) - { - __get_db()->__insert_ic(this, __p); - } -#else - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} -#endif - - template <class _Up> friend class __wrap_iter; - template <class _CharT, class _Traits, class _Alloc> friend class basic_string; - template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector; - template <class _Tp, size_t> friend class _LIBCPP_TEMPLATE_VIS span; -}; - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT -{ - return __x.base() == __y.base(); -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -{ - return __x.base() == __y.base(); -} - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), - "Attempted to compare incomparable iterators"); -#endif - return __x.base() < __y.base(); -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), - "Attempted to compare incomparable iterators"); -#endif - return __x.base() < __y.base(); -} - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT -{ - return !(__x == __y); -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -{ - return !(__x == __y); -} - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT -{ - return __y < __x; -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -{ - return __y < __x; -} - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT -{ - return !(__x < __y); -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -{ - return !(__x < __y); -} - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT -{ - return !(__y < __x); -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -{ - return !(__y < __x); -} - -template <class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -#ifndef _LIBCPP_CXX03_LANG -auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT - -> decltype(__x.base() - __y.base()) -#else -typename __wrap_iter<_Iter1>::difference_type -operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -#endif // C++03 -{ -#if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), - "Attempted to subtract incompatible iterators"); -#endif - return __x.base() - __y.base(); -} - -template <class _Iter1> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG -__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT -{ - __x += __n; - return __x; -} - -#if _LIBCPP_STD_VER <= 17 -template <class _It> -struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; -#endif - -template <class _It> -struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > -{ - typedef __wrap_iter<_It> pointer; - typedef typename pointer_traits<_It>::element_type element_type; - typedef typename pointer_traits<_It>::difference_type difference_type; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR - static element_type *to_address(pointer __w) _NOEXCEPT { - return _VSTD::__to_address(__w.base()); - } -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_WRAP_ITER_H +// -*- 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___ITERATOR_WRAP_ITER_H +#define _LIBCPP___ITERATOR_WRAP_ITER_H + +#include <__config> +#include <__debug> +#include <__iterator/iterator_traits.h> +#include <__memory/pointer_traits.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Iter> +class __wrap_iter +{ +public: + typedef _Iter iterator_type; + typedef typename iterator_traits<iterator_type>::value_type value_type; + typedef typename iterator_traits<iterator_type>::difference_type difference_type; + typedef typename iterator_traits<iterator_type>::pointer pointer; + typedef typename iterator_traits<iterator_type>::reference reference; + typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef contiguous_iterator_tag iterator_concept; +#endif + +private: + iterator_type __i; +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __i{} +#endif + { +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif + } + template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + __wrap_iter(const __wrap_iter<_Up>& __u, + typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT + : __i(__u.base()) + { +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__iterator_copy(this, &__u); +#endif + } +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + __wrap_iter(const __wrap_iter& __x) + : __i(__x.base()) + { + __get_db()->__iterator_copy(this, &__x); + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + __wrap_iter& operator=(const __wrap_iter& __x) + { + if (this != &__x) + { + __get_db()->__iterator_copy(this, &__x); + __i = __x.__i; + } + return *this; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + ~__wrap_iter() + { + __get_db()->__erase_i(this); + } +#endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif + return *__i; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif + return _VSTD::__to_address(__i); + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment a non-incrementable iterator"); +#endif + ++__i; + return *this; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT + {__wrap_iter __tmp(*this); ++(*this); return __tmp;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), + "Attempted to decrement a non-decrementable iterator"); +#endif + --__i; + return *this; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT + {__wrap_iter __tmp(*this); --(*this); return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT + {__wrap_iter __w(*this); __w += __n; return __w;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n), + "Attempted to add/subtract an iterator outside its valid range"); +#endif + __i += __n; + return *this; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT + {return *this + (-__n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT + {*this += -__n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n), + "Attempted to subscript an iterator outside its valid range"); +#endif + return __i[__n]; + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;} + +private: +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) + { + __get_db()->__insert_ic(this, __p); + } +#else + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} +#endif + + template <class _Up> friend class __wrap_iter; + template <class _CharT, class _Traits, class _Alloc> friend class basic_string; + template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector; + template <class _Tp, size_t> friend class _LIBCPP_TEMPLATE_VIS span; +}; + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return __x.base() == __y.base(); +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return __x.base() == __y.base(); +} + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to compare incomparable iterators"); +#endif + return __x.base() < __y.base(); +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to compare incomparable iterators"); +#endif + return __x.base() < __y.base(); +} + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__x == __y); +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return !(__x == __y); +} + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return __y < __x; +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return __y < __x; +} + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__x < __y); +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return !(__x < __y); +} + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__y < __x); +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return !(__y < __x); +} + +template <class _Iter1, class _Iter2> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +#ifndef _LIBCPP_CXX03_LANG +auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT + -> decltype(__x.base() - __y.base()) +#else +typename __wrap_iter<_Iter1>::difference_type +operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +#endif // C++03 +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to subtract incompatible iterators"); +#endif + return __x.base() - __y.base(); +} + +template <class _Iter1> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT +{ + __x += __n; + return __x; +} + +#if _LIBCPP_STD_VER <= 17 +template <class _It> +struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; +#endif + +template <class _It> +struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > +{ + typedef __wrap_iter<_It> pointer; + typedef typename pointer_traits<_It>::element_type element_type; + typedef typename pointer_traits<_It>::difference_type difference_type; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR + static element_type *to_address(pointer __w) _NOEXCEPT { + return _VSTD::__to_address(__w.base()); + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_WRAP_ITER_H |