has_nothrow_constructor クラス
更新 : 2007 年 11 月
既定のコンストラクタで例外がスローされない型であるかどうかをテストします。
template<class Ty>
struct has_nothrow_constructor;
パラメータ
- Ty
問い合わせる型。
解説
型 Ty が nothrow の既定のコンストラクタを持つ場合、型述語のインスタンスは true を保持します。それ以外の場合は、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::tr1::has_nothrow_constructor<trivial>::value << std::endl;
std::cout << "has_nothrow_constructor<throws> == " << std::boolalpha
<< std::tr1::has_nothrow_constructor<throws>::value << std::endl;
return (0);
}
has_nothrow_constructor<trivial> == true
has_nothrow_constructor<throws> == false
必要条件
ヘッダー : <type_traits>
名前空間 : std::tr1