mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 15:56:27 +00:00
24 lines
430 B
C++
24 lines
430 B
C++
#include <cstddef>
|
|
|
|
/**
|
|
* Get size of the given array.
|
|
*
|
|
* @param array An array
|
|
* @return Size of the array
|
|
*/
|
|
template <class T, std::size_t N>
|
|
constexpr std::size_t size(const T (&array)[N]) noexcept {
|
|
return N;
|
|
}
|
|
|
|
/**
|
|
* Get size of the given container.
|
|
*
|
|
* @param c An container
|
|
* @return Size of the container
|
|
*/
|
|
template <class C>
|
|
constexpr auto size(const C& c) -> decltype(c.size()) {
|
|
return c.size();
|
|
}
|