Title
Unary call to std::views::repeat does not decay the argument
Status
wp
Section
[range.repeat.view]
Submitter
Jiang An

Created on 2024-02-05.00:00:00 last changed 7 months ago

Messages

Date: 2024-04-02.10:29:12

Proposed resolution:

This wording is relative to N4971.

  1. Modify [range.repeat.view], class template repeat_view synopsis, as indicated:

    [Drafting note: The proposed wording has been suggested by Casey Carter, see microsoft/STL#3576]

    namespace std::ranges {
      […]
    
      template<class T, class Bound = unreachable_sentinel_t>
        repeat_view(T, Bound = Bound()) -> repeat_view<T, Bound>;
    }
    
Date: 2024-04-02.10:29:12

[ Tokyo 2024-03-23; Status changed: Voting → WP. ]

Date: 2024-03-15.00:00:00

[ 2024-03-12; Reflector poll ]

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

Date: 2024-02-05.00:00:00

Currently, a binary call to std::views::repeat decay the arguments due to the deduction guide, but a unary call doesn't, which is inconsistent.

For example:

#include <concepts>
#include <ranges>

using RPV = std::ranges::repeat_view<const char*>;

static_assert(std::same_as<decltype(std::views::repeat("foo", std::unreachable_sentinel)), RPV>); // OK
static_assert(std::same_as<decltype(std::views::repeat(+"foo", std::unreachable_sentinel)), RPV>); // OK
static_assert(std::same_as<decltype(std::views::repeat("foo")), RPV>); // ill-formed
static_assert(std::same_as<decltype(std::views::repeat(+"foo")), RPV>); // OK

Presumably we should extend the deduction guide of std::ranges::repeat_view to cover the unary cases.

History
Date User Action Args
2024-04-02 10:29:12adminsetmessages: + msg14049
2024-04-02 10:29:12adminsetstatus: voting -> wp
2024-03-18 09:32:04adminsetstatus: ready -> voting
2024-03-12 01:10:06adminsetmessages: + msg13995
2024-03-12 01:10:06adminsetstatus: new -> ready
2024-02-10 15:54:03adminsetmessages: + msg13948
2024-02-05 00:00:00admincreate