[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 33d09e1: Remove accidental use of a reserved
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 33d09e1: Remove accidental use of a reserved identifier |
Date: |
Sat, 8 May 2021 21:25:34 -0400 (EDT) |
branch: master
commit 33d09e15ab2b013a4793678478d3e1fabc564d38
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Remove accidental use of a reserved identifier
C++11 made a stray space obligatory, and thus required the use of
reserved identifiers, at least in the global namespace. That mistake
has been rectified; C++20 (N4861) gives these examples:
// OK: does not use the reserved identifier _Bq (5.10)
double operator""_Bq(long double);
// uses the reserved identifier _Bq (5.10)
double operator"" _Bq(long double);
'_cents' was chosen precisely because it can be used at global scope
without causing any conflict: lmi certainly won't use another currency
library, or any other sort of library that would use that name. Writing
zero as
currency::0_cents
would be rather too verbose.
Incidentally made the operator 'inline'.
---
currency.hpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/currency.hpp b/currency.hpp
index 3f4a6f7..8a6ce9f 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -39,7 +39,7 @@ class currency
friend currency from_cents(double); // private ctor
template<typename> friend class round_to; // private ctor
friend class round_to_test; // currency::cents_digits
- friend constexpr currency operator"" _cents(unsigned long long int);
+ friend constexpr currency operator""_cents(unsigned long long int);
static constexpr int cents_digits = 2;
static constexpr double cents_per_dollar = 100.0;
@@ -70,7 +70,7 @@ class currency
data_type m_ = {};
};
-constexpr currency operator"" _cents(unsigned long long int cents)
+inline constexpr currency operator""_cents(unsigned long long int cents)
{
constexpr auto mant_dig = std::numeric_limits<currency::data_type>::digits;
constexpr unsigned long long int limit = 1ULL << mant_dig;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [lmi] master 33d09e1: Remove accidental use of a reserved identifier,
Greg Chicares <=