Last active
April 1, 2020 09:27
-
-
Save paxbun/90ec02236a73c5a00d08e17ab1dd1e8d to your computer and use it in GitHub Desktop.
Struct templates for array traits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
template <typename T> | |
struct ArrayDimension; | |
template <typename T, size_t N> | |
struct ArrayDimension<T[N]> | |
{ | |
static constexpr size_t Value = ArrayDimension<T>::Value + 1; | |
}; | |
template <typename T> | |
struct ArrayDimension | |
{ | |
static constexpr size_t Value = 0; | |
}; | |
template <typename T> | |
struct IsArray | |
{ | |
static constexpr bool Value = ArrayDimension<T>::Value != 0; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment