[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))
- [lmi-commits] [lmi] valyuta/002 updated (9433c8e -> 3f71218), Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 53de040 01/14: Add an extra argument to currency(data_type),
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/002 c5e0b01 04/14: Make currency class mandatory, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 c80d1eb 09/14: Add two experimental options, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 e4cb0f1 10/14: Make it float, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 cfe336c 11/14: Make it faster, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 4a6bc6c 02/14: Resolve confusion, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 0d47d8d 03/14: Refine an assertion, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 27c198e 05/14: fixup, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 3d1ff11 06/14: Remove useless casts, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 594bd68 07/14: Allow floating currency::data_type, Greg Chicares, 2020/09/17
- [lmi-commits] [lmi] valyuta/002 1fbef51 13/14: Make it even faster, Greg Chicares, 2020/09/17