040类型萃取_迭代器萃取
#include<iostream>
#include<iostream>
#include<cstdlib>
#include<functional>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
template <typename T>
void printTraitsInfo(const T& t)
{
cout << "--------------begin-----------" << endl;
cout << "我们要萃取的类型名字是:" << typeid(T).name() << endl;
cout << "is_void = " << is_void<T>::value << endl;
cout << "is_class = " << is_class<T>::value << endl;
cout << "is_object = " << is_object<T>::value << endl;
cout << "is_pod = " << is_pod<T>::value << endl;
cout << "is_default_constructible = " << is_default_constructible<T>::value << endl;
cout << "is_copy_constructible = " << is_copy_constructible<T>::value << endl;
cout << "is_move_constructible = " << is_move_constructible<T>::value << endl;
cout << "is_destructible = " << is_destructible<T>::value << endl;
cout << "is_polymorphic = " << is_polymorphic<T>::value << endl;
cout << "is_trivially_default_constructible = " << is_trivially_default_constructible<T>::value << endl;
cout << "has_virtual_destructor = " << has_virtual_destructor<T>::value << endl;
cout << "--------------end-------------" << endl;
}
class A
{
public:
A() = default;
A(A&& ta) = delete;
A(const A& ta) = delete;
virtual ~A() {}
};
class B
{
public:
int m_i;
int m_j;
};
class C
{
public:
C(int t) {}
};
void func()
{
printTraitsInfo(int());
printTraitsInfo(string());
printTraitsInfo(A());
printTraitsInfo(B());
printTraitsInfo(C(1));
printTraitsInfo(list<int>());
}
int main(void)
{
func();
system("pause");
return 0;
}