Skip to content

Commit dc9135c

Browse files
authored
Merge pull request #37 from kimkulling/refactoring/cleanup_tbitfield
Cleanup interface
2 parents f01433e + fef1a6b commit dc9135c

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

include/cppcore/Common/TBitField.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ template <class T>
3737
class TBitField {
3838
public:
3939
/// @brief The default class constructor.
40-
TBitField();
40+
TBitField() = default;
4141

4242
/// @brief The class constructor with the initial value.
4343
/// @param[in] init The init value.
@@ -48,12 +48,12 @@ class TBitField {
4848

4949
/// @brief Returns the current bit-mask.
5050
/// @return The bitmask.
51-
T GetMask() const;
51+
T getMask() const;
5252

5353
/// @brief Will return the bit at the given position.
5454
/// @param[in] pos The bit position for readout.
5555
/// @return true for bit is set, false for not.
56-
bool getBit(size_t pos) const;
56+
bool constexpr getBit(size_t pos) const noexcept ;
5757

5858
/// @brief Will set the bit at the given position to the given state.
5959
/// @param[in] pos The bit position for write.
@@ -76,28 +76,21 @@ class TBitField {
7676
size_t maxBits() const;
7777

7878
private:
79-
T mBitMask;
79+
T mBitMask{0};
8080
};
8181

8282
template <class T>
83-
inline TBitField<T>::TBitField() :
84-
mBitMask(0) {
83+
inline TBitField<T>::TBitField(T init) : mBitMask(init) {
8584
// empty
8685
}
8786

8887
template <class T>
89-
inline TBitField<T>::TBitField(T init) :
90-
mBitMask(init) {
91-
// empty
92-
}
93-
94-
template <class T>
95-
inline T TBitField<T>::GetMask() const {
88+
inline T TBitField<T>::getMask() const {
9689
return mBitMask;
9790
}
9891

9992
template <class T>
100-
inline bool TBitField<T>::getBit(size_t pos) const {
93+
inline bool constexpr TBitField<T>::getBit(size_t pos) const noexcept {
10194
assert(pos < maxBits());
10295
return (mBitMask & (1 << pos)) != 0;
10396
}

0 commit comments

Comments
 (0)