4 ms·
Or use the std::size free function. It's overloaded to work with C-style arrays.
by bstamour 9y ago
Or use the std::size free function. It's overloaded to work with C-style arrays.
- colanderman 9y agoDid not know about that, though unfortunately it's C++17 only.
- bstamour 9y agoUnfortunately 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; }