This question already has an answer here:
Consider plain-old-data structs - with no methods explicitly defined, no final, no inheritance etc. They either have some data members, or are empty - and I want to tell the two cases apart, generically.
That is, I want a constexpr function template <typename T> magic()
for which magic<T>()
is true for empty structs, and false for non-empty ones (and I don't care about other types). Alternatively, magic_alt<T>::value
is true for empty structs and magic_alt<T>::value
is false otherwise.
Can this be done: (1) in C++11? (2) In C++17 or C++20?
Aucun commentaire:
Enregistrer un commentaire