Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofWP status.

4105.ranges::ends_with'sReturns misses difference casting

Section: 26.6.17[alg.ends.with]Status:WPSubmitter: Hewill KangOpened: 2024-05-17Last modified: 2024-07-08

Priority:Not Prioritized

View all issues withWP status.

Discussion:

TheReturns of the ranges version ofranges::ends_with are specified asranges::equal(ranges::drop_view(ranges::ref_view(r1), N1 - N2), r2, ...) which is not quite rightwhenN2 is an integer-class type andN1 is an integer type, because in this caseN1 - N2 will be an integer-class type which cannot be implicitly converted to thedifference_type ofr1 leading to the construction ofdrop_view being ill-formed.

[2024-06-24; Reflector poll]

Set status to Tentatively Ready after five votes in favour during reflector poll.

[St. Louis 2024-06-29; Status changed: Voting → WP.]

Proposed resolution:

This wording is relative toN4981.

  1. Modify 26.6.17[alg.ends.with] as indicated:

    template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity,         class Proj2 = identity>  requires (forward_range<R1> || sized_range<R1>) &&           (forward_range<R2> || sized_range<R2>) &&           indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>  constexpr bool ranges::ends_with(R1&& r1, R2&& r2, Pred pred = {},                                   Proj1 proj1 = {}, Proj2 proj2 = {});

    -3- LetN1 beranges::distance(r1) andN2 beranges::distance(r2).

    -4-Returns:false ifN1 < N2, otherwise

    ranges::equal(ranges::drop_view(ranges::ref_view(r1), N1 -static_cast<decltype(N1)>(N2)), r2, pred, proj1, proj2)

[8]ページ先頭

©2009-2026 Movatter.jp