What are the best practices to write abbreviated function templates?
I understand, that since C++20, the following is valid code:
void f(auto&& val) {...}
Is it essential to use decltype(auto) as the return type of such functions? In particular, is the following code the right way to write abbreviated function templates?
decltype(auto) f(auto&& val) {return std::forward<decltype(val)>(val+=2);}
- How should I specialize the above function?
//something like this?:
template<> decltype(auto) f<MyClass>(MyClass& val) {...}