J
johnkalane
Maybe I'm missing something, but IMO the 4th bullet point in iso §12.1 p5is wrong:
"X is a union and all of its variant members are of const-qualified type (or array thereof),"
Take for example the following snippet which compiles in Coliru and Ideone (http://ideone.com/QW45u7), but it shouldn't as the defaulted default constructor for the union should be deleted according to the bullet point alluded above.
union T
{
const int y;
const char c;
const float z;
T(int j) : y(j) {}
T() = default;
};
int main()
{
T t;
}
I also don't understand why does the Standard disallow this code (see note in iso §9.5 p2)
struct S
{
int i;
S() : i(1) {}
};
union T
{
S s;
char c;
};
int main()
{
T t;
}
but allows this. What's the difference?
struct S
{
int i;
S() : i(1) {}
};
union T
{
S s;
char c;
T() {}
};
int main()
{
T t;
}
"X is a union and all of its variant members are of const-qualified type (or array thereof),"
Take for example the following snippet which compiles in Coliru and Ideone (http://ideone.com/QW45u7), but it shouldn't as the defaulted default constructor for the union should be deleted according to the bullet point alluded above.
union T
{
const int y;
const char c;
const float z;
T(int j) : y(j) {}
T() = default;
};
int main()
{
T t;
}
I also don't understand why does the Standard disallow this code (see note in iso §9.5 p2)
struct S
{
int i;
S() : i(1) {}
};
union T
{
S s;
char c;
};
int main()
{
T t;
}
but allows this. What's the difference?
struct S
{
int i;
S() : i(1) {}
};
union T
{
S s;
char c;
T() {}
};
int main()
{
T t;
}