ClickHouse/base/ext/size.h

15 lines
398 B
C++
Raw Normal View History

2015-11-17 13:25:36 +00:00
#pragma once
#include <cstdlib>
namespace ext
{
/** \brief Returns number of elements in an automatic array. */
template <typename T, std::size_t N>
constexpr std::size_t size(const T (&)[N]) noexcept { return N; }
2015-11-17 13:25:36 +00:00
/** \brief Returns number of in a container providing size() member function. */
template <typename T> constexpr auto size(const T & t) { return t.size(); }
2015-11-17 13:25:36 +00:00
}