From 10f9364209082be58361c455f437b910cb5c29fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yohann=20B=C3=A9n=C3=A9dic?= Date: Wed, 7 Feb 2024 11:56:24 +0100 Subject: [PATCH] clang format --- include/io1/money.hpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/include/io1/money.hpp b/include/io1/money.hpp index cc2c2e3..db31101 100644 --- a/include/io1/money.hpp +++ b/include/io1/money.hpp @@ -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::max() >= 9'223'372'036'854'775'807 && // NOLINT(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers) - std::numeric_limits::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::max() >= + 9'223'372'036'854'775'807 && // NOLINT(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers) + std::numeric_limits::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; @@ -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, + value_type divisor) noexcept // NOLINT(bugprone-easily-swappable-parameters) : std::runtime_error("Cannot perform an inexact division!"), dividend(dividend), divisor(divisor) { } @@ -231,15 +236,11 @@ namespace io1 constexpr auto new_mantissa = []() { if constexpr (not_a_digit()) { return CURRENT_MANTISSA; } - else - { - return parse_digit(); - } + else { return parse_digit(); } }(); if constexpr (0 < sizeof...(STR)) { return parse_mantissa(); } - else - { return new_mantissa; } + else { return new_mantissa; } } }; } // namespace detail @@ -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;