Topic: Can a POD-struct have a user-declared copy assignment operator or
Author: kuyper@wizard.net ("James Russell Kuyper Jr.")
Date: Fri, 20 Sep 2002 12:02:01 +0000 (UTC) Raw View
Ken Hagan wrote:
>=20
> "Martin v. L=F6wis" <loewis@informatik.hu-berlin.de> wrote...
> > Otherwise, the standard would be difficult to implement: you can't
> > really diagnose anymore whether a type is POD until you see the
> > complete program - at which time you forgot at what points you made
> > use of the PODness.
>=20
> In what ways might a compiler make use of the PODness?
>=20
> If a compiler can't prove PODness without seeing the whole
> program, does that prevent it generating safe code, or does it
> merely make the "well-formedness" of the code undetermined until
> link time?
No, it's much simpler than that. The standard makes a long list of
guarantees that every POD type must satisfy. An implementation doesn't
have to diagnose PODness. All it has to do is make sure those guarantees
are met by all POD types.
That's easily achievable, just by making sure that the implementation
never does anything to violate those guarantees, except as a result of
the type possessing some feature that is guaranteed to make it no longer
a POD type. The result will be that most of those guarantees will happen
to work even on many non-POD types, and there will be many non-POD types
for which all of those guarantees work. That's no problem - nobody
actively wants those guarantees to fail.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]