std :: is_same
と std :: is_base_of
の挙動を調べた
#include <iostream>
#include <type_traits>
struct Base {};
struct A : public Base {};
int main(int argc, const char * argv[]) {
std :: cout << std :: is_same < Base, A > :: value << std :: endl;
std :: cout << std :: is_base_of< Base, A > :: value << std :: endl;
std :: cout << std :: is_base_of< A, Base > :: value << std :: endl;
std :: cout << std :: is_base_of< Base, Base > :: value << std :: endl;
std :: cout << std :: is_base_of< A, A > :: value << std :: endl;
return 0;
}
0
1
0
1
1
is_same< [基底], [派生]> :: value
false
)is_base_of< [基底], [派生] > :: value
true
)is_base_of< [派生], [基底] > :: value
false
)is_base_of< [基底], [基底] > :: value
true
)is_base_of< [派生], [派生] > :: value
true
)template < typename Type >
using base_of_A = std :: is_base_of<A, Type> :: value;