has_nothrow_constructor 클래스

Tests if type doesn't throw on default construction.

template<class Ty>
    struct has_nothrow_constructor;

매개 변수

  • Ty
    The type to query.

설명

An instance of the type predicate holds true if the type Ty has a nothrow default constructor, otherwise it holds false.

예제

 

// std_tr1__type_traits__has_nothrow_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_nothrow_constructor<trivial> == " << std::boolalpha 
        << std::has_nothrow_constructor<trivial>::value << std::endl; 
    std::cout << "has_nothrow_constructor<throws> == " << std::boolalpha 
        << std::has_nothrow_constructor<throws>::value << std::endl; 
 
    return (0); 
    } 
 
  

요구 사항

헤더: <type_traits>

네임스페이스: std

참고 항목

참조

<type_traits>

has_trivial_constructor 클래스

기타 리소스

<type_traits> 멤버