Created on 2026-04-03.00:00:00 last changed 2 weeks 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>>(*)[]>;
[…]
}
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-04-04 15:38:16 | admin | set | messages: + msg16254 |
| 2026-04-03 00:00:00 | admin | create | |