From 91039b3406f922e502a211d4634977e50aa63c2e Mon Sep 17 00:00:00 2001 From: Rex Schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:50:52 +0100 Subject: [PATCH] [core] linux warning fixed: use of std::iterator is deprecated (#1928) --- .../shm/relocatable_circular_queue.h | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/ecal/core/src/registration/shm/relocatable_circular_queue.h b/ecal/core/src/registration/shm/relocatable_circular_queue.h index 30d8f4c460..fcc4b03328 100644 --- a/ecal/core/src/registration/shm/relocatable_circular_queue.h +++ b/ecal/core/src/registration/shm/relocatable_circular_queue.h @@ -31,16 +31,23 @@ #include template -class RelocatableCircularQueue{ +class RelocatableCircularQueue { public: static constexpr auto invalid_index = std::numeric_limits::max(); - class iterator : public std::iterator { + class iterator { public: - explicit iterator(RelocatableCircularQueue& relocatable_circular_queue, std::uint64_t index): m_relocatable_circular_queue(relocatable_circular_queue), m_index(index){ + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using reference = T&; + + explicit iterator(RelocatableCircularQueue& relocatable_circular_queue, std::uint64_t index) + : m_relocatable_circular_queue(relocatable_circular_queue), m_index(index) { } - iterator& operator++() + iterator& operator++() { if (m_index == m_relocatable_circular_queue.m_header->front_index) m_index = invalid_index; @@ -85,7 +92,7 @@ class RelocatableCircularQueue{ iterator begin() { - if(m_header->size == 0) + if (m_header->size == 0) return iterator(*this, invalid_index); else return iterator(*this, m_header->back_index); @@ -98,7 +105,7 @@ class RelocatableCircularQueue{ const iterator begin() const { - if(m_header->size == 0) + if (m_header->size == 0) return iterator(*this, invalid_index); else return iterator(*this, m_header->back_index); @@ -109,7 +116,7 @@ class RelocatableCircularQueue{ return iterator(*this, invalid_index); } - RelocatableCircularQueue(): m_header(nullptr) + RelocatableCircularQueue() : m_header(nullptr) {} void Push(const T& value) @@ -218,18 +225,18 @@ class RelocatableCircularQueue{ }; #pragma pack(pop) - void* m_base_address{nullptr}; + void* m_base_address{ nullptr }; Header* m_header; - T * Value(std::uint64_t index) + T* Value(std::uint64_t index) { assert(m_base_address != nullptr); - return reinterpret_cast(static_cast(m_base_address) + sizeof(Header) + sizeof(T) * index); + return reinterpret_cast(static_cast(m_base_address) + sizeof(Header) + sizeof(T) * index); } - const T * Value(std::uint64_t index) const + const T* Value(std::uint64_t index) const { assert(m_base_address != nullptr); - return reinterpret_cast(static_cast(m_base_address) + sizeof(Header) + sizeof(T) * index); + return reinterpret_cast(static_cast(m_base_address) + sizeof(Header) + sizeof(T) * index); } };