You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
These do the same as `min()`/`max()`/`minmax()`, but take multipass sequences and return a cursor to the requisite elements rather than an optional value, returning a past-the-end cursor if the input sequence is empty.
Fixes#112
These do the same as `min()`/`max()`/`minmax()`, but take multipass sequences and return a cursor to the requisite elements rather than an optional value, returning a past-the-end cursor if the input sequence is empty.
Fixes#112
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
The text was updated successfully, but these errors were encountered: