Lets say I have the following class:
struct Color
{
enum {
blue,
red,
unknown
};
};
I would like to test in compile time if the class Color has the unknown value.
I thought the following could work but it is currently returning an incorrect result.
#include <iostream>
template <typename T, typename U = T>
struct test
{
static constexpr bool value = false;
};
template <typename T>
struct test<T, decltype(T::unknown)>
{
static constexpr bool value = true;
};
int main()
{
std::cout << test<Color>::value << std::endl; //prints 0
}
Could you provide some insight on how I can accomplish the check? Or what is wrong with my example?
Thanks
Aucun commentaire:
Enregistrer un commentaire