From 15b1b3010e04ec2657eaf555df311f8143e267a6 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Mon, 30 Sep 2019 18:43:21 +0100 Subject: [PATCH] Remove void in zero-parameter functions (#63) The isocpp FAQ recommends against this practice. --- src/FixedPoints/Details.h | 16 +++++++-------- src/FixedPoints/SFixed.h | 26 ++++++++++++------------- src/FixedPoints/SFixedMemberFunctions.h | 24 +++++++++++------------ src/FixedPoints/UFixed.h | 24 +++++++++++------------ src/FixedPoints/UFixedMemberFunctions.h | 22 ++++++++++----------- src/FixedPoints/Utils.h | 8 ++++---- 6 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/FixedPoints/Details.h b/src/FixedPoints/Details.h index 6abedd0..e0e4edf 100644 --- a/src/FixedPoints/Details.h +++ b/src/FixedPoints/Details.h @@ -43,7 +43,7 @@ namespace FIXED_POINTS_DETAILS template< typename T > struct BitSize { - BitSize(void) = delete; + BitSize() = delete; constexpr static const auto Value = sizeof(T) * CHAR_BIT; }; @@ -77,14 +77,14 @@ namespace FIXED_POINTS_DETAILS template< unsigned Bits, typename T, typename... Ts > struct LeastTypeHelper { - LeastTypeHelper(void) = delete; + LeastTypeHelper() = delete; using Type = ConditionalT<(Bits <= BitSize::Value), T, typename LeastTypeHelper::Type>; }; template< unsigned Bits > struct LeastTypeHelper { - LeastTypeHelper(void) = delete; + LeastTypeHelper() = delete; using Type = void; }; @@ -96,7 +96,7 @@ namespace FIXED_POINTS_DETAILS struct LeastUIntDef { static_assert(Bits <= BitSize::Value, "No type large enough"); - LeastUIntDef(void) = delete; + LeastUIntDef() = delete; using Type = LeastType; }; @@ -108,7 +108,7 @@ namespace FIXED_POINTS_DETAILS struct LeastIntDef { static_assert(Bits <= BitSize::Value, "No type large enough"); - LeastIntDef(void) = delete; + LeastIntDef() = delete; using Type = LeastType; }; @@ -118,21 +118,21 @@ namespace FIXED_POINTS_DETAILS template< unsigned Bits > struct MsbMask { - MsbMask(void) = delete; + MsbMask() = delete; constexpr const static LeastUInt Value = (1ull << (Bits - 1)); }; template< unsigned Bits > struct IdentityMask { - IdentityMask(void) = delete; + IdentityMask() = delete; constexpr const static LeastUInt Value = 1 | (IdentityMask::Value << 1); }; template<> struct IdentityMask<0> { - IdentityMask(void) = delete; + IdentityMask() = delete; constexpr const static LeastUInt<0> Value = 0; }; diff --git a/src/FixedPoints/SFixed.h b/src/FixedPoints/SFixed.h index da7ad3a..7a0349f 100644 --- a/src/FixedPoints/SFixed.h +++ b/src/FixedPoints/SFixed.h @@ -64,7 +64,7 @@ protected: public: constexpr inline explicit RawType(const InternalType & value) : value(value) {} - constexpr inline explicit operator InternalType(void) const { return this->value; } + constexpr inline explicit operator InternalType() const { return this->value; } }; protected: @@ -74,7 +74,7 @@ protected: constexpr SFixed(const RawType & value); public: - constexpr SFixed(void); + constexpr SFixed(); constexpr SFixed(const IntegerType & integer, const FractionType & fraction); constexpr SFixed(const char & value); constexpr SFixed(const unsigned char & value); @@ -91,23 +91,23 @@ public: constexpr SFixed(const float & value); constexpr SFixed(const long double & value); - constexpr InternalType getInternal(void) const; - constexpr IntegerType getInteger(void) const; - constexpr FractionType getFraction(void) const; + constexpr InternalType getInternal() const; + constexpr IntegerType getInteger() const; + constexpr FractionType getFraction() const; - constexpr explicit operator IntegerType(void) const; - constexpr explicit operator float(void) const; - constexpr explicit operator double(void) const; - constexpr explicit operator long double(void) const; + constexpr explicit operator IntegerType() const; + constexpr explicit operator float() const; + constexpr explicit operator double() const; + constexpr explicit operator long double() const; template< unsigned IntegerOut, unsigned FractionOut > - constexpr explicit operator SFixed(void) const; + constexpr explicit operator SFixed() const; constexpr static SFixed fromInternal(const InternalType & value); - constexpr SFixed operator -(void) const; - SFixed & operator ++(void); - SFixed & operator --(void); + constexpr SFixed operator -() const; + SFixed & operator ++(); + SFixed & operator --(); SFixed & operator +=(const SFixed & other); SFixed & operator -=(const SFixed & other); SFixed & operator *=(const SFixed & other); diff --git a/src/FixedPoints/SFixedMemberFunctions.h b/src/FixedPoints/SFixedMemberFunctions.h index e11b8ef..e2ab090 100644 --- a/src/FixedPoints/SFixedMemberFunctions.h +++ b/src/FixedPoints/SFixedMemberFunctions.h @@ -25,7 +25,7 @@ constexpr SFixed::SFixed(const RawType & value) } template< unsigned Integer, unsigned Fraction > -constexpr SFixed::SFixed(void) +constexpr SFixed::SFixed() : value(0) { } @@ -125,19 +125,19 @@ constexpr SFixed::SFixed(const long double & value) // template< unsigned Integer, unsigned Fraction > -constexpr typename SFixed::InternalType SFixed::getInternal(void) const +constexpr typename SFixed::InternalType SFixed::getInternal() const { return this->value; } template< unsigned Integer, unsigned Fraction > -constexpr typename SFixed::IntegerType SFixed::getInteger(void) const +constexpr typename SFixed::IntegerType SFixed::getInteger() const { return (static_cast(this->value >> IntegerShift) & IntegerMask) | ((this->value < 0) ? ~IntegerMask : 0); } template< unsigned Integer, unsigned Fraction > -constexpr typename SFixed::FractionType SFixed::getFraction(void) const +constexpr typename SFixed::FractionType SFixed::getFraction() const { return static_cast(this->value >> FractionShift) & FractionMask; } @@ -147,13 +147,13 @@ constexpr typename SFixed::FractionType SFixed -constexpr SFixed::operator IntegerType(void) const +constexpr SFixed::operator IntegerType() const { return this->getInteger(); } template< unsigned Integer, unsigned Fraction > -constexpr SFixed::operator float(void) const +constexpr SFixed::operator float() const { return (1.0F / Scale) * static_cast @@ -162,7 +162,7 @@ constexpr SFixed::operator float(void) const } template< unsigned Integer, unsigned Fraction > -constexpr SFixed::operator double(void) const +constexpr SFixed::operator double() const { return (1.0 / Scale) * static_cast @@ -171,7 +171,7 @@ constexpr SFixed::operator double(void) const } template< unsigned Integer, unsigned Fraction > -constexpr SFixed::operator long double(void) const +constexpr SFixed::operator long double() const { return (1.0L / Scale) * static_cast @@ -181,7 +181,7 @@ constexpr SFixed::operator long double(void) const template< unsigned Integer, unsigned Fraction > template< unsigned IntegerOut, unsigned FractionOut > -constexpr SFixed::operator SFixed(void) const +constexpr SFixed::operator SFixed() const { using OutputType = SFixed; using OutputInternalType = typename OutputType::InternalType; @@ -209,7 +209,7 @@ constexpr SFixed SFixed::fromInternal(cons } template< unsigned Integer, unsigned Fraction > -constexpr SFixed SFixed::operator -(void) const +constexpr SFixed SFixed::operator -() const { return SFixed::fromInternal(-this->value); } @@ -219,14 +219,14 @@ constexpr SFixed SFixed::operator -(void) // template< unsigned Integer, unsigned Fraction > -SFixed & SFixed::operator ++(void) +SFixed & SFixed::operator ++() { this->value += (1 << FractionSize); return *this; } template< unsigned Integer, unsigned Fraction > -SFixed & SFixed::operator --(void) +SFixed & SFixed::operator --() { this->value -= (1 << FractionSize); return *this; diff --git a/src/FixedPoints/UFixed.h b/src/FixedPoints/UFixed.h index 34344eb..bcb5c94 100644 --- a/src/FixedPoints/UFixed.h +++ b/src/FixedPoints/UFixed.h @@ -64,7 +64,7 @@ protected: public: constexpr inline explicit RawType(const InternalType & value) : value(value) {} - constexpr inline explicit operator InternalType(void) const { return this->value; } + constexpr inline explicit operator InternalType() const { return this->value; } }; protected: @@ -74,7 +74,7 @@ protected: constexpr UFixed(const RawType & value); public: - constexpr UFixed(void); + constexpr UFixed(); constexpr UFixed(const IntegerType & integer, const FractionType & fraction); constexpr UFixed(const char & value); constexpr UFixed(const unsigned char & value); @@ -92,22 +92,22 @@ public: constexpr UFixed(const long double & value); public: - constexpr InternalType getInternal(void) const; - constexpr IntegerType getInteger(void) const; - constexpr FractionType getFraction(void) const; + constexpr InternalType getInternal() const; + constexpr IntegerType getInteger() const; + constexpr FractionType getFraction() const; - constexpr explicit operator IntegerType(void) const; - constexpr explicit operator float(void) const; - constexpr explicit operator double(void) const; - constexpr explicit operator long double(void) const; + constexpr explicit operator IntegerType() const; + constexpr explicit operator float() const; + constexpr explicit operator double() const; + constexpr explicit operator long double() const; template< unsigned IntegerOut, unsigned FractionOut > - constexpr explicit operator UFixed(void) const; + constexpr explicit operator UFixed() const; constexpr static UFixed fromInternal(const InternalType & value); - UFixed & operator ++(void); - UFixed & operator --(void); + UFixed & operator ++(); + UFixed & operator --(); UFixed & operator +=(const UFixed & other); UFixed & operator -=(const UFixed & other); UFixed & operator *=(const UFixed & other); diff --git a/src/FixedPoints/UFixedMemberFunctions.h b/src/FixedPoints/UFixedMemberFunctions.h index 69f99e0..9f7ddd0 100644 --- a/src/FixedPoints/UFixedMemberFunctions.h +++ b/src/FixedPoints/UFixedMemberFunctions.h @@ -25,7 +25,7 @@ constexpr UFixed::UFixed(const RawType & value) } template< unsigned Integer, unsigned Fraction > -constexpr UFixed::UFixed(void) +constexpr UFixed::UFixed() : value(0) { } @@ -125,19 +125,19 @@ constexpr UFixed::UFixed(const long double & value) // template< unsigned Integer, unsigned Fraction > -constexpr typename UFixed::InternalType UFixed::getInternal(void) const +constexpr typename UFixed::InternalType UFixed::getInternal() const { return this->value; } template< unsigned Integer, unsigned Fraction > -constexpr typename UFixed::IntegerType UFixed::getInteger(void) const +constexpr typename UFixed::IntegerType UFixed::getInteger() const { return static_cast(this->value >> IntegerShift) & IntegerMask; } template< unsigned Integer, unsigned Fraction > -constexpr typename UFixed::FractionType UFixed::getFraction(void) const +constexpr typename UFixed::FractionType UFixed::getFraction() const { return static_cast(this->value >> FractionShift) & FractionMask; } @@ -147,32 +147,32 @@ constexpr typename UFixed::FractionType UFixed -constexpr UFixed::operator IntegerType(void) const +constexpr UFixed::operator IntegerType() const { return this->getInteger(); } template< unsigned Integer, unsigned Fraction > -constexpr UFixed::operator float(void) const +constexpr UFixed::operator float() const { return ((this->value & IdentityMask) * (1.0F / Scale)); } template< unsigned Integer, unsigned Fraction > -constexpr UFixed::operator double(void) const +constexpr UFixed::operator double() const { return ((this->value & IdentityMask) * (1.0 / Scale)); } template< unsigned Integer, unsigned Fraction > -constexpr UFixed::operator long double(void) const +constexpr UFixed::operator long double() const { return ((this->value & IdentityMask) * (1.0L / Scale)); } template< unsigned Integer, unsigned Fraction > template< unsigned IntegerOut, unsigned FractionOut > -constexpr UFixed::operator UFixed(void) const +constexpr UFixed::operator UFixed() const { using OutputType = UFixed; using OutputInternalType = typename OutputType::InternalType; @@ -204,14 +204,14 @@ constexpr UFixed UFixed::fromInternal(cons // template< unsigned Integer, unsigned Fraction > -UFixed & UFixed::operator ++(void) +UFixed & UFixed::operator ++() { this->value += (1 << FractionSize); return *this; } template< unsigned Integer, unsigned Fraction > -UFixed & UFixed::operator --(void) +UFixed & UFixed::operator --() { this->value -= (1 << FractionSize); return *this; diff --git a/src/FixedPoints/Utils.h b/src/FixedPoints/Utils.h index 0d1cf6b..ea5ddba 100644 --- a/src/FixedPoints/Utils.h +++ b/src/FixedPoints/Utils.h @@ -63,7 +63,7 @@ constexpr UFixed nextafterFixed(const UFixed -UFixed randomUFixed(void); +UFixed randomUFixed(); template< unsigned Integer, unsigned Fraction > UFixed randomUFixed(const UFixed & exclusiveUpperBound); @@ -78,7 +78,7 @@ UFixed randomUFixed(const UFixed & inclusi #if !defined(FIXED_POINTS_NO_RANDOM) template< unsigned Integer, unsigned Fraction > -SFixed randomSFixed(void); +SFixed randomSFixed(); template< unsigned Integer, unsigned Fraction > SFixed randomSFixed(const SFixed & exclusiveUpperBound); @@ -204,7 +204,7 @@ constexpr UFixed nextafterFixed(const UFixed -UFixed randomUFixed(void) +UFixed randomUFixed() { using InternalType = typename UFixed::InternalType; return UFixed::fromInternal(FIXED_POINTS_DETAILS::RandomHelper::Random()); @@ -231,7 +231,7 @@ UFixed randomUFixed(const UFixed & inclusi #if !defined(FIXED_POINTS_NO_RANDOM) template< unsigned Integer, unsigned Fraction > -SFixed randomSFixed(void) +SFixed randomSFixed() { using InternalType = typename SFixed::InternalType; return SFixed::fromInternal(FIXED_POINTS_DETAILS::RandomHelper::Random());