I'm trying to add a partial specialization to a quite complex class. I tried to simplify it already.
Compiler gives the error:
main.cpp:43:39: error: invalid use of incomplete type 'struct Baz' Baz::doSomething(const Foo::type& a)
main.cpp:22:8: note: declaration of 'struct Baz' struct Baz {
I'm constrained in C++ 03, how can I make this right?
#include <iostream>
using namespace std;
struct Foo {
typedef int type;
};
struct Bar {
typedef int type;
};
template <typename A, typename B>
struct Baz {
template <typename V>
struct ReturnType {
typedef typename V::type type;
};
typedef typename ReturnType<B>::type RtType;
RtType doSomething(const typename A::type& a);
};
template <typename A, typename B>
typename Baz<A, B>::RtType
Baz<A, B>::doSomething(const typename A::type &a)
{
cout << "In templated implementation" << endl;
}
//// The above is working fine
//// The below is what I'm trying to specializae, and it doens't work.
template <typename B>
typename Baz<Foo, B>::RtType
Baz<Foo, B>::doSomething(const Foo::type& a)
{
cout << "In partial specialization" << endl;
}
int main()
{
Baz<Foo, Bar> baz;
baz.doSomething(3);
return 0;
}