RAD Studio
ContentsIndex
PreviousUpNext
__has_trivial_default_constructor

Category 

Type Trait Functions 

Syntax 

bool __has_trivial_default_constructor (typename T ) 

Returns true if and only if T has a trivial default constructor. 

Errorif T is an incomplete type. 

False (but well-formed) if a class type does not have a default constructor. 

According to the definition from Section 20.4.4.3 of the Working Draft notes, a type T has a trivial copy assignment operator if:

  • a scalar type (or array thereof)
  • an array of class type with a trivial default constructor
  • a class type with a trivial default constructorr
Especially note false for reference types. 

According to Section 21.1 p5 of the Working Draft, a default constructor is trivial if:

  • It is not user provided
  • Its class has no virtual functions
  • Its class has no virtual base classes
  • Each direct base class of X has a trivial copy assignment operator.
  • All the direct base classes of its class have trivial default constructors.
  • For all the non-static data members of its class that are of class type (or array thereof), each such class has a trivial default constructor.
 

A default consructor is not user provided if it is implicitly declared, or defined inline as = default;

Ox interaction if the copy assign operator is defined as deleted. 

Ox interaction false if the default constructor is defined as deleted. 

Ox interaction with default function definitions. 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!