Simplify lengthof header
This commit is contained in:
parent
599520fabb
commit
ad3e540b62
|
@ -6,18 +6,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef DXX_HAVE_CXX11_FUNCTION_AUTO
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef DXX_HAVE_CXX11_EXPLICIT_DELETE
|
||||
template <typename T>
|
||||
static void array_identity(T) = delete;
|
||||
#endif
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
static auto array_identity(T (&t)[N]) -> T(&)[N] { return t; }
|
||||
#define lengthof(A) (sizeof((array_identity)(A)) / sizeof((A)[0]))
|
||||
|
||||
#else
|
||||
#define lengthof(A) (sizeof((A)) / sizeof((A)[0]))
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue