Topic: Can a POD-struct have a user-declared copy assignment operator or destructor?


Author: "Ken Hagan" <K.Hagan@thermoteknix.co.uk>
Date: 19 Sep 2002 21:30:04 GMT
Raw View
"Martin v. L   wis" <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.

In what ways might a compiler make use of the PODness?

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?


---
[ 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                       ]





Author: Gennaro Prota <gennaro_prota@yahoo.com>
Date: Thu, 19 Sep 2002 16:54:16 CST
Raw View
On Thu, 19 Sep 2002 12:44:04 +0000 (UTC), Allan_W@my-dejanews.com
(Allan W) wrote:

>gennaro_prota@yahoo.com (Gennaro Prota) wrote
>> Is it the intent that [...]
>
>No.

Well, two letters for two letters...: DR! :-)

Genny [the telegraphic one].

---
[ 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                       ]





Author: loewis@informatik.hu-berlin.de (Martin v. =?iso-8859-1?q?L=F6wis?=)
Date: Wed, 18 Sep 2002 19:05:18 +0000 (UTC)
Raw View
gennaro_prota@yahoo.com (Gennaro Prota) writes:

> Note that it says 'user-defined', not 'user-declared'. Is it the
> intent that if e.g. a copy assignment operator is declared but not
> defined, this does not (per se) prevent the class to be a POD-struct?

I don't think this is the intent. Instead, the expectation is that a
program that has only a user-defined assignment operator will be
ill-formed, since the assignment operator is likely used.

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.

Regards,
Martin

---
[ 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                       ]





Author: Allan_W@my-dejanews.com (Allan W)
Date: Thu, 19 Sep 2002 12:44:04 +0000 (UTC)
Raw View
gennaro_prota@yahoo.com (Gennaro Prota) wrote
> The standard (par. 9/4) says that "A POD-struct is an aggregate class
> that has no non-static data members of type non-POD-struct,
> non-POD-union (or array of such types) or reference, and has no
> user-defined copy assignment operator and no user-defined destructor."
>
> Note that it says 'user-defined', not 'user-declared'. Is it the
> intent that if e.g. a copy assignment operator is declared but not
> defined, this does not (per se) prevent the class to be a POD-struct?

No.

---
[ 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                       ]





Author: gennaro_prota@yahoo.com (Gennaro Prota)
Date: Wed, 18 Sep 2002 01:34:37 +0000 (UTC)
Raw View
The standard (par. 9/4) says that "A POD-struct is an aggregate class
that has no non-static data members of type non-POD-struct,
non-POD-union (or array of such types) or reference, and has no
user-defined copy assignment operator and no user-defined destructor."

Note that it says 'user-defined', not 'user-declared'. Is it the
intent that if e.g. a copy assignment operator is declared but not
defined, this does not (per se) prevent the class to be a POD-struct?

Genny.

---
[ 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                       ]