|
Boost : |
From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-02-06 07:39:43
Steve,
>I think we're almost done!
>There's just one little change I'd like now. . . While reviewing the
>definition of a POD type, I noticed that not all POD types have to have
>trivial default constructors. Therefore, in our type_traits, I recommend
>that is_POD should not imply has_trivial_constructor:<
You had me worried there for a minute - but checking the standard I'm
fairly sure that if a type is a POD then the default constructor is
trivial:
From 9.0:
"A POD-struct is an aggregate class
that has no non-static data members of type pointer to member, 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. Similarly, a POD-union is an aggregate union that has no
non-static data members of type pointer to member, 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. A
POD class is a class that is either a POD-struct or a POD-union."
The definition of an aggregate is in 8.5.1:
"1 An aggregate is an array or a class (_class_) with no user-declared
constructors (_class.ctor_), no private or protected non-static data
members (_class.access_), no base classes (_class.derived_), and no
virtual functions (_class.virtual_)."
Those definitions are actually pretty tight, I don't see how any POD-struct
type can fail to have a trivial default constructor given those rules - did
you have a specific case in mind?
- John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk