Files
OpenRCT2-Web/src/core/Util.hpp
T
Michał Janiszewski 98e204552a countof with type safety
For reference see http://www.g-truc.net/post-0708.html and
http://lxr.free-electrons.com/source/include/linux/kernel.h#L54

This will provide a type-safe mechanism for counting elements of array.
If you try passing something which cannot be counted, compiler will
frown at you right away.
2015-12-15 00:28:58 +01:00

21 lines
303 B
C++

#ifndef _UTIL_HPP_
#define _UTIL_HPP_
#include <cstdlib>
/**
* Common utility functions.
*/
namespace Util {
// Based on http://www.g-truc.net/post-0708.html
template <typename T, size_t N>
constexpr size_t CountOf(T const (&)[N]) noexcept
{
return N;
}
} // namespace Util
#endif // _UTIL_HPP_