@Chris-Kawa said in Unnecessary const referencing:
Notice that you're actually doing what I proposed i.e. have an overload for copy and ref variants.
No argument there.
The inlined && forward is just an unrelated complication for style points.
As far as we are talking + 42, if for example the body was something like:
template <typename T> std::remove_reference_t<T> foo1(T&& a) { return smthng(std::forward<T>(a)) + 42; }Where smthng is some other templated nonsense (or simply overloaded), then, I'm sure you'd agree the forward is no longer redundant. :)
Btw. I love how the float version transforms into a fixed point xmm arithmetic with magic constant. Compilers are so smart these days :)
Yeah, true enough. Although you can still catch them missing optimization opportunities from time to time.
@JonB said in Unnecessary const referencing:
Why write this getting-more-complex-all-the-time code if you can ...
What Chris said (... and since this is indeed an academic discussion at this point).