2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
4 * This file is part of StormByte.
6 * StormByte is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
10 * StormByte is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
22// Out-of-line implementation of StormByte::Bitmask, included by bitmask.hxx.
23// See bitmask.hxx for documentation of each member.
26 template<typename Derived, Type::UnsignedEnum E>
27 constexpr bool Bitmask<Derived, E>::operator==(const Bitmask& other) const noexcept {
28 return m_value == other.m_value;
31 template<typename Derived, Type::UnsignedEnum E>
32 constexpr bool Bitmask<Derived, E>::operator!=(const Bitmask& other) const noexcept {
33 return m_value != other.m_value;
36 template<typename Derived, Type::UnsignedEnum E>
37 constexpr Derived Bitmask<Derived, E>::operator|(const Bitmask& other) const noexcept {
38 return Derived(m_value | other.m_value);
41 template<typename Derived, Type::UnsignedEnum E>
42 constexpr Derived Bitmask<Derived, E>::operator&(const Bitmask& other) const noexcept {
43 return Derived(m_value & other.m_value);
46 template<typename Derived, Type::UnsignedEnum E>
47 constexpr Derived Bitmask<Derived, E>::operator^(const Bitmask& other) const noexcept {
48 return Derived(m_value ^ other.m_value);
51 template<typename Derived, Type::UnsignedEnum E>
52 constexpr Derived Bitmask<Derived, E>::operator~() const noexcept {
53 return Derived(~m_value);
56 template<typename Derived, Type::UnsignedEnum E>
57 constexpr Bitmask<Derived, E>& Bitmask<Derived, E>::operator|=(const Bitmask& other) noexcept {
58 m_value = m_value | other.m_value;
62 template<typename Derived, Type::UnsignedEnum E>
63 constexpr Bitmask<Derived, E>& Bitmask<Derived, E>::operator&=(const Bitmask& other) noexcept {
64 m_value = m_value & other.m_value;
68 template<typename Derived, Type::UnsignedEnum E>
69 constexpr Bitmask<Derived, E>& Bitmask<Derived, E>::operator^=(const Bitmask& other) noexcept {
70 m_value = m_value ^ other.m_value;
74 template<typename Derived, Type::UnsignedEnum E>
75 constexpr void Bitmask<Derived, E>::Add(E value) noexcept {
76 m_value = m_value | value;
79 template<typename Derived, Type::UnsignedEnum E>
80 constexpr void Bitmask<Derived, E>::Remove(E value) noexcept {
81 m_value = m_value & ~value;
84 template<typename Derived, Type::UnsignedEnum E>
85 constexpr E Bitmask<Derived, E>::Value() const noexcept {
89 template<typename Derived, Type::UnsignedEnum E>
90 constexpr bool Bitmask<Derived, E>::Has(E value) const noexcept {
91 return (m_value & value) == value;
94 template<typename Derived, Type::UnsignedEnum E>
95 constexpr bool Bitmask<Derived, E>::Has(const Bitmask& other) const noexcept {
96 return Has(other.m_value);
99 template<typename Derived, Type::UnsignedEnum E>
100 constexpr bool Bitmask<Derived, E>::HasAny(E value) const noexcept {
101 return (m_value & value) != static_cast<E>(0);
104 template<typename Derived, Type::UnsignedEnum E>
105 constexpr bool Bitmask<Derived, E>::HasAny(const Bitmask& other) const noexcept {
106 return HasAny(other.m_value);
109 template<typename Derived, Type::UnsignedEnum E>
110 constexpr bool Bitmask<Derived, E>::HasNone(E value) const noexcept {
111 return (m_value & value) == static_cast<E>(0);
114 template<typename Derived, Type::UnsignedEnum E>
115 constexpr bool Bitmask<Derived, E>::HasNone(const Bitmask& other) const noexcept {
116 return HasNone(other.m_value);