is_same Class
Если тесты 2 типа.
template<class Ty1, class Ty2>
struct is_same;
Параметры
Ty1
Первый тип для запроса.Ty2
Второй тип для запроса.
Заметки
Экземпляр предиката типа выполняются, если типы Ty1 и Ty2 один и тот же тип; в противном случае он хранит false.
Пример
// std_tr1__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);
}
Требования
заголовок:<type_traits>
пространство имен: STD