mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
20 lines
524 B
C++
20 lines
524 B
C++
#ifndef COSMOPOLITAN_THIRD_PARTY_LIBCXX_COUNTOF_H_
|
|
#define COSMOPOLITAN_THIRD_PARTY_LIBCXX_COUNTOF_H_
|
|
#include "third_party/libcxx/__config"
|
|
|
|
namespace {
|
|
|
|
template <typename T, size_t N>
|
|
inline _LIBCPP_CONSTEXPR size_t countof(const T (&)[N]) {
|
|
return N;
|
|
}
|
|
|
|
template <typename T>
|
|
inline _LIBCPP_CONSTEXPR size_t countof(const T* const begin,
|
|
const T* const end) {
|
|
return static_cast<size_t>(end - begin);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
#endif /* COSMOPOLITAN_THIRD_PARTY_LIBCXX_COUNTOF_H_ */
|