In a template, I want to drill down the template parameter to the real non-templated type. So:
template <typename T>
struct MyTemplate
{
// sadly there's no extract_Base
typedef typename extract_base<T>::MyType WorkType;
};
struct X {};
template <typename T> struct Templ {};
//MyTemplate<Templ<X>>::WorkType is X;
//MyTemplate<X>::WorkType is X;
The only solution I see is to define real base type like std::vector<X>::value_type is X. But I am curious if there's a way to do this without defining auxiliary types inside each destination template.
I saw something like http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2965.html but this is draft? and I don't quite get it.
Yes I know there's multiple inheritance, but even for simple case this would be nice.
UPDATE: Nawaz solution works for me very well, and it is easy to extend to specific cases, e.g.
template<template<typename, typename> class X, typename T1, typename T2>
struct extract_base <X<T1, T2>> //specialization
{
typedef T1 base;
};
I can even apply is_base_of or other filters to T1/T2 and so on. So it does work for X<T,U> - at least with g++ 4.6.7.