lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 638d421 6/6: Prefer explicitly-defaulted to u


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 638d421 6/6: Prefer explicitly-defaulted to user-written default ctor
Date: Mon, 6 Mar 2017 19:46:58 -0500 (EST)

branch: master
commit 638d4213533fe798e108cd9cd6ec3ae758f593ab
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Prefer explicitly-defaulted to user-written default ctor
    
    Replaced a ctor that had not been explicitly defaulted but could
    readily be, by substituting brace-or-equal-initializers for
    ctor-initializers.
---
 round_to.hpp | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/round_to.hpp b/round_to.hpp
index be13c1e..63814d3 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -285,7 +285,9 @@ class round_to
     static_assert(std::is_floating_point<RealType>::value, "");
 
   public:
-    round_to();
+    /// The default ctor only makes the class DefaultConstructible;
+    /// the object it creates throws on use.
+    round_to() = default;
     round_to(int decimals, rounding_style style);
     round_to(round_to const&) = default;
     round_to& operator=(round_to const&) = default;
@@ -300,26 +302,13 @@ class round_to
     using rounding_fn_t = RealType (*)(RealType);
     rounding_fn_t select_rounding_function(rounding_style) const;
 
-    int decimals_;
-    rounding_style style_;
-    max_prec_real scale_fwd_;
-    max_prec_real scale_back_;
-    rounding_fn_t rounding_function_;
+    int decimals_                    {0};
+    rounding_style style_            {r_indeterminate};
+    max_prec_real scale_fwd_         {1.0};
+    max_prec_real scale_back_        {1.0};
+    rounding_fn_t rounding_function_ {detail::erroneous_rounding_function};
 };
 
-/// This default ctor serves only to render the class DefaultConstructible.
-/// The object it creates throws on use.
-
-template<typename RealType>
-round_to<RealType>::round_to()
-    :decimals_          (0)
-    ,style_             (r_indeterminate)
-    ,scale_fwd_         (1.0)
-    ,scale_back_        (1.0)
-    ,rounding_function_ (detail::erroneous_rounding_function)
-{
-}
-
 // Naran used const data members, reasoning that a highly optimizing
 // compiler could then calculate std::pow(10.0, n) at compile time.
 // Not all compilers do this. None available to the author do.



reply via email to

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