lmi-commits
[Top][All Lists]
Advanced

[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;
 }
 



reply via email to

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