has_nothrow_constructor Class

如果在預設的建構的型別不能擲回的測試。

template<class Ty>
    struct has_nothrow_constructor;

參數

  • Ty
    要查詢的類型。

備註

如果為 true,則保留型別述詞的執行個體的型別Ty有 nothrow 預設建構函式,否則它會保留,則為 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>

Namespace: 標準

請參閱

參考

<type_traits>

has_trivial_constructor Class

其他資源

<type_traits> 成員