An important functionality of MyClass
is to quickly call a method of one of its members; I try to encouraging inlining of this call. The member is of type Foo
. I wish to hide Foo
by placing its implementation and interface in an anonymous namespace.
Here's how the relevant source and header files are currently set up...
In test.h, I have:
struct Foo;
class MyClass {
public:
void doStuff();
private:
Foo f;
inline unsigned long long int code() { return f.getCode(); }
};
In test.cpp, I have:
namespace
{
struct Foo {
public:
unsigned long long int getCode() {
// ...
}
};
} // end anon namespace
void MyClass::doStuff() {
// do stuff, such as calling code()
}
The problem, of course, is that in the context of the inlined definition of MyClass::code()
, f
is not of a complete type.
Is there any way to hide Foo
while also inlining MyClass::code()
?