Title
ranges::ends_with's Returns misses difference casting
Status
wp
Section
[alg.ends.with]
Submitter
Hewill Kang

Created on 2024-05-17.00:00:00 last changed 5 months ago

Messages

Date: 2024-07-08.09:00:03

Proposed resolution:

This wording is relative to N4981.

  1. Modify [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- Let N1 be ranges::distance(r1) and N2 be ranges::distance(r2).

    -4- Returns: false if N1 < N2, otherwise

    ranges::equal(ranges::drop_view(ranges::ref_view(r1), N1 - static_cast<decltype(N1)>(N2)), r2, pred, proj1, proj2)
    
Date: 2024-07-08.09:00:03

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

Date: 2024-06-15.00:00:00

[ 2024-06-24; Reflector poll ]

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

Date: 2024-05-17.00:00:00

The Returns of the ranges version of ranges::ends_with are specified as ranges::equal(ranges::drop_view(ranges::ref_view(r1), N1 - N2), r2, ...) which is not quite right when N2 is an integer-class type and N1 is an integer type, because in this case N1 - N2 will be an integer-class type which cannot be implicitly converted to the difference_type of r1 leading to the construction of drop_view being ill-formed.

History
Date User Action Args
2024-07-08 09:00:03adminsetmessages: + msg14247
2024-07-08 09:00:03adminsetstatus: voting -> wp
2024-06-24 13:01:55adminsetstatus: ready -> voting
2024-06-24 12:08:14adminsetmessages: + msg14175
2024-06-24 12:08:14adminsetstatus: new -> ready
2024-05-19 09:47:38adminsetmessages: + msg14150
2024-05-17 00:00:00admincreate