Moving private functions to opaque inner
What triggered me to post it was that I saw in comp.std.c++ a
strange "Proposal: Compilation-unit scoped private member functions"
that received some positive feedback, so may be there is some
market for idiom like that? Idiom (sorry, I do not have name):
// public interface
int PublicGetter() const;
int PublicSetter(int param);
// the place for private member functions,
// so (sometimes annoying) bloat is removed
// only virtuals constructors and operators here
// ... not relevant for example
// member data not moved, this isn't "pimpl"
// private functions of A hidden parameter exposed,
// 7 chars of bloat per signature compare with:
// "int A::PrivateGetter() const"
static int PrivateGetter(A const&x)
// 2 chars of bloat per access
// same here
static int PrivateSetter(A&a,int param)
x.data += param;
int A::PublicGetter() const
// 9 chars of bloat per private call
int A::PublicSetter(int param)
// same here
No differences in efficiency.
Removes most private functions from header.
Makes private calls more visible in code.
Changes in implementation modify header less likely.
May be that ... I do not see something obvious?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]