[Scummvm-git-logs] scummvm master -> 5e98ef6d21ad5337fc45daea3ff903d769e08649

lephilousophe noreply at scummvm.org
Sun Feb 16 12:32:39 UTC 2025


This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e556f54f98 COMMON: Rename type-traits.h to type_traits.h
95051b52d4 COMMON: Delete RemoveConst construct and move remove_*
89f632ef39 COMMON: Add add_cv, add_const, add_volatiles constructs
d2ec868154 COMMON: Rename Conditional type
203d724e41 COMMON: Move remove_reference to type-traits.h
5e98ef6d21 COMMON: Silence cast-user-defined GCC warning


Commit: e556f54f9886c24047a2923421dca41210441fa8
    https://github.com/scummvm/scummvm/commit/e556f54f9886c24047a2923421dca41210441fa8
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-02-16T13:10:07+01:00

Commit Message:
COMMON: Rename type-traits.h to type_traits.h

This now matches the STL header

Changed paths:
  A common/type_traits.h
  R common/type-traits.h
    common/span.h


diff --git a/common/span.h b/common/span.h
index 515d712b34f..6e72d79882d 100644
--- a/common/span.h
+++ b/common/span.h
@@ -26,7 +26,7 @@
 #include "common/memstream.h"
 #include "common/safe-bool.h"
 #include "common/scummsys.h"
-#include "common/type-traits.h"
+#include "common/type_traits.h"
 
 namespace Common {
 
diff --git a/common/type-traits.h b/common/type_traits.h
similarity index 100%
rename from common/type-traits.h
rename to common/type_traits.h


Commit: 95051b52d462102d006659192223887a469d71d6
    https://github.com/scummvm/scummvm/commit/95051b52d462102d006659192223887a469d71d6
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-02-16T13:10:07+01:00

Commit Message:
COMMON: Delete RemoveConst construct and move remove_*

We already have remove_const which has the same name as the STL
construct.
Move the STL compliant versions to type-traits.h to match STL more and
lighten util.h.

Changed paths:
    common/span.h
    common/type_traits.h
    common/util.h
    engines/dgds/sound/scispan.h
    engines/sci/util.h


diff --git a/common/span.h b/common/span.h
index 6e72d79882d..56116ca7de6 100644
--- a/common/span.h
+++ b/common/span.h
@@ -69,7 +69,7 @@ namespace SpanInternal {
 
 	public:
 		typedef typename Span::difference_type difference_type;
-		typedef typename RemoveConst<span_value_type>::type value_type;
+		typedef typename remove_const<span_value_type>::type value_type;
 		typedef typename Conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
 		typedef typename Conditional<IsConst, const span_value_type, span_value_type>::type &reference;
 
@@ -254,7 +254,7 @@ template <typename ValueType, template <typename> class Derived>
 class SpanBase : public SafeBool<Derived<ValueType> > {
 	typedef Derived<ValueType> derived_type;
 	typedef typename AddConst<derived_type>::type const_derived_type;
-	typedef typename RemoveConst<derived_type>::type mutable_derived_type;
+	typedef typename remove_const<derived_type>::type mutable_derived_type;
 
 	template <typename T, bool U> friend class SpanInternal::SpanIterator;
 	template <typename T, template <typename> class U> friend class SpanBase;
@@ -534,7 +534,7 @@ template <typename ValueType, template <typename> class Derived>
 class SpanImpl : public SpanBase<ValueType, Derived> {
 	typedef SpanBase<ValueType, Derived> super_type;
 	typedef typename AddConst<Derived<ValueType> >::type const_derived_type;
-	typedef typename RemoveConst<Derived<ValueType> >::type mutable_derived_type;
+	typedef typename remove_const<Derived<ValueType> >::type mutable_derived_type;
 
 	template <typename T, template <typename> class U> friend class SpanImpl;
 #ifdef CXXTEST_RUNNING
@@ -644,7 +644,7 @@ protected:
 #pragma mark SpanImpl - Allocation
 
 private:
-	typedef typename RemoveConst<value_type>::type mutable_value_type;
+	typedef typename remove_const<value_type>::type mutable_value_type;
 	typedef Derived<mutable_value_type> mutable_value_derived_type;
 
 public:
@@ -690,7 +690,7 @@ template <typename ValueType>
 class Span : public SpanImpl<ValueType, Span> {
 	typedef SpanImpl<ValueType, ::Common::Span> super_type;
 	typedef typename AddConst<Span<ValueType> >::type const_derived_type;
-	typedef typename RemoveConst<Span<ValueType> >::type mutable_derived_type;
+	typedef typename remove_const<Span<ValueType> >::type mutable_derived_type;
 	template <typename T> friend class Span;
 
 public:
@@ -713,7 +713,7 @@ template <typename ValueType, template <typename> class Derived>
 class NamedSpanImpl : public SpanImpl<ValueType, Derived> {
 	typedef SpanImpl<ValueType, Derived> super_type;
 	typedef typename AddConst<Derived<ValueType> >::type const_derived_type;
-	typedef typename RemoveConst<Derived<ValueType> >::type mutable_derived_type;
+	typedef typename remove_const<Derived<ValueType> >::type mutable_derived_type;
 
 	template <typename T, template <typename> class U> friend class NamedSpanImpl;
 #ifdef CXXTEST_RUNNING
@@ -820,7 +820,7 @@ public:
 #pragma mark NamedSpanImpl - Allocation
 
 private:
-	typedef typename RemoveConst<value_type>::type mutable_value_type;
+	typedef typename remove_const<value_type>::type mutable_value_type;
 	typedef Derived<mutable_value_type> mutable_value_derived_type;
 
 public:
@@ -924,7 +924,7 @@ public:
 			return *this;
 		}
 
-		delete[] const_cast<typename RemoveConst<value_type>::type *>(_span.data());
+		delete[] const_cast<typename remove_const<value_type>::type *>(_span.data());
 		_span.clear();
 
 		// Allocating memory when copy-assigning from an unallocated owner
@@ -938,7 +938,7 @@ public:
 	}
 
 	inline ~SpanOwner() {
-		delete[] const_cast<typename RemoveConst<value_type>::type *>(_span.data());
+		delete[] const_cast<typename remove_const<value_type>::type *>(_span.data());
 	}
 
 	/**
@@ -949,7 +949,7 @@ public:
 			return *this;
 		}
 
-		delete[] const_cast<typename RemoveConst<value_type>::type *>(_span.data());
+		delete[] const_cast<typename remove_const<value_type>::type *>(_span.data());
 		_span = other._span;
 		other.release();
 		return *this;
@@ -968,7 +968,7 @@ public:
 	 * Destroys the memory owned by this owner.
 	 */
 	inline void clear() {
-		delete[] const_cast<typename RemoveConst<value_type>::type *>(_span.data());
+		delete[] const_cast<typename remove_const<value_type>::type *>(_span.data());
 		_span.clear();
 	}
 
diff --git a/common/type_traits.h b/common/type_traits.h
index decc65e40c9..c226c147931 100644
--- a/common/type_traits.h
+++ b/common/type_traits.h
@@ -23,10 +23,46 @@
 #define COMMON_TYPE_TRAITS_H
 
 namespace Common {
+/**
+ * A set of templates which removes const and/or volatile specifiers.
+ * Use the remove_*_t<T> variants.
+ */
+template<class T> struct remove_cv {
+	typedef T type;
+};
+template<class T> struct remove_cv<const T> {
+	typedef T type;
+};
+template<class T> struct remove_cv<volatile T> {
+	typedef T type;
+};
+template<class T> struct remove_cv<const volatile T> {
+	typedef T type;
+};
+
+template<class T> struct remove_const {
+	typedef T type;
+};
+template<class T> struct remove_const<const T> {
+	typedef T type;
+};
+
+template<class T> struct remove_volatile {
+	typedef T type;
+};
+template<class T> struct remove_volatile<volatile T> {
+	typedef T type;
+};
+
+template<class T>
+using remove_cv_t        = typename remove_cv<T>::type;
+template<class T>
+using remove_const_t     = typename remove_const<T>::type;
+template<class T>
+using remove_volatile_t  = typename remove_volatile<T>::type;
+
 	template <bool b, class T, class U> struct Conditional { typedef T type; };
 	template <class T, class U> struct Conditional<false, T, U> { typedef U type; };
-	template <typename T> struct RemoveConst { typedef T type; };
-	template <typename T> struct RemoveConst<const T> { typedef T type; };
 	template <typename T> struct AddConst { typedef const T type; };
 } // End of namespace Common
 
diff --git a/common/util.h b/common/util.h
index 6ec1472c9b8..6fd0d30d187 100644
--- a/common/util.h
+++ b/common/util.h
@@ -130,37 +130,6 @@ class U32String;
  * @{
  */
 
-/**
- * A set of templates which remove const and/or volatile specifiers.
- * Use the remove_*_t<T> variants.
- */
-template<class T> struct remove_cv {
-	typedef T type;
-};
-template<class T> struct remove_cv<const T> {
-	typedef T type;
-};
-template<class T> struct remove_cv<volatile T> {
-	typedef T type;
-};
-template<class T> struct remove_cv<const volatile T> {
-	typedef T type;
-};
-
-template<class T> struct remove_const {
-	typedef T type;
-};
-template<class T> struct remove_const<const T> {
-	typedef T type;
-};
-
-template<class T> struct remove_volatile {
-	typedef T type;
-};
-template<class T> struct remove_volatile<volatile T> {
-	typedef T type;
-};
-
 /**
  * A set of templates which removes the reference over types.
  * Use remove_reference_t<T> for this.
@@ -178,13 +147,6 @@ struct remove_reference<T &&> {
 	typedef T type;
 };
 
-template<class T>
-using remove_cv_t        = typename remove_cv<T>::type;
-template<class T>
-using remove_const_t     = typename remove_const<T>::type;
-template<class T>
-using remove_volatile_t  = typename remove_volatile<T>::type;
-
 template<class T>
 using remove_reference_t = typename remove_reference<T>::type;
 
diff --git a/engines/dgds/sound/scispan.h b/engines/dgds/sound/scispan.h
index c10e844bfc0..2fa5d314aad 100644
--- a/engines/dgds/sound/scispan.h
+++ b/engines/dgds/sound/scispan.h
@@ -50,7 +50,7 @@ namespace SciSpanInternal {
 
 	public:
 		typedef typename Span::difference_type difference_type;
-		typedef typename Common::RemoveConst<span_value_type>::type value_type;
+		typedef typename Common::remove_const<span_value_type>::type value_type;
 		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
 		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type &reference;
 
@@ -126,7 +126,7 @@ public:
 // SpanOwner, since this will result in the wrong pointer to memory to be
 // deleted
 private:
-	typedef typename Common::RemoveConst<Derived<ValueType> >::type mutable_derived_type;
+	typedef typename Common::remove_const<Derived<ValueType> >::type mutable_derived_type;
 
 public:
 
diff --git a/engines/sci/util.h b/engines/sci/util.h
index 120369c0a5e..3faacf57c87 100644
--- a/engines/sci/util.h
+++ b/engines/sci/util.h
@@ -59,7 +59,7 @@ namespace SciSpanInternal {
 
 	public:
 		typedef typename Span::difference_type difference_type;
-		typedef typename Common::RemoveConst<span_value_type>::type value_type;
+		typedef typename Common::remove_const<span_value_type>::type value_type;
 		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
 		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type &reference;
 
@@ -210,7 +210,7 @@ public:
 // SpanOwner, since this will result in the wrong pointer to memory to be
 // deleted
 private:
-	typedef typename Common::RemoveConst<Derived<ValueType> >::type mutable_derived_type;
+	typedef typename Common::remove_const<Derived<ValueType> >::type mutable_derived_type;
 
 public:
 	inline const_reference operator*() const {


Commit: 89f632ef39855759909cc2013f2d88a8a2f2fddf
    https://github.com/scummvm/scummvm/commit/89f632ef39855759909cc2013f2d88a8a2f2fddf
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-02-16T13:10:07+01:00

Commit Message:
COMMON: Add add_cv, add_const, add_volatiles constructs

And migrate away from the old AddConst

Changed paths:
    common/span.h
    common/type_traits.h


diff --git a/common/span.h b/common/span.h
index 56116ca7de6..e071648158d 100644
--- a/common/span.h
+++ b/common/span.h
@@ -253,7 +253,7 @@ namespace SpanInternal {
 template <typename ValueType, template <typename> class Derived>
 class SpanBase : public SafeBool<Derived<ValueType> > {
 	typedef Derived<ValueType> derived_type;
-	typedef typename AddConst<derived_type>::type const_derived_type;
+	typedef typename add_const<derived_type>::type const_derived_type;
 	typedef typename remove_const<derived_type>::type mutable_derived_type;
 
 	template <typename T, bool U> friend class SpanInternal::SpanIterator;
@@ -533,7 +533,7 @@ protected:
 template <typename ValueType, template <typename> class Derived>
 class SpanImpl : public SpanBase<ValueType, Derived> {
 	typedef SpanBase<ValueType, Derived> super_type;
-	typedef typename AddConst<Derived<ValueType> >::type const_derived_type;
+	typedef typename add_const<Derived<ValueType> >::type const_derived_type;
 	typedef typename remove_const<Derived<ValueType> >::type mutable_derived_type;
 
 	template <typename T, template <typename> class U> friend class SpanImpl;
@@ -689,7 +689,7 @@ public:
 template <typename ValueType>
 class Span : public SpanImpl<ValueType, Span> {
 	typedef SpanImpl<ValueType, ::Common::Span> super_type;
-	typedef typename AddConst<Span<ValueType> >::type const_derived_type;
+	typedef typename add_const<Span<ValueType> >::type const_derived_type;
 	typedef typename remove_const<Span<ValueType> >::type mutable_derived_type;
 	template <typename T> friend class Span;
 
@@ -712,7 +712,7 @@ public:
 template <typename ValueType, template <typename> class Derived>
 class NamedSpanImpl : public SpanImpl<ValueType, Derived> {
 	typedef SpanImpl<ValueType, Derived> super_type;
-	typedef typename AddConst<Derived<ValueType> >::type const_derived_type;
+	typedef typename add_const<Derived<ValueType> >::type const_derived_type;
 	typedef typename remove_const<Derived<ValueType> >::type mutable_derived_type;
 
 	template <typename T, template <typename> class U> friend class NamedSpanImpl;
diff --git a/common/type_traits.h b/common/type_traits.h
index c226c147931..c566b0f452e 100644
--- a/common/type_traits.h
+++ b/common/type_traits.h
@@ -23,6 +23,7 @@
 #define COMMON_TYPE_TRAITS_H
 
 namespace Common {
+
 /**
  * A set of templates which removes const and/or volatile specifiers.
  * Use the remove_*_t<T> variants.
@@ -54,6 +55,21 @@ template<class T> struct remove_volatile<volatile T> {
 	typedef T type;
 };
 
+/**
+ * A set of templates which add const or volatile qualifiers
+ */
+template<class T>
+struct add_cv {
+	typedef const volatile T type;
+};
+template<class T>
+struct add_const {
+	typedef const T type;
+};
+template<class T> struct add_volatile {
+	typedef volatile T type;
+};
+
 template<class T>
 using remove_cv_t        = typename remove_cv<T>::type;
 template<class T>
@@ -61,9 +77,15 @@ using remove_const_t     = typename remove_const<T>::type;
 template<class T>
 using remove_volatile_t  = typename remove_volatile<T>::type;
 
+template<class T>
+using add_cv_t        = typename add_cv<T>::type;
+template<class T>
+using add_const_t     = typename add_const<T>::type;
+template<class T>
+using add_volatile_t  = typename add_volatile<T>::type;
+
 	template <bool b, class T, class U> struct Conditional { typedef T type; };
 	template <class T, class U> struct Conditional<false, T, U> { typedef U type; };
-	template <typename T> struct AddConst { typedef const T type; };
 } // End of namespace Common
 
 #endif


Commit: d2ec8681542f5ed71f47f3a4ad2f1d7283dbd8bd
    https://github.com/scummvm/scummvm/commit/d2ec8681542f5ed71f47f3a4ad2f1d7283dbd8bd
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-02-16T13:10:07+01:00

Commit Message:
COMMON: Rename Conditional type

This now matches what STL does
Also add conditional_t type introduced in C++14.

Changed paths:
    common/span.h
    common/type_traits.h
    engines/dgds/sound/scispan.h
    engines/sci/util.h


diff --git a/common/span.h b/common/span.h
index e071648158d..f8bd45fe066 100644
--- a/common/span.h
+++ b/common/span.h
@@ -65,13 +65,13 @@ namespace SpanInternal {
 	template <typename Span, bool IsConst>
 	class SpanIterator {
 		typedef typename Span::value_type span_value_type;
-		typedef typename Conditional<IsConst, const Span, Span>::type span_type;
+		typedef typename conditional<IsConst, const Span, Span>::type span_type;
 
 	public:
 		typedef typename Span::difference_type difference_type;
 		typedef typename remove_const<span_value_type>::type value_type;
-		typedef typename Conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
-		typedef typename Conditional<IsConst, const span_value_type, span_value_type>::type &reference;
+		typedef typename conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
+		typedef typename conditional<IsConst, const span_value_type, span_value_type>::type &reference;
 
 		inline SpanIterator() : _span(nullptr), _index(0) {}
 
diff --git a/common/type_traits.h b/common/type_traits.h
index c566b0f452e..6b2615fb5f6 100644
--- a/common/type_traits.h
+++ b/common/type_traits.h
@@ -84,8 +84,18 @@ using add_const_t     = typename add_const<T>::type;
 template<class T>
 using add_volatile_t  = typename add_volatile<T>::type;
 
-	template <bool b, class T, class U> struct Conditional { typedef T type; };
-	template <class T, class U> struct Conditional<false, T, U> { typedef U type; };
+template<bool b, class T, class F>
+struct conditional {
+	typedef T type;
+};
+template<class T, class F>
+struct conditional<false, T, F> {
+	typedef F type;
+};
+
+template<bool b, class T, class F>
+using conditional_t = typename conditional<b, T, F>::type;
+
 } // End of namespace Common
 
 #endif
diff --git a/engines/dgds/sound/scispan.h b/engines/dgds/sound/scispan.h
index 2fa5d314aad..8be1811cccc 100644
--- a/engines/dgds/sound/scispan.h
+++ b/engines/dgds/sound/scispan.h
@@ -46,13 +46,13 @@ namespace SciSpanInternal {
 	class SciSpanIterator : public Common::SpanInternal::SpanIterator<Span, IsConst> {
 		typedef typename Common::SpanInternal::SpanIterator<Span, IsConst> super_type;
 		typedef typename Span::value_type span_value_type;
-		typedef typename Common::Conditional<IsConst, const Span, Span>::type span_type;
+		typedef typename Common::conditional<IsConst, const Span, Span>::type span_type;
 
 	public:
 		typedef typename Span::difference_type difference_type;
 		typedef typename Common::remove_const<span_value_type>::type value_type;
-		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
-		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type &reference;
+		typedef typename Common::conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
+		typedef typename Common::conditional<IsConst, const span_value_type, span_value_type>::type &reference;
 
 		inline SciSpanIterator() : super_type() {}
 
diff --git a/engines/sci/util.h b/engines/sci/util.h
index 3faacf57c87..c6e8540a41b 100644
--- a/engines/sci/util.h
+++ b/engines/sci/util.h
@@ -55,13 +55,13 @@ namespace SciSpanInternal {
 	class SciSpanIterator : public Common::SpanInternal::SpanIterator<Span, IsConst> {
 		typedef typename Common::SpanInternal::SpanIterator<Span, IsConst> super_type;
 		typedef typename Span::value_type span_value_type;
-		typedef typename Common::Conditional<IsConst, const Span, Span>::type span_type;
+		typedef typename Common::conditional<IsConst, const Span, Span>::type span_type;
 
 	public:
 		typedef typename Span::difference_type difference_type;
 		typedef typename Common::remove_const<span_value_type>::type value_type;
-		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
-		typedef typename Common::Conditional<IsConst, const span_value_type, span_value_type>::type &reference;
+		typedef typename Common::conditional<IsConst, const span_value_type, span_value_type>::type *pointer;
+		typedef typename Common::conditional<IsConst, const span_value_type, span_value_type>::type &reference;
 
 		inline SciSpanIterator() : super_type() {}
 


Commit: 203d724e4156d808ef66ae0b4fcbe0c0614fee26
    https://github.com/scummvm/scummvm/commit/203d724e4156d808ef66ae0b4fcbe0c0614fee26
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-02-16T13:10:07+01:00

Commit Message:
COMMON: Move remove_reference to type-traits.h

And remove the duplicate implementation in the Common::Std namespace.

Changed paths:
    common/std/utility.h
    common/type_traits.h
    common/util.h


diff --git a/common/std/utility.h b/common/std/utility.h
index c44e459bad1..a63501c86dc 100644
--- a/common/std/utility.h
+++ b/common/std/utility.h
@@ -31,7 +31,7 @@
 #ifndef COMMON_STD_UTILITY_H
 #define COMMON_STD_UTILITY_H
 
-#include "common/textconsole.h"
+#include "common/util.h"
 
 namespace Std {
 
@@ -51,32 +51,7 @@ pair<T1, T2> make_pair(T1 first, T2 second) {
 	return pair<T1, T2>(first, second);
 }
 
-// STRUCT TEMPLATE remove_reference
-template <class _Ty>
-struct remove_reference {
-	typedef _Ty type;
-};
-
-template<class _Ty>
-struct remove_reference<_Ty &> {
-	typedef _Ty type;
-};
-
-template<class _Ty>
-struct remove_reference<_Ty &&> {
-	typedef _Ty type;
-};
-
-template <class _Ty>
-using remove_reference_t = typename remove_reference<_Ty>::type;
-
-// FUNCTION TEMPLATE move
-// TODO: Haven't been able to get this to properly work to reset
-// the source when moving the contents of Std::vector arrays
-template <class _Ty>
-constexpr remove_reference_t<_Ty> &&move(_Ty &&_Arg) noexcept {
-	return static_cast<remove_reference_t<_Ty> &&>(_Arg);
-}
+using Common::move;
 
 } // namespace Std
 
diff --git a/common/type_traits.h b/common/type_traits.h
index 6b2615fb5f6..7eb99d6f76c 100644
--- a/common/type_traits.h
+++ b/common/type_traits.h
@@ -84,6 +84,26 @@ using add_const_t     = typename add_const<T>::type;
 template<class T>
 using add_volatile_t  = typename add_volatile<T>::type;
 
+/**
+ * A set of templates which removes the reference over types.
+ * Use remove_reference_t<T> for this.
+ */
+template<class T>
+struct remove_reference {
+	typedef T type;
+};
+template<class T>
+struct remove_reference<T &> {
+	typedef T type;
+};
+template<class T>
+struct remove_reference<T &&> {
+	typedef T type;
+};
+
+template<class T>
+using remove_reference_t = typename remove_reference<T>::type;
+
 template<bool b, class T, class F>
 struct conditional {
 	typedef T type;
diff --git a/common/util.h b/common/util.h
index 6fd0d30d187..f4a1933b650 100644
--- a/common/util.h
+++ b/common/util.h
@@ -24,6 +24,8 @@
 
 #include "common/scummsys.h"
 
+#include "common/type_traits.h"
+
 /**
  * @defgroup common_util Util
  * @ingroup common
@@ -130,26 +132,6 @@ class U32String;
  * @{
  */
 
-/**
- * A set of templates which removes the reference over types.
- * Use remove_reference_t<T> for this.
- */
-template<class T>
-struct remove_reference {
-	typedef T type;
-};
-template<class T>
-struct remove_reference<T &> {
-	typedef T type;
-};
-template<class T>
-struct remove_reference<T &&> {
-	typedef T type;
-};
-
-template<class T>
-using remove_reference_t = typename remove_reference<T>::type;
-
 /**
  * A reimplementation of std::move.
  */


Commit: 5e98ef6d21ad5337fc45daea3ff903d769e08649
    https://github.com/scummvm/scummvm/commit/5e98ef6d21ad5337fc45daea3ff903d769e08649
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-02-16T13:30:36+01:00

Commit Message:
COMMON: Silence cast-user-defined GCC warning

Make it explicit that we don't want to call any copy constructor but
only casting a reference type.

Changed paths:
    common/span.h


diff --git a/common/span.h b/common/span.h
index f8bd45fe066..3cc6dcd43fc 100644
--- a/common/span.h
+++ b/common/span.h
@@ -653,7 +653,7 @@ public:
 		assert(numEntries != kSpanMaxSize);
 		_data = new mutable_value_type[numEntries];
 		_size = numEntries;
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	template <typename Other>
@@ -663,7 +663,7 @@ public:
 		_data = new mutable_value_type[other.size()];
 		_size = other.size();
 		copy(other.begin(), other.end(), const_cast<mutable_value_type *>(_data));
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	mutable_value_derived_type &allocateFromStream(SeekableReadStream &stream, size_type numEntries = kSpanMaxSize) {
@@ -676,7 +676,7 @@ public:
 		allocate(numEntries);
 		const uint32 bytesRead = stream.read((void *)const_cast<mutable_value_type *>(_data), bytesRequested);
 		assert(bytesRead == bytesRequested);
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	value_type *_data;
@@ -828,7 +828,7 @@ public:
 		super_type::allocate(numEntries);
 		_name = name_;
 		_sourceByteOffset = 0;
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	template <typename OtherValueType>
@@ -836,20 +836,20 @@ public:
 		super_type::allocateFromSpan(other);
 		_name = other.name();
 		_sourceByteOffset = other.sourceByteOffset();
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	template <typename OtherValueType, template <typename> class OtherDerived>
 	mutable_value_derived_type &allocateFromSpan(const SpanImpl<OtherValueType, OtherDerived> &other) {
 		super_type::allocateFromSpan(other);
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	mutable_value_derived_type &allocateFromStream(SeekableReadStream &stream, size_type numEntries = kSpanMaxSize, const String &name_ = String()) {
 		super_type::allocateFromStream(stream, numEntries);
 		_name = name_;
 		_sourceByteOffset = 0;
-		return (mutable_value_derived_type &)const_cast<Derived<value_type> &>(this->impl());
+		return reinterpret_cast<mutable_value_derived_type &>(const_cast<Derived<value_type> &>(this->impl()));
 	}
 
 	mutable_value_derived_type &allocateFromStream(File &file, const size_type numEntries = kSpanMaxSize) {




More information about the Scummvm-git-logs mailing list