共用方式為


has_nothrow_assign 類別

測試,如果型別在指定不會擲回。

template<class Ty>
    struct has_nothrow_assign;

參數

  • Ty
    查詢的型別。

備註

這個型別述詞的執行個體之型別,則這個 Ty 有 nothrow 複製指派運算子,否則它保留 false。

nothrow 函式是有空白擲回規範的函式,則編譯器可以為識別的函式不會擲回例外狀況。

範例

 

// std_tr1__type_traits__has_nothrow_assign.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_assign<trivial> == " << std::boolalpha 
        << std::has_nothrow_assign<trivial>::value << std::endl; 
    std::cout << "has_nothrow_assign<throws> == " << std::boolalpha 
        << std::has_nothrow_assign<throws>::value << std::endl; 
 
    return (0); 
    } 
 
  

需求

標題: <type_traits>

命名空間: std

請參閱

參考

<type_traits>

has_trivial_assign 類別

其他資源

<type_traits> 成員