Show: Object Pascal C++

Display Preferences

# __has_trivial_destructor

From Appmethod Topics

*Go Up to Type Trait Functions (C++0x) Index*

**Category**

Type Trait Functions

**Syntax**

bool __has_trivial_destructor (typename T )

Returns true if and only if T has a trivial destructor.

**Error**if T is an incomplete type.

Note: Definition from 20.4.4.3 notes has a type T has a trivial destructor if T is one of:

- a scalartype (or array thereof)
- a scalartype (or array thereof)
- an array of class type with a trivial destructor
- an array of class type with a trivial destructor
- a class type with a trivial destructor

According to Section 12.4, p 3 of the Working Draft, a destructor for class X is trivial if:

- it is not user-provided
- class X has no virtual functions
- class X has no virtual base classes
- all of the direct base classes of its class have trivial destructors
- for all of the non-static data members of its class that are of class type (or array thereof), each such class has a trivial destructor.

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

**Ox interaction** false if the destructor is defined as deleted.

**Ox interaction** with default function definitions.