constexpr vs. non-literal library types round two
Jason Merrill
jason@redhat.com
Wed Nov 10 04:17:00 GMT 2010
On 11/09/2010 03:04 PM, Benjamin Kosnik wrote:
>
> I believe that non-literal types cannot be used to create constexpr
> variables if they have a non-trivial destructor.
constexpr variables must have literal type.
> This is not currently specified in the standard
> that I can see. If I'm wrong, can somebody help me out?
http://wiki.dinkumware.com/twiki/pub/Wg21batavia/CoreWorkingGroup/proposed_resolution_core-1125.html
> This seems obvious: a non-trivial destructor means that the object has
> to be registered for destruction. No compiler magic allowed! Ipso
> Facto, no constexpr construction is allowed.
We can still statically initialize objects of non-literal (and
non-const) types via constexpr constructors.
> So, the language changes that I would expect to see would be:
>
> 1) 3.9 p 10, literal type: remove the first point, ie:
>
> â a trivial copy constructor,
This is issue 1198 in
http://wiki.dinkumware.com/twiki/pub/Wg21batavia/CoreWorkingGroup/constexpr-misc.html
> 2) 5.19 p 2, constant expressions: add
>
> --- expressions that use or call non-literal class types with
> user-defined (and not defaulted) destructors.
See 1125, above.
Jason
More information about the Libstdc++
mailing list