This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: has_trivial_destructor improvable?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "Hite, Christopher" <Christopher dot Hite at partner dot commerzbank dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Wed, 22 Feb 2012 16:13:50 +0000
- Subject: Re: has_trivial_destructor improvable?
- Authentication-results: mr.google.com; spf=pass (google.com: domain of jwakely.gcc@gmail.com designates 10.152.130.102 as permitted sender) smtp.mail=jwakely.gcc@gmail.com; dkim=pass header.i=jwakely.gcc@gmail.com
- References: <56888C35366397458A8FA0626BA836F119B5AD78D8@SE002568.cs.commerzbank.com> <56888C35366397458A8FA0626BA836F119B5AD78D9@SE002568.cs.commerzbank.com>
On 22 February 2012 15:55, Hite, Christopher wrote:
>
> Hi, does has_trivial_destructor<> and co depend on compiler magic?
Yes.
> Is it possible to detect empty deconstructors/constructors. ?The reason I ask is because I'd like to make better placeholders for a boost::optional implementation using new unions from N2544.
>
> template<typename T>
> union placeholder{
> ? ? ? ?T v;
> ? ? ? ?placeholder() {} ? // breaks has_trivial_constructor
> ? ? ? ?~placeholder (){} // breaks has_trivial_destructor
> };
>
> Is improving these possible or is there some conceptual problem with a circular reference?
I don't understand the question, sorry.
What do you mean "breaks has_trivial_constructor" ?
Do you just mean has_trivial_default_constructor::value is false?
If you declare the constructor and destructor as defaulted then they
will be trivial for placeholder<X> if they are trivial for X:
placeholder() = default;
~placeholder () = default;