I have a doubt about if that approach is possible, lets say you want two ways of calling a function at same time, one is returning an object and the other return by reference in parameter:
// ... template <class T> void func(Foo<T>& f, const T n) { f.a = Something(f.a + n); f.b = Something(f.b + n); } template <class T> Foo<T> func(const Foo<T>& f, const T n) { return Foo<T>( Something(f.a + n), Something(f.b + n) ); } // ... // main Foo<int> foo(1, 1); func(foo, 2); Foo<int> foo2 = func(foo, 2); The const word in first parameter affect the signature of method?