Files
MapLibreParticleLab/include/mln/util/bitmask_operations.hpp
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

34 lines
949 B
C++

#pragma once
#include <mln/util/traits.hpp>
#include <mln/util/util.hpp>
namespace mln {
template <typename Enum>
constexpr Enum operator|(Enum a, Enum b) {
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
// NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
return Enum(mln::underlying_type(a) | mln::underlying_type(b));
}
template <typename Enum>
constexpr Enum& operator|=(Enum& a, Enum b) {
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return (a = a | b);
}
template <typename Enum>
constexpr bool operator&(Enum a, Enum b) {
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return bool(mln::underlying_type(a) & mln::underlying_type(b));
}
template <typename Enum>
constexpr Enum operator~(Enum value) {
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return Enum(~mln::underlying_type(value));
}
} // namespace mln