News for hackers. Stuff that matters.
Re:Ill-Advised C++ Rant, Part 2 (2016) by bstamour on Wednesday October 25, 2017 @03:22PM (#15553254)
Or use the std::size free function. It's overloaded to work with C-style arrays.
Re:Ill-Advised C++ Rant, Part 2 (2016) by colanderman on Wednesday October 25, 2017 @03:41PM (#15553401)
Did not know about that, though unfortunately it's C++17 only.
Re:Ill-Advised C++ Rant, Part 2 (2016) by bstamour on Wednesday October 25, 2017 @04:14PM (#15553739)
Unfortunately yes. The implementation is straight forward though:

    template <typename Container>
    std::size_t size(Container const& c) { return c.size(); }

    template <typename T, std::size_t K>
    std::size_t size(T (&)[K]) { return K; }