I am trying to make compile time decisions based on whether a struct defines
a member type. It seems to be a job for SFNIAE but I am struggling:
#include <iostream>
#include <cstdlib>
using namespace std;
struct fu { };
struct bar { typedef int type; };
template<typename T, typename U = void>
struct is_true {
static const bool value = false;
};
template<typename T>
struct is_true<T, typename T::type> {
static const bool value = true;
};
int main() {
bool b;
b = is_true<fu>::value;
cout << b << endl;
b = is_true<bar>::value;
cout << b << endl;
system("pause");
};
However, this outputs:
0
0
I am looking at the following:
http://boost-consulting.com/boost/li...enable_if.html
But it doesn't seem to do what it is that I specifically need.
Any help would be greatly appreciated. TIA!
--
Christopher Diggins
http://www.cdiggins.com