From e57d4a11ae1db3b965a24e3de5efcae1ffc29781 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 16:01:05 +0200 Subject: [PATCH] fixed ordered multi map changes integrated --- container/FixedOrderedMultimap.h | 13 +++++-------- container/FixedOrderedMultimap.tpp | 15 +++------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/container/FixedOrderedMultimap.h b/container/FixedOrderedMultimap.h index 41465c33..99825dc4 100644 --- a/container/FixedOrderedMultimap.h +++ b/container/FixedOrderedMultimap.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ -#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ +#ifndef FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ +#define FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ #include "../container/ArrayList.h" #include @@ -39,10 +39,6 @@ public: Iterator(); /** Initializes iterator to given entry */ Iterator(std::pair *pair); - /** Dereference operator can be used to get value */ - T operator*(); - /** Arrow operator can be used to get pointer to value */ - T *operator->(); }; /** Iterator to start of map */ @@ -160,7 +156,8 @@ private: if (_size <= position) { return; } - memmove(&theMap[position], &theMap[position + 1], + std::memmove(static_cast(&theMap[position]), + static_cast(&theMap[position + 1]), (_size - position - 1) * sizeof(std::pair)); --_size; } @@ -168,4 +165,4 @@ private: #include "FixedOrderedMultimap.tpp" -#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ */ +#endif /* FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ */ diff --git a/container/FixedOrderedMultimap.tpp b/container/FixedOrderedMultimap.tpp index 74edbf9a..5b7b9ead 100644 --- a/container/FixedOrderedMultimap.tpp +++ b/container/FixedOrderedMultimap.tpp @@ -10,11 +10,6 @@ inline FixedOrderedMultimap::Iterator::Iterator( std::pair *pair): ArrayList, uint32_t>::Iterator(pair){} -template -inline T FixedOrderedMultimap::Iterator::operator*() { - return ArrayList, uint32_t>::Iterator::value->second; -} - template inline typename FixedOrderedMultimap::Iterator FixedOrderedMultimap::begin() const { @@ -33,11 +28,6 @@ inline size_t FixedOrderedMultimap::size() const { return _size; } -template -inline T* FixedOrderedMultimap::Iterator::operator->() { - return &ArrayList, uint32_t>::Iterator::value->second; -} - template inline FixedOrderedMultimap::FixedOrderedMultimap( size_t maxSize): theMap(maxSize), _size(0) {} @@ -52,8 +42,9 @@ inline ReturnValue_t FixedOrderedMultimap::insert( uint32_t position = findNicePlace(key); // Compiler might emitt warning because std::pair is not a POD type (yet..) // See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm#std::pair-example - // Should still work without issues. - std::memmove(&theMap[position + 1], &theMap[position], + // Circumvent warning by casting to void* + std::memmove(static_cast(&theMap[position + 1]), + static_cast(&theMap[position]), (_size - position) * sizeof(std::pair)); theMap[position].first = key; theMap[position].second = value;