Title
§[iterator.range] Missing noexcept for std::rbegin/rend for arrays and initializer_list
Status
new
Section
[iterator.range]
Submitter
Jiang An

Created on 2021-03-21.00:00:00 last changed 4 weeks ago

Messages

Date: 2021-03-15.00:00:00

[ 2021-03-21; Daniel comments ]

There is intentionally no P/R provided at this point, but I'm volunteering to provide it if we got feedback whether adding conditional noexcept specifiers similar to those provided by LWG 2280 would be preferred or not.

Date: 2021-03-21.00:00:00

Overloads for std::rbegin/rend for built-in arrays and std::initializer_list's has no preconditions and never throw exceptions, thus should be noexcept. LWG 2280 addressed a similar issue for std::begin/end.

Suggestion: change these declarations in [iterator.range] (p10, 11, 12, 13) as indicated:

template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]) noexcept;

template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]) noexcept;

template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il) noexcept;

template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il) noexcept;

If this change is accepted, we may also specify conditional noexcept for std::crbegin/crend (in [iterator.range] p14, 15), by adding noexcept(noexcept(std::rbegin/crend(c))), like in LWG 2280.

Conditional noexcept for other functions in [iterator.range] (p2, 3, 7, 8, 16, 18, 20 22) may also be added for consistency.

History
Date User Action Args
2021-03-21 19:01:47adminsetmessages: + msg11754
2021-03-21 00:00:00admincreate