Skip to content

Commit

Permalink
Update single header
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbrindle authored and github-actions[bot] committed Aug 8, 2023
1 parent 8048d83 commit 49c0f3c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions single_include/flux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,39 @@ FLUX_EXPORT inline constexpr auto odd = detail::predicate([](auto const& val) ->

} // namespace pred

namespace cmp {

namespace detail {

struct min_fn {
template <typename T, typename U, typename Cmp = std::ranges::less>
requires std::strict_weak_order<Cmp&, T&, U&>
[[nodiscard]]
constexpr auto operator()(T&& t, U&& u, Cmp cmp = Cmp{}) const
-> std::common_reference_t<T, U>
{
return std::invoke(cmp, u, t) ? FLUX_FWD(u) : FLUX_FWD(t);
}
};

struct max_fn {
template <typename T, typename U, typename Cmp = std::ranges::less>
requires std::strict_weak_order<Cmp&, T&, U&>
[[nodiscard]]
constexpr auto operator()(T&& t, U&& u, Cmp cmp = Cmp{}) const
-> std::common_reference_t<T, U>
{
return !std::invoke(cmp, u, t) ? FLUX_FWD(u) : FLUX_FWD(t);
}
};

} // namespace detail

FLUX_EXPORT inline constexpr auto min = detail::min_fn{};
FLUX_EXPORT inline constexpr auto max = detail::max_fn{};

} // namespace cmp

} // namespace flux

#endif
Expand Down

0 comments on commit 49c0f3c

Please sign in to comment.