c++type traitの検査タイプ関係(Type Relation)

3091 ワード

#include 

using namespace std;

int main()
{
    cout << boolalpha;
    // is_same T1 T2      (  const volatile   )
    cout << is_same<const int&, int>::value << endl;
    // is_base_of T   D   
    cout << is_base_of<char, string>::value << endl;
    // is_convertible T     D
    cout << is_convertible<double, int>::value << endl;
    // is_constructible    Args...   T
    cout << is_constructible<string, char, double>::value << endl;
    // is_trivially_constructible   Args...  (  )   T
    cout << is_trivially_constructible<string, char, double>::value << endl;
    // is_nothrow_constructible    Args...   T      
    cout << is_nothrow_constructible<string, char, double>::value << endl;
    // is_assignable   T     D  
    cout << is_assignable<double, int>::value << endl;
    // is_trivially_assignable   T    D    
    cout << is_trivially_assignable<double, int>::value << endl;
    // is_nothrow_assignable   T    D        
    cout << is_nothrow_assignable<double,int>::value;
    //uses_allocator Alloc    T::allocator_type
    system("pause");
    return 0;
}