I have defined a type trait for to be used with a type defined as an inner class, but could not specialise the template of the trait.
The code below is my problem in its simplest form. It has been tested with gcc 4 (gentoo linux) and a gcc 3 (latest MinGW). It should not compile, just yield an error indicating the type. My intention was that it returned true_type in the compiler's error messages, but it returns false_type.
Code: Select all
struct false_type {};
struct true_type {};
template<typename T> struct trait {
typedef false_type value;
};
template<typename T> struct X {
struct Y {
};
};
template<typename T> struct trait< X<T> > {
typedef true_type value;
};
//template<>
template<typename T> struct trait< typename X<T>::Y > {
typedef true_type value;
};
int main() {
trait< X<int>::Y >::value::error_member;
return 0;
}
Can anyone please help me? This is getting to be the bottleneck in my projects.
I know this is not the most appropriate place to post this, but I could find nowhere else.
Thanks in advance.