Skip to content

Commit 0767ceb

Browse files
committed
suppress unused warning and avoid call == when always equal
1 parent d129813 commit 0767ceb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/oneapi/tbb/concurrent_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class concurrent_queue {
237237

238238
private:
239239
void internal_swap(concurrent_queue& src) {
240-
if (!allocator_traits_type::queue_allocator_traits::propagate_on_container)
240+
if (!queue_allocator_traits::propagate_on_container_swap::value)
241241
__TBB_ASSERT(my_allocator == src.my_allocator, "Swapping with unequal allocators is not allowed");
242242
using std::swap;
243243
swap(my_queue_representation, src.my_queue_representation);

include/oneapi/tbb/detail/_allocator_traits.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ void swap_allocators_impl( Allocator& lhs, Allocator& rhs, /*pocs = */ std::true
9393
template <typename Allocator>
9494
void swap_allocators_impl( Allocator& lhs, Allocator& rhs, /*pocs = */ std::false_type ) {
9595
// If the lhs and rhs are not equal, the behavior is undefined
96-
__TBB_ASSERT(lhs == rhs, "Swapping with unequal allocators is not allowed");
96+
if (!allocator_traits<Allocator>::is_always_equal::value) {
97+
__TBB_ASSERT(lhs == rhs, "Swapping with unequal allocators is not allowed");
98+
}
99+
tbb::detail::suppress_unused_warning(lhs);
100+
tbb::detail::suppress_unused_warning(rhs);
97101
}
98102

99103
// Swaps allocators only if propagate_on_container_swap is true

0 commit comments

Comments
 (0)