Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
yobeonline committed Feb 7, 2024
1 parent 5f77c10 commit 10f9364
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions include/io1/money.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ namespace io1
using value_type = std::int64_t;
// -9'223'372'036'854'775'807-1 below, is a portable way to have the value -9'223'372'036'854'775'808 with no
// overflow because of operator- applied after the positive int (too big) is created.
static_assert(std::numeric_limits<value_type>::max() >= 9'223'372'036'854'775'807 && // NOLINT(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers)
std::numeric_limits<value_type>::lowest() <= -9'223'372'036'854'775'807 - 1, // NOLINT(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers)
"Type too short to hold the advertised value range.");
static_assert(
std::numeric_limits<value_type>::max() >=
9'223'372'036'854'775'807 && // NOLINT(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers)
std::numeric_limits<value_type>::lowest() <=
-9'223'372'036'854'775'807 -

Check failure on line 30 in include/io1/money.hpp

View workflow job for this annotation

GitHub Actions / clang-tidy

clang-tidy: 9'223'372'036'854'775'807 is a magic number; consider replacing it with a named constant (cppcoreguidelines-avoid-magic-numbers)
1, // NOLINT(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers)
"Type too short to hold the advertised value range.");

money() noexcept = default;

Expand Down Expand Up @@ -101,7 +105,8 @@ namespace io1

struct [[nodiscard]] InexactDivision : public std::runtime_error
{
explicit InexactDivision(value_type dividend, value_type divisor) noexcept // NOLINT(bugprone-easily-swappable-parameters)
explicit InexactDivision(value_type dividend,

Check failure on line 108 in include/io1/money.hpp

View workflow job for this annotation

GitHub Actions / clang-tidy

clang-tidy: 2 adjacent parameters of 'InexactDivision' of similar type ('io1::money::value_type') are easily swapped by mistake (bugprone-easily-swappable-parameters)
value_type divisor) noexcept // NOLINT(bugprone-easily-swappable-parameters)
: std::runtime_error("Cannot perform an inexact division!"), dividend(dividend), divisor(divisor)
{
}
Expand Down Expand Up @@ -231,15 +236,11 @@ namespace io1
constexpr auto new_mantissa = []()
{
if constexpr (not_a_digit<DIGIT>()) { return CURRENT_MANTISSA; }
else
{
return parse_digit<CURRENT_MANTISSA, DIGIT>();
}
else { return parse_digit<CURRENT_MANTISSA, DIGIT>(); }
}();

if constexpr (0 < sizeof...(STR)) { return parse_mantissa<new_mantissa, STR...>(); }
else
{ return new_mantissa; }
else { return new_mantissa; }
}
};
} // namespace detail
Expand All @@ -250,7 +251,8 @@ namespace io1
}
inline std::istream & operator>>(std::istream & stream, io1::money & val)
{
io1::money::value_type amount; // NOLINT(cppcoreguidelines-init-variables) value is used once we have confirmation that it has been initialized
io1::money::value_type amount; // NOLINT(cppcoreguidelines-init-variables) value is used once we have confirmation
// that it has been initialized
stream >> amount;
if (stream) { val = io1::money(amount); } // strong guarantee
return stream;
Expand Down

0 comments on commit 10f9364

Please sign in to comment.