#pragma once
template <typename T>
struct TraitsHelper;
template <typename T>
struct TraitsHelper {
static const bool isPointer = false;
enum {IsPointer = false};
bool GetIsPointer()
{
return IsPointer;
}
};
template <typename T>
struct TraitsHelper<T*> {
static const bool isPointer = true;
enum {IsPointer = true};
bool GetIsPointer()
{
return IsPointer;
}
};
//call
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int val = 0;
int* pVal = &val;
TraitsHelper<int> a;
TraitsHelper<int*> b;
bool b1 = a.IsPointer;
bool b2 = b.IsPointer;
bool b3 = a.GetIsPointer();
bool b4 = TraitsHelper<int>::IsPointer;
bool b5 = TraitsHelper<int*>::IsPointer;
return 0;
}