What I want is for some class members to be sometimes private
and others times public
. These members are supposed to be accessible by some modules and inaccessible by others.
Imaging this class:
class Foo {
public:
...
private:
...
protected:
...
internal:
int x;
};
In module X the internal
is defined as:
#define internal public
and in module Y it's defined as:
#define internal private
So the real question is if this trick is acceptable by the standard or if it will change the signature of the class (or its members) in any way.
I know that friend
and PIMPL
are for this kind of job but friend
can get extremely messy and PIMPL
's performance (an indirection and the fact that you can't inline) are not acceptable for the codebase I'm working on.