I have one library that declared a template function:
template <typename T>
void Foo(blah...)
{
class Bar mybar;
...
}
class Bar is not defined in this library, but since it's just a template it should not be instantiated at this time; so by explicitly using the class keyword, the library is successfully compiled.
Later in the main program file where I do need to instantiate this template, I included the file with the complete definition of class Bar. It used to work with gcc 4.4.2 but now upgraded to 4.8.1 I am getting the error:
"Foo(blah...) [with T = blahblah]::Bar mybar has incomplete type"
It seems like the compiler treated Bar as a temporary class declaration inside the template function instead of a forwarded class. I'm wondering if there is anything to work around this or this trick is not supposed to work anyhow? The point to do this is, class Bar has a lot of dependencies and most program using my library does not need class Bar, so no point to link all the extra libs that class Bar depends on.
TIA