has_trivial_copy-Klasse
Testet, ob Typ trivialen Kopierkonstruktor ist.
template<class Ty>
struct has_trivial_copy;
Parameter
- Ty
Der Typ in Abfragen.
Hinweise
Eine Instanz der Typprädikatgriffe True, wenn der Typ Ty ist eine Klasse, die einen trivialen Kopierkonstruktor ist; andernfalls false hält er an.
Durch einen Kopierkonstruktor für eine Klasse Ty ist trivial, wenn:
wird sie implizit deklariert
Ty-Klasse hat keine virtuellen Funktionen
Ty-Klasse hat keine virtuellen Basen
alle direkten Basen der Klasse Ty haben triviale Kopierkonstruktoren
die Klassen aller nicht statischen Datenmembern des Klassentyps haben triviale Kopierkonstruktoren
die Klassen aller nicht statischen Datenmembers des Typarrays Klasse verfügen triviale Kopierkonstruktoren
Beispiel
// std_tr1__type_traits__has_trivial_copy.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_trivial_copy<trivial> == " << std::boolalpha
<< std::has_trivial_copy<trivial>::value << std::endl;
std::cout << "has_trivial_copy<throws> == " << std::boolalpha
<< std::has_trivial_copy<throws>::value << std::endl;
return (0);
}
Anforderungen
Header: <type_traits>
Namespace: std