Re: Using std::less_equl predicate with std::min()
Vladimir Grigoriev wrote:
int a[] = { 6, 1, 7, 1, 8 };
int *p = std::min_element( a, a + sizeof( a ) / sizeof( *a ),
std::less_equal() );
Use a reverse iterator to search from the end. All search functions =
return
the first match, not the last.
How to use reverse iterators with arrays?
typedef std::reverse_iterator<int*> rev_it;
int a[] = { 6, 1, 7, 1, 8 };
int *p = std::min_element(
rev_it(a + sizeof( a ) / sizeof( *a )), rev_it(a), std::less() =
).base();
Nope, the strict ordering comes from the C++ standard which in turn =
took
it
from the STL. You're barking up the wrong tree. BTW: I'd ask this on
comp.lang.c++.moderated, you have typically more C++ experts there.
Yes, I do not know the standard
You can get a copy of C++98 here:
http://www-d0.fnal.gov/~dladams/cxx_standard.pdf
C++03 here:
http://openassist.googlecode.com/files/C%2B%2B%20Standard%20-%20ANSI%20IS=
O%20IEC%2014882%202003.pdf
and the most recent draft of C++0x here:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf
but I think that strict ordering requirments
is applied not to all algorithms.
Perhaps, but it does apply to std::min and std::min_element.
--
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