mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK: Add first_is_equal_to_all_of()
This method returns true if all arguments are equal.
This commit is contained in:
parent
97e917bdf5
commit
040dca0223
Notes:
github-actions[bot]
2025-03-18 20:56:20 +00:00
Author: https://github.com/tcl3
Commit: 040dca0223
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3982
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
2 changed files with 28 additions and 0 deletions
|
@ -41,6 +41,12 @@ template<typename T, typename... Ts>
|
|||
return (... || (forward<T>(to_compare) >= forward<Ts>(valid_values)));
|
||||
}
|
||||
|
||||
template<typename T, typename... Ts>
|
||||
[[nodiscard]] constexpr bool first_is_equal_to_all_of(T&& to_compare, Ts&&... valid_values)
|
||||
{
|
||||
return (... && (forward<T>(to_compare) == forward<Ts>(valid_values)));
|
||||
}
|
||||
|
||||
template<typename T, typename... Ts>
|
||||
[[nodiscard]] constexpr bool first_is_smaller_than_all_of(T&& to_compare, Ts&&... valid_values)
|
||||
{
|
||||
|
@ -67,6 +73,7 @@ template<typename T, typename... Ts>
|
|||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
using AK::first_is_equal_to_all_of;
|
||||
using AK::first_is_larger_or_equal_than_all_of;
|
||||
using AK::first_is_larger_or_equal_than_one_of;
|
||||
using AK::first_is_larger_than_all_of;
|
||||
|
|
|
@ -203,6 +203,27 @@ TEST_CASE(first_is_larger_than_one_of)
|
|||
EXPECT(!first_is_larger_than_one_of(10));
|
||||
}
|
||||
|
||||
TEST_CASE(first_is_equal_to_all_of)
|
||||
{
|
||||
static_assert(first_is_equal_to_all_of(1));
|
||||
EXPECT(first_is_equal_to_all_of(1));
|
||||
|
||||
static_assert(first_is_equal_to_all_of(1, 1));
|
||||
EXPECT(first_is_equal_to_all_of(1, 1));
|
||||
|
||||
static_assert(!first_is_equal_to_all_of(1, 2));
|
||||
EXPECT(!first_is_equal_to_all_of(1, 2));
|
||||
|
||||
static_assert(!first_is_equal_to_all_of(1, 1, 2));
|
||||
EXPECT(!first_is_equal_to_all_of(1, 1, 2));
|
||||
|
||||
static_assert(!first_is_equal_to_all_of(2, 1, 1));
|
||||
EXPECT(!first_is_equal_to_all_of(2, 1, 1));
|
||||
|
||||
static_assert(!first_is_equal_to_all_of(2, 2, 1));
|
||||
EXPECT(!first_is_equal_to_all_of(2, 2, 1));
|
||||
}
|
||||
|
||||
TEST_CASE(first_is_larger_or_equal_than_all_of)
|
||||
{
|
||||
// Finds larger than all items
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue