1 #ifndef SIPLASPLAS_CONSTEXPR_ALGORITHM_HPP 2 #define SIPLASPLAS_CONSTEXPR_ALGORITHM_HPP 28 constexpr
Equal() =
default;
30 template<
typename T,
typename U>
31 constexpr
bool operator()(
const T& lhs,
const U& rhs)
const 48 template<
typename T,
typename U>
49 constexpr
bool operator()(
const T& lhs,
const U& rhs)
const 61 template<
typename Sequence>
62 constexpr
auto begin(
const Sequence& sequence)
64 return sequence.begin();
73 template<
typename T, std::
size_t N>
74 constexpr
auto begin(
const T (&array)[N])
85 template<
typename Sequence>
86 constexpr
auto end(
const Sequence& sequence)
88 return sequence.end();
97 template<
typename T, std::
size_t N>
98 constexpr
auto end(
const T (&array)[N])
107 template<
typename Begin,
typename End>
133 typename Begin1,
typename End1,
134 typename Begin2,
typename End2,
138 Begin1 begin1, End1 end1,
139 Begin2 begin2, End2 end2,
143 return (begin1 == end1 || begin2 == end2) ?
151 compare(*begin1++, *begin2++) &&
172 typename Begin1,
typename End1,
173 typename Begin2,
typename End2
176 Begin1 begin1, End1 end1,
177 Begin2 begin2, End2 end2
197 template<
typename Lhs,
typename Rhs>
198 constexpr
bool equal(
const Lhs& lhs,
const Rhs& rhs)
212 constexpr
const T&
max(
const T& lhs,
const T& rhs)
225 template<
typename T,
typename U>
226 constexpr std::common_type_t<T, U>
max(
const T& lhs,
const U& rhs)
228 return static_cast<std::common_type_t<T, U>
>(lhs) >=
229 static_cast<std::common_type_t<T, U>
>(rhs) ?
239 template<
typename First,
typename Second,
typename Third,
typename... Tail>
240 constexpr decltype(
auto)
max(const First& first, const Second& second, const Third& third,
261 constexpr
const T&
min(
const T& lhs,
const T& rhs)
274 template<
typename T,
typename U>
275 constexpr std::common_type_t<T, U>
min(
const T& lhs,
const U& rhs)
279 return static_cast<std::common_type_t<T, U>
>(lhs) <=
280 static_cast<std::common_type_t<T, U>
>(rhs) ?
290 template<
typename First,
typename Second,
typename Third,
typename... Tail>
291 constexpr decltype(
auto)
min(const First& first, const Second& second, const Third& third,
311 typename Begin1,
typename End1,
312 typename Begin2,
typename End2
315 Begin1 begin1, End1 end1,
316 Begin2 begin2, End2 end2
319 return (begin1 >= end1) ?
329 ((*begin1 == *begin2) ? 0 : 1)
339 template<
typename Lhs,
typename Rhs>
360 template<
typename Iterator,
typename T>
363 return (begin == end) ? end :
364 (*begin == value) ? begin :
365 find(begin + 1, end, value);
368 #ifndef SIPLASPLAS_CONSTEXPR_ALGORITHM_MAX_STRLEN_LENGTH 382 constexpr std::size_t MAX_STRLEN_LENGTH = 1024 * 1024;
397 constexpr std::size_t MAX_STRLEN_LENGTH = SIPLASPLAS_CONSTEXPR_ALGORITHM_MAX_STRLEN_LENGTH;
398 #endif // SIPLASPLAS_CONSTEXPR_ALGORITHM_MAX_STRLEN_LENGTH 409 constexpr std::size_t strlen(
const char* str)
421 #endif // SIPLASPLAS_CONSTEXPR_ALGORITHM_HPP constexpr auto begin(const T(&array)[N])
Returns an iterator pointing to the beginning of an array.
Definition: algorithm.hpp:74
Constexpr functor that compares two values for equality.
Definition: algorithm.hpp:26
Definition: canary_allocator.hpp:7
decltype(auto) constexpr min(const First &first, const Second &second, const Third &third, const Tail &... tail)
Returns the smallest value of the set of values given.
Definition: algorithm.hpp:291
constexpr Iterator find(Iterator begin, Iterator end, const T &value)
Finds a value in a sequence.
Definition: algorithm.hpp:361
constexpr auto distance(Begin begin, End end)
Returns the distance between two iterators.
Definition: algorithm.hpp:108
constexpr auto end(const T(&array)[N])
Returns an iterator pointing to the end of an array.
Definition: algorithm.hpp:98
Constexpr functor that compares two values for inequality.
Definition: algorithm.hpp:44
decltype(auto) constexpr max(const First &first, const Second &second, const Third &third, const Tail &... tail)
Returns the greatest value of the set of values given.
Definition: algorithm.hpp:240
constexpr std::size_t levenshteinDistance(const Lhs &lhs, const Rhs &rhs)
Computes the distance between two sequences using the Levenshtein distance algorithm.
Definition: algorithm.hpp:340
constexpr bool equal(const Lhs &lhs, const Rhs &rhs)
Compares if two sequences are equal.
Definition: algorithm.hpp:198