Title
begin/end for arrays should be constexpr and noexcept
Status
c++14
Section
[iterator.range]
Submitter
Andy Sawyer

Created on 2013-08-22.00:00:00 last changed 122 months ago

Messages

Date: 2014-01-12.11:50:30

Proposed resolution:

This wording is relative to N3797.

  1. Edit header <iterator> synopsis, [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));
    […]
    
  2. Edit [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).

Date: 2014-01-12.11:50:30

[ 2013-09 Chicago ]

Add noexcept(noexcept(std::begin/end(c))) to cbegin and cend, move to ready

Date: 2014-01-12.11:50:30

The array forms of std::begin and std::end should be constexpr and noexcept.

Previous resolution from Andy Sawyer:

  1. Edit header <iterator> synopsis, [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));
    […]
    
  2. Edit [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).

History
Date User Action Args
2014-02-27 17:03:20adminsetstatus: wp -> c++14
2014-02-20 13:52:38adminsetstatus: voting -> wp
2014-02-12 14:19:44adminsetstatus: ready -> voting
2014-01-12 11:50:30adminsetmessages: + msg6768
2014-01-12 11:50:30adminsetstatus: new -> ready
2013-08-22 22:09:25adminsetmessages: + msg6566
2013-08-22 00:00:00admincreate