Created on 2026-04-03.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5032.
Modify [range.subrange.general] as indicated:
namespace std::ranges {
template<class From, class To>
concept uses-nonqualification-pointer-conversion = // exposition only
is_pointer_vcontiguous_iterator<From> && is_pointer_vcontiguous_iterator<To> &&
!convertible_to<remove_pointer_tremove_reference_t<iter_reference_t<From>>(*)[],
remove_pointer_tremove_reference_t<iter_reference_t<To>>(*)[]>;
[…]
}
[ 2026-05-29; Reflector poll. ]
Set priority to 3 after reflector poll.
"It seems like we should apply this protection to all iterator adaptors. Derived-to-base conversions are not valid for pointers that are used as iterators."
Currently, the subrange uses the following exposition-only concept:
template<class From, class To>
concept uses-nonqualification-pointer-conversion = // exposition only
is_pointer_v<From> && is_pointer_v<To> &&
!convertible_to<remove_pointer_t<From>(*)[], remove_pointer_t<To>(*)[]>;
to disallow derived to base conversions. However, this only applies to pointers.
Given that subrange is intended to universally take any iterator-pair to
form a view, we may need to generally prevent this in the case of contiguous iterators
(demo):
struct Base {};
struct Derived : Base {};
ranges::subrange<Derived*> sd;
ranges::subrange<Base*> sb = sd; // error
ranges::subrange<const Base*> sb = views::as_const(sd); // ok
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-05-29 08:44:59 | admin | set | messages: + msg16329 |
| 2026-04-04 15:38:16 | admin | set | messages: + msg16254 |
| 2026-04-03 00:00:00 | admin | create | |