Skip to content

Commit

Permalink
suppress unused warning and avoid call == when always equal
Browse files Browse the repository at this point in the history
  • Loading branch information
YexuanXiao committed Oct 3, 2024
1 parent d129813 commit 0767ceb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/oneapi/tbb/concurrent_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class concurrent_queue {

private:
void internal_swap(concurrent_queue& src) {
if (!allocator_traits_type::queue_allocator_traits::propagate_on_container)
if (!queue_allocator_traits::propagate_on_container_swap::value)
__TBB_ASSERT(my_allocator == src.my_allocator, "Swapping with unequal allocators is not allowed");
using std::swap;
swap(my_queue_representation, src.my_queue_representation);
Expand Down
6 changes: 5 additions & 1 deletion include/oneapi/tbb/detail/_allocator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ void swap_allocators_impl( Allocator& lhs, Allocator& rhs, /*pocs = */ std::true
template <typename Allocator>
void swap_allocators_impl( Allocator& lhs, Allocator& rhs, /*pocs = */ std::false_type ) {
// If the lhs and rhs are not equal, the behavior is undefined
__TBB_ASSERT(lhs == rhs, "Swapping with unequal allocators is not allowed");
if (!allocator_traits<Allocator>::is_always_equal::value) {
__TBB_ASSERT(lhs == rhs, "Swapping with unequal allocators is not allowed");
}
tbb::detail::suppress_unused_warning(lhs);
tbb::detail::suppress_unused_warning(rhs);
}

// Swaps allocators only if propagate_on_container_swap is true
Expand Down

0 comments on commit 0767ceb

Please sign in to comment.