How does one avoid code duplication in a snippet code like this: class A{} void foo(const A, void delegate(const A) fn) { // some stuff // ... // ... } void foo(A, void delegate(A) fn) { // exact same stuff, with different qualifiers // ... // ... }