Skip to content

Commit

Permalink
further corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
yobeonline committed Feb 7, 2024
1 parent 3f6e80c commit 61f6bc0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/io1/money.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ 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)
std::numeric_limits<value_type>::lowest() <= -9'223'372'036'854'775'807 - 1, // NOLINT(cppcoreguidelines-avoid-magic-numbers)
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.");

money() noexcept = default;
Expand All @@ -46,8 +46,8 @@ namespace io1

[[nodiscard]] constexpr value_type const & data() const noexcept { return amount_; }

[[nodiscard]] constexpr money const operator++(int) noexcept { return money{amount_++}; }
[[nodiscard]] constexpr money const operator--(int) noexcept { return money{amount_--}; }
[[nodiscard]] constexpr money operator++(int) noexcept { return money{amount_++}; }

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

View workflow job for this annotation

GitHub Actions / clang-tidy

clang-tidy: overloaded 'operator++' returns a non-constant object instead of a constant object type (cert-dcl21-cpp)
[[nodiscard]] constexpr money operator--(int) noexcept { return money{amount_--}; }

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

View workflow job for this annotation

GitHub Actions / clang-tidy

clang-tidy: overloaded 'operator--' returns a non-constant object instead of a constant object type (cert-dcl21-cpp)

constexpr money & operator++() noexcept
{
Expand Down Expand Up @@ -250,7 +250,7 @@ namespace io1
}
inline std::istream & operator>>(std::istream & stream, io1::money & val)
{
io1::money::value_type amount;
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 61f6bc0

Please sign in to comment.