Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Tests if type doesn't throw on default construction.
template<class Ty>
struct has_nothrow_constructor;
Parameters
- Ty
The type to query.
Remarks
An instance of the type predicate holds true if the type Ty has a nothrow default constructor, otherwise it holds false.
Example
// 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);
}
has_nothrow_constructor<trivial> == true has_nothrow_constructor<throws> == false
Requirements
Header: <type_traits>
Namespace: std