This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.
begin/end
for arrays should be constexpr
and noexcept
Section: 24.7 [iterator.range] Status: C++14 Submitter: Andy Sawyer Opened: 2013-08-22 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [iterator.range].
View all other issues in [iterator.range].
View all issues with C++14 status.
Discussion:
The array forms of std::begin
and std::end
should be constexpr
and noexcept
.
Previous resolution from Andy Sawyer:
Edit header
<iterator>
synopsis, 24.2 [iterator.synopsis] as indicated:[…] template <class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; template <class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; template <class C> constexpr auto cbegin(const C& c) -> decltype(std::begin(c)); template <class C> constexpr auto cend(const C& c) -> decltype(std::end(c)); […]Edit 24.7 [iterator.range] before p4+5 as indicated:
template <class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept;-4- Returns:
array
.template <class T, size_t N> constexpr T* end(T (&array)[N]) noexcept;-5- Returns:
array + N
.template <class C> constexpr auto cbegin(const C& c) -> decltype(std::begin(c));-6- Returns:
std::begin(c)
.template <class C> constexpr auto cend(const C& c) -> decltype(std::end(c));-7- Returns:
std::end(c)
.
[2013-09 Chicago]
Add noexcept(noexcept(std::begin/end(c)))
to cbegin
and cend
, move to ready
Proposed resolution:
This wording is relative to N3797.
Edit header <iterator>
synopsis, 24.2 [iterator.synopsis] as indicated:
[…] template <class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; template <class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; template <class C> constexpr auto cbegin(const C& c) noexcept(noexcept(std::begin(c))) -> decltype(std::begin(c)); template <class C> constexpr auto cend(const C& c) noexcept(noexcept(std::end(c))) -> decltype(std::end(c)); […]
Edit 24.7 [iterator.range] before p4+5 as indicated:
template <class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept;-4- Returns:
array
.template <class T, size_t N> constexpr T* end(T (&array)[N]) noexcept;-5- Returns:
array + N
.template <class C> constexpr auto cbegin(const C& c) noexcept(noexcept(std::begin(c))) -> decltype(std::begin(c));-6- Returns:
std::begin(c)
.template <class C> constexpr auto cend(const C& c) noexcept(noexcept(std::end(c))) -> decltype(std::end(c));-7- Returns:
std::end(c)
.