diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-08-20 14:34:29 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-08-20 14:34:29 +0200 |
commit | 7175b9e435a54cff33914d21384625a445cc5cf0 (patch) | |
tree | 7feb44f1e8e4ed7ea4d5bf0ba1d173abd3417f34 /src/Globals.h | |
parent | Added cWorld:SetSpawn() API and Lua binding (#3316) (diff) | |
download | cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.gz cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.bz2 cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.lz cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.xz cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.zst cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Globals.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/Globals.h b/src/Globals.h index e3a537eaa..804b0a5ac 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -444,17 +444,49 @@ typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value) return static_cast<C>(std::ceil(a_Value)); } - - -//temporary replacement for std::make_unique until we get c++14 - namespace cpp14 { + // Temporary replacement for std::make_unique until we get c++14 template <class T, class... Args> std::unique_ptr<T> make_unique(Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } + + // Temporary workaround for ... + template <typename StorageType> + struct move_on_copy_wrapper + { + move_on_copy_wrapper(StorageType && a_Value) : + value(std::move(a_Value)) + { + } + + move_on_copy_wrapper(const move_on_copy_wrapper & a_Other) : + value(std::move(a_Other.value)) + { + } + + move_on_copy_wrapper& operator=(const move_on_copy_wrapper & a_Other) + { + value = std::move(a_Other.value); + return *this; + } + + mutable StorageType value; + }; +} + +namespace std +{ + template <typename WeakPtrType> + struct equal_to<std::weak_ptr<WeakPtrType>> + { + constexpr bool operator()(const std::weak_ptr<WeakPtrType> & a_Lhs, const std::weak_ptr<WeakPtrType> & a_Rhs) const + { + return (!a_Lhs.owner_before(a_Rhs) && !a_Rhs.owner_before(a_Lhs)); + } + }; } // a tick is 50 ms |