2022-07-04 06:29:46 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Frhun <serenitystuff@frhun.de>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-11-26 14:18:30 +03:00
|
|
|
#include <AK/Platform.h>
|
|
|
|
|
2022-07-04 06:29:46 +03:00
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
template<typename T, typename... Ts>
|
|
|
|
[[nodiscard]] 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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return (... && (to_compare >= valid_values));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-26 14:18:30 +03:00
|
|
|
#if USING_AK_GLOBALLY
|
2022-07-04 06:29:46 +03:00
|
|
|
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;
|
|
|
|
using AK::first_is_larger_than_one_of;
|
|
|
|
using AK::first_is_one_of;
|
|
|
|
using AK::first_is_smaller_or_equal_than_all_of;
|
|
|
|
using AK::first_is_smaller_or_equal_than_one_of;
|
|
|
|
using AK::first_is_smaller_than_all_of;
|
|
|
|
using AK::first_is_smaller_than_one_of;
|
2022-11-26 14:18:30 +03:00
|
|
|
#endif
|