C ++ 11 was when std::labs and std::llabs were added. This was part of a partial synchronization with the C ++ standard library with the C99 standard library.
In C ++ code, this really is not necessary, because we have had an overload of long std::abs since forever. But if you have C code (which coincidentally also compiles using the C ++ compiler) and it uses labs , you can create it using the compiler and the standard C ++ 11 library.
In retrospect, there is one very useful use case for these functions. And then the attempt to use std::abs ambiguous. For example:
template<typename T> T run_func(T (&f)(T)) { return f({}); }
Then an attempt to call run_func(std::abs); poorly formed. We need to either explicitly specify the template argument, or apply std::abs to the appropriate type. On the other hand, run_func(std::labs); not ambiguous and not too detailed.
However, not too helpful.
StoryTeller Sep 27 '17 at 6:45 2017-09-27 06:45
source share