From daae25615f520a175abf680d31d151273455654b Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Mon, 30 Sep 2019 18:54:09 +0100 Subject: [PATCH] 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. --- src/FixedPoints/Details.h | 8 ++++---- src/FixedPoints/SFixed.h | 40 +++++++++++++++++++-------------------- src/FixedPoints/UFixed.h | 40 +++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/FixedPoints/Details.h b/src/FixedPoints/Details.h index 02b3e25..0e88263 100644 --- a/src/FixedPoints/Details.h +++ b/src/FixedPoints/Details.h @@ -44,7 +44,7 @@ namespace FIXED_POINTS_DETAILS struct BitSize { BitSize() = delete; - constexpr static const auto Value = sizeof(T) * CHAR_BIT; + static constexpr auto Value = sizeof(T) * CHAR_BIT; }; template< bool Condition, typename TTrue, typename TFalse > @@ -119,21 +119,21 @@ namespace FIXED_POINTS_DETAILS struct MsbMask { MsbMask() = delete; - constexpr static LeastUInt Value = (1ull << (Bits - 1)); + static constexpr LeastUInt Value = (1ull << (Bits - 1)); }; template< unsigned Bits > struct IdentityMask { IdentityMask() = delete; - constexpr static LeastUInt Value = 1 | (IdentityMask::Value << 1); + static constexpr LeastUInt Value = 1 | (IdentityMask::Value << 1); }; template<> struct IdentityMask<0> { IdentityMask() = delete; - constexpr static LeastUInt<0> Value = 0; + static constexpr LeastUInt<0> Value = 0; }; #if !defined(FIXED_POINTS_NO_RANDOM) diff --git a/src/FixedPoints/SFixed.h b/src/FixedPoints/SFixed.h index 9ab7201..b2aa96d 100644 --- a/src/FixedPoints/SFixed.h +++ b/src/FixedPoints/SFixed.h @@ -26,10 +26,10 @@ template< unsigned Integer, unsigned Fraction > class SFixed { public: - constexpr static uintmax_t IntegerSize = Integer + 1; - constexpr static uintmax_t FractionSize = Fraction; - constexpr static uintmax_t LogicalSize = IntegerSize + FractionSize; - constexpr static uintmax_t Scale = UINTMAX_C(1) << FractionSize; + static constexpr uintmax_t IntegerSize = Integer + 1; + static constexpr uintmax_t FractionSize = Fraction; + static constexpr uintmax_t LogicalSize = IntegerSize + FractionSize; + static constexpr uintmax_t Scale = UINTMAX_C(1) << FractionSize; public: static_assert(LogicalSize <= FIXED_POINTS_DETAILS::BitSize::Value, "Platform does not have a native type large enough for SFixed."); @@ -39,22 +39,22 @@ public: using FractionType = FIXED_POINTS_DETAILS::LeastUInt; using InternalType = FIXED_POINTS_DETAILS::LeastInt; - constexpr static uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize::Value; + static constexpr uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize::Value; using ShiftType = FIXED_POINTS_DETAILS::LeastUInt; using MaskType = FIXED_POINTS_DETAILS::LeastUInt; public: - constexpr static ShiftType IntegerShift = FractionSize; - constexpr static ShiftType FractionShift = 0; + static constexpr ShiftType IntegerShift = FractionSize; + static constexpr ShiftType FractionShift = 0; - constexpr static MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask::Value; - constexpr static MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask::Value; + static constexpr MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask::Value; + static constexpr MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask::Value; - constexpr static MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift); + static constexpr MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift); - constexpr static MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask::Value; - constexpr static MaskType LesserMidpointMask = MidpointMask - 1; + static constexpr MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask::Value; + static constexpr MaskType LesserMidpointMask = MidpointMask - 1; protected: class RawType @@ -103,7 +103,7 @@ public: template< unsigned IntegerOut, unsigned FractionOut > constexpr explicit operator SFixed() const; - constexpr static SFixed fromInternal(const InternalType & value); + static constexpr SFixed fromInternal(const InternalType & value); constexpr SFixed operator -() const; SFixed & operator ++(); @@ -114,15 +114,15 @@ public: SFixed & operator /=(const SFixed & other); public: - constexpr static SFixed Epsilon = SFixed::fromInternal(1); - constexpr static SFixed MinValue = SFixed::fromInternal(FIXED_POINTS_DETAILS::MsbMask::Value); - constexpr static SFixed MaxValue = SFixed::fromInternal(~FIXED_POINTS_DETAILS::MsbMask::Value); + static constexpr SFixed Epsilon = SFixed::fromInternal(1); + static constexpr SFixed MinValue = SFixed::fromInternal(FIXED_POINTS_DETAILS::MsbMask::Value); + static constexpr SFixed MaxValue = SFixed::fromInternal(~FIXED_POINTS_DETAILS::MsbMask::Value); // 40 digits is probably enough for these - constexpr static SFixed Pi = 3.1415926535897932384626433832795028841971; - constexpr static SFixed E = 2.718281828459045235360287471352662497757; - constexpr static SFixed Phi = 1.6180339887498948482045868343656381177203; - constexpr static SFixed Tau = 6.2831853071795864769252867665590057683943; + static constexpr SFixed Pi = 3.1415926535897932384626433832795028841971; + static constexpr SFixed E = 2.718281828459045235360287471352662497757; + static constexpr SFixed Phi = 1.6180339887498948482045868343656381177203; + static constexpr SFixed Tau = 6.2831853071795864769252867665590057683943; }; diff --git a/src/FixedPoints/UFixed.h b/src/FixedPoints/UFixed.h index c7b77e4..64079da 100644 --- a/src/FixedPoints/UFixed.h +++ b/src/FixedPoints/UFixed.h @@ -26,10 +26,10 @@ template< unsigned Integer, unsigned Fraction > class UFixed { public: - constexpr static uintmax_t IntegerSize = Integer; - constexpr static uintmax_t FractionSize = Fraction; - constexpr static uintmax_t LogicalSize = IntegerSize + FractionSize; - constexpr static uintmax_t Scale = UINTMAX_C(1) << FractionSize; + static constexpr uintmax_t IntegerSize = Integer; + static constexpr uintmax_t FractionSize = Fraction; + static constexpr uintmax_t LogicalSize = IntegerSize + FractionSize; + static constexpr uintmax_t Scale = UINTMAX_C(1) << FractionSize; public: static_assert(LogicalSize <= FIXED_POINTS_DETAILS::BitSize::Value, "Platform does not have a native type large enough for UFixed."); @@ -39,22 +39,22 @@ public: using FractionType = FIXED_POINTS_DETAILS::LeastUInt; using InternalType = FIXED_POINTS_DETAILS::LeastUInt; - constexpr static uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize::Value; + static constexpr uintmax_t InternalSize = FIXED_POINTS_DETAILS::BitSize::Value; using ShiftType = FIXED_POINTS_DETAILS::LeastUInt; using MaskType = FIXED_POINTS_DETAILS::LeastUInt; public: - constexpr static ShiftType IntegerShift = FractionSize; - constexpr static ShiftType FractionShift = 0; + static constexpr ShiftType IntegerShift = FractionSize; + static constexpr ShiftType FractionShift = 0; - constexpr static MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask::Value; - constexpr static MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask::Value; + static constexpr MaskType IntegerMask = FIXED_POINTS_DETAILS::IdentityMask::Value; + static constexpr MaskType FractionMask = FIXED_POINTS_DETAILS::IdentityMask::Value; - constexpr static MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift); + static constexpr MaskType IdentityMask = (IntegerMask << IntegerShift) | (FractionMask << FractionShift); - constexpr static MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask::Value; - constexpr static MaskType LesserMidpointMask = MidpointMask - 1; + static constexpr MaskType MidpointMask = FIXED_POINTS_DETAILS::MsbMask::Value; + static constexpr MaskType LesserMidpointMask = MidpointMask - 1; protected: class RawType @@ -104,7 +104,7 @@ public: template< unsigned IntegerOut, unsigned FractionOut > constexpr explicit operator UFixed() const; - constexpr static UFixed fromInternal(const InternalType & value); + static constexpr UFixed fromInternal(const InternalType & value); UFixed & operator ++(); UFixed & operator --(); @@ -114,15 +114,15 @@ public: UFixed & operator /=(const UFixed & other); public: - constexpr static UFixed Epsilon = UFixed::fromInternal(1); - constexpr static UFixed MinValue = UFixed::fromInternal(0); - constexpr static UFixed MaxValue = UFixed::fromInternal(~0); + static constexpr UFixed Epsilon = UFixed::fromInternal(1); + static constexpr UFixed MinValue = UFixed::fromInternal(0); + static constexpr UFixed MaxValue = UFixed::fromInternal(~0); // 40 digits is probably enough for these - constexpr static UFixed Pi = 3.1415926535897932384626433832795028841971; - constexpr static UFixed E = 2.718281828459045235360287471352662497757; - constexpr static UFixed Phi = 1.6180339887498948482045868343656381177203; - constexpr static UFixed Tau = 6.2831853071795864769252867665590057683943; + static constexpr UFixed Pi = 3.1415926535897932384626433832795028841971; + static constexpr UFixed E = 2.718281828459045235360287471352662497757; + static constexpr UFixed Phi = 1.6180339887498948482045868343656381177203; + static constexpr UFixed Tau = 6.2831853071795864769252867665590057683943; };