Fixes for C++17 conformance

This commit is contained in:
Silent 2017-12-22 00:13:16 +01:00
parent 0a5f47ab1b
commit ce0fe83e66
2 changed files with 15 additions and 10 deletions

View file

@ -116,21 +116,20 @@ std::tuple<int,int> CObject::TryOrFreeUpTempObjects( int numObjects, bool force
int numProcessed = 0, numFreed = 0; int numProcessed = 0, numFreed = 0;
auto& pool = CPools::GetObjectPool(); auto& pool = CPools::GetObjectPool();
for ( auto& obj : pool ) for ( auto obj : pool )
{ {
if ( numFreed >= numObjects ) break; if ( numFreed >= numObjects ) break;
CObject* const objPtr = &obj; if ( pool.IsValidPtr( obj ) )
if ( pool.IsValidPtr( objPtr ) )
{ {
if ( objPtr->m_objectCreatedBy == TEMP_OBJECT ) if ( obj->m_objectCreatedBy == TEMP_OBJECT )
{ {
numProcessed++; numProcessed++;
if ( force || !objPtr->IsVisible() ) if ( force || !obj->IsVisible() )
{ {
numFreed++; numFreed++;
WorldRemove( objPtr ); WorldRemove( obj );
delete objPtr; delete obj;
} }
} }
} }

View file

@ -53,9 +53,15 @@ public:
return !GetIsFree( index ); return !GetIsFree( index );
} }
class iterator : public std::iterator<std::random_access_iterator_tag, ReturnType> class iterator
{ {
public: 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) iterator() : m_ptr(nullptr)
{ {
} }
@ -64,8 +70,8 @@ public:
{ {
} }
reference operator* () const { return *reinterpret_cast<ReturnType*>(m_ptr); } reference operator* () const { return reinterpret_cast<ReturnType*>(m_ptr); }
pointer operator->() const { return reinterpret_cast<ReturnType*>(m_ptr); } pointer operator->() const { return &reinterpret_cast<ReturnType*>(m_ptr); }
iterator& operator ++ () { ++m_ptr; return *this; } iterator& operator ++ () { ++m_ptr; return *this; }
bool operator == ( const iterator& rhs ) const { return m_ptr == rhs.m_ptr; } bool operator == ( const iterator& rhs ) const { return m_ptr == rhs.m_ptr; }