Skip to content

Commit

Permalink
fix further cases which can break PVS
Browse files Browse the repository at this point in the history
  • Loading branch information
sunethwarna authored Nov 21, 2024
1 parent 0ca518b commit 2aee55f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kratos/containers/pointer_vector_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <cstddef>
#include <utility>
#include <type_traits>
#include <type_traits>

// External includes
#include <boost/iterator/indirect_iterator.hpp>
Expand Down Expand Up @@ -593,6 +592,7 @@ class PointerVectorSet final
{
std::swap(mSortedPartSize, rOther.mSortedPartSize);
std::swap(mMaxBufferSize, rOther.mMaxBufferSize);
std::swap(mHasMutablePass, rOther.mHasMutablePass);
mData.swap(rOther.mData);
}

Expand Down Expand Up @@ -711,8 +711,6 @@ class PointerVectorSet final
template <class InputIterator>
void insert(InputIterator first, InputIterator last)
{
KRATOS_ERROR_IF(mHasMutablePass)
<< "A mutable pass is active. Hence, use of PointerVectorSet::insert(first, last) is prohibited.";
// first sorts the input iterators and make the input unique.
std::sort(first, last, CompareKey());
auto new_last = std::unique(first, last, EqualKeyTo());
Expand Down Expand Up @@ -1150,6 +1148,9 @@ class PointerVectorSet final
mData.push_back(GetPointer(it));
}
} else {
KRATOS_ERROR_IF(mHasMutablePass)
<< "A mutable pass is active. Hence, use of PointerVectorSet::insert(first, last) is prohibited.";

if (KeyOf(GetReference(first)) > KeyOf(*(mData.back()))) {
// all are pointing to the end of the vector, hence pushing back.
mData.reserve(mData.size() + std::distance(first, last));
Expand Down

0 comments on commit 2aee55f

Please sign in to comment.