lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] valyuta/002 53de040 01/14: Add an extra argument to


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 53de040 01/14: Add an extra argument to currency(data_type)
Date: Thu, 17 Sep 2020 16:27:13 -0400 (EDT)

branch: valyuta/002
commit 53de040b178cdf45d900016a0b9d58c4afbe40c2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Add an extra argument to currency(data_type)
    
    currency::data_type needn't necessarily be 'std::int64_t'; perhaps
    'double' would be better. Changing it to 'double' would ambiguate the
    currency(data_type) ctor:
        explicit currency(double    d)
        explicit currency(int       i)
    -   explicit currency(data_type i)
    +   explicit currency(data_type i, bool)
    Prevented that problem by adding an extra, disregarded argument.
---
 currency.hpp | 2 +-
 round_to.hpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/currency.hpp b/currency.hpp
index fc0d61e..f0c153d 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -65,7 +65,7 @@ class currency
 
     explicit currency(double    d) : m_ {from_double(d)}           {}
     explicit currency(int       i) : m_ {cents_per_dollar * 
bourn_cast<data_type>(i)} {}
-    explicit currency(data_type i) : m_ {bourn_cast<data_type>(i)} {}
+    explicit currency(data_type i, bool) : m_ {i} {}
 
     currency& operator=(currency const&) = default;
     // IMPORTANT eventually suppress this? or both of these?
diff --git a/round_to.hpp b/round_to.hpp
index 1779712..498ef7e 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -392,7 +392,7 @@ inline currency round_to<RealType>::c(RealType r) const
         (rounding_function_(static_cast<RealType>(r * scale_fwd_)) * 
scale_back_c_
         );
     // include required headers
-    return currency(bourn_cast<currency::data_type>(z));
+    return currency(bourn_cast<currency::data_type>(z), true);
 #if 0
     // don't do this in production:
     if(z != std::trunc(z))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]