cosmopolitan/third_party/libcxx/countof.internal.hh
2022-09-04 04:53:52 -07:00

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_ */