http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57515

            Bug ID: 57515
           Summary: implement begin() and end() for fixed size arrays
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jos at vandenoever dot info

Currently this code does not compile:


    int total = 0;
    std::for_each(begin(some_list), end(some_list), [&total](int x) {
      total += x;
    });

because begin() and end() are not defined for simple arrays. Implementing this
functionality is simple:

    template <class T>
    constexpr inline T* begin(T t[]) {
        return t;
    }
    template <class T, size_t N>
    constexpr inline T* end(T (&t)[N]) {
        return t + sizeof(t) / sizeof(T);
    }

Reply via email to