Check this simple code:
http://dpaste.dzfl.pl/2772c9144f1c

I can't understand how to minimize code duplication for function like get().
Of course on real case body is much bigger and complex than that.

The only way I found is to move the body of function inside a mixin template:

mixin template getterImpl()
{
   auto getterImpl() { /* very long body */ return inner; }
}

and then:

auto get() const { mixin getterImpl; return getterImpl; }
auto get() { mixin getterImpl; return getterImpl; }

Am I missing something? I don't think it's the right way.

Reply via email to