From 97152f4430985337b5db42989acb876650d17cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 8 Nov 2012 18:58:50 +0100 Subject: [PATCH] GCC 4.5 compatibility: fugly fix for missing move constructor in pair. My first use of const_cast ever! --- src/ResourceManager.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ResourceManager.h b/src/ResourceManager.h index d5f9b4e34..edbbe4db0 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -127,12 +127,21 @@ namespace Implementation { public: struct Data { - Data(const Data&) = delete; Data& operator=(const Data&) = delete; Data& operator=(Data&&) = delete; inline Data(): data(nullptr), state(ResourceDataState::Mutable), policy(ResourcePolicy::Manual), referenceCount(0) {} + /* Fugly hack for GCC 4.5, because std::pair doesn't have move constructor yet */ + #ifndef CORRADE_GCC45_COMPATIBILITY + Data(const Data&) = delete; + #else + Data(const Data& other): data(other.data), state(other.state), policy(other.policy), referenceCount(other.referenceCount) { + const_cast(other).data = nullptr; + const_cast(other).referenceCount = 0; + } + #endif + Data(Data&& other): data(other.data), state(other.state), policy(other.policy), referenceCount(other.referenceCount) { other.data = nullptr; other.referenceCount = 0;