Files
2025-10-25 03:02:53 +03:00

11 KiB
Raw Permalink Blame History

[range.concat.view]

25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.18 Concat view [range.concat]

25.7.18.2 Class template concat_view [range.concat.view]

🔗

namespace std::ranges {template<class... Rs>using concat-reference-t = common_reference_t<range_reference_t...>; // exposition onlytemplate<class... Rs>using concat-value-t = common_type_t<range_value_t...>; // exposition onlytemplate<class... Rs>using concat-rvalue-reference-t = // exposition only common_reference_t<range_rvalue_reference_t...>; template<class... Rs>concept concat-indirectly-readable = see below; // exposition onlytemplate<class... Rs>concept concatable = see below; // exposition onlytemplate<bool Const, class... Rs>concept concat-is-random-access = see below; // exposition onlytemplate<bool Const, class... Rs>concept concat-is-bidirectional = see below; // exposition onlytemplate<input_range... Views>requires (view && ...) && (sizeof...(Views) > 0) &&concatable<Views...>class concat_view : public view_interface<concat_view<Views...>> { tuple<Views...> views_; // exposition only// [range.concat.iterator], class template concat_view::iteratortemplate class iterator; // exposition onlypublic:constexpr concat_view() = default; constexpr explicit concat_view(Views... views); constexpr iterator begin() requires (!(simple-view && ...)); constexpr iterator begin() constrequires (range && ...) && concatable; constexpr auto end() requires (!(simple-view && ...)); constexpr auto end() constrequires (range && ...) && concatable; constexpr auto size() requires (sized_range && ...); constexpr auto size() const requires (sized_range && ...); }; template<class... R> concat_view(R&&...) -> concat_view<views::all_t...>;}

🔗

template<class... Rs> concept [concat-indirectly-readable](#concept:concat-indirectly-readable "25.7.18.2Class template concat_­view[range.concat.view]") = see below; // exposition only

1

#

The exposition-only concat-indirectly-readable concept is equivalent to:template<class Ref, class RRef, class It>concept concat-indirectly-readable-impl = // exposition onlyrequires (const It it) {{ *it } -> convertible_to; { ranges::iter_move(it) } -> convertible_to; };

template<class... Rs>concept concat-indirectly-readable = // exposition onlycommon_reference_with<concat-reference-t<Rs...>&&, concat-value-t<Rs...>&> &&common_reference_with<concat-reference-t<Rs...>&&, concat-rvalue-reference-t<Rs...>&&> &&common_reference_with<concat-rvalue-reference-t<Rs...>&&, concat-value-t<Rs...> const&> &&(concat-indirectly-readable-impl<concat-reference-t<Rs...>, concat-rvalue-reference-t<Rs...>, iterator_t> && ...);

🔗

template<class... Rs> concept [concatable](#concept:concatable "25.7.18.2Class template concat_­view[range.concat.view]") = see below; // exposition only

2

#

The exposition-only concatable concept is equivalent to:template<class... Rs>concept concatable = requires { // exposition onlytypename concat-reference-t<Rs...>; typename concat-value-t<Rs...>; typename concat-rvalue-reference-t<Rs...>; } && concat-indirectly-readable<Rs...>;

🔗

template<bool Const, class... Rs> concept [concat-is-random-access](#concept:concat-is-random-access "25.7.18.2Class template concat_­view[range.concat.view]") = see below; // exposition only

3

#

Let Fs be the pack that consists of all elements of Rs except the last element, then concat-is-random-access is equivalent to:template<bool Const, class... Rs>concept concat-is-random-access = // exposition onlyall-random-access<Const, Rs...> &&(common_range<maybe-const<Const, Fs>> && ...);

🔗

template<bool Const, class... Rs> concept [concat-is-bidirectional](#concept:concat-is-bidirectional "25.7.18.2Class template concat_­view[range.concat.view]") = see below; // exposition only

4

#

Let Fs be the pack that consists of all elements of Rs except the last element, then concat-is-bidirectional is equivalent to:template<bool Const, class... Rs>concept concat-is-bidirectional = // exposition onlyall-bidirectional<Const, Rs...> &&(common_range<maybe-const<Const, Fs>> && ...);

🔗

constexpr explicit concat_view(Views... views);

5

#

Effects: Initializes views_ with std::move(views)....

🔗

constexpr iterator<false> begin() requires (!([simple-view](range.utility.helpers#concept:simple-view "25.5.2Helper concepts[range.utility.helpers]")<Views> && ...)); constexpr iterator<true> begin() const requires ([range](range.range#concept:range "25.4.2Ranges[range.range]")<const Views> && ...) && [concatable](#concept:concatable "25.7.18.2Class template concat_­view[range.concat.view]")<const Views...>;

6

#

Effects: Let is-const betrue for the const-qualified overload, andfalse otherwise.

Equivalent to:iterator<is-const> it(this, in_place_index<0>, ranges::begin(std::get<0>(views_))); it.template satisfy<0>();return it;

🔗

constexpr auto end() requires (!([simple-view](range.utility.helpers#concept:simple-view "25.5.2Helper concepts[range.utility.helpers]")<Views> && ...)); constexpr auto end() const requires ([range](range.range#concept:range "25.4.2Ranges[range.range]")<const Views> && ...) && [concatable](#concept:concatable "25.7.18.2Class template concat_­view[range.concat.view]")<const Views...>;

7

#

Effects: Let is-const betrue for the const-qualified overload, andfalse otherwise.

Equivalent to:constexpr auto N = sizeof...(Views);if constexpr (common_range<maybe-const<is-const, Views...[N - 1]>>) {return iterator<is-const>(this, in_place_index<N - 1>, ranges::end(std::get<N - 1>(views_)));} else {return default_sentinel;}

🔗

constexpr auto size() requires ([sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]")<Views> && ...); constexpr auto size() const requires ([sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]")<const Views> && ...);

8

#

Effects: Equivalent to:return apply([](auto... sizes) {using CT = make-unsigned-like-t<common_type_t<decltype(sizes)...>>; return (CT(sizes) + ...); }, tuple-transform(ranges::size, views_));