diff --git a/include/cppcore/Common/TBitField.h b/include/cppcore/Common/TBitField.h index 9e7fc4d..341f567 100644 --- a/include/cppcore/Common/TBitField.h +++ b/include/cppcore/Common/TBitField.h @@ -37,7 +37,7 @@ template class TBitField { public: /// @brief The default class constructor. - TBitField(); + TBitField() = default; /// @brief The class constructor with the initial value. /// @param[in] init The init value. @@ -48,12 +48,12 @@ class TBitField { /// @brief Returns the current bit-mask. /// @return The bitmask. - T GetMask() const; + T getMask() const; /// @brief Will return the bit at the given position. /// @param[in] pos The bit position for readout. /// @return true for bit is set, false for not. - bool getBit(size_t pos) const; + bool constexpr getBit(size_t pos) const noexcept ; /// @brief Will set the bit at the given position to the given state. /// @param[in] pos The bit position for write. @@ -76,28 +76,21 @@ class TBitField { size_t maxBits() const; private: - T mBitMask; + T mBitMask{0}; }; template -inline TBitField::TBitField() : - mBitMask(0) { +inline TBitField::TBitField(T init) : mBitMask(init) { // empty } template -inline TBitField::TBitField(T init) : - mBitMask(init) { - // empty -} - -template -inline T TBitField::GetMask() const { +inline T TBitField::getMask() const { return mBitMask; } template -inline bool TBitField::getBit(size_t pos) const { +inline bool constexpr TBitField::getBit(size_t pos) const noexcept { assert(pos < maxBits()); return (mBitMask & (1 << pos)) != 0; }