[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] odd/unique_vs_shared2 8b18269 1/4: Move a defaulted
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] odd/unique_vs_shared2 8b18269 1/4: Move a defaulted dtor out of its header (for unique_ptr) |
Date: |
Fri, 5 Feb 2021 18:29:45 -0500 (EST) |
branch: odd/unique_vs_shared2
commit 8b1826908f6897986bd95847176ff7e1ccf5fd02
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Move a defaulted dtor out of its header (for unique_ptr)
* basic_values.hpp: To prepare for holding objects of some forward-
declared classes by std::unique_ptr, moved dtor out of header.
* basicvalues.cpp: Moved dtor into TU.
* ihs_basicval.cpp: Likewise.
* ihs_irc7702.cpp: Adopted a uniform comment block that better explains
the dtor rationale, specifically mentioning std::unique_ptr.
---
basic_values.hpp | 2 +-
basicvalues.cpp | 9 +++++++++
ihs_basicval.cpp | 9 +++++++++
ihs_irc7702.cpp | 7 ++++---
4 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/basic_values.hpp b/basic_values.hpp
index 9bb237f..e6771a4 100644
--- a/basic_values.hpp
+++ b/basic_values.hpp
@@ -96,7 +96,7 @@ class LMI_SO BasicValues
,double a_TargetPremium
);
BasicValues(BasicValues&&) = default;
- virtual ~BasicValues() = default;
+ virtual ~BasicValues();
void Init();
diff --git a/basicvalues.cpp b/basicvalues.cpp
index 08a2d1b..659277a 100644
--- a/basicvalues.cpp
+++ b/basicvalues.cpp
@@ -85,6 +85,15 @@ BasicValues::BasicValues(Input const& input)
Init();
}
+/// Destructor.
+///
+/// Although it is explicitly defaulted, this destructor is not
+/// implemented inside the class definition, because the header
+/// forward-declares one or more classes that are held by
+/// std::unique_ptr, so their destructors are visible only here.
+
+BasicValues::~BasicValues() = default;
+
//============================================================================
void BasicValues::Init()
{
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 9ca74f1..9010187 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -163,6 +163,15 @@ BasicValues::BasicValues
Init();
}
+/// Destructor.
+///
+/// Although it is explicitly defaulted, this destructor is not
+/// implemented inside the class definition, because the header
+/// forward-declares one or more classes that are held by
+/// std::unique_ptr, so their destructors are visible only here.
+
+BasicValues::~BasicValues() = default;
+
//============================================================================
void BasicValues::Init()
{
diff --git a/ihs_irc7702.cpp b/ihs_irc7702.cpp
index a249014..c7355b3 100644
--- a/ihs_irc7702.cpp
+++ b/ihs_irc7702.cpp
@@ -204,9 +204,10 @@ Irc7702::Irc7702
/// Destructor.
///
-/// Although it is explicitly defaulted, this destructor cannot be
-/// implemented inside the class definition, where a class type that
-/// it depends upon is incomplete.
+/// Although it is explicitly defaulted, this destructor is not
+/// implemented inside the class definition, because the header
+/// forward-declares one or more classes that are held by
+/// std::unique_ptr, so their destructors are visible only here.
Irc7702::~Irc7702() = default;