문서를 영문으로 보려면 영문 확인란을 선택하세요. 마우스 포인터를 텍스트 위로 이동시켜 팝업 창에서 영문 텍스트를 표시할 수도 있습니다.
번역
영문
Visual Studio 2017을 사용하는 것이 좋습니다.

has_trivial_constructor 클래스

Tests if type has trivial default constructor.

template<class Ty>
    struct has_trivial_constructor;

Ty

The type to query.

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

A constructor for a class Ty is trivial if:

it is an implicitly declared default constructor

the class Ty has no virtual functions

the class Ty has no virtual bases

all the direct bases of the class Ty have trivial constructors

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

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

 

// std_tr1__type_traits__has_trivial_constructor.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) 
        { 
        } 
 
    int val; 
    }; 
 
int main() 
    { 
    std::cout << "has_trivial_constructor<trivial> == " << std::boolalpha 
        << std::has_trivial_constructor<trivial>::value << std::endl; 
    std::cout << "has_trivial_constructor<throws> == " << std::boolalpha 
        << std::has_trivial_constructor<throws>::value << std::endl; 
 
    return (0); 
    } 
 
has_trivial_constructor<trivial> == true
has_trivial_constructor<throws> == false

헤더: <type_traits>

네임스페이스: std

표시: