changeset 921:1ba4d30b337d

Changed the miniumum standard to C++20 and fixed all compilation issues.
author John Schneiderman <JohnMS@member.fsf.org>
date Fri, 11 Nov 2022 12:18:31 +0100
parents 6435a3ad605a
children 465399fc22b7
files CMakeLists.txt src/budgeting/external/budgeting/BudgetedMoneyMap.hpp src/foundation/external/foundation/ObserverPtr.hpp src/foundation/external/foundation/QtMemory.hpp src/foundation/external/foundation/ScopeExecutor.cpp src/foundation/external/foundation/ScopeExecutor.h
diffstat 6 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Nov 07 20:27:19 2022 +0100
+++ b/CMakeLists.txt	Fri Nov 11 12:18:31 2022 +0100
@@ -25,7 +25,7 @@
 )
 
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 20)
 set(CMAKE_DEBUG_POSTFIX "d")
 set(${PROJECT_NAME}_COPYRIGHT_YEARS "\"2017 - 2021\"")
 
--- a/src/budgeting/external/budgeting/BudgetedMoneyMap.hpp	Mon Nov 07 20:27:19 2022 +0100
+++ b/src/budgeting/external/budgeting/BudgetedMoneyMap.hpp	Fri Nov 11 12:18:31 2022 +0100
@@ -264,7 +264,8 @@
 	const BudgetedMoneyMap& other
 ) const
 {
-	return static_cast<const std::map<BudgetSource, BudgetedMoneyType>&>(*this) == other;
+	return static_cast<const std::map<BudgetSource, BudgetedMoneyType>&>(*this)
+			== static_cast<const std::map<BudgetSource, BudgetedMoneyType>&>(other);
 }
 
 template<typename BudgetedMoneyType>
--- a/src/foundation/external/foundation/ObserverPtr.hpp	Mon Nov 07 20:27:19 2022 +0100
+++ b/src/foundation/external/foundation/ObserverPtr.hpp	Fri Nov 11 12:18:31 2022 +0100
@@ -70,7 +70,7 @@
 	 * @brief An accessor to the object being observed.
 	 */
 	ObservedType* observed() const;
-	// TODO: add operator& // TODO: then .observed is not needed in QtMemory.
+	// TODO: add operator& // TODO: then .observed is not needed in QtMemory, et al.
 };
 
 template<typename ObservedType>
@@ -125,7 +125,7 @@
 template<typename ObservedType>
 bool drn::foundation::ObserverPtr<ObservedType>::operator==(const ObserverPtr& other) const
 {
-	return *this == other.observed_;
+	return this->observed_ == other.observed_;
 }
 
 template<typename ObservedType>
@@ -207,7 +207,7 @@
 template<typename ObservedType, typename ObservedPtrType>
 bool drn::foundation::operator==(const ObservedType* lhs, const ObserverPtr<ObservedPtrType>& rhs)
 {
-	return rhs == lhs;
+	return lhs == rhs.observed();
 }
 
 template<typename ObservedType>
--- a/src/foundation/external/foundation/QtMemory.hpp	Mon Nov 07 20:27:19 2022 +0100
+++ b/src/foundation/external/foundation/QtMemory.hpp	Fri Nov 11 12:18:31 2022 +0100
@@ -59,7 +59,6 @@
 	using ObserverPtr<ObjectType>::observed;
 	using ObserverPtr<ObjectType>::operator*;
 	using ObserverPtr<ObjectType>::operator->;
-	using ObserverPtr<ObjectType>::operator=;
 	using ObserverPtr<ObjectType>::operator==;
 	using ObserverPtr<ObjectType>::operator!=;
 	using ObserverPtr<ObjectType>::operator<;
@@ -111,14 +110,13 @@
 >::type makeQtPtr(ObjectArgTypes&& ... objectArgs);
 
 // TODO: makeUniqueQtPtr
+template<typename ObservedType, typename ObservedPtrType>
+bool operator==(const ObservedType* lhs, const QtPtr<ObservedPtrType>& rhs);
 
 }}
 
 template<typename ObjectType>
-drn::foundation::QtPtr<ObjectType>::QtPtr(
-	ObjectType* const observe,
-	QMetaObject::Connection connection
-) :
+drn::foundation::QtPtr<ObjectType>::QtPtr(ObjectType* const observe) :
 	ObserverPtr<ObjectType>{observe},
 	connection_{connection}
 {}
@@ -196,4 +194,13 @@
 	return obj;
 }
 
+template<typename ObservedType, typename ObservedPtrType>
+bool drn::foundation::operator==(
+	const ObservedType* lhs,
+	const drn::foundation::QtPtr<ObservedPtrType>& rhs
+)
+{
+	return lhs == static_cast<ObserverPtr<ObservedPtrType>>(rhs);
+}
+
 #endif
--- a/src/foundation/external/foundation/ScopeExecutor.cpp	Mon Nov 07 20:27:19 2022 +0100
+++ b/src/foundation/external/foundation/ScopeExecutor.cpp	Fri Nov 11 12:18:31 2022 +0100
@@ -27,7 +27,7 @@
 using std::move;
 
 
-ScopeExecutor::ScopeExecutor(function<void() noexcept> execute) :
+ScopeExecutor::ScopeExecutor(function<void() /*noexcept*/> execute) :
 	execute_{move(execute)}
 {
 	assert(this->execute_ != nullptr && "The supplied execute function cannot be null");
--- a/src/foundation/external/foundation/ScopeExecutor.h	Mon Nov 07 20:27:19 2022 +0100
+++ b/src/foundation/external/foundation/ScopeExecutor.h	Fri Nov 11 12:18:31 2022 +0100
@@ -35,7 +35,7 @@
  */
 class DRN_FOUNDATION_EXPORT ScopeExecutor
 {
-	std::function<void() noexcept> execute_;
+	std::function<void() /*noexcept*/> execute_; // TODO: Fix GCC error when using C++20.
 
 public:
 	/**
@@ -43,7 +43,7 @@
 	 *
 	 * @param execute The function that should be executed upon object destruction.
 	 */
-	ScopeExecutor(std::function<void() noexcept> execute);
+	ScopeExecutor(std::function<void() /*noexcept*/> execute);
 	/**
 	 * @brief Executes the supplied function.
 	 */