Issue 3948: possibly-const-range and as-const-pointer should be noexcept (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
3948. _possibly-const-range_
and _as-const-pointer_
should be noexcept
Section: 25.2 [ranges.syn], 25.3.16 [range.prim.cdata] Status: WP Submitter: Jiang An Opened: 2023-06-20 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [ranges.syn].
View all issues with WP status.
Discussion:
As of P2278R4, several range access CPOs are specified with _possibly-const-range_
and _as-const-pointer_
. These helper functions never throw exceptions, but are not marked with noexcept
. As a result, implementations are currently allowed to make a call to ranges::c_cpo_
potentially throwing while the underlying ranges::_cpo_
call is non-throwing, which doesn't seem to be intended.
[2023-10-27; Reflector poll]
Set status to Tentatively Ready after five votes in favour during reflector poll.
[2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4950.
- Modify 25.2 [ranges.syn], header
<ranges>
synopsis, as indicated:[…]
// 25.7.22 [range.as.const], as const view
template
constexpr auto& possibly-const-range(R& r) noexcept { // exposition only
if constexpr (constant_range && !constant_range) {
return const_cast<const R&>(r);
} else {
return r;
}
}
[…] 2. Modify 25.3.16 [range.prim.cdata] before p1 as indicated:
template
constexpr auto as-const-pointer(const T* p) noexcept { return p; } // exposition only