Delegate to a template that can be called with a const or a non-const instance of Presented
:
class Presented{
public:
Presented() : a(0), b(0.) {}
void bind(Presenter& p){
bindImpl(p, *this);
}
void bind(Presenter& p) const {
bindImpl(p, *this);
}
private:
template<typename P>
static void bindImpl(Presenter& p, P& presented)
{
p.addField(presented.a);
p.addField(presented.b);
}
int a;
double b;
};