Skip to content

Commit

Permalink
Avoid clang-tidy false positives for intrusive_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Nov 27, 2024
1 parent 10afbbc commit 2c69607
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libcaf_core/caf/intrusive_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ class intrusive_ptr {
/// Returns the raw pointer without modifying reference
/// count and sets this to `nullptr`.
pointer detach() noexcept {
auto result = ptr_;
if (result)
if (ptr_ != nullptr) {
auto result = ptr_;
ptr_ = nullptr;
return result;
return result;
}
return nullptr;
}

/// Returns the raw pointer without modifying reference
Expand All @@ -116,10 +118,8 @@ class intrusive_ptr {
}

void reset(pointer new_value = nullptr, bool add_ref = true) noexcept {
auto old = ptr_;
set_ptr(new_value, add_ref);
if (old)
intrusive_ptr_access<T>::release(old);
intrusive_ptr tmp{new_value, add_ref};
swap(tmp);
}

template <class... Ts>
Expand Down

0 comments on commit 2c69607

Please sign in to comment.