Fix performance-noexcept-swap clang-tidy warning

This commit is contained in:
Siarhei Fedartsou 2024-06-07 07:11:44 +02:00
parent 6f8e63f3da
commit edd19bb1fd
2 changed files with 7 additions and 6 deletions

View File

@ -166,7 +166,7 @@ class DeallocatingVectorIterator
template <typename ElementT> class DeallocatingVector; template <typename ElementT> class DeallocatingVector;
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs); template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) noexcept;
template <typename ElementT> class DeallocatingVector template <typename ElementT> class DeallocatingVector
{ {
@ -221,9 +221,10 @@ template <typename ElementT> class DeallocatingVector
~DeallocatingVector() { clear(); } ~DeallocatingVector() { clear(); }
friend void swap<>(DeallocatingVector<ElementT> &lhs, DeallocatingVector<ElementT> &rhs); friend void swap<>(DeallocatingVector<ElementT> &lhs,
DeallocatingVector<ElementT> &rhs) noexcept;
void swap(DeallocatingVector<ElementT> &other) void swap(DeallocatingVector<ElementT> &other) noexcept
{ {
std::swap(current_size, other.current_size); std::swap(current_size, other.current_size);
bucket_list.swap(other.bucket_list); bucket_list.swap(other.bucket_list);
@ -342,7 +343,7 @@ template <typename ElementT> class DeallocatingVector
} }
}; };
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) noexcept
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }

View File

@ -10,9 +10,9 @@ namespace osrm::util
namespace permutation_detail namespace permutation_detail
{ {
template <typename T> static inline void swap(T &a, T &b) { std::swap(a, b); } template <typename T> static inline void swap(T &a, T &b) noexcept { std::swap(a, b); }
static inline void swap(std::vector<bool>::reference a, std::vector<bool>::reference b) static inline void swap(std::vector<bool>::reference a, std::vector<bool>::reference b) noexcept
{ {
std::vector<bool>::swap(a, b); std::vector<bool>::swap(a, b);
} }