summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2016-12-18 19:31:44 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2016-12-18 19:31:44 +0100
commit1f109febbaae43612c8f47058055ce3b101b3b12 (patch)
tree92ff2e9a36cc0c78bed7f7ec038bfa24fb5df433 /src/Globals.h
parentAdded cWorld:SetSpawn() API and Lua binding (#3316) (diff)
downloadcuberite-1f109febbaae43612c8f47058055ce3b101b3b12.tar
cuberite-1f109febbaae43612c8f47058055ce3b101b3b12.tar.gz
cuberite-1f109febbaae43612c8f47058055ce3b101b3b12.tar.bz2
cuberite-1f109febbaae43612c8f47058055ce3b101b3b12.tar.lz
cuberite-1f109febbaae43612c8f47058055ce3b101b3b12.tar.xz
cuberite-1f109febbaae43612c8f47058055ce3b101b3b12.tar.zst
cuberite-1f109febbaae43612c8f47058055ce3b101b3b12.zip
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/Globals.h b/src/Globals.h
index e3a537eaa..0ab78121c 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