From ce0fe83e66810a303df7ac8504736c59b0caeef8 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 22 Dec 2017 00:13:16 +0100 Subject: [PATCH] Fixes for C++17 conformance --- SilentPatchSA/GeneralSA.cpp | 13 ++++++------- SilentPatchSA/PoolsSA.h | 12 +++++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/SilentPatchSA/GeneralSA.cpp b/SilentPatchSA/GeneralSA.cpp index 2e07328..86728fc 100644 --- a/SilentPatchSA/GeneralSA.cpp +++ b/SilentPatchSA/GeneralSA.cpp @@ -116,21 +116,20 @@ std::tuple CObject::TryOrFreeUpTempObjects( int numObjects, bool force int numProcessed = 0, numFreed = 0; auto& pool = CPools::GetObjectPool(); - for ( auto& obj : pool ) + for ( auto obj : pool ) { if ( numFreed >= numObjects ) break; - CObject* const objPtr = &obj; - if ( pool.IsValidPtr( objPtr ) ) + if ( pool.IsValidPtr( obj ) ) { - if ( objPtr->m_objectCreatedBy == TEMP_OBJECT ) + if ( obj->m_objectCreatedBy == TEMP_OBJECT ) { numProcessed++; - if ( force || !objPtr->IsVisible() ) + if ( force || !obj->IsVisible() ) { numFreed++; - WorldRemove( objPtr ); - delete objPtr; + WorldRemove( obj ); + delete obj; } } } diff --git a/SilentPatchSA/PoolsSA.h b/SilentPatchSA/PoolsSA.h index 106aca7..ac45c4d 100644 --- a/SilentPatchSA/PoolsSA.h +++ b/SilentPatchSA/PoolsSA.h @@ -53,9 +53,15 @@ public: return !GetIsFree( index ); } - class iterator : public std::iterator + class iterator { public: + using iterator_category = std::random_access_iterator_tag; + using value_type = ReturnType*; + using difference_type = ptrdiff_t; + using pointer = ReturnType* const *; + using reference = ReturnType*; + iterator() : m_ptr(nullptr) { } @@ -64,8 +70,8 @@ public: { } - reference operator* () const { return *reinterpret_cast(m_ptr); } - pointer operator->() const { return reinterpret_cast(m_ptr); } + reference operator* () const { return reinterpret_cast(m_ptr); } + pointer operator->() const { return &reinterpret_cast(m_ptr); } iterator& operator ++ () { ++m_ptr; return *this; } bool operator == ( const iterator& rhs ) const { return m_ptr == rhs.m_ptr; }