[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0c65a684 3/4: Default five special members fo
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0c65a684 3/4: Default five special members for RTTI class; test them all |
Date: |
Tue, 12 Jul 2022 17:53:10 -0400 (EDT) |
branch: master
commit 0c65a684dfdae9e9aaec2d2320af2c28604f21ad
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Default five special members for RTTI class; test them all
---
rtti_lmi.hpp | 4 ++--
rtti_lmi_test.cpp | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/rtti_lmi.hpp b/rtti_lmi.hpp
index e20d704d..3570937f 100644
--- a/rtti_lmi.hpp
+++ b/rtti_lmi.hpp
@@ -85,7 +85,7 @@ namespace lmi
/// explains why the addresses of std::type_info objects should not
/// be compared directly.
///
-/// Implicitly-declared special member functions do the right thing.
+/// Explicitly-defaulted special member functions do the right thing.
/// It may seem odd to say that of a class with a pointer member, but
/// std::type_info is not Copyable, so a deep copy is not possible;
/// neither is it necessary, because a std::type_info object is, in
@@ -126,7 +126,7 @@ class TypeInfo final
TypeInfo(std::type_info const& z): ti_(&z) {}
TypeInfo(TypeInfo const&) = default;
- TypeInfo(TypeInfo&&) = delete;
+ TypeInfo(TypeInfo&&) = default;
TypeInfo& operator=(TypeInfo const&) = default;
TypeInfo& operator=(TypeInfo&&) = default;
~TypeInfo() = default;
diff --git a/rtti_lmi_test.cpp b/rtti_lmi_test.cpp
index bc3ad762..bd338621 100644
--- a/rtti_lmi_test.cpp
+++ b/rtti_lmi_test.cpp
@@ -27,6 +27,7 @@
#include <map>
#include <sstream>
+#include <utility> // std::move()
#include <vector>
struct RttiLmiTest
@@ -49,6 +50,17 @@ void RttiLmiTest::TestTypeInfo()
lmi::TypeInfo ti2(ti1);
LMI_TEST(typeid(int) == *ti2.ti_);
+ // MoveAssignable.
+ lmi::TypeInfo mti0(typeid(double));
+ lmi::TypeInfo mti1(typeid(int));
+ mti0 = std::move(mti1);
+ LMI_TEST(typeid(int) == *mti0.ti_);
+
+ // MoveConstructible.
+
+ lmi::TypeInfo mti2(std::move(mti0));
+ LMI_TEST(typeid(int) == *mti2.ti_);
+
// EqualityComparable.
LMI_TEST(ti1 == ti2);