has_trivial_destructor Class

Tests if type has trivial destructor.

template<class Ty>
    struct has_trivial_destructor;

Parameters

  • Ty
    The type to query.

Remarks

An instance of the type predicate holds true if the type Ty is a class that has a trivial destructor, otherwise it holds false.

A destructor for a class Ty is trivial if:

it is an implicitly declared destructor

all the direct bases of the class Ty have trivial destructors

the classes of all the non-static data members of class type have trivial destructors

the classes of all the non-static data members of type array of class have trivial destructors

Example

 

// std_tr1__type_traits__has_trivial_destructor.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
struct trivial 
    { 
    int val; 
    }; 
 
struct throws 
    { 
    throws() throw(int) 
        { 
        } 
 
    throws(const throws&) throw(int) 
        { 
        } 
 
    throws& operator=(const throws&) throw(int) 
        { 
        } 
 
    ~throws() 
        { 
        } 
 
    int val; 
    }; 
 
int main() 
    { 
    std::cout << "has_trivial_destructor<trivial> == " << std::boolalpha 
        << std::has_trivial_destructor<trivial>::value << std::endl; 
    std::cout << "has_trivial_destructor<throws> == " << std::boolalpha 
        << std::has_trivial_destructor<throws>::value << std::endl; 
 
    return (0); 
    } 
 
has_trivial_destructor<trivial> == true
has_trivial_destructor<throws> == false

Requirements

Header: <type_traits>

Namespace: std

See Also

Reference

<type_traits>

has_trivial_constructor Class

has_virtual_destructor Class

Other Resources

<type_traits> Members