based

Opinionated utility library
git clone git://git.dimitrijedobrota.com/based.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit d85dc077fe9dbbe4c2e7eb1fb693ad9fcd244d5b
parent 6e46d26b128258ef84271466f4631d04ae678d75
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Sun, 27 Apr 2025 21:27:35 +0200

Improve formating, rework type tests to fit

Diffstat:
M .clang-format | ++ --
M example/algorithm.cpp | ++++++++++++++++++ ------
M example/functional.cpp | ++++++++ --
M example/instrumentation.cpp | ++++++++++++ ----
M example/template.cpp | ++++++++++++++++++ -----
M example/type_traits.cpp | +++++++++++++++++ ------
M include/based/algorithm.hpp | ++++++++++++ ------
M include/based/functional.hpp | ++++++++++++++++++++++++++++++ ------------
M include/based/instrumentation.hpp | +++++++++++++++++++++++ ------------------
M include/based/list.hpp | ++ -
M include/based/template.hpp | +++++++++++++++++++ -------------
M include/based/type_traits.hpp | +++ --
M test/source/count_if_n_test.cpp | +++++++++++++++++++++++++++++++++++++ ------------------------
M test/source/count_if_test.cpp | +++++++++++++++++++++++++++++ -----------------
M test/source/count_n_test.cpp | ++++++++++++++++++++++++++++++++ -------------------
M test/source/count_test.cpp | ++++++++++++++++++++++++++ -----------------
M test/source/find_if_unguarded_test.cpp | +++ --
M test/source/find_mismatch_n_test.cpp | ++++++++++++++++++++++++++++++++++++++++++++++++ ----------------------------------
M test/source/find_mismatch_test.cpp | ++++++++++++++++++++++++++++++++++++++++++++++++++ --------------------------------
M test/source/list_test.cpp | +++++++++ ----
M test/source/max_test.cpp | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ----------------------
M test/source/min_test.cpp | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ----------------------
M test/source/string_literal_test.cpp | ++++++++ --

23 files changed, 743 insertions(+), 396 deletions(-)


diff --git a/ .clang-format b/ .clang-format

@@ -2,7 +2,7 @@

Language: Cpp
# BasedOnStyle: Chromium
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignAfterOpenBracket: BlockIndent
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false

@@ -17,7 +17,7 @@ AllowShortEnumsOnASingleLine: false

AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortLambdasOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None

diff --git a/ example/algorithm.cpp b/ example/algorithm.cpp

@@ -10,8 +10,12 @@ int main()

based::count_operations(
16UL,
16UL * 1024 * 1024,
[](const auto& a, const auto& b) { based::min_element(a, b); },
based::normalize_n);
[](const auto& a, const auto& b)
{
based::min_element(a, b);
},
based::normalize_n
);
}

{

@@ -20,8 +24,12 @@ int main()

based::count_operations(
16UL,
16UL * 1024 * 1024,
[](const auto& a, const auto& b) { based::max_element(a, b); },
based::normalize_n);
[](const auto& a, const auto& b)
{
based::max_element(a, b);
},
based::normalize_n
);
}

{

@@ -30,8 +38,12 @@ int main()

based::count_operations(
16UL,
16UL * 1024 * 1024,
[](const auto& a, const auto& b) { based::minmax_element(a, b); },
based::normalize_n);
[](const auto& a, const auto& b)
{
based::minmax_element(a, b);
},
based::normalize_n
);
}

return 0;

diff --git a/ example/functional.cpp b/ example/functional.cpp

@@ -4,8 +4,14 @@


int main()
{
static const auto func = [](int x) { return x != 32 ? 2 * x : 1; };
static const auto pred = [](int /* x */) { return true; };
static const auto func = [](int x)
{
return x != 32 ? 2 * x : 1;
};
static const auto pred = [](int /* x */)
{
return true;
};

std::cout << based::distance(1, 16, func) << '\n';
std::cout << based::power_unary(1, 2, func) << '\n';

diff --git a/ example/instrumentation.cpp b/ example/instrumentation.cpp

@@ -22,8 +22,12 @@ int main()

based::count_operations(
16UL,
16UL * 1024 * 1024,
[](const auto& a, const auto& b) { std::sort(a, b); },
based::normalize_nlogn);
[](const auto& a, const auto& b)
{
std::sort(a, b);
},
based::normalize_nlogn
);
}

{

@@ -32,8 +36,12 @@ int main()

based::count_operations(
16UL,
16UL * 1024 * 1024,
[](const auto& a, const auto& b) { std::stable_sort(a, b); },
based::normalize_nlogn);
[](const auto& a, const auto& b)
{
std::stable_sort(a, b);
},
based::normalize_nlogn
);
}

const reg a(0);

diff --git a/ example/template.cpp b/ example/template.cpp

@@ -5,9 +5,16 @@


int main()
{
const auto l =
based::overload([](const int* i) { std::cout << "i=" << *i << '\n'; },
[](const double* d) { std::cout << "d=" << *d << '\n'; });
const auto l = based::overload {
[](const int* i)
{
std::cout << "i=" << *i << '\n';
},
[](const double* d)
{
std::cout << "d=" << *d << '\n';
}
};

int i = 5;
l(&i);

@@ -16,12 +23,18 @@ int main()

l(&d);

{
const based::Function f = [](int a) { return a + 1; };
const based::Function f = [](int a)
{
return a + 1;
};
std::cout << f(3) << '\n';
}

{
const std::function f = [](int a) { return a + 1; };
const std::function f = [](int a)
{
return a + 1;
};
std::cout << f(3) << '\n';
}

diff --git a/ example/type_traits.cpp b/ example/type_traits.cpp

@@ -98,20 +98,31 @@ int main()

static_assert(based::RegularProcedure<md, double*>);
static_assert(!based::FunctionalProcedure<md>);

static_assert(
based::RegularProcedure<decltype(sub<double, double>), double, double>);

static const auto l1 = [](double a) { return a; };
static_assert(based::RegularProcedure<
decltype(sub<double, double>),
double,
double>);

static const auto l1 = [](double a)
{
return a;
};
static_assert(based::Procedure<decltype(l1), double>);
static_assert(based::RegularProcedure<decltype(l1), double>);
static_assert(based::FunctionalProcedure<decltype(l1), double>);

static const auto l2 = [](irregular /* a */) { return 1; };
static const auto l2 = [](irregular /* a */)
{
return 1;
};
static_assert(!based::Procedure<decltype(l2), irregular>);
static_assert(!based::RegularProcedure<decltype(l2), irregular>);
static_assert(!based::FunctionalProcedure<decltype(l2), irregular>);

static const auto l3 = [](const irregular& /* a */) { return 1; };
static const auto l3 = [](const irregular& /* a */)
{
return 1;
};
static_assert(based::Procedure<decltype(l3), irregular>);
static_assert(!based::RegularProcedure<decltype(l3), irregular>);
static_assert(!based::FunctionalProcedure<decltype(l3), irregular>);

diff --git a/ include/based/algorithm.hpp b/ include/based/algorithm.hpp

@@ -38,7 +38,8 @@ template<BareRegular T, BareRegular U>

decltype(auto) min(T&& lhs, U&& rhs)
{
return based::min(
std::forward<T>(lhs), std::forward<U>(rhs), std::less<bare_t<T>>());
std::forward<T>(lhs), std::forward<U>(rhs), std::less<bare_t<T>>()
);
}

// returns max element, second if equal

@@ -55,7 +56,8 @@ template<BareRegular T, BareRegular U>

decltype(auto) max(T&& lhs, U&& rhs)
{
return based::max(
std::forward<T>(lhs), std::forward<U>(rhs), std::less<bare_t<T>>());
std::forward<T>(lhs), std::forward<U>(rhs), std::less<bare_t<T>>()
);
}

/* ----- Bounded Range Algorithms ----- */

@@ -342,7 +344,8 @@ auto reduce_nonempty(I f, I d, Op op, F fun)


template<Iterator I, UnaryFunction<I> F, BinaryOperation<codomain_t<F, I>> Op>
auto reduce(
I f, I d, Op op, F fun, const decltype(reduce_nonempty(f, d, op, fun))& z)
I f, I d, Op op, F fun, const decltype(reduce_nonempty(f, d, op, fun))& z
)
{
// Precondition: bounded_range(f,d)
// Precondition: partially_associative(op)

@@ -354,7 +357,8 @@ auto reduce(


template<Iterator I, UnaryFunction<I> F, BinaryOperation<codomain_t<F, I>> Op>
auto reduce_nonzero(
I f, I d, Op op, F fun, const decltype(reduce_nonempty(f, d, op, fun))& z)
I f, I d, Op op, F fun, const decltype(reduce_nonempty(f, d, op, fun))& z
)
{
// Precondition: bounded_range(f,d)
// Precondition: partially_associative(op)

@@ -634,7 +638,8 @@ auto find_mismatch_m(I0 f0, I0 d0, I1 f1, iter_dist_t<I1> n1, R r)

template<ReadableIterator I0, ReadableIterator I1, IterRelation<I0> R>
requires BareSameAs<iter_value_t<I0>, iter_value_t<I1>>
auto find_mismatch_n_m(
I0 f0, iter_dist_t<I0> n0, I1 f1, iter_dist_t<I1> n1, R r)
I0 f0, iter_dist_t<I0> n0, I1 f1, iter_dist_t<I1> n1, R r
)
{
// Precondition: readable_weak_range(f0,n0)
// Precondition: readable_weak_range(f1,n1)

@@ -690,7 +695,8 @@ bool increasing_range_n(I f, iter_dist_t<I> n, R r)

// Precondition: readable_bounded_range(f,n)
// Precondition: weak_ordering(r);
return relation_preserving_n(
f, n, complement_of_converse<iter_value_t<I>>(r));
f, n, complement_of_converse<iter_value_t<I>>(r)
);
}

/* ----- Sentinel Ranges ----- */

diff --git a/ include/based/functional.hpp b/ include/based/functional.hpp

@@ -84,9 +84,9 @@ bool connection_point(const T& x, F f, P p)

}

template<typename T, Transformation<T> F, UnaryPredicate<T> P>
std::tuple<distance_t<F>, distance_t<F>, T> orbit_structure(const T& x,
F f,
P p)
std::tuple<distance_t<F>, distance_t<F>, T> orbit_structure(
const T& x, F f, P p
)
{
// Precondition: p(x) <=> F(x) is defined
const auto y = connection_point(x, f, p);

@@ -197,11 +197,14 @@ T power(T a, I n, Op op, T id)

}

template<Integer I>
std::pair<I, I> fibonacci_matrix_multiply(const std::pair<I, I>& x,
const std::pair<I, I>& y)
std::pair<I, I> fibonacci_matrix_multiply(
const std::pair<I, I>& x, const std::pair<I, I>& y
)
{
return {(x.first * (y.first + y.second)) + (x.second * y.first),
(x.first * y.first) + (x.second * y.second)};
return {
(x.first * (y.first + y.second)) + (x.second * y.first),
(x.first * y.first) + (x.second * y.second)
};
}

template<Integer I>

@@ -217,31 +220,46 @@ I fibonacci(I n)

template<typename T, Relation<T> R>
auto complement(R r)
{
return [=](const T& a, const T& b) { return !r(a, b); };
return [=](const T& a, const T& b)
{
return !r(a, b);
};
}

template<typename T, Relation<T> R>
auto converse(R r)
{
return [=](const T& a, const T& b) { return r(b, a); };
return [=](const T& a, const T& b)
{
return r(b, a);
};
}

template<typename T, Relation<T> R>
auto complement_of_converse(R r)
{
return [=](const T& a, const T& b) { return !r(b, a); };
return [=](const T& a, const T& b)
{
return !r(b, a);
};
}

template<typename T, Relation<T> R>
auto lower_bound_predicate(const T& a, R r)
{
return [=](const T& x) { return !r(x, a); };
return [=](const T& x)
{
return !r(x, a);
};
}

template<typename T, Relation<T> R>
auto upper_bound_predicate(const T& a, R r)
{
return [=](const T& x) { return r(a, x); };
return [=](const T& x)
{
return r(a, x);
};
}

} // namespace based

diff --git a/ include/based/instrumentation.hpp b/ include/based/instrumentation.hpp

@@ -74,18 +74,20 @@ inline auto normalize_nlogn1(double x, double n)


struct instrumented_base
{
BASED_ENUM(op,
std::uint8_t,
n,
ctor_default,
ctor_value,
ctor_copy,
ctor_move,
asgn_copy,
asgn_move,
destructor,
equality,
comparison)
BASED_ENUM(
op,
std::uint8_t,
n,
ctor_default,
ctor_value,
ctor_copy,
ctor_move,
asgn_copy,
asgn_move,
destructor,
equality,
comparison
)

static constexpr std::array<const char*, op::size> names = {
"n",

@@ -257,10 +259,12 @@ template<typename D>

D* registry<D>::head(nullptr);

template<typename Function>
void count_operations(size_t i,
size_t j,
Function fun,
double (*norm)(double, double) = dont_normalize)
void count_operations(
size_t i,
size_t j,
Function fun,
double (*norm)(double, double) = dont_normalize
)
{
using instrumented = based::instrumented<double>;

@@ -270,8 +274,9 @@ void count_operations(size_t i,

std::array<double, cols> values = {0};

table tbl(12);
tbl.print_header(std::begin(instrumented::names),
std::end(instrumented::names));
tbl.print_header(
std::begin(instrumented::names), std::end(instrumented::names)
);

std::mt19937 rng(0); // NOLINT cert-msc32-c cert-msc51-cpp
while (i <= j) {

diff --git a/ include/based/list.hpp b/ include/based/list.hpp

@@ -123,7 +123,8 @@ public:


list_type free(
list_type front, // NOLINT bugprone-easily-swappable-parameters
list_type back)
list_type back
)
{
if (is_empty(front)) {
return node_empty();

diff --git a/ include/based/template.hpp b/ include/based/template.hpp

@@ -235,8 +235,9 @@ struct Buffer


template<typename T, typename... Args>
requires(valid_type<T>() && std::constructible_from<T, Args...>)
explicit Buffer(std::in_place_type_t<T> /* t */, Args&&... args) noexcept(
std::is_nothrow_constructible_v<T, Args...>)
explicit Buffer(
std::in_place_type_t<T> /* t */, Args&&... args
) noexcept(std::is_nothrow_constructible_v<T, Args...>)
{
static_assert(std::is_trivially_destructible_v<T>);
static_assert(std::is_trivially_copyable_v<T>);

@@ -245,8 +246,8 @@ struct Buffer


template<typename T, typename... Args>
requires(valid_type<T>() && std::constructible_from<T, Args...>)
T* emplace(Args&&... args) noexcept(
std::is_nothrow_constructible_v<T, Args...>)
T* emplace(Args&&... args
) noexcept(std::is_nothrow_constructible_v<T, Args...>)
{
static_assert(std::is_trivially_destructible_v<T>);
static_assert(std::is_trivially_copyable_v<T>);

@@ -294,10 +295,11 @@ overload(F&&...) -> overload<F...>;

template<typename Signature, std::size_t Size = 16, std::size_t Alignment = 8>
class Function;

template<std::size_t Size,
std::size_t Alignment,
typename Res,
typename... Args>
template<
std::size_t Size,
std::size_t Alignment,
typename Res,
typename... Args>
class Function<Res(Args...), Size, Alignment>
{
Buffer<Size, Alignment> m_space;

@@ -317,7 +319,8 @@ class Function<Res(Args...), Size, Alignment>

{
return std::invoke(
*static_cast<Function*>(func)->m_space.template as<Callable>(),
std::forward<Args>(args)...);
std::forward<Args>(args)...
);
}

public:

@@ -333,8 +336,9 @@ public:

})

Function(CallableArg&& callable) // NOLINT *explicit
: m_space(std::in_place_type<Callable>,
std::forward<CallableArg>(callable))
: m_space(
std::in_place_type<Callable>, std::forward<CallableArg>(callable)
)
, m_executor(executor<Callable>)
{
}

@@ -342,8 +346,10 @@ public:

template<typename... CallArgs>
Res operator()(CallArgs&&... callargs) const
{
return this->m_executor(std::forward<CallArgs>(callargs)...,
const_cast<Function*>(this)); // NOLINT *const_cast
return this->m_executor(
std::forward<CallArgs>(callargs)...,
const_cast<Function*>(this) // NOLINT *const_cast
);
}
};

diff --git a/ include/based/type_traits.hpp b/ include/based/type_traits.hpp

@@ -221,8 +221,9 @@ concept UnaryPredicate = requires {

template<typename P, typename... Args>
concept Operation = requires {
requires(HomogeneousFunction<P, Args...>);
requires(BareSameAs<codomain_t<P, Args...>,
std::tuple_element_t<0, std::tuple<Args...>>>);
requires(BareSameAs<
codomain_t<P, Args...>,
std::tuple_element_t<0, std::tuple<Args...>>>);
};

template<typename P, typename Arg>

diff --git a/ test/source/count_if_n_test.cpp b/ test/source/count_if_n_test.cpp

@@ -21,18 +21,26 @@ TEST_CASE("count_if_n return type", "[algorithm/count_if_n]")

{
const std::array<int, 0> arr = {};

REQUIRE(
based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_if_n(
std::begin(arr), std::size(arr), predicate {0})
.second)>);

REQUIRE(based::SameAs<std::uint8_t,
decltype(based::count_if_n(std::begin(arr),
std::size(arr),
predicate {0},
std::uint8_t {0})
.second)>);
SECTION("auto counter")
{
using res_t = decltype(based::count_if_n(
std::begin(arr), std::size(arr), predicate {0}
)
.second);
REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>, res_t>);
}

SECTION("explicit counter")
{
using res_t = decltype(based::count_if_n(
std::begin(arr),
std::size(arr),
predicate {0},
std::uint8_t {0}
)
.second);
REQUIRE(based::SameAs<std::uint8_t, res_t>);
}
}

TEST_CASE("count_if_n(empty)", "[algorithm/count_if_n]")

@@ -90,18 +98,23 @@ TEST_CASE("count_if_not_n return type", "[algorithm/count_if_not_n]")

{
const std::array<int, 0> arr = {};

REQUIRE(
based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_if_not_n(
std::begin(arr), std::size(arr), predicate {0})
.second)>);

REQUIRE(based::SameAs<std::uint8_t,
decltype(based::count_if_not_n(std::begin(arr),
std::size(arr),
predicate {0},
std::uint8_t {0})
.second)>);
SECTION("auto counter")
{
using res_t = decltype(based::count_if_not_n(
std::begin(arr), std::size(arr), predicate {0}
));
REQUIRE(based::SameAs<
based::iter_dist_t<decltype(arr)::iterator>,
res_t::second_type>);
}

SECTION("explicit counter")
{
using res_t = decltype(based::count_if_not_n(
std::begin(arr), std::size(arr), predicate {0}, std::uint8_t {0}
));
REQUIRE(based::SameAs<std::uint8_t, res_t::second_type>);
}
}

TEST_CASE("count_if_not_n(empty)", "[algorithm/count_if_not_n]")

diff --git a/ test/source/count_if_test.cpp b/ test/source/count_if_test.cpp

@@ -21,15 +21,21 @@ TEST_CASE("count_if return type", "[algorithm/count_if]")

{
const std::array<int, 0> arr = {};

REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_if(
std::begin(arr), std::end(arr), predicate {0}))>);

REQUIRE(based::SameAs<std::uint8_t,
decltype(based::count_if(std::begin(arr),
std::end(arr),
predicate {0},
std::uint8_t {0}))>);
SECTION("auto counter")
{
using res_t =
decltype(based::count_if(std::begin(arr), std::end(arr), predicate {0})
);
REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>, res_t>);
}

SECTION("explicit counter")
{
using res_t = decltype(based::count_if(
std::begin(arr), std::end(arr), predicate {0}, std::uint8_t {0}
));
REQUIRE(based::SameAs<std::uint8_t, res_t>);
}
}

TEST_CASE("count_if(empty)", "[algorithm/count_if]")

@@ -75,15 +81,21 @@ TEST_CASE("count_if_not return type", "[algorithm/count_if_not]")

{
const std::array<int, 0> arr = {};

REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_if_not(
std::begin(arr), std::end(arr), predicate {0}))>);
SECTION("auto counter")
{
using res_t = decltype(based::count_if_not(
std::begin(arr), std::end(arr), predicate {0}
));
REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>, res_t>);
}

REQUIRE(based::SameAs<std::uint8_t,
decltype(based::count_if_not(std::begin(arr),
std::end(arr),
predicate {0},
std::uint8_t {0}))>);
SECTION("explicit counter")
{
using res_t = decltype(based::count_if_not(
std::begin(arr), std::end(arr), predicate {0}, std::uint8_t {0}
));
REQUIRE(based::SameAs<std::uint8_t, res_t>);
}
}

TEST_CASE("count_if_not(empty)", "[algorithm/count_if_not]")

diff --git a/ test/source/count_n_test.cpp b/ test/source/count_n_test.cpp

@@ -9,15 +9,22 @@ TEST_CASE("count_n return type", "[algorithm/count_n]")

{
const std::array<int, 0> arr = {};

REQUIRE(based::SameAs<
based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_n(std::begin(arr), std::size(arr), 0).second)>);

REQUIRE(based::SameAs<
std::uint8_t,
decltype(based::count_n(
std::begin(arr), std::size(arr), 0, std::uint8_t {0})
.second)>);
SECTION("auto counter")
{
using res_t =
decltype(based::count_n(std::begin(arr), std::size(arr), 0).second);
REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>, res_t>);
}

SECTION("explicit counter")
{
using res_t =
decltype(based::count_n(
std::begin(arr), std::size(arr), 0, std::uint8_t {0}
)
.second);
REQUIRE(based::SameAs<std::uint8_t, res_t>);
}
}

TEST_CASE("count_n(empty)", "[algorithm/count_n]")

@@ -74,16 +81,22 @@ TEST_CASE("count_not_n return type", "[algorithm/count_not_n]")

{
const std::array<int, 0> arr = {};

REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_not_n(
std::begin(arr), std::size(arr), 0)
.second)>);

REQUIRE(based::SameAs<
std::uint8_t,
decltype(based::count_not_n(
std::begin(arr), std::size(arr), 0, std::uint8_t {0})
.second)>);
SECTION("auto counter")
{
using res_t =
decltype(based::count_not_n(std::begin(arr), std::size(arr), 0));
REQUIRE(based::SameAs<
based::iter_dist_t<decltype(arr)::iterator>,
res_t::second_type>);
}

SECTION("explicit counter")
{
using res_t = decltype(based::count_not_n(
std::begin(arr), std::size(arr), 0, std::uint8_t {0}
));
REQUIRE(based::SameAs<std::uint8_t, res_t::second_type>);
}
}

TEST_CASE("count_not_n(empty)", "[algorithm/count_not_n]")

diff --git a/ test/source/count_test.cpp b/ test/source/count_test.cpp

@@ -9,14 +9,19 @@ TEST_CASE("count return type", "[algorithm/count]")

{
const std::array<int, 0> arr = {};

REQUIRE(
based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count(std::begin(arr), std::end(arr), 0))>);

REQUIRE(
based::SameAs<std::uint8_t,
decltype(based::count(
std::begin(arr), std::end(arr), 0, std::uint8_t {0}))>);
SECTION("auto counter")
{
using res_t = decltype(based::count(std::begin(arr), std::end(arr), 0));
REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>, res_t>);
}

SECTION("explicit counter")
{
using res_t = decltype(based::count(
std::begin(arr), std::end(arr), 0, std::uint8_t {0}
));
REQUIRE(based::SameAs<std::uint8_t, res_t>);
}
}

TEST_CASE("count(empty)", "[algorithm/count]")

@@ -34,7 +39,6 @@ TEST_CASE("count(homogeneous)", "[algorithm/count]")


const auto count0 = based::count(std::begin(arr), std::end(arr), 0);
const auto count1 = based::count(std::begin(arr), std::end(arr), 1);

REQUIRE(count0 == 0);
REQUIRE(count1 == 6);
}

@@ -56,14 +60,19 @@ TEST_CASE("count_not return type", "[algorithm/count_not]")

{
const std::array<int, 0> arr = {};

REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>,
decltype(based::count_not(
std::begin(arr), std::end(arr), 0))>);

REQUIRE(
based::SameAs<std::uint8_t,
decltype(based::count_not(
std::begin(arr), std::end(arr), 0, std::uint8_t {0}))>);
SECTION("auto counter")
{
using res_t = decltype(based::count_not(std::begin(arr), std::end(arr), 0));
REQUIRE(based::SameAs<based::iter_dist_t<decltype(arr)::iterator>, res_t>);
}

SECTION("explicit counter")
{
using res_t = decltype(based::count_not(
std::begin(arr), std::end(arr), 0, std::uint8_t {0}
));
REQUIRE(based::SameAs<std::uint8_t, res_t>);
}
}

TEST_CASE("count_not(empty)", "[algorithm/count_not]")

diff --git a/ test/source/find_if_unguarded_test.cpp b/ test/source/find_if_unguarded_test.cpp

@@ -63,8 +63,9 @@ TEST_CASE("find_if_not_unguarded(two)", "[algorithm/find_if_not_unguarded]")

REQUIRE(idx == 1);
}

TEST_CASE("find_if_not_unguarded(multiple)",
"[algorithm/find_if_not_unguarded]")
TEST_CASE(
"find_if_not_unguarded(multiple)", "[algorithm/find_if_not_unguarded]"
)
{
const std::array arr = {1, 1, 0, 1};

diff --git a/ test/source/find_mismatch_n_test.cpp b/ test/source/find_mismatch_n_test.cpp

@@ -14,11 +14,13 @@ TEST_CASE("find_mismatch_n(empty)", "[algorithm/find_mismatch_n]")

std::array<int, 0> arr0 = {};
std::array<int, 0> arr1 = {};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -31,11 +33,13 @@ TEST_CASE("find_mismatch_n(empty, nonempty)", "[algorithm/find_mismatch_n]")

std::array<int, 0> arr0 = {};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -48,11 +52,13 @@ TEST_CASE("find_mismatch_n(nonempty, empty)", "[algorithm/find_mismatch_n]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array<int, 0> arr1 = {};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::begin(arr0));
REQUIRE(n0 == std::size(arr0));

@@ -65,11 +71,13 @@ TEST_CASE("find_mismatch_n(equal)", "[algorithm/find_mismatch_n]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -82,11 +90,13 @@ TEST_CASE("find_mismatch_n(equal, longer)", "[algorithm/find_mismatch_n]")

std::array arr0 = {0, 1, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -99,11 +109,13 @@ TEST_CASE("find_mismatch_n(longer, equal)", "[algorithm/find_mismatch_n]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), std::size(arr1)));
REQUIRE(n0 == 2);

@@ -116,11 +128,13 @@ TEST_CASE("find_mismatch_n(mismatch)", "[algorithm/find_mismatch_n]")

std::array arr0 = {0, 1, 4, 3, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1] = based::find_mismatch_n(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, n0, itr1] = based::find_mismatch_n(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), 2));
REQUIRE(n0 == 3);

@@ -133,11 +147,13 @@ TEST_CASE("find_mismatch_m(empty)", "[algorithm/find_mismatch_m]")

std::array<int, 0> arr0 = {};
std::array<int, 0> arr1 = {};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));

@@ -150,11 +166,13 @@ TEST_CASE("find_mismatch_m(empty, nonempty)", "[algorithm/find_mismatch_m]")

std::array<int, 0> arr0 = {};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));

@@ -167,11 +185,13 @@ TEST_CASE("find_mismatch_m(nonempty, empty)", "[algorithm/find_mismatch_m]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array<int, 0> arr1 = {};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::begin(arr0));

@@ -184,11 +204,13 @@ TEST_CASE("find_mismatch_m(equal)", "[algorithm/find_mismatch_m]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));

@@ -201,11 +223,13 @@ TEST_CASE("find_mismatch_m(equal, longer)", "[algorithm/find_mismatch_m]")

std::array arr0 = {0, 1, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));

@@ -218,11 +242,13 @@ TEST_CASE("find_mismatch_m(longer, equal)", "[algorithm/find_mismatch_m]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), std::size(arr1)));

@@ -235,11 +261,13 @@ TEST_CASE("find_mismatch_m(mismatch)", "[algorithm/find_mismatch_m]")

std::array arr0 = {0, 1, 4, 3, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1, n1] = based::find_mismatch_m(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, itr1, n1] = based::find_mismatch_m(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), 2));

@@ -252,11 +280,13 @@ TEST_CASE("find_mismatch_n_m(empty)", "[algorithm/find_mismatch_n_m]")

std::array<int, 0> arr0 = {};
std::array<int, 0> arr1 = {};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -270,11 +300,13 @@ TEST_CASE("find_mismatch_n_m(empty, nonempty)", "[algorithm/find_mismatch_n_m]")

std::array<int, 0> arr0 = {};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -288,11 +320,13 @@ TEST_CASE("find_mismatch_n_m(nonempty, empty)", "[algorithm/find_mismatch_n_m]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array<int, 0> arr1 = {};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::begin(arr0));
REQUIRE(n0 == std::size(arr0));

@@ -306,11 +340,13 @@ TEST_CASE("find_mismatch_n_m(equal)", "[algorithm/find_mismatch_n_m]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -324,11 +360,13 @@ TEST_CASE("find_mismatch_n_m(equal, longer)", "[algorithm/find_mismatch_n_m]")

std::array arr0 = {0, 1, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(n0 == 0);

@@ -342,11 +380,13 @@ TEST_CASE("find_mismatch_n_m(longer, equal)", "[algorithm/find_mismatch_n_m]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), std::size(arr1)));
REQUIRE(n0 == 2);

@@ -360,11 +400,13 @@ TEST_CASE("find_mismatch_n_m(mismatch)", "[algorithm/find_mismatch_n_m]")

std::array arr0 = {0, 1, 4, 3, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {});
const auto [itr0, n0, itr1, n1] = based::find_mismatch_n_m(
std::begin(arr0),
std::size(arr0),
std::begin(arr1),
std::size(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), 2));
REQUIRE(n0 == 3);

diff --git a/ test/source/find_mismatch_test.cpp b/ test/source/find_mismatch_test.cpp

@@ -14,11 +14,13 @@ TEST_CASE("find_mismatch(empty)", "[algorithm/find_mismatch]")

std::array<int, 0> arr0 = {};
std::array<int, 0> arr1 = {};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(itr1 == std::end(arr1));

@@ -29,11 +31,13 @@ TEST_CASE("find_mismatch(empty, nonempty)", "[algorithm/find_mismatch]")

std::array<int, 0> arr0 = {};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(itr1 == std::begin(arr1));

@@ -44,11 +48,13 @@ TEST_CASE("find_mismatch(nonempty, empty)", "[algorithm/find_mismatch]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array<int, 0> arr1 = {};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::begin(arr0));
REQUIRE(itr1 == std::end(arr1));

@@ -59,11 +65,13 @@ TEST_CASE("find_mismatch(equal)", "[algorithm/find_mismatch]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(itr1 == std::end(arr1));

@@ -74,11 +82,13 @@ TEST_CASE("find_mismatch(equal, longer)", "[algorithm/find_mismatch]")

std::array arr0 = {0, 1, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::end(arr0));
REQUIRE(itr1 == std::next(std::begin(arr1), std::size(arr0)));

@@ -89,11 +99,13 @@ TEST_CASE("find_mismatch(longer, equal)", "[algorithm/find_mismatch]")

std::array arr0 = {0, 1, 2, 3, 4};
std::array arr1 = {0, 1, 2};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), std::size(arr1)));
REQUIRE(itr1 == std::end(arr1));

@@ -104,11 +116,13 @@ TEST_CASE("find_mismatch(mismatch)", "[algorithm/find_mismatch]")

std::array arr0 = {0, 1, 4, 3, 2};
std::array arr1 = {0, 1, 2, 3, 4};

const auto [itr0, itr1] = based::find_mismatch(std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {});
const auto [itr0, itr1] = based::find_mismatch(
std::begin(arr0),
std::end(arr0),
std::begin(arr1),
std::end(arr1),
equal {}
);

REQUIRE(itr0 == std::next(std::begin(arr0), 2));
REQUIRE(itr1 == std::next(std::begin(arr1), 2));

@@ -134,8 +148,9 @@ TEST_CASE("find_adjacent_mismatch(one)", "[algorithm/find_adjacent_mismatch]")

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch(two equal)",
"[algorithm/find_adjacent_mismatch]")
TEST_CASE(
"find_adjacent_mismatch(two equal)", "[algorithm/find_adjacent_mismatch]"
)
{
std::array arr = {0, 0};

@@ -145,8 +160,9 @@ TEST_CASE("find_adjacent_mismatch(two equal)",

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch(two nonequal)",
"[algorithm/find_adjacent_mismatch]")
TEST_CASE(
"find_adjacent_mismatch(two nonequal)", "[algorithm/find_adjacent_mismatch]"
)
{
std::array arr = {0, 1};

@@ -166,8 +182,9 @@ TEST_CASE("find_adjacent_mismatch(equal)", "[algorithm/find_adjacent_mismatch]")

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch(nonequal)",
"[algorithm/find_adjacent_mismatch]")
TEST_CASE(
"find_adjacent_mismatch(nonequal)", "[algorithm/find_adjacent_mismatch]"
)
{
std::array arr = {0, 0, 0, 0, 1, 1, 1, 1};

@@ -177,68 +194,86 @@ TEST_CASE("find_adjacent_mismatch(nonequal)",

REQUIRE(itr == std::next(std::begin(arr), 4));
}

TEST_CASE("find_adjacent_mismatch_forward(empty)",
"[algorithm/find_adjacent_mismatch_forward]")
TEST_CASE(
"find_adjacent_mismatch_forward(empty)",
"[algorithm/find_adjacent_mismatch_forward]"
)
{
std::array<int, 0> arr = {};

const auto* itr = based::find_adjacent_mismatch_forward(
std::begin(arr), std::end(arr), equal {});
std::begin(arr), std::end(arr), equal {}
);

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch_forward(one)",
"[algorithm/find_adjacent_mismatch_forward]")
TEST_CASE(
"find_adjacent_mismatch_forward(one)",
"[algorithm/find_adjacent_mismatch_forward]"
)
{
std::array arr = {0};

const auto* itr = based::find_adjacent_mismatch_forward(
std::begin(arr), std::end(arr), equal {});
std::begin(arr), std::end(arr), equal {}
);

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch_forward(two equal)",
"[algorithm/find_adjacent_mismatch_forward]")
TEST_CASE(
"find_adjacent_mismatch_forward(two equal)",
"[algorithm/find_adjacent_mismatch_forward]"
)
{
std::array arr = {0, 0};

const auto* itr = based::find_adjacent_mismatch_forward(
std::begin(arr), std::end(arr), equal {});
std::begin(arr), std::end(arr), equal {}
);

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch_forward(two nonequal)",
"[algorithm/find_adjacent_mismatch_forward]")
TEST_CASE(
"find_adjacent_mismatch_forward(two nonequal)",
"[algorithm/find_adjacent_mismatch_forward]"
)
{
std::array arr = {0, 1};

const auto* itr = based::find_adjacent_mismatch_forward(
std::begin(arr), std::end(arr), equal {});
std::begin(arr), std::end(arr), equal {}
);

REQUIRE(itr == std::next(std::begin(arr), 1));
}

TEST_CASE("find_adjacent_mismatch_forward(equal)",
"[algorithm/find_adjacent_mismatch_forward]")
TEST_CASE(
"find_adjacent_mismatch_forward(equal)",
"[algorithm/find_adjacent_mismatch_forward]"
)
{
std::array arr = {0, 0, 0, 0, 0, 0};

const auto* itr = based::find_adjacent_mismatch_forward(
std::begin(arr), std::end(arr), equal {});
std::begin(arr), std::end(arr), equal {}
);

REQUIRE(itr == std::end(arr));
}

TEST_CASE("find_adjacent_mismatch_forward(nonequal)",
"[algorithm/find_adjacent_mismatch_forward]")
TEST_CASE(
"find_adjacent_mismatch_forward(nonequal)",
"[algorithm/find_adjacent_mismatch_forward]"
)
{
std::array arr = {0, 0, 0, 0, 1, 1, 1, 1};

const auto* itr = based::find_adjacent_mismatch_forward(
std::begin(arr), std::end(arr), equal {});
std::begin(arr), std::end(arr), equal {}
);

REQUIRE(itr == std::next(std::begin(arr), 4));
}

diff --git a/ test/source/list_test.cpp b/ test/source/list_test.cpp

@@ -82,10 +82,15 @@ TEST_CASE("list_pool iterator", "[list/list_pool/iterator]")


SECTION("accumulate")
{
const auto sum = std::accumulate(iter(pool, head),
iter(pool),
std::uint64_t {0},
[](auto a, auto b) { return a + b; });
const auto sum = std::accumulate(
iter(pool, head),
iter(pool),
std::uint64_t {0},
[](auto a, auto b)
{
return a + b;
}
);

REQUIRE(sum == 0xFF * 0xFE / 2);
}

diff --git a/ test/source/max_test.cpp b/ test/source/max_test.cpp

@@ -4,41 +4,51 @@


TEST_CASE("max(literal, literal) = right", "[algorithm/max]")
{
REQUIRE(std::same_as<int&&, decltype(based::max(3, 4))>);
using res_t = decltype(based::max(3, 4));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(3, 4) == 4);
}

TEST_CASE("max(literal, literal) = left", "[algorithm/max]")
{
REQUIRE(std::same_as<int&&, decltype(based::max(4, 3))>);
using res_t = decltype(based::max(4, 3));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(4, 3) == 4);
}

TEST_CASE("max(value, literal) = right", "[algorithm/max]")
{
int a = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::max(a, 4))>);

using res_t = decltype(based::max(a, 4));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, 4) == 4);
}

TEST_CASE("max(value, literal) = left", "[algorithm/max]")
{
int a = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::max(a, 3))>);

using res_t = decltype(based::max(a, 3));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, 3) == 4);
}

TEST_CASE("max(literal, value) = right", "[algorithm/max]")
{
int b = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::max(3, b))>);

using res_t = decltype(based::max(3, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(3, b) == 4);
}

TEST_CASE("max(literal, value) = left", "[algorithm/max]")
{
int b = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::max(4, b))>);

using res_t = decltype(based::max(4, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(4, b) == 4);
}

@@ -46,7 +56,9 @@ TEST_CASE("max(value, value) = right", "[algorithm/max]")

{
int a = 3;
int b = 4;
REQUIRE(std::same_as<int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -54,35 +66,45 @@ TEST_CASE("max(value, value) = left", "[algorithm/max]")

{
int a = 4;
int b = 3;
REQUIRE(std::same_as<int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

TEST_CASE("max(const value, literal) = right", "[algorithm/max]")
{
const int a = 3;
REQUIRE(std::same_as<int, decltype(based::max(a, 4))>);

using res_t = decltype(based::max(a, 4));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, 4) == 4);
}

TEST_CASE("max(const value, literal) = left", "[algorithm/max]")
{
const int a = 4;
REQUIRE(std::same_as<int, decltype(based::max(a, 3))>);

using res_t = decltype(based::max(a, 3));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, 3) == 4);
}

TEST_CASE("max(literal, const value) = right", "[algorithm/max]")
{
const int b = 4;
REQUIRE(std::same_as<int, decltype(based::max(3, b))>);

using res_t = decltype(based::max(3, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(3, b) == 4);
}

TEST_CASE("max(literal, const value) = left", "[algorithm/max]")
{
const int b = 3;
REQUIRE(std::same_as<int, decltype(based::max(4, b))>);

using res_t = decltype(based::max(4, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(4, b) == 4);
}

@@ -90,7 +112,9 @@ TEST_CASE("max(const value, const value) = right", "[algorithm/max]")

{
const int a = 3;
const int b = 4;
REQUIRE(std::same_as<const int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -98,7 +122,9 @@ TEST_CASE("max(const value, const value) = left", "[algorithm/max]")

{
const int a = 4;
const int b = 3;
REQUIRE(std::same_as<const int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -106,7 +132,9 @@ TEST_CASE("max(value, const value) = right", "[algorithm/max]")

{
int a = 3; // NOLINT misc-const-correctness
const int b = 4;
REQUIRE(std::same_as<const int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -114,7 +142,9 @@ TEST_CASE("max(value, const value) = left", "[algorithm/max]")

{
int a = 4; // NOLINT misc-const-correctness
const int b = 3;
REQUIRE(std::same_as<const int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -122,7 +152,9 @@ TEST_CASE("max(const value, value) = right", "[algorithm/max]")

{
const int a = 3;
int b = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<const int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -130,7 +162,9 @@ TEST_CASE("max(const value, value) = left", "[algorithm/max]")

{
const int a = 4;
int b = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<const int&, decltype(based::max(a, b))>);

using res_t = decltype(based::max(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::max(a, b) == 4);
}

@@ -139,14 +173,18 @@ TEST_CASE("max(const value, value) = left", "[algorithm/max]")

TEST_CASE("max(move, literal) = right", "[algorithm/max]")
{
int a = 3;
REQUIRE(std::same_as<int&&, decltype(based::max(std::move(a), 4))>);

using res_t = decltype(based::max(std::move(a), 4));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(std::move(a), 4) == 4);
}

TEST_CASE("max(move, literal) = left", "[algorithm/max]")
{
int a = 4;
REQUIRE(std::same_as<int&&, decltype(based::max(std::move(a), 3))>);

using res_t = decltype(based::max(std::move(a), 3));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(std::move(a), 3) == 4);
}

@@ -154,7 +192,9 @@ TEST_CASE("max(move, value) = right", "[algorithm/max]")

{
int a = 3;
int b = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::max(std::move(a), b))>);

using res_t = decltype(based::max(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(std::move(a), b) == 4);
}

@@ -162,7 +202,9 @@ TEST_CASE("max(move, value) = left", "[algorithm/max]")

{
int a = 4;
int b = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::max(std::move(a), b))>);

using res_t = decltype(based::max(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(std::move(a), b) == 4);
}

@@ -170,7 +212,9 @@ TEST_CASE("max(move, const value) = right", "[algorithm/max]")

{
int a = 3;
const int b = 4;
REQUIRE(std::same_as<int, decltype(based::max(std::move(a), b))>);

using res_t = decltype(based::max(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(std::move(a), b) == 4);
}

@@ -178,21 +222,27 @@ TEST_CASE("max(move, const value) = left", "[algorithm/max]")

{
int a = 4;
const int b = 3;
REQUIRE(std::same_as<int, decltype(based::max(std::move(a), b))>);

using res_t = decltype(based::max(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(std::move(a), b) == 4);
}

TEST_CASE("max(literal, move) = right", "[algorithm/max]")
{
int b = 4;
REQUIRE(std::same_as<int&&, decltype(based::max(3, std::move(b)))>);

using res_t = decltype(based::max(3, std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(3, std::move(b)) == 4);
}

TEST_CASE("max(literal, move) = left", "[algorithm/max]")
{
int b = 3;
REQUIRE(std::same_as<int&&, decltype(based::max(4, std::move(b)))>);

using res_t = decltype(based::max(4, std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(4, std::move(b)) == 4);
}

@@ -200,7 +250,9 @@ TEST_CASE("max(value, move) = right", "[algorithm/max]")

{
int a = 3; // NOLINT misc-const-correctness
int b = 4;
REQUIRE(std::same_as<int, decltype(based::max(a, std::move(b)))>);

using res_t = decltype(based::max(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, std::move(b)) == 4);
}

@@ -208,7 +260,9 @@ TEST_CASE("max(value, move) = left", "[algorithm/max]")

{
int a = 4; // NOLINT misc-const-correctness
int b = 3;
REQUIRE(std::same_as<int, decltype(based::max(a, std::move(b)))>);

using res_t = decltype(based::max(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, std::move(b)) == 4);
}

@@ -216,7 +270,9 @@ TEST_CASE("max(const value, move) = right", "[algorithm/max]")

{
const int a = 3;
int b = 4;
REQUIRE(std::same_as<int, decltype(based::max(a, std::move(b)))>);

using res_t = decltype(based::max(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, std::move(b)) == 4);
}

@@ -224,7 +280,9 @@ TEST_CASE("max(const value, move) = left", "[algorithm/max]")

{
const int a = 4;
int b = 3;
REQUIRE(std::same_as<int, decltype(based::max(a, std::move(b)))>);

using res_t = decltype(based::max(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::max(a, std::move(b)) == 4);
}

@@ -232,8 +290,9 @@ TEST_CASE("max(move, move) = right", "[algorithm/max]")

{
int a = 3;
int b = 4;
REQUIRE(
std::same_as<int&&, decltype(based::max(std::move(a), std::move(b)))>);

using res_t = decltype(based::max(std::move(a), std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(std::move(a), std::move(b)) == 4);
}

@@ -241,8 +300,9 @@ TEST_CASE("max(move, move) = left", "[algorithm/max]")

{
int a = 4;
int b = 3;
REQUIRE(
std::same_as<int&&, decltype(based::max(std::move(a), std::move(b)))>);

using res_t = decltype(based::max(std::move(a), std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::max(std::move(a), std::move(b)) == 4);
}

@@ -253,7 +313,9 @@ TEST_CASE("max-stability", "[algorithm/max]")

using type_t = std::pair<int, int>;

static const auto cmp = [](const type_t& x, const type_t& y)
{ return x.first < y.first; };
{
return x.first < y.first;
};

const type_t a = {3, 4};
const type_t b = {3, 5};

diff --git a/ test/source/min_test.cpp b/ test/source/min_test.cpp

@@ -4,41 +4,51 @@


TEST_CASE("min(literal, literal) = left", "[algorithm/min]")
{
REQUIRE(std::same_as<int&&, decltype(based::min(3, 4))>);
using res_t = decltype(based::min(3, 4));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(3, 4) == 3);
}

TEST_CASE("min(literal, literal) = right", "[algorithm/min]")
{
REQUIRE(std::same_as<int&&, decltype(based::min(4, 3))>);
using res_t = decltype(based::min(4, 3));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(4, 3) == 3);
}

TEST_CASE("min(value, literal) = left", "[algorithm/min]")
{
int a = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::min(a, 4))>);

using res_t = decltype(based::min(a, 4));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, 4) == 3);
}

TEST_CASE("min(value, literal) = right", "[algorithm/min]")
{
int a = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::min(a, 3))>);

using res_t = decltype(based::min(a, 3));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, 3) == 3);
}

TEST_CASE("min(literal, value) = left", "[algorithm/min]")
{
int b = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::min(3, b))>);

using res_t = decltype(based::min(3, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(3, b) == 3);
}

TEST_CASE("min(literal, value) = right", "[algorithm/min]")
{
int b = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::min(4, b))>);

using res_t = decltype(based::min(4, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(4, b) == 3);
}

@@ -46,7 +56,9 @@ TEST_CASE("min(value, value) = left", "[algorithm/min]")

{
int a = 3;
int b = 4;
REQUIRE(std::same_as<int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -54,35 +66,45 @@ TEST_CASE("min(value, value) = right", "[algorithm/min]")

{
int a = 4;
int b = 3;
REQUIRE(std::same_as<int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

TEST_CASE("min(const value, literal) = left", "[algorithm/min]")
{
const int a = 3;
REQUIRE(std::same_as<int, decltype(based::min(a, 4))>);

using res_t = decltype(based::min(a, 4));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, 4) == 3);
}

TEST_CASE("min(const value, literal) = right", "[algorithm/min]")
{
const int a = 4;
REQUIRE(std::same_as<int, decltype(based::min(a, 3))>);

using res_t = decltype(based::min(a, 3));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, 3) == 3);
}

TEST_CASE("min(literal, const value) = left", "[algorithm/min]")
{
const int b = 4;
REQUIRE(std::same_as<int, decltype(based::min(3, b))>);

using res_t = decltype(based::min(3, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(3, b) == 3);
}

TEST_CASE("min(literal, const value) = right", "[algorithm/min]")
{
const int b = 3;
REQUIRE(std::same_as<int, decltype(based::min(4, b))>);

using res_t = decltype(based::min(4, b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(4, b) == 3);
}

@@ -90,7 +112,9 @@ TEST_CASE("min(const value, const value) = left", "[algorithm/min]")

{
const int a = 3;
const int b = 4;
REQUIRE(std::same_as<const int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -98,7 +122,9 @@ TEST_CASE("min(const value, const value) = right", "[algorithm/min]")

{
const int a = 4;
const int b = 3;
REQUIRE(std::same_as<const int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -106,7 +132,9 @@ TEST_CASE("min(value, const value) = left", "[algorithm/min]")

{
int a = 3; // NOLINT misc-const-correctness
const int b = 4;
REQUIRE(std::same_as<const int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -114,7 +142,9 @@ TEST_CASE("min(value, const value) = right", "[algorithm/min]")

{
int a = 4; // NOLINT misc-const-correctness
const int b = 3;
REQUIRE(std::same_as<const int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -122,7 +152,9 @@ TEST_CASE("min(const value, value) = left", "[algorithm/min]")

{
const int a = 3;
int b = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<const int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -130,7 +162,9 @@ TEST_CASE("min(const value, value) = right", "[algorithm/min]")

{
const int a = 4;
int b = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<const int&, decltype(based::min(a, b))>);

using res_t = decltype(based::min(a, b));
REQUIRE(std::same_as<const int&, res_t>);
REQUIRE(based::min(a, b) == 3);
}

@@ -139,14 +173,18 @@ TEST_CASE("min(const value, value) = right", "[algorithm/min]")

TEST_CASE("min(move, literal) = left", "[algorithm/min]")
{
int a = 3;
REQUIRE(std::same_as<int&&, decltype(based::min(std::move(a), 4))>);

using res_t = decltype(based::min(std::move(a), 4));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(std::move(a), 4) == 3);
}

TEST_CASE("min(move, literal) = right", "[algorithm/min]")
{
int a = 4;
REQUIRE(std::same_as<int&&, decltype(based::min(std::move(a), 3))>);

using res_t = decltype(based::min(std::move(a), 3));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(std::move(a), 3) == 3);
}

@@ -154,7 +192,9 @@ TEST_CASE("min(move, value) = left", "[algorithm/min]")

{
int a = 3;
int b = 4; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::min(std::move(a), b))>);

using res_t = decltype(based::min(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(std::move(a), b) == 3);
}

@@ -162,7 +202,9 @@ TEST_CASE("min(move, value) = right", "[algorithm/min]")

{
int a = 4;
int b = 3; // NOLINT misc-const-correctness
REQUIRE(std::same_as<int, decltype(based::min(std::move(a), b))>);

using res_t = decltype(based::min(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(std::move(a), b) == 3);
}

@@ -170,7 +212,9 @@ TEST_CASE("min(move, const value) = left", "[algorithm/min]")

{
int a = 3;
const int b = 4;
REQUIRE(std::same_as<int, decltype(based::min(std::move(a), b))>);

using res_t = decltype(based::min(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(std::move(a), b) == 3);
}

@@ -178,21 +222,27 @@ TEST_CASE("min(move, const value) = right", "[algorithm/min]")

{
int a = 4;
const int b = 3;
REQUIRE(std::same_as<int, decltype(based::min(std::move(a), b))>);

using res_t = decltype(based::min(std::move(a), b));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(std::move(a), b) == 3);
}

TEST_CASE("min(literal, move) = left", "[algorithm/min]")
{
int b = 4;
REQUIRE(std::same_as<int&&, decltype(based::min(3, std::move(b)))>);

using res_t = decltype(based::min(3, std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(3, std::move(b)) == 3);
}

TEST_CASE("min(literal, move) = right", "[algorithm/min]")
{
int b = 3;
REQUIRE(std::same_as<int&&, decltype(based::min(4, std::move(b)))>);

using res_t = decltype(based::min(4, std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(4, std::move(b)) == 3);
}

@@ -200,7 +250,9 @@ TEST_CASE("min(value, move) = left", "[algorithm/min]")

{
int a = 3; // NOLINT misc-const-correctness
int b = 4;
REQUIRE(std::same_as<int, decltype(based::min(a, std::move(b)))>);

using res_t = decltype(based::min(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, std::move(b)) == 3);
}

@@ -208,7 +260,9 @@ TEST_CASE("min(value, move) = right", "[algorithm/min]")

{
int a = 4; // NOLINT misc-const-correctness
int b = 3;
REQUIRE(std::same_as<int, decltype(based::min(a, std::move(b)))>);

using res_t = decltype(based::min(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, std::move(b)) == 3);
}

@@ -216,7 +270,9 @@ TEST_CASE("min(const value, move) = left", "[algorithm/min]")

{
const int a = 3;
int b = 4;
REQUIRE(std::same_as<int, decltype(based::min(a, std::move(b)))>);

using res_t = decltype(based::min(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, std::move(b)) == 3);
}

@@ -224,7 +280,9 @@ TEST_CASE("min(const value, move) = right", "[algorithm/min]")

{
const int a = 4;
int b = 3;
REQUIRE(std::same_as<int, decltype(based::min(a, std::move(b)))>);

using res_t = decltype(based::min(a, std::move(b)));
REQUIRE(std::same_as<int, res_t>);
REQUIRE(based::min(a, std::move(b)) == 3);
}

@@ -232,8 +290,9 @@ TEST_CASE("min(move, move) = left", "[algorithm/min]")

{
int a = 3;
int b = 4;
REQUIRE(
std::same_as<int&&, decltype(based::min(std::move(a), std::move(b)))>);

using res_t = decltype(based::min(std::move(a), std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(std::move(a), std::move(b)) == 3);
}

@@ -241,8 +300,9 @@ TEST_CASE("min(move, move) = right", "[algorithm/min]")

{
int a = 4;
int b = 3;
REQUIRE(
std::same_as<int&&, decltype(based::min(std::move(a), std::move(b)))>);

using res_t = decltype(based::min(std::move(a), std::move(b)));
REQUIRE(std::same_as<int&&, res_t>);
REQUIRE(based::min(std::move(a), std::move(b)) == 3);
}

@@ -253,7 +313,9 @@ TEST_CASE("min-stability", "[algorithm/min]")

using type_t = std::pair<int, int>;

static const auto cmp = [](const type_t& x, const type_t& y)
{ return x.first < y.first; };
{
return x.first < y.first;
};

const type_t a = {3, 4};
const type_t b = {3, 5};

diff --git a/ test/source/string_literal_test.cpp b/ test/source/string_literal_test.cpp

@@ -20,8 +20,14 @@ TEST_CASE("nonempty", "[string/string_literal]")


TEST_CASE("template", "[string/string_literal]")
{
const auto data = []<based::string_literal L>() { return L.data(); };
const auto size = []<based::string_literal L>() { return L.size(); };
const auto data = []<based::string_literal L>()
{
return L.data();
};
const auto size = []<based::string_literal L>()
{
return L.size();
};

REQUIRE(size.operator()<"">() == 1);
REQUIRE(size.operator()<"nonempty">() == 9);