[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 6a59da54 8/8: When in doubt, prefer the Rule
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 6a59da54 8/8: When in doubt, prefer the Rule of Five to the Rule of Zero |
Date: |
Sun, 10 Jul 2022 20:41:31 -0400 (EDT) |
branch: master
commit 6a59da54d452e0e623714dfcdb48dabbff172f1d
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
When in doubt, prefer the Rule of Five to the Rule of Zero
The Rule of Zero is fine for trivial classes, but few if any of these
classes are trivial. See:
https://lists.nongnu.org/archive/html/lmi/2022-07/msg00028.html
This revision reverts the deletion of dtors, and adds the four other
special member functions as "= delete" if possible or "= default" if
necessary for compiling and linking. Inspecting the haphazard outcomes
suggests that this is not a good strategy, though the exercise was
illuminating.
In class product_data, the copy ctor and copy assignment operator had
been private, with the former implemented out of line and the latter
deleted. The deleted member needn't be private. Perhaps the copy ctor
should be private, or perhaps not; that will be considered next, but
for now it's public.
---
dbvalue.hpp | 6 ++++++
fund_data.hpp | 6 ++++++
gpt_server.hpp | 6 ++++++
ihs_irc7702a.hpp | 6 ++++++
illustrator.hpp | 6 ++++++
ledger.hpp | 6 ++++++
mec_server.hpp | 6 ++++++
product_data.hpp | 16 ++++++++++++----
rounding_rules.hpp | 6 ++++++
rtti_lmi.hpp | 6 ++++++
stratified_charges.hpp | 6 ++++++
test_coding_rules.cpp | 6 ++++++
yare_input.hpp | 6 ++++++
13 files changed, 84 insertions(+), 4 deletions(-)
diff --git a/dbvalue.hpp b/dbvalue.hpp
index 6ee024b9..6e27f797 100644
--- a/dbvalue.hpp
+++ b/dbvalue.hpp
@@ -78,6 +78,12 @@ class LMI_SO database_entity final
,std::string const& gloss = std::string()
);
+ database_entity(database_entity const&) = default;
+ database_entity(database_entity&&) = delete;
+ database_entity& operator=(database_entity const&) = default;
+ database_entity& operator=(database_entity&&) = default;
+ ~database_entity() = default;
+
bool operator==(database_entity const&) const;
void reshape(std::vector<int> const& dims);
diff --git a/fund_data.hpp b/fund_data.hpp
index 15478273..96be4017 100644
--- a/fund_data.hpp
+++ b/fund_data.hpp
@@ -48,6 +48,12 @@ class LMI_SO FundInfo final
,std::string const& gloss = std::string()
);
+ FundInfo(FundInfo const&) = default;
+ FundInfo(FundInfo&&) = default;
+ FundInfo& operator=(FundInfo const&) = delete;
+ FundInfo& operator=(FundInfo&&) = default;
+ ~FundInfo() = default;
+
double ScalarIMF() const;
std::string const& ShortName() const;
std::string const& LongName() const;
diff --git a/gpt_server.hpp b/gpt_server.hpp
index cafeb177..f911087f 100644
--- a/gpt_server.hpp
+++ b/gpt_server.hpp
@@ -48,6 +48,12 @@ class LMI_SO gpt_server final
public:
explicit gpt_server(mcenum_emission);
+ gpt_server(gpt_server const&) = default;
+ gpt_server(gpt_server&&) = default;
+ gpt_server& operator=(gpt_server const&) = delete;
+ gpt_server& operator=(gpt_server&&) = delete;
+ ~gpt_server() = default;
+
bool operator()(fs::path const&);
bool operator()(fs::path const&, gpt_input const&);
diff --git a/ihs_irc7702a.hpp b/ihs_irc7702a.hpp
index 16ebacc4..c778b6d7 100644
--- a/ihs_irc7702a.hpp
+++ b/ihs_irc7702a.hpp
@@ -67,6 +67,12 @@ class Irc7702A final
// TAXATION !! probably other arguments are needed for reproposals
);
+ Irc7702A(Irc7702A const&) = default;
+ Irc7702A(Irc7702A&&) = delete;
+ Irc7702A& operator=(Irc7702A const&) = delete;
+ Irc7702A& operator=(Irc7702A&&) = delete;
+ ~Irc7702A() = default;
+
void Initialize7702A
(bool a_Ignore
,bool a_MecAtIssue
diff --git a/illustrator.hpp b/illustrator.hpp
index 7971e467..62209d8a 100644
--- a/illustrator.hpp
+++ b/illustrator.hpp
@@ -43,6 +43,12 @@ class LMI_SO illustrator final
public:
explicit illustrator(mcenum_emission);
+ illustrator(illustrator const&) = default;
+ illustrator(illustrator&&) = default;
+ illustrator& operator=(illustrator const&) = delete;
+ illustrator& operator=(illustrator&&) = delete;
+ ~illustrator() = default;
+
bool operator()(fs::path const&);
bool operator()(fs::path const&, Input const&);
bool operator()(fs::path const&, std::vector<Input> const&);
diff --git a/ledger.hpp b/ledger.hpp
index 66856941..2fdbd511 100644
--- a/ledger.hpp
+++ b/ledger.hpp
@@ -73,6 +73,12 @@ class LMI_SO Ledger final
,bool is_composite
);
+ Ledger(Ledger const&) = default;
+ Ledger(Ledger&&) = delete;
+ Ledger& operator=(Ledger const&) = delete;
+ Ledger& operator=(Ledger&&) = delete;
+ virtual ~Ledger() = default;
+
void ZeroInforceAfterLapse();
Ledger& PlusEq(Ledger const& a_Addend);
diff --git a/mec_server.hpp b/mec_server.hpp
index fb6b707c..a037c879 100644
--- a/mec_server.hpp
+++ b/mec_server.hpp
@@ -48,6 +48,12 @@ class LMI_SO mec_server final
public:
explicit mec_server(mcenum_emission);
+ mec_server(mec_server const&) = default;
+ mec_server(mec_server&&) = default;
+ mec_server& operator=(mec_server const&) = delete;
+ mec_server& operator=(mec_server&&) = delete;
+ ~mec_server() = default;
+
bool operator()(fs::path const&);
bool operator()(fs::path const&, mec_input const&);
diff --git a/product_data.hpp b/product_data.hpp
index 0294af0d..237bcecd 100644
--- a/product_data.hpp
+++ b/product_data.hpp
@@ -51,6 +51,12 @@ class glossed_string final
,std::string const& gloss = std::string()
);
+ glossed_string(glossed_string const&) = default;
+ glossed_string(glossed_string&&) = default;
+ glossed_string& operator=(glossed_string const&) = default;
+ glossed_string& operator=(glossed_string&&) = default;
+ ~glossed_string() = default;
+
glossed_string& operator=(std::string const&);
bool operator==(glossed_string const&) const;
@@ -91,7 +97,12 @@ class LMI_SO product_data
public:
explicit product_data(fs::path const& product_filename);
explicit product_data(std::string const& product_name);
- ~product_data() override;
+
+ product_data(product_data const&); // Implemented out of line.
+ product_data(product_data&&) = delete;
+ product_data& operator=(product_data const&) = delete;
+ product_data& operator=(product_data&&) = delete;
+ ~product_data() override; // Implemented out of line.
std::string const& datum(std::string const& name) const;
@@ -104,9 +115,6 @@ class LMI_SO product_data
glossed_string& item(std::string const& name);
private:
- product_data(product_data const&);
- product_data& operator=(product_data const&) = delete;
-
void ascribe_members();
// xml_serializable required implementation.
diff --git a/rounding_rules.hpp b/rounding_rules.hpp
index 402dcb6d..9d986ef0 100644
--- a/rounding_rules.hpp
+++ b/rounding_rules.hpp
@@ -49,6 +49,12 @@ class LMI_SO rounding_parameters final
,std::string const& gloss = std::string()
);
+ rounding_parameters(rounding_parameters const&) = default;
+ rounding_parameters(rounding_parameters&&) = delete;
+ rounding_parameters& operator=(rounding_parameters const&) = default;
+ rounding_parameters& operator=(rounding_parameters&&) = default;
+ ~rounding_parameters() = default;
+
bool operator==(rounding_parameters const&) const;
int decimals() const;
diff --git a/rtti_lmi.hpp b/rtti_lmi.hpp
index 00e4c5ac..17086548 100644
--- a/rtti_lmi.hpp
+++ b/rtti_lmi.hpp
@@ -125,6 +125,12 @@ class TypeInfo final
public:
TypeInfo(std::type_info const& z): ti_(&z) {}
+ TypeInfo(TypeInfo const&) = default;
+ TypeInfo(TypeInfo&&) = delete;
+ TypeInfo& operator=(TypeInfo const&) = default;
+ TypeInfo& operator=(TypeInfo&&) = default;
+ ~TypeInfo() = default;
+
bool operator==(TypeInfo const& z) const {return *z.ti_ == *ti_;}
bool operator<(TypeInfo const& z) const {return ti_->before(*z.ti_);}
diff --git a/stratified_charges.hpp b/stratified_charges.hpp
index 5d0bac87..50b1a2ee 100644
--- a/stratified_charges.hpp
+++ b/stratified_charges.hpp
@@ -78,6 +78,12 @@ class LMI_SO stratified_entity final
,std::string const& gloss = std::string()
);
+ stratified_entity(stratified_entity const&) = default;
+ stratified_entity(stratified_entity&&) = delete;
+ stratified_entity& operator=(stratified_entity const&) = default;
+ stratified_entity& operator=(stratified_entity&&) = default;
+ ~stratified_entity() = default;
+
bool operator==(stratified_entity const&) const;
void read (xml::element const& node);
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 9f2cf8e1..a9253f35 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -1171,6 +1171,12 @@ class statistics
public:
statistics() = default;
+ statistics(statistics const&) = delete;
+ statistics(statistics&&) = default;
+ statistics& operator=(statistics const&) = delete;
+ statistics& operator=(statistics&&) = delete;
+ ~statistics() = default;
+
statistics& operator+=(statistics const&);
static statistics analyze_file(file const&);
diff --git a/yare_input.hpp b/yare_input.hpp
index b202f59d..7f3f1751 100644
--- a/yare_input.hpp
+++ b/yare_input.hpp
@@ -55,6 +55,12 @@ class yare_input final
public:
explicit yare_input(Input const&);
+ yare_input(yare_input const&) = delete;
+ yare_input(yare_input&&) = default;
+ yare_input& operator=(yare_input const&) = delete;
+ yare_input& operator=(yare_input&&) = delete;
+ ~yare_input() = default;
+
int IssueAge ;
int RetirementAge ;
mcenum_gender Gender ;
- [lmi-commits] [lmi] master updated (2d6a27f6 -> 6a59da54), Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master 9d52b331 1/8: Correct a comment, Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master a5d06b78 6/8: Enable clang's '-Wdeprecated-copy-with-dtor', Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master 6a59da54 8/8: When in doubt, prefer the Rule of Five to the Rule of Zero,
Greg Chicares <=
- [lmi-commits] [lmi] master 601db178 2/8: Follow the Rule of Zero, Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master 4d052024 5/8: Follow the Rule of Five, Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master 7d05361b 3/8: Follow the Rule of Zero, even expunging a virtual dtor, Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master 702c4cdd 4/8: Follow the Rule of Zero (initializing all data members in class), Greg Chicares, 2022/07/10
- [lmi-commits] [lmi] master cb417264 7/8: Remove an antediluvian stub that has become unnecessary, Greg Chicares, 2022/07/10