microsoft / GSL

Guidelines Support Library
Other
6.11k stars 736 forks source link

make value_or_reference_return_t non-const T or const T& #1123

Closed beinhaerter closed 1 year ago

beinhaerter commented 1 year ago

Returning a const T is not better than returning a T. In fact it is worse because it prevents moving the returned temporary. So let value_or_reference_return_t be either T or const T&, and not const T or const T& (which would be a good match for an in parameter, but not for a return value).

beinhaerter commented 1 year ago

I just saw https://github.com/microsoft/GSL/issues/550#issuecomment-1267448863, so I'll close this PR.