Browse Source

GCC 4.5 compatibility: fugly fix for missing move constructor in pair.

My first use of const_cast ever!
Vladimír Vondruš 14 years ago
parent
commit
97152f4430
  1. 11
      src/ResourceManager.h

11
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<Data&>(other).data = nullptr;
const_cast<Data&>(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;

Loading…
Cancel
Save