I do not think that this can be done truly unprofessional, at least without unnecessary explanations. One of the important points is static or dynamic initialization, but the explanation is that the layman will have several pages on their own ...
PODs were (incorrectly) defined in C ++ 98. There are really two separate intentions that are not very well expressed: 1) that if you compile a C-structure declaration in C ++, then you will get the equivalent of what you had on C. 2) POD will ever be needed / use static (not dynamic).
C ++ 0x / 11 completely cancels the designation of "POD" (almost), in favor of the "trivial" and "standard layout". The standard layout is designed to capture the first intention - to create something with a layout just as you would get in C. Trivial is designed to capture support for static initialization.
Since new T
vs. new T()
deals with initialization, you probably want is_trivial
.
I'm not sure if compiler magic is required. My immediate reaction would probably be yes, but knowing some of the things that people did with TMP, itβs hard for me to understand that someone couldnβt do this either ...
Edit: for example, perhaps the best examples are from the N3290:
struct N { // neither trivial nor standard-layout int i; int j; virtual ~N(); }; struct T { // trivial but not standard-layout int i; private: int j; }; struct SL { // standard-layout but not trivial int i; int j; ~SL(); }; struct POD { // both trivial and standard-layout int i; int j; };
As you can no doubt assume, POD
also a POD structure.
Jerry Coffin Jun 27 '11 at 17:39 2011-06-27 17:39
source share