Does the C++ standard guarantee that the call
c = std::min(f(x), g(x));
evaluates the functions f and g only once?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. Since std::min is a function, f(x) and g(x) will be evaluated only once. And returned values won’t be copied. See the prototype of the function :
It is a clear difference with preprocessor-genuinely-defined min macro :