Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Testet, ob zwei Typen identisch sind.
Syntax
template <class Ty1, class Ty2>
struct is_same;
Parameter
Ty1
Der erste abzufragende Typ.
Ty2
Der zweite abzufragende Typ.
Hinweise
Eine Instanz des Typprädikats enthält "true", wenn die Typen "Ty1 " und "Ty2 " denselben Typ aufweisen, andernfalls "false".
Beispiel
// std__type_traits__is_same.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct base
{
int val;
};
struct derived
: public base
{
};
int main()
{
std::cout << "is_same<base, base> == " << std::boolalpha
<< std::is_same<base, base>::value << std::endl;
std::cout << "is_same<base, derived> == " << std::boolalpha
<< std::is_same<base, derived>::value << std::endl;
std::cout << "is_same<derived, base> == " << std::boolalpha
<< std::is_same<derived, base>::value << std::endl;
std::cout << "is_same<int, int> == " << std::boolalpha
<< std::is_same<int, int>::value << std::endl;
std::cout << "is_same<int, const int> == " << std::boolalpha
<< std::is_same<int, const int>::value << std::endl;
return (0);
}
is_same<base, base> == true
is_same<base, derived> == false
is_same<derived, base> == false
is_same<int, int> == true
is_same<int, const int> == false
Anforderungen
Header:<type_traits>
Namespace: std