7 #ifndef ZPP_INCLUDE_ZPP_UTILS_HPP
8 #define ZPP_INCLUDE_ZPP_UTILS_HPP
20 template<
class T_LHS,
class T_RHS>
21 constexpr
bool operator==(
const T_LHS& lhs,
const T_RHS& rhs) noexcept
23 if constexpr (std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
27 if constexpr (std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
28 return lhs == rhs.native_handle();
31 if constexpr (!std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
32 return lhs.native_handle() == rhs;
35 if constexpr (!std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
36 return lhs.native_handle() == rhs.native_handle();
39 static_assert(
true,
"should never be reached");
49 template<
class T_LHS,
class T_RHS>
50 constexpr
bool operator!=(
const T_LHS& lhs,
const T_RHS& rhs) noexcept
52 if constexpr (std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
56 if constexpr (std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
57 return lhs != rhs.native_handle();
60 if constexpr (!std::is_pointer_v<T_LHS> && std::is_pointer_v<T_RHS>) {
61 return lhs.native_handle() != rhs;
64 if constexpr (!std::is_pointer_v<T_LHS> && !std::is_pointer_v<T_RHS>) {
65 return lhs.native_handle() != rhs.native_handle();
68 static_assert(
true,
"should never be reached");
83 for (uint32_t i = 1; i <= power; ++i) {
104 }
while (calc_val < value);
106 return calc_val == value;
119 if (value == 0 || base == 0) {
122 return (value % base) == 0;
consteval bool is_power_of_two(uint32_t value) noexcept
check if a value is a power of two
constexpr bool operator==(const result< T_Ok, T_Error > &lhs, bool rhs) noexcept
compare result with bool
consteval bool is_multiple_of(uint32_t value, uint32_t base)
Check if a value is a multiple of another value.
consteval uint32_t power_of_two(uint32_t power) noexcept
calculate a power of 2
constexpr bool operator!=(const result< T_Ok, T_Error > &lhs, bool rhs) noexcept
compare result with bool