I
Igor R.
Hello,
I'm trying to do the following: if and only if a metafunction is
defined for T, it's defined for wrapper<T> (i.e. for a type dependent
on T).
For some reason the following code is incorrect.
I'd appreciate any comment on this.
template<class T, class Enable = void>
struct metafunc;
template<>
struct metafunc<int>
{
typedef double type;
};
template<class T>
struct wrapper
{
typedef T type;
};
template<typename T>
struct metafunc<wrapper<T>, typename metafunc<T>::type>
{
typedef typename metafunc<T>::type type;
};
int main()
{
metafunc<wrapper<int> >::type t;
}
I'm trying to do the following: if and only if a metafunction is
defined for T, it's defined for wrapper<T> (i.e. for a type dependent
on T).
For some reason the following code is incorrect.
I'd appreciate any comment on this.
template<class T, class Enable = void>
struct metafunc;
template<>
struct metafunc<int>
{
typedef double type;
};
template<class T>
struct wrapper
{
typedef T type;
};
template<typename T>
struct metafunc<wrapper<T>, typename metafunc<T>::type>
{
typedef typename metafunc<T>::type type;
};
int main()
{
metafunc<wrapper<int> >::type t;
}