5#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MINMAX_ELEMENT_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MINMAX_ELEMENT_HPP_
8#include "arene/base/algorithm/detail/traits.hpp"
10#include "arene/base/functional/detail/operator_less.hpp"
62 class ForwardIterator,
68 arene::base::algorithm_detail::iter_reference_t<ForwardIterator>>>> =
nullptr>
69constexpr auto minmax_element(ForwardIterator first, ForwardIterator last, Compare comp)
noexcept(
70 noexcept(!comp(*first, *first)) &&
71 noexcept(first == first) &&
72 noexcept(first != first) &&
77 std::pair<ForwardIterator, ForwardIterator>,
80) -> std::pair<ForwardIterator, ForwardIterator> {
82 auto result = std::pair<ForwardIterator, ForwardIterator>{first, first};
84 if (first == last || ++first == last) {
88 auto&
min = result.first;
89 auto&
max = result.second;
91 if (comp(*first, *
min)) {
98 auto const update_with_last = [&
min, &
max, &comp](
auto const& iter) {
99 if (comp(*iter, *
min)) {
101 }
else if (!comp(*iter, *
max)) {
108 auto const update_with_next_two = [&
min, &
max, &comp](
auto lower,
auto upper) {
109 if (!comp(*lower, *upper)) {
112 if (comp(*lower, *
min)) {
115 if (!comp(*upper, *
max)) {
120 while (first != last) {
121 auto const iter = first++;
124 update_with_last(iter);
126 update_with_next_two(first, iter);
164 class ForwardIterator,
168 decltype(arene::base::functional_detail::operator_less)&,
169 arene::base::algorithm_detail::iter_reference_t<ForwardIterator>>>> =
nullptr>
170constexpr auto minmax_element(ForwardIterator first, ForwardIterator last)
noexcept(
172) -> std::pair<ForwardIterator, ForwardIterator> {
Public export header for the constraints subpackage.
static ARENE_MAYBE_UNUSED constexpr auto const & swap
A Customization Point Object implementation of the constexpr compatible std::swap from C++17.
Definition swap.hpp:130
constexpr bool is_compare_v
determines if a type satisfies the Compare named requirement
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
constexpr auto disable_constexpr_in_cpp14() noexcept -> void
function used to disable constexpr in C++14 but allow for it in C++17
Definition internal_disable_constexpr_in_cpp14.hpp:23
constexpr auto max(initializer_list< T > list, Compare comp) noexcept(noexcept(comp(std::declval< T & >(), std::declval< T & >())) &&std::is_nothrow_copy_constructible_v< T >) -> T
Returns the largest value in the std::initializer_list.
Definition max_initializer_list_overload.hpp:49
constexpr auto minmax_element(ForwardIterator first, ForwardIterator last, Compare comp) noexcept(noexcept(!comp(*first, *first)) &&//noexcept(first==first) &&//noexcept(first !=first) &&//noexcept(++first) &&//noexcept(first++) &&//std::is_nothrow_copy_assignable_v< ForwardIterator > &&//std::is_nothrow_constructible_v< std::pair< ForwardIterator, ForwardIterator >, ForwardIterator &, ForwardIterator & >) -> std::pair< ForwardIterator, ForwardIterator >
returns the smallest and largest elements in a range
Definition minmax_element.hpp:69
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
constexpr bool is_nothrow_copy_assignable_v
Type trait to detect if an instance of T is copy assignable without throwing.
constexpr bool is_nothrow_constructible_v
Type trait to detect if a type is constructible from arguments of the specified types and is noexcept...
constexpr auto min(initializer_list< T > list, Compare comp) noexcept(noexcept(comp(std::declval< T & >(), std::declval< T & >())) &&std::is_nothrow_copy_constructible_v< T >) -> T
Returns the smallest value in the std::initializer_list.
Definition min_initializer_list_overload.hpp:50