Skip to content

Commit daae256

Browse files
authored
Ensure that 'static' comes before 'constexpr' (#65)
This commit is purely to bring the code in the library more in line with my personal code style.
1 parent 080ffa2 commit daae256

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

src/FixedPoints/Details.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace FIXED_POINTS_DETAILS
4444
struct BitSize
4545
{
4646
BitSize() = delete;
47-
constexpr static const auto Value = sizeof(T) * CHAR_BIT;
47+
static constexpr auto Value = sizeof(T) * CHAR_BIT;
4848
};
4949

5050
template< bool Condition, typename TTrue, typename TFalse >
@@ -119,21 +119,21 @@ namespace FIXED_POINTS_DETAILS
119119
struct MsbMask
120120
{
121121
MsbMask() = delete;
122-
constexpr static LeastUInt<Bits> Value = (1ull << (Bits - 1));
122+
static constexpr LeastUInt<Bits> Value = (1ull << (Bits - 1));
123123
};
124124

125125
template< unsigned Bits >
126126
struct IdentityMask
127127
{
128128
IdentityMask() = delete;
129-
constexpr static LeastUInt<Bits> Value = 1 | (IdentityMask<Bits - 1>::Value << 1);
129+
static constexpr LeastUInt<Bits> Value = 1 | (IdentityMask<Bits - 1>::Value << 1);
130130
};
131131

132132
template<>
133133
struct IdentityMask<0>
134134
{
135135
IdentityMask() = delete;
136-
constexpr static LeastUInt<0> Value = 0;
136+
static constexpr LeastUInt<0> Value = 0;
137137
};
138138

139139
#if !defined(FIXED_POINTS_NO_RANDOM)

src/FixedPoints/SFixed.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ template< unsigned Integer, unsigned Fraction >
2626
class SFixed
2727
{
2828
public:
29-
constexpr static uintmax_t IntegerSize = Integer + 1;
30-
constexpr static uintmax_t FractionSize = Fraction;
31-
constexpr static uintmax_t LogicalSize = IntegerSize + FractionSize;
32-
constexpr static uintmax_t Scale = UINTMAX_C(1) << FractionSize;
29+
static constexpr uintmax_t IntegerSize = Integer + 1;
30+
static constexpr uintmax_t FractionSize = Fraction;
31+
static constexpr uintmax_t LogicalSize = IntegerSize + FractionSize;
32+
static constexpr uintmax_t Scale = UINTMAX_C(1) << FractionSize;
3333

3434
public:
3535
static_assert(LogicalSize <= FIXED_POINTS_DETAILS::BitSize<intmax_t>::Value, "Platform does not have a native type large enough for SFixed.");
@@ -39,22 +39,22 @@ class SFixed
3939
using FractionType = FIXED_POINTS_DETAILS::LeastUInt<FractionSize>;
4040
using InternalType = FIXED_POINTS_DETAILS::LeastInt<LogicalSize>;
4141

42-
constexpr static uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize<InternalType>::Value;
42+
static constexpr uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize<InternalType>::Value;
4343

4444
using ShiftType = FIXED_POINTS_DETAILS::LeastUInt<LogicalSize>;
4545
using MaskType = FIXED_POINTS_DETAILS::LeastUInt<LogicalSize>;
4646

4747
public:
48-
constexpr static ShiftType IntegerShift = FractionSize;
49-
constexpr static ShiftType FractionShift = 0;
48+
static constexpr ShiftType IntegerShift = FractionSize;
49+
static constexpr ShiftType FractionShift = 0;
5050

51-
constexpr static MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask<IntegerSize>::Value;
52-
constexpr static MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask<FractionSize>::Value;
51+
static constexpr MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask<IntegerSize>::Value;
52+
static constexpr MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask<FractionSize>::Value;
5353

54-
constexpr static MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift);
54+
static constexpr MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift);
5555

56-
constexpr static MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask<FractionSize>::Value;
57-
constexpr static MaskType LesserMidpointMask = MidpointMask - 1;
56+
static constexpr MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask<FractionSize>::Value;
57+
static constexpr MaskType LesserMidpointMask = MidpointMask - 1;
5858

5959
protected:
6060
class RawType
@@ -103,7 +103,7 @@ class SFixed
103103
template< unsigned IntegerOut, unsigned FractionOut >
104104
constexpr explicit operator SFixed<IntegerOut, FractionOut>() const;
105105

106-
constexpr static SFixed fromInternal(const InternalType & value);
106+
static constexpr SFixed fromInternal(const InternalType & value);
107107

108108
constexpr SFixed operator -() const;
109109
SFixed & operator ++();
@@ -114,15 +114,15 @@ class SFixed
114114
SFixed & operator /=(const SFixed & other);
115115

116116
public:
117-
constexpr static SFixed Epsilon = SFixed::fromInternal(1);
118-
constexpr static SFixed MinValue = SFixed::fromInternal(FIXED_POINTS_DETAILS::MsbMask<InternalSize>::Value);
119-
constexpr static SFixed MaxValue = SFixed::fromInternal(~FIXED_POINTS_DETAILS::MsbMask<InternalSize>::Value);
117+
static constexpr SFixed Epsilon = SFixed::fromInternal(1);
118+
static constexpr SFixed MinValue = SFixed::fromInternal(FIXED_POINTS_DETAILS::MsbMask<InternalSize>::Value);
119+
static constexpr SFixed MaxValue = SFixed::fromInternal(~FIXED_POINTS_DETAILS::MsbMask<InternalSize>::Value);
120120

121121
// 40 digits is probably enough for these
122-
constexpr static SFixed Pi = 3.1415926535897932384626433832795028841971;
123-
constexpr static SFixed E = 2.718281828459045235360287471352662497757;
124-
constexpr static SFixed Phi = 1.6180339887498948482045868343656381177203;
125-
constexpr static SFixed Tau = 6.2831853071795864769252867665590057683943;
122+
static constexpr SFixed Pi = 3.1415926535897932384626433832795028841971;
123+
static constexpr SFixed E = 2.718281828459045235360287471352662497757;
124+
static constexpr SFixed Phi = 1.6180339887498948482045868343656381177203;
125+
static constexpr SFixed Tau = 6.2831853071795864769252867665590057683943;
126126
};
127127

128128

src/FixedPoints/UFixed.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ template< unsigned Integer, unsigned Fraction >
2626
class UFixed
2727
{
2828
public:
29-
constexpr static uintmax_t IntegerSize = Integer;
30-
constexpr static uintmax_t FractionSize = Fraction;
31-
constexpr static uintmax_t LogicalSize = IntegerSize + FractionSize;
32-
constexpr static uintmax_t Scale = UINTMAX_C(1) << FractionSize;
29+
static constexpr uintmax_t IntegerSize = Integer;
30+
static constexpr uintmax_t FractionSize = Fraction;
31+
static constexpr uintmax_t LogicalSize = IntegerSize + FractionSize;
32+
static constexpr uintmax_t Scale = UINTMAX_C(1) << FractionSize;
3333

3434
public:
3535
static_assert(LogicalSize <= FIXED_POINTS_DETAILS::BitSize<uintmax_t>::Value, "Platform does not have a native type large enough for UFixed.");
@@ -39,22 +39,22 @@ class UFixed
3939
using FractionType = FIXED_POINTS_DETAILS::LeastUInt<FractionSize>;
4040
using InternalType = FIXED_POINTS_DETAILS::LeastUInt<LogicalSize>;
4141

42-
constexpr static uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize<InternalType>::Value;
42+
static constexpr uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize<InternalType>::Value;
4343

4444
using ShiftType = FIXED_POINTS_DETAILS::LeastUInt<LogicalSize>;
4545
using MaskType = FIXED_POINTS_DETAILS::LeastUInt<LogicalSize>;
4646

4747
public:
48-
constexpr static ShiftType IntegerShift = FractionSize;
49-
constexpr static ShiftType FractionShift = 0;
48+
static constexpr ShiftType IntegerShift = FractionSize;
49+
static constexpr ShiftType FractionShift = 0;
5050

51-
constexpr static MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask<IntegerSize>::Value;
52-
constexpr static MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask<FractionSize>::Value;
51+
static constexpr MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask<IntegerSize>::Value;
52+
static constexpr MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask<FractionSize>::Value;
5353

54-
constexpr static MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift);
54+
static constexpr MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift);
5555

56-
constexpr static MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask<FractionSize>::Value;
57-
constexpr static MaskType LesserMidpointMask = MidpointMask - 1;
56+
static constexpr MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask<FractionSize>::Value;
57+
static constexpr MaskType LesserMidpointMask = MidpointMask - 1;
5858

5959
protected:
6060
class RawType
@@ -104,7 +104,7 @@ class UFixed
104104
template< unsigned IntegerOut, unsigned FractionOut >
105105
constexpr explicit operator UFixed<IntegerOut, FractionOut>() const;
106106

107-
constexpr static UFixed fromInternal(const InternalType & value);
107+
static constexpr UFixed fromInternal(const InternalType & value);
108108

109109
UFixed & operator ++();
110110
UFixed & operator --();
@@ -114,15 +114,15 @@ class UFixed
114114
UFixed & operator /=(const UFixed & other);
115115

116116
public:
117-
constexpr static UFixed Epsilon = UFixed::fromInternal(1);
118-
constexpr static UFixed MinValue = UFixed::fromInternal(0);
119-
constexpr static UFixed MaxValue = UFixed::fromInternal(~0);
117+
static constexpr UFixed Epsilon = UFixed::fromInternal(1);
118+
static constexpr UFixed MinValue = UFixed::fromInternal(0);
119+
static constexpr UFixed MaxValue = UFixed::fromInternal(~0);
120120

121121
// 40 digits is probably enough for these
122-
constexpr static UFixed Pi = 3.1415926535897932384626433832795028841971;
123-
constexpr static UFixed E = 2.718281828459045235360287471352662497757;
124-
constexpr static UFixed Phi = 1.6180339887498948482045868343656381177203;
125-
constexpr static UFixed Tau = 6.2831853071795864769252867665590057683943;
122+
static constexpr UFixed Pi = 3.1415926535897932384626433832795028841971;
123+
static constexpr UFixed E = 2.718281828459045235360287471352662497757;
124+
static constexpr UFixed Phi = 1.6180339887498948482045868343656381177203;
125+
static constexpr UFixed Tau = 6.2831853071795864769252867665590057683943;
126126
};
127127

128128

0 commit comments

Comments
 (0)