Hello...
I am writing a templated 'wrapper' class that takes as its template
parameter a class to be inherited from. I need a specialisation of this
wrapper class in certain cases, however I am having trouble with the
specialisation when its parameter is itself a templated class.
The following code compiles with g++ 4.0.3, however Comeau says it's
invalid. Is what I'm trying to do possible in C++, or is there another
way to do the same thing? Thanks...
template<typename A>
struct NoParamBase { };
template<typename A>
struct BaseWithParam {
BaseWithParam(A i) {}
};
template< typename T >
struct Wrapper : public T { };
// This attempted specialisation is the dodgy bit...
template<>
template <typename T>
struct Wrapper<BaseWithParam<T> > : public BaseWithParam<T>
{
Wrapper(T i)
: BaseWithParam<T>(i)
{
}
};
int main()
{
Wrapper<NoParamBase<int> > a;
Wrapper<BaseWithParam<int> > b(1);
return 0;
}