Long time no write, been busy with my master thesis project for the past few months :)
However, in the final coding stage, I stumbled upon a small problem I can't seem to solve: I get an unresolved external symbol when compiling a class that has a private member function template with the function definition in the .cpp file.
I already know that templates can't be exported and should be placed in the header (!!), but this case is different: The corresponding function is inlined and only used in the corresponding .cpp file.
In particular,
// file.h
class SomeClass
{
template <typename A, typename B>
__forceinline shared_pointer<A> doSomething
(B& b, weak_pointer<T> a);
};
// file.cpp
template <typename A, typename B>
__forceinline shared_pointer<A> SomeClass::doSomething
(B &b, weak_pointer<T> a)
{
// ...
}
shared_pointer<BaseOfA> SomeClass::callMethod()
{
return doSomething(myb, mya); // only use of doSomething here
}
Up to now, I was of the opinion that this is possible in standard C++.
However, I get a linker error (unresolved external symbol) once I include the appropriate .cpp file into compilation. I guess this is a bug (VS2010 SP1) or some cross-influence from another code problem.
Placing the function definition into the header works, but the function is quite intricate, and I'd rather keep it hidden from potential header users.
Up to now, I haven't been able to google up anything relevant...
Ideas / suggestions / known bugs / or should this generally not work ?
Thank you for your time! :)
Cheers,
- Wernaeh












