what's the difference between

template<typename T>
auto add1(const T& a, const T& b)
{ return a + b; }

and

template<typename T>
auto add2(T a, const T& b)
{ return a += b; }

?

Follow

<type_traits>

static_assert(not std::is_same_v<
decltype(add1( short{1}, short{2} )),
decltype(add2( short{1}, short{2} ))
>);

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.