[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 98a214c 01/14: Rule of three <<< five < zero
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 98a214c 01/14: Rule of three <<< five < zero |
Date: |
Thu, 1 Apr 2021 18:15:16 -0400 (EDT) |
branch: master
commit 98a214c2a5418a7d5ccb8889d88b884d8bab27e9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Rule of three <<< five < zero
This class has const data members, so copy and move assignment are
implicitly deleted. The rule of zero works well nevertheless: it
defines all special member functions as defaulted, and it defines
defaulted assignment operators as deleted where necessary.
Specifying five special member functions explicitly is not usually
necessary. Specifying three and relying on implicit rules to delete
certain others seems quirky.
---
i7702.hpp | 4 ----
i7702_test.cpp | 7 +++++++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/i7702.hpp b/i7702.hpp
index 9e05c57..4b739ca 100644
--- a/i7702.hpp
+++ b/i7702.hpp
@@ -41,10 +41,6 @@ class LMI_SO i7702 final
,stratified_charges const&
);
- i7702(i7702 const&) = delete;
- i7702& operator=(i7702 const&) = delete;
- ~i7702() = default;
-
std::vector<double> const& ic_usual() const {return ic_usual_;}
std::vector<double> const& ic_glp () const {return ic_glp_ ;}
std::vector<double> const& ic_gsp () const {return ic_gsp_ ;}
diff --git a/i7702_test.cpp b/i7702_test.cpp
index ff052db..40e0cca 100644
--- a/i7702_test.cpp
+++ b/i7702_test.cpp
@@ -71,6 +71,13 @@ void i7702_test::test0()
LMI_TEST(materially_equal(0.00327373978219886374239, z.ig_usual()[0]));
std::cout<< std::setprecision(DECIMAL_DIG) << z.ig_usual()[0] << std::endl;
+
+ // Class i7702 is copy- and move-constructible, but not assignable
+ // because of const data members.
+ i7702 x = z;
+ i7702 y = std::move(z);
+// x = y; // operator=(i7702 const&) implicitly deleted
+// x = std::move(y); // operator=(i7702&&) implicitly deleted
}
void i7702_test::test1()
- [lmi-commits] [lmi] master updated (8d18fa1 -> 29b2ad4), Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 98a214c 01/14: Rule of three <<< five < zero,
Greg Chicares <=
- [lmi-commits] [lmi] master c309291 02/14: Factor out precondition assertions, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 218e02a 03/14: Reflect short-term guarantees in 7702 interest rates, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 2d10858 06/14: Use DB_AnnIntRateGspDelta instead of hard-coding two percent, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 8a9085a 08/14: Reflect DB_GenAcctIntBonus in 7702 interest, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 836c6f9 09/14: Refactor unit test, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 637f0de 12/14: Reorder unit-test functions, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master c291b59 05/14: Assert more preconditions, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master cb16682 10/14: Make i7702 vector assignments idempotent, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 8723736 11/14: Make bland1() truly bland, Greg Chicares, 2021/04/01
- [lmi-commits] [lmi] master 36266d1 13/14: Don't echo unneeded values in unit test, Greg Chicares, 2021/04/01