From f077725b904d6c0d37758f4387d8022e638cca4a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 18 Jun 2025 12:56:44 +0200 Subject: [PATCH 1/2] Cleanup interface --- include/cppcore/Common/TBitField.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/include/cppcore/Common/TBitField.h b/include/cppcore/Common/TBitField.h index 9e7fc4d..8c1b940 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,7 +48,7 @@ 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. @@ -76,15 +76,9 @@ class TBitField { size_t maxBits() const; private: - T mBitMask; + T mBitMask = 0; }; -template -inline TBitField::TBitField() : - mBitMask(0) { - // empty -} - template inline TBitField::TBitField(T init) : mBitMask(init) { @@ -92,7 +86,7 @@ inline TBitField::TBitField(T init) : } template -inline T TBitField::GetMask() const { +inline T TBitField::getMask() const { return mBitMask; } From fef1a6bddb76367b28036d65ed16fe34bdd6c2f9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 19 Jun 2025 16:51:15 +0200 Subject: [PATCH 2/2] Fix review findings --- include/cppcore/Common/TBitField.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/cppcore/Common/TBitField.h b/include/cppcore/Common/TBitField.h index 8c1b940..341f567 100644 --- a/include/cppcore/Common/TBitField.h +++ b/include/cppcore/Common/TBitField.h @@ -53,7 +53,7 @@ class TBitField { /// @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,12 +76,11 @@ class TBitField { size_t maxBits() const; private: - T mBitMask = 0; + T mBitMask{0}; }; template -inline TBitField::TBitField(T init) : - mBitMask(init) { +inline TBitField::TBitField(T init) : mBitMask(init) { // empty } @@ -91,7 +90,7 @@ inline T TBitField::getMask() const { } 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; }