I have a templated class inside a templated class. I can easily implement the member functions inline, but in my specific case I’m running into forward declare problems, so forced to implement it after the declaration — and I realize I’ve forgotten how to do so.
If this small example can be made to compile (without moving the definition inline) my question will be answered:
#include <iostream>
template <typename T, typename V>
struct Outer {
template <int Count>
struct Inner {
void printer() const;
};
};
template <typename T, typename V, int Count>
inline void Outer<T, V>::Inner<Count>::printer() const {
std::cout << "Oh hai. I'm inner<" << Count << ">" << std::endl;
}
int main() {
Outer<int, int>::Inner<3> i;
i.printer();
return 0;
}
Edit: Fixed the unrelated typos that Stuart fix (to help make the answer more clear)
The following compiles and works for me with g++ 4.2.1. (It also compiles with the online Comeau compiler, for what it’s worth.) The key changes are (a) consistently spelling
Outercorrectly, (b) separating out the two sets of template parameters, and (c) changingCountertoCount.