ยง12.1 / 4: and its first marker point
The default constructor for class X is the constructor of class X, which can be called without an argument. If there is no constructor declared by the user for class X, a constructor without parameters is implicitly declared as default (8.4). The implicitly declared default constructor is an inline public member of its class. By default, the default constructor for class X is determined to be deleted if:
- X is a unified class that has a variant element with a non-trivial default constructor,
According to this brand, this fragment should not be compiled, since struct A is a unified class (it contains an anonymous union) and has a variant member B b; with a non-trivial default constructor. But the code compiles without problems in vC ++, clang ++ and g ++ .
c ++ constructor language-lawyer c ++ 11
Belloc
source share