Created
November 29, 2017 20:28
-
-
Save ahafidi/0de5f3444301297a3fa40e16d0d4c6bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <iostream> | |
#include <cstddef> | |
template<typename T> | |
struct IsArray | |
{ | |
static constexpr bool value = false; | |
}; | |
template<typename T> | |
struct IsArray<T[]> | |
{ | |
static constexpr bool value = true; | |
}; | |
template<typename T, std::size_t N> | |
struct IsArray<T[N]> | |
{ | |
static constexpr bool value = true; | |
}; | |
class Test; | |
int main() | |
{ | |
std::cout << std::boolalpha | |
<< IsArray<int>::value << std::endl | |
<< IsArray<float>::value << std::endl | |
<< IsArray<Test>::value << std::endl | |
<< IsArray<int[]>::value << std::endl | |
<< IsArray<float[]>::value << std::endl | |
<< IsArray<Test[]>::value << std::endl | |
<< IsArray<int[21]>::value << std::endl | |
<< IsArray<float[42]>::value << std::endl | |
<< IsArray<Test[84]>::value << std::endl | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment