Sometimes I find myself writing really simple wrappers, where a wrappers method directly corresponds to one method of the adapted class, i.e.:
class ToBeAdapted
{
public:
void a();
void b(int arg);
};
class Wrapper
{
public:
void newA()
{
_adapted.a();
}
void newB(int arg)
{
_adapted.b(arg);
}
private:
ToBeAdapted _adapted;
};
Can this (perhaps with the use of template magic and/or dark preprocessor rituals?) be generalized somewhat, simply to save writing time and make it easier to switch the wrapper interface later?
Something like this would be cool:
wrap_around<ToBeAdapted>(ToBeAdapted::a, newA, ToBeAdapted::b,newB) Wrapper; //Creates the same wrapper class as specified above.
Consider using private inheritance: