[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 21685250 11/13: Use another abstract-xor-fina
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 21685250 11/13: Use another abstract-xor-final hierarchy |
Date: |
Wed, 27 Jul 2022 15:16:34 -0400 (EDT) |
branch: master
commit 216852504615213079f1a37a9037a3517b4ef5c2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Use another abstract-xor-final hierarchy
---
any_entity.hpp | 12 +++---------
any_member.hpp | 2 ++
any_member_test.cpp | 16 +++++++---------
3 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/any_entity.hpp b/any_entity.hpp
index f451a6e1..8097235a 100644
--- a/any_entity.hpp
+++ b/any_entity.hpp
@@ -24,6 +24,8 @@
#include "config.hpp"
+#include "crtp_base.hpp" // abstract_base
+
#include <ostream>
#include <string>
#include <typeinfo>
@@ -32,17 +34,9 @@
/// entities in the MVC Model. Class any_member is derived from this
/// class, but other implementations may be substituted.
-class any_entity
+class any_entity : private lmi::abstract_base<any_entity>
{
public:
- any_entity() = default;
-
- any_entity(any_entity const&) = default;
- any_entity(any_entity&&) = default;
- any_entity& operator=(any_entity const&) = default;
- any_entity& operator=(any_entity&&) = default;
- virtual ~any_entity() = default;
-
any_entity& operator=(std::string const& s) {return assign(s);}
virtual std::string str() const = 0;
diff --git a/any_member.hpp b/any_member.hpp
index 22f7c1d1..e60a1726 100644
--- a/any_member.hpp
+++ b/any_member.hpp
@@ -265,6 +265,8 @@ class any_member final
template<typename ExactMemberType>
ExactMemberType* exact_cast();
+ void concrete_if_not_pure() override {}
+
// any_entity required implementation.
any_member& assign(std::string const&) override;
diff --git a/any_member_test.cpp b/any_member_test.cpp
index c6f7140b..9529264e 100644
--- a/any_member_test.cpp
+++ b/any_member_test.cpp
@@ -23,6 +23,7 @@
#include "any_member.hpp"
+#include "crtp_base.hpp" // abstract_base
#include "test_tools.hpp"
#include <cmath> // exp()
@@ -32,17 +33,11 @@
#include <ostream>
#include <sstream>
-struct base_datum
+struct base_datum : private lmi::abstract_base<base_datum>
{
base_datum() :sane(7) {}
- base_datum(base_datum const&) = default;
- base_datum(base_datum&&) = default;
- base_datum& operator=(base_datum const&) = default;
- base_datum& operator=(base_datum&&) = default;
- virtual ~base_datum() = default; // Just to make it polymorphic.
-
- virtual int virtual_function() = 0; // Just to make it abstract.
+ virtual int virtual_function() = 0;
bool base_function()
{
std::cout << "base_datum::base_function() called " << sane <<
std::endl;
@@ -63,12 +58,15 @@ std::ostream& operator<<(std::ostream& os, base_datum
const& z)
return os << z.sane << '\n';
}
-struct derived_datum
+struct derived_datum final
:public base_datum
{
bool operator==(derived_datum const& z) const
{return 7 == sane && 7 == z.sane;}
int virtual_function() override {return 1729;}
+
+ private:
+ void concrete_if_not_pure() override {}
};
// Unused stub.
- [lmi-commits] [lmi] master 41339667 06/13: Rename uncopyable_lmi.hpp -> crtp_base.hpp, (continued)
- [lmi-commits] [lmi] master 41339667 06/13: Rename uncopyable_lmi.hpp -> crtp_base.hpp, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 48007e3c 09/13: Support an abstract-xor-final hierarchy, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master a07a61b8 13/13: Declutter, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 22a759fa 12/13: Devirtualize, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master f12819ba 02/13: Make md5sum_for_file ctor noexcept, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 6e590f5c 01/13: Work around a spurious gcc 12 -Wnull-dereference, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 0c2fceb0 04/13: Resurrect 'uncopyable_lmi.hpp', Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master cde94ff9 10/13: Use an abstract-xor-final hierarchy, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master efa79f5c 07/13: Establish unit tests for CRTP convenience classes, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 4ebf92ed 03/13: Suppress warnings for deprecated unary_function in cgicc, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 21685250 11/13: Use another abstract-xor-final hierarchy,
Greg Chicares <=
- [lmi-commits] [lmi] master 2143f359 08/13: Add unit tests for CRTP convenience classes, Greg Chicares, 2022/07/27