diff options
author | peterbell10 <peterbell10@live.co.uk> | 2020-05-10 18:16:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-10 18:16:38 +0200 |
commit | 154df6b09d0c39ef9a9b1ee049251b645c13f559 (patch) | |
tree | dd5976d81910d369e09b95c35fd89cd8cccb378c /src | |
parent | Remove pkFishingFloat documentation (#4732) (diff) | |
download | cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.tar cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.tar.gz cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.tar.bz2 cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.tar.lz cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.tar.xz cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.tar.zst cuberite-154df6b09d0c39ef9a9b1ee049251b645c13f559.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/AllocationPool.h | 6 | ||||
-rw-r--r-- | src/Bindings/LuaState.h | 6 | ||||
-rw-r--r-- | src/DeadlockDetect.h | 2 | ||||
-rw-r--r-- | src/Entities/Entity.h | 2 | ||||
-rw-r--r-- | src/Globals.h | 39 | ||||
-rw-r--r-- | src/LazyArray.h | 14 | ||||
-rw-r--r-- | src/OSSupport/AtomicUniquePtr.h | 20 | ||||
-rw-r--r-- | src/OSSupport/NetworkSingleton.cpp | 2 | ||||
-rw-r--r-- | src/OSSupport/NetworkSingleton.h | 2 | ||||
-rw-r--r-- | src/WorldStorage/FastNBT.cpp | 6 | ||||
-rw-r--r-- | src/WorldStorage/FastNBT.h | 2 |
11 files changed, 33 insertions, 68 deletions
diff --git a/src/AllocationPool.h b/src/AllocationPool.h index 0a529a8e3..78bb87eee 100644 --- a/src/AllocationPool.h +++ b/src/AllocationPool.h @@ -34,7 +34,7 @@ public: virtual void Free(T * a_ptr) = 0; /** Two pools compare equal if memory allocated by one can be freed by the other */ - bool IsEqual(const cAllocationPool & a_Other) const NOEXCEPT + bool IsEqual(const cAllocationPool & a_Other) const noexcept { return ((this == &a_Other) || DoIsEqual(a_Other) || a_Other.DoIsEqual(*this)); } @@ -50,7 +50,7 @@ public: } private: - virtual bool DoIsEqual(const cAllocationPool & a_Other) const NOEXCEPT = 0; + virtual bool DoIsEqual(const cAllocationPool & a_Other) const noexcept = 0; }; @@ -176,7 +176,7 @@ private: std::list<void *> m_FreeList; std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks; - virtual bool DoIsEqual(const cAllocationPool<T> & a_Other) const NOEXCEPT override + virtual bool DoIsEqual(const cAllocationPool<T> & a_Other) const noexcept override { return (dynamic_cast<const cListAllocationPool<T>*>(&a_Other) != nullptr); } diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 94b4ec16d..8caa7fef4 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -78,7 +78,7 @@ public: } } - ~cStackBalanceCheck() CAN_THROW + ~cStackBalanceCheck() noexcept(false) { auto currStackPos = lua_gettop(m_LuaState); if (currStackPos != m_StackPos) @@ -118,7 +118,7 @@ public: { } - ~cStackBalancePopper() CAN_THROW + ~cStackBalancePopper() noexcept(false) { auto curTop = lua_gettop(m_LuaState); if (curTop > m_Count) @@ -478,7 +478,7 @@ public: std::swap(m_StackLen, a_Src.m_StackLen); } - ~cStackValue() CAN_THROW + ~cStackValue() noexcept(false) { if (m_LuaState != nullptr) { diff --git a/src/DeadlockDetect.h b/src/DeadlockDetect.h index 15d8a3027..a2ec1823f 100644 --- a/src/DeadlockDetect.h +++ b/src/DeadlockDetect.h @@ -80,7 +80,7 @@ protected: /** Called when a deadlock is detected in a world. Aborts the server. a_WorldName is the name of the world whose age has triggered the detection. a_WorldAge is the age (in ticks) in which the world is stuck. */ - NORETURN void DeadlockDetected(const AString & a_WorldName, Int64 a_WorldAge); + [[noreturn]] void DeadlockDetected(const AString & a_WorldName, Int64 a_WorldAge); /** Outputs a listing of the tracked CSs, together with their name and state. */ void ListTrackedCSs(); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 7d8238c21..8bc941354 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -469,7 +469,7 @@ public: virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); /** Schedules a MoveToWorld call to occur on the next Tick of the entity */ - OBSOLETE void ScheduleMoveToWorld(cWorld & a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown = false, bool a_ShouldSendRespawn = true) + [[deprecated]] void ScheduleMoveToWorld(cWorld & a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown = false, bool a_ShouldSendRespawn = true) { LOGWARNING("ScheduleMoveToWorld is deprecated, use MoveToWorld instead"); MoveToWorld(a_World, a_NewPosition, a_ShouldSetPortalCooldown, a_ShouldSendRespawn); diff --git a/src/Globals.h b/src/Globals.h index e6fde373e..121dd42d4 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -36,17 +36,6 @@ // 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data - #define OBSOLETE __declspec(deprecated) - - #define NORETURN __declspec(noreturn) - #if (_MSC_VER < 1900) // noexcept support was added in VS 2015 - #define NOEXCEPT throw() - #define CAN_THROW throw(...) - #else - #define NOEXCEPT noexcept - #define CAN_THROW noexcept(false) - #endif - // Use non-standard defines in <cmath> #define _USE_MATH_DEFINES @@ -73,17 +62,6 @@ // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)? #define abstract - // override is part of c++11 - #if __cplusplus < 201103L - #define override - #endif - - #define OBSOLETE __attribute__((deprecated)) - - #define NORETURN __attribute((__noreturn__)) - #define NOEXCEPT noexcept - #define CAN_THROW noexcept(false) - #else #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler" @@ -91,15 +69,6 @@ #endif - - -#ifdef _DEBUG - #define NORETURNDEBUG NORETURN -#else - #define NORETURNDEBUG -#endif - - #include <stddef.h> @@ -367,15 +336,11 @@ typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value) -//temporary replacement for std::make_unique until we get c++14 +// TODO: Replace cpp14 with std at point of use namespace cpp14 { - template <class T, class... Args> - std::unique_ptr<T> make_unique(Args&&... args) - { - return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); - } +using std::make_unique; } // a tick is 50 ms diff --git a/src/LazyArray.h b/src/LazyArray.h index 310a1e2c6..dbb772585 100644 --- a/src/LazyArray.h +++ b/src/LazyArray.h @@ -21,7 +21,7 @@ public: using iterator = pointer; using const_iterator = const_pointer; - cLazyArray(size_type a_Size) NOEXCEPT: + cLazyArray(size_type a_Size) noexcept: m_Size{ a_Size } { ASSERT(a_Size > 0); @@ -37,7 +37,7 @@ public: } } - cLazyArray(cLazyArray && a_Other) NOEXCEPT: + cLazyArray(cLazyArray && a_Other) noexcept: m_Array{ std::move(a_Other.m_Array) }, m_Size{ a_Other.m_Size } { @@ -49,7 +49,7 @@ public: return *this; } - cLazyArray & operator = (cLazyArray && a_Other) NOEXCEPT + cLazyArray & operator = (cLazyArray && a_Other) noexcept { m_Array = std::move(a_Other.m_Array); m_Size = a_Other.m_Size; @@ -77,7 +77,7 @@ public: iterator end() { return data() + m_Size; } const_iterator end() const { return cend(); } - size_type size() const NOEXCEPT { return m_Size; } + size_type size() const noexcept { return m_Size; } const T * data() const { @@ -95,13 +95,13 @@ public: return const_cast<T *>(const_this->data()); } - void swap(cLazyArray & a_Other) NOEXCEPT + void swap(cLazyArray & a_Other) noexcept { std::swap(m_Array, a_Other.m_Array); std::swap(m_Size, a_Other.m_Size); } - friend void swap(cLazyArray & a_Lhs, cLazyArray & a_Rhs) NOEXCEPT + friend void swap(cLazyArray & a_Lhs, cLazyArray & a_Rhs) noexcept { a_Lhs.swap(a_Rhs); } @@ -124,7 +124,7 @@ public: } /** Returns true if the array has already been allocated. */ - bool IsStorageAllocated() const NOEXCEPT { return (m_Array != nullptr); } + bool IsStorageAllocated() const noexcept { return (m_Array != nullptr); } private: // Mutable so const data() can allocate the array diff --git a/src/OSSupport/AtomicUniquePtr.h b/src/OSSupport/AtomicUniquePtr.h index 5b18763d3..92debbac6 100644 --- a/src/OSSupport/AtomicUniquePtr.h +++ b/src/OSSupport/AtomicUniquePtr.h @@ -11,34 +11,34 @@ public: static_assert(!std::is_array<T>::value, "cAtomicUniquePtr does not support arrays"); DISALLOW_COPY_AND_ASSIGN(cAtomicUniquePtr); - cAtomicUniquePtr() NOEXCEPT: + cAtomicUniquePtr() noexcept: m_Ptr(nullptr) { } - cAtomicUniquePtr(std::unique_ptr<T> a_Ptr) NOEXCEPT: + cAtomicUniquePtr(std::unique_ptr<T> a_Ptr) noexcept: m_Ptr(a_Ptr.release()) { } - cAtomicUniquePtr & operator = (std::unique_ptr<T> a_Ptr) NOEXCEPT + cAtomicUniquePtr & operator = (std::unique_ptr<T> a_Ptr) noexcept { store(std::move(a_Ptr)); return *this; } - ~cAtomicUniquePtr() NOEXCEPT + ~cAtomicUniquePtr() noexcept { delete load(); } - operator T * () const NOEXCEPT + operator T * () const noexcept { return load(); } - bool compare_exchange_weak(T *& a_Expected, std::unique_ptr<T> && a_Desired, std::memory_order a_Order = std::memory_order_seq_cst) NOEXCEPT + bool compare_exchange_weak(T *& a_Expected, std::unique_ptr<T> && a_Desired, std::memory_order a_Order = std::memory_order_seq_cst) noexcept { bool DidExchange = m_Ptr.compare_exchange_weak(a_Expected, a_Desired.get(), a_Order); if (DidExchange) @@ -49,7 +49,7 @@ public: return DidExchange; } - bool compare_exchange_strong(T *& a_Expected, std::unique_ptr<T> && a_Desired, std::memory_order a_Order = std::memory_order_seq_cst) NOEXCEPT + bool compare_exchange_strong(T *& a_Expected, std::unique_ptr<T> && a_Desired, std::memory_order a_Order = std::memory_order_seq_cst) noexcept { bool DidExchange = m_Ptr.compare_exchange_strong(a_Expected, a_Desired.get(), a_Order); if (DidExchange) @@ -60,17 +60,17 @@ public: return DidExchange; } - std::unique_ptr<T> exchange(std::unique_ptr<T> a_Ptr, std::memory_order a_Order = std::memory_order_seq_cst) NOEXCEPT + std::unique_ptr<T> exchange(std::unique_ptr<T> a_Ptr, std::memory_order a_Order = std::memory_order_seq_cst) noexcept { return std::unique_ptr<T>{ m_Ptr.exchange(a_Ptr.release(), a_Order) }; } - T * load(std::memory_order a_Order = std::memory_order_seq_cst) const NOEXCEPT + T * load(std::memory_order a_Order = std::memory_order_seq_cst) const noexcept { return m_Ptr.load(a_Order); } - void store(std::unique_ptr<T> a_Ptr, std::memory_order a_Order = std::memory_order_seq_cst) NOEXCEPT + void store(std::unique_ptr<T> a_Ptr, std::memory_order a_Order = std::memory_order_seq_cst) noexcept { // Store new value and delete old value delete m_Ptr.exchange(a_Ptr.release(), a_Order); diff --git a/src/OSSupport/NetworkSingleton.cpp b/src/OSSupport/NetworkSingleton.cpp index 046768c14..0d8ba31e6 100644 --- a/src/OSSupport/NetworkSingleton.cpp +++ b/src/OSSupport/NetworkSingleton.cpp @@ -24,7 +24,7 @@ cNetworkSingleton::cNetworkSingleton() : -cNetworkSingleton::~cNetworkSingleton() CAN_THROW +cNetworkSingleton::~cNetworkSingleton() noexcept(false) { // Check that Terminate has been called already: ASSERT(m_HasTerminated); diff --git a/src/OSSupport/NetworkSingleton.h b/src/OSSupport/NetworkSingleton.h index 5f3c11720..4bcd58745 100644 --- a/src/OSSupport/NetworkSingleton.h +++ b/src/OSSupport/NetworkSingleton.h @@ -39,7 +39,7 @@ class cNetworkSingleton { public: cNetworkSingleton(); - ~cNetworkSingleton() CAN_THROW; + ~cNetworkSingleton() noexcept(false); /** Returns the singleton instance of this class */ static cNetworkSingleton & Get(void); diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index d7901217d..b7c1c9c45 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -37,7 +37,7 @@ class cNBTParseErrorCategory final : cNBTParseErrorCategory() = default; public: /** Category name */ - virtual const char * name() const NOEXCEPT override + virtual const char * name() const noexcept override { return "NBT parse error"; } @@ -46,7 +46,7 @@ public: virtual AString message(int a_Condition) const override; /** Returns the canonical error category instance. */ - static const cNBTParseErrorCategory & Get() NOEXCEPT + static const cNBTParseErrorCategory & Get() noexcept { static cNBTParseErrorCategory Category; return Category; @@ -123,7 +123,7 @@ AString cNBTParseErrorCategory::message(int a_Condition) const -std::error_code make_error_code(eNBTParseError a_Err) NOEXCEPT +std::error_code make_error_code(eNBTParseError a_Err) noexcept { return { static_cast<int>(a_Err), cNBTParseErrorCategory::Get() }; } diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index 1f11ec7f3..412543dc2 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -126,7 +126,7 @@ enum class eNBTParseError }; // The following is required to make an error_code constructible from an eNBTParseError -std::error_code make_error_code(eNBTParseError a_Err) NOEXCEPT; +std::error_code make_error_code(eNBTParseError a_Err) noexcept; namespace std { |