Is there a way to get the number of union members in C ++? For instance:
union U
{
int a;
double b;
char c;
};
int main()
{
std::cout << std::union_members_count<U>::value << std::endl;
}
Of course, std::union_members_count<>is fictional.
If there is a way, how to implement / use it?
source
share