11#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_EQUAL_HPP_
12#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_EQUAL_HPP_
21#include "arene/base/stdlib_choice/equal_to.hpp"
22#include "arene/base/stdlib_choice/iterator_tags.hpp"
23#include "arene/base/stdlib_choice/iterator_traits.hpp"
24#include "arene/base/stdlib_choice/move.hpp"
29namespace equal_detail {
50template <
typename Itr1,
typename Itr2,
typename BinaryPredicate>
51ARENE_NODISCARD constexpr auto do_equal(Itr1 first_itr, Itr1 first_end, Itr2 second_itr, BinaryPredicate cmp) ->
bool {
52 while (first_itr != first_end) {
53 if (!cmp(*first_itr, *second_itr)) {
81template <
typename Itr1,
typename Itr2,
typename BinaryPredicate>
83 std::input_iterator_tag,
86 std::input_iterator_tag,
91 while (first_itr != first_end && second_itr != second_end) {
92 if (!cmp(*first_itr, *second_itr)) {
98 return first_itr == first_end && second_itr == second_end;
119template <
typename Itr1,
typename Itr2,
typename BinaryPredicate>
121 std::random_access_iterator_tag,
124 std::random_access_iterator_tag,
132 do_equal(first_itr, first_end, second_itr,
std::move(cmp));
153 template <
typename Itr1,
typename Itr2>
154 ARENE_NODISCARD constexpr auto operator()(Itr1 first_start, Itr1 first_end, Itr2 second_start)
const noexcept
156 return (*
this)(first_start, first_end, second_start, std::equal_to<>{});
176 template <
typename Itr1,
typename Itr2,
typename BinaryPredicate>
177 ARENE_NODISCARD constexpr auto operator()(Itr1 first_start, Itr1 first_end, Itr2 second_start, BinaryPredicate cmp)
178 const noexcept ->
bool {
179 return do_equal(first_start, first_end, second_start,
std::move(cmp));
194 template <
typename Itr1,
typename Itr2>
195 ARENE_NODISCARD constexpr auto operator()(Itr1 first_start, Itr1 first_end, Itr2 second_start, Itr2 second_end)
196 const noexcept ->
bool {
197 return (*
this)(first_start, first_end, second_start, second_end, std::equal_to<>{});
216 template <
typename Itr1,
typename Itr2,
typename BinaryPredicate>
218 operator()(Itr1 first_start, Itr1 first_end, Itr2 second_start, Itr2 second_end, BinaryPredicate cmp)
const noexcept
221 typename std::iterator_traits<Itr1>::iterator_category{},
224 typename std::iterator_traits<Itr2>::iterator_category{},
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
Definition accumulate.hpp:37
constexpr auto distance(Iterator first, Iterator last) noexcept(noexcept(distance_impl::do_distance(first, last, typename std::iterator_traits< Iterator >::iterator_category{}))) -> typename std::iterator_traits< Iterator >::difference_type
Find the number of elements between first and last.
Definition distance.hpp:79
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
#define ARENE_NODISCARD
An alias for [[nodiscard]] , or a no-op if the attribute is not supported.
Definition nodiscard.hpp:26