[Scummvm-git-logs] scummvm master -> 155aefb82c8d797081a3fe349a8d40450d04a416
bluegr
noreply at scummvm.org
Tue Aug 6 06:39:05 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
155aefb82c COMMON: Add move constructors and assign operators to Pair
Commit: 155aefb82c8d797081a3fe349a8d40450d04a416
https://github.com/scummvm/scummvm/commit/155aefb82c8d797081a3fe349a8d40450d04a416
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-08-06T09:39:02+03:00
Commit Message:
COMMON: Add move constructors and assign operators to Pair
Changed paths:
common/util.h
diff --git a/common/util.h b/common/util.h
index bf1b99351b6..6ec1472c9b8 100644
--- a/common/util.h
+++ b/common/util.h
@@ -130,20 +130,6 @@ class U32String;
* @{
*/
-/**
- * Provides a way to store two heterogeneous objects as a single unit.
- */
-template<class T1, class T2>
-struct Pair {
- T1 first;
- T2 second;
-
- Pair() {
- }
- Pair(T1 first_, T2 second_) : first(first_), second(second_) {
- }
-};
-
/**
* A set of templates which remove const and/or volatile specifiers.
* Use the remove_*_t<T> variants.
@@ -220,6 +206,48 @@ constexpr T&& forward(remove_reference_t<T> &t) noexcept {
return static_cast<T &&>(t);
}
+/**
+ * Provides a way to store two heterogeneous objects as a single unit.
+ */
+template<class T1, class T2>
+struct Pair {
+ T1 first;
+ T2 second;
+
+ Pair() {
+ }
+
+ Pair(const Pair &other) : first(other.first), second(other.second) {
+ }
+
+ Pair(Pair &&other) : first(Common::move(other.first)), second(Common::move(other.second)) {
+ }
+
+ Pair(const T1 &first_, const T2 &second_) : first(first_), second(second_) {
+ }
+
+ Pair(T1 &&first_, T2 &&second_) : first(Common::move(first_)), second(Common::move(second_)) {
+ }
+
+ Pair(T1 &&first_, const T2 &second_) : first(Common::move(first_)), second(second_) {
+ }
+
+ Pair(const T1 &first_, T2 &&second_) : first(first_), second(Common::move(second_)) {
+ }
+
+ Pair &operator=(const Pair &other) {
+ this->first = other.first;
+ this->second = other.second;
+ return *this;
+ }
+
+ Pair &operator=(Pair &&other) {
+ this->first = Common::move(other.first);
+ this->second = Common::move(other.second);
+ return *this;
+ }
+};
+
/**
* Print a hexdump of the data passed in. The number of bytes per line is
* customizable.
More information about the Scummvm-git-logs
mailing list