AK: Mark generic shorthand functions as constexpr

This commit is contained in:
MacDue 2023-05-29 19:02:00 +01:00 committed by Andreas Kling
parent 5339b54b5d
commit 81ff242e86
Notes: sideshowbarker 2024-07-17 22:01:16 +09:00

View file

@ -11,55 +11,55 @@
namespace AK {
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_one_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_one_of(T const to_compare, Ts const... valid_values)
{
return (... || (to_compare == valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_smaller_than_one_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_smaller_than_one_of(T const to_compare, Ts const... valid_values)
{
return (... || (to_compare < valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_smaller_or_equal_than_one_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_smaller_or_equal_than_one_of(T const to_compare, Ts const... valid_values)
{
return (... || (to_compare <= valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_larger_than_one_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_larger_than_one_of(T const to_compare, Ts const... valid_values)
{
return (... || (to_compare > valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_larger_or_equal_than_one_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_larger_or_equal_than_one_of(T const to_compare, Ts const... valid_values)
{
return (... || (to_compare >= valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_smaller_than_all_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_smaller_than_all_of(T const to_compare, Ts const... valid_values)
{
return (... && (to_compare < valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_smaller_or_equal_than_all_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_smaller_or_equal_than_all_of(T const to_compare, Ts const... valid_values)
{
return (... && (to_compare <= valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_larger_than_all_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_larger_than_all_of(T const to_compare, Ts const... valid_values)
{
return (... && (to_compare > valid_values));
}
template<typename T, typename... Ts>
[[nodiscard]] bool first_is_larger_or_equal_than_all_of(T const to_compare, Ts const... valid_values)
[[nodiscard]] constexpr bool first_is_larger_or_equal_than_all_of(T const to_compare, Ts const... valid_values)
{
return (... && (to_compare >= valid_values));
}