News for hackers. Stuff that matters.
Re:Ill-Advised C++ Rant, Part 2 (2016) by stabbles on Wednesday October 25, 2017 @03:29PM (#15553322)
> Calculating the size of static array

In C++17 you can do

    #include <array>

    std::array myarray{ 4, 5, 6, 7, 8, 9 };
    int my_size = myarray.size(); // returns 6
which even deducts the type `std::array<int, 6>` for you.
Re:Ill-Advised C++ Rant, Part 2 (2016) by mattnewport on Wednesday October 25, 2017 @04:36PM (#15553987)
You can also use the std::size() free function to get the size of a C array, an std::array or any other standard container.

http://en.cppreference.com/w/cpp/iterator/size

Re:Ill-Advised C++ Rant, Part 2 (2016) by stabbles on Wednesday October 25, 2017 @04:42PM (#15554065)
A free function for this looks even better IMO.
Re:Ill-Advised C++ Rant, Part 2 (2016) by ender341341 on Wednesday October 25, 2017 @04:12PM (#15553711)
or just use std::extent which type safely gets the size of arrays (though most of my new c++ will probably be using std::array)