class template
<type_traits>
std::is_sametemplate <class T, class U> struct is_same;
Is same type
Two different type names are considered to represent the same type if -and only if- one is a typedef of the other: Two names representing types with the exact same characteristics but which none is a typedef of the other are not considered the same type.
is_same inherits from integral_constant as being either true_type or false_type, depending on whether T and U are the same type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// is_same example
#include <iostream>
#include <type_traits>
#include <cstdint>
typedef int integer_type;
struct A { int x,y; };
struct B { int x,y; };
typedef A C;
int main() {
std::cout << std::boolalpha;
std::cout << "is_same:" << std::endl;
std::cout << "int, const int: " << std::is_same<int, const int>::value << std::endl;
std::cout << "int, integer_type: " << std::is_same<int, integer_type>::value << std::endl;
std::cout << "A, B: " << std::is_same<A,B>::value << std::endl;
std::cout << "A, C: " << std::is_same<A,C>::value << std::endl;
std::cout << "signed char, std::int8_t: " << std::is_same<signed char,std::int8_t>::value << std::endl;
return 0;
}
is_same: int, const int: false int, integer_type: true A, B: false A, C: true signed char, std::int8_t: true
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4