[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/005 1dd82ec 3/9: Rationalize argument names
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/005 1dd82ec 3/9: Rationalize argument names |
Date: |
Wed, 20 Jan 2021 00:51:32 -0500 (EST) |
branch: valyuta/005
commit 1dd82ec2f6ce0802113ac5a0c4f290fedfd484dc
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Rationalize argument names
Naming the argument in a declaration like
void foo(some_object an_object);
is useless; worse, over time, such a name is likely to diverge from
the name used in a definition elsewhere, creating confusion.
If an argument of a "real" type is naturally called 'r', then using
the same name for a std::vector<that_real_type> is confusing; it's
better to differentiate them (using 'v' for a vector, e.g.), or to
use 'z' everywhere.
---
round_to.hpp | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/round_to.hpp b/round_to.hpp
index 132c077..41d66d9 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -264,13 +264,13 @@ class round_to
round_to& operator=(round_to const&) = default;
bool operator==(round_to const&) const;
- RealType operator()(RealType r) const;
- std::vector<RealType> operator()(std::vector<RealType> const& r) const;
+ RealType operator()(RealType) const;
+ std::vector<RealType> operator()(std::vector<RealType> const&) const;
- currency c(RealType r) const;
- std::vector<currency> c(std::vector<RealType> const& r) const;
+ currency c(RealType) const;
+ std::vector<currency> c(std::vector<RealType> const&) const;
- currency c(currency z) const;
+ currency c(currency) const;
int decimals() const;
rounding_style style() const;
@@ -374,11 +374,11 @@ inline RealType round_to<RealType>::operator()(RealType
r) const
template<typename RealType>
inline std::vector<RealType> round_to<RealType>::operator()
- (std::vector<RealType> const& r) const
+ (std::vector<RealType> const& v) const
{
std::vector<RealType> z;
- z.reserve(r.size());
- for(auto const& i : r) {z.push_back(operator()(i));}
+ z.reserve(v.size());
+ for(auto const& i : v) {z.push_back(operator()(i));}
return z;
}
@@ -394,11 +394,11 @@ inline currency round_to<RealType>::c(RealType r) const
template<typename RealType>
inline std::vector<currency> round_to<RealType>::c
- (std::vector<RealType> const& r) const
+ (std::vector<RealType> const& v) const
{
std::vector<currency> z;
- z.reserve(r.size());
- for(auto const& i : r) {z.push_back(c(i));}
+ z.reserve(v.size());
+ for(auto const& i : v) {z.push_back(c(i));}
return z;
}
- [lmi-commits] [lmi] valyuta/005 updated (4401725 -> ca84095), Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 4483b09 1/9: Avoid passing 'currency' by const reference, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 1dd82ec 3/9: Rationalize argument names,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/005 cb722b2 4/9: Replace a complaint with a solution, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 2e73521 5/9: Begin to conditionalize use of currency class, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 b835c6d 2/9: Partially revert the last commit, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 afa4967 8/9: Make lmi build without currency class, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 ca84095 9/9: Record speed measurements, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 df368ca 6/9: Replace currency::d() with d(currency) almost everywhere, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 75f8adf 7/9: Add and use free function from_cents(), Greg Chicares, 2021/01/20