cppreference says for zero initialization:
Zero initialization is performed in the following situations: ... 2) As part of value-initialization sequence for non-class types and for members of value-initialized class types that have no constructors, ...
What trait or combination of traits can I use to test either for:
- type is zero-initializable with an empty
{}
, or - class type has "no constructors"
- (which I think means no user-defined constructors?)
(P.S. tagged C++11
to indicate any "modern C++" approach is acceptable; also tagged C++17
to indicate the latest C++ version I'd like for an answer.)
(P.P.S. I know cppreference is not the standard, but it is almost always correct. If it is not correct in this case, that should be part of the answer ...)
Aucun commentaire:
Enregistrer un commentaire