Re: Using std::less_equl predicate with std::min()
Vladimir Grigoriev wrote:
In fact without any serious reason the Microsoft compiler prevents =
from
compiling of a valid code.
Yours is not a valid code, it exhibits undefined behavior. The C++ =
standard requires that the predicate be a strict weak ordering, and =
less_equal isn't.
In my opinion it is one mode serious bug of the
Microsoft compiler.
It's not a bug, it's a feature.
I have not seen any reasonable explanation why this code
may not be compiled.
To be precise, it compiled - it failed at run time. Anyway, MSVC's STL =
implementation is doing you a favor by turning an instance of undefined =
behavior into a hard error, so you can find and fix your bug more =
easily.
It seems that Microsoft inserted this check everywhere
in its library without any thought about consequences
No - it inserted this check _because_ it thought about consequences.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not =
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly overhead. =
-- RFC 1925