by fytch · 9y ago · 0 comments
https://www.reddit.com/r/cpp/comments/5zzurr/c_value_categor...
int const &f(int const &a) { return a; }
int r = f(3);
Is the value of r implementation-defined according to the standard?I think this is similar to the std::max/std::min stuff
Or have I suddenly gone blind by looking at C++ code one too many times? :)
This is not a problem. The temporary ceases to exist after the function call expression. Copying the return value has to be done before that, otherwise you could never return the value of any local variable.