C++20 provides both std::ranges::min() (an overload of which takes an input range and returns the value of the least element) and std::ranges::min_element() (which takes a forward range and returns an iterator to the least element).
In Flux we currently have flux::min() which is the equivalent of the first function, except that we return an optional to avoid UB in the case where the sequence is empty.
We should also provide an equivalent for min_element(), taking a multipass_sequence and returning a cursor to the least element. Because we use the term "element" in Flux to mean a member of a sequence in general, reusing the standard library function name could be confusing, so instead we'll go for find_min() -- which makes it clear that it's returning a cursor, like the rest of the find() family.
Of course, we should have find_max() and find_minmax() (returning a pair of cursors) too.
C++20 provides both
std::ranges::min()
(an overload of which takes an input range and returns the value of the least element) andstd::ranges::min_element()
(which takes a forward range and returns an iterator to the least element).In Flux we currently have
flux::min()
which is the equivalent of the first function, except that we return anoptional
to avoid UB in the case where the sequence is empty.We should also provide an equivalent for
min_element()
, taking amultipass_sequence
and returning a cursor to the least element. Because we use the term "element" in Flux to mean a member of a sequence in general, reusing the standard library function name could be confusing, so instead we'll go forfind_min()
-- which makes it clear that it's returning a cursor, like the rest of thefind()
family.Of course, we should have
find_max()
andfind_minmax()
(returning a pair of cursors) too.Related: #101