mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-02 22:14:35 +02:00
Fix empty control statement warnings
This change replaces code like this: if(safemode_or_autounlink) BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); with: BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert)); The reason for this change is that the first form generates a warning for Visual C++ 14.1 in builds without asserts: warning C4390: ';': empty controlled statement found; is this the intent? Before this change the code was using a mix of the two forms when invoking the BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT() and BOOST_INTRUSIVE_INVARIANT_ASSERT() macros. Now it consistently uses the second form.
This commit is contained in:
@@ -1062,8 +1062,7 @@ class bstree_impl
|
||||
iterator insert_equal(reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
iterator ret(node_algorithms::insert_equal_upper_bound
|
||||
(this->header_ptr(), to_insert, this->key_node_comp(this->key_comp())), this->priv_value_traits_ptr());
|
||||
this->sz_traits().increment();
|
||||
@@ -1087,8 +1086,7 @@ class bstree_impl
|
||||
iterator insert_equal(const_iterator hint, reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
iterator ret(node_algorithms::insert_equal
|
||||
(this->header_ptr(), hint.pointed_node(), to_insert, this->key_node_comp(this->key_comp())), this->priv_value_traits_ptr());
|
||||
this->sz_traits().increment();
|
||||
@@ -1317,8 +1315,7 @@ class bstree_impl
|
||||
iterator insert_unique_commit(reference value, const insert_commit_data &commit_data)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
|
||||
#if !(defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) ))
|
||||
//Test insertion position is correct
|
||||
@@ -1355,8 +1352,7 @@ class bstree_impl
|
||||
iterator insert_before(const_iterator pos, reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
this->sz_traits().increment();
|
||||
return iterator(node_algorithms::insert_before
|
||||
(this->header_ptr(), pos.pointed_node(), to_insert), this->priv_value_traits_ptr());
|
||||
@@ -1379,8 +1375,7 @@ class bstree_impl
|
||||
void push_back(reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
this->sz_traits().increment();
|
||||
node_algorithms::push_back(this->header_ptr(), to_insert);
|
||||
}
|
||||
@@ -1402,8 +1397,7 @@ class bstree_impl
|
||||
void push_front(reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
this->sz_traits().increment();
|
||||
node_algorithms::push_front(this->header_ptr(), to_insert);
|
||||
}
|
||||
@@ -1421,8 +1415,7 @@ class bstree_impl
|
||||
const_iterator ret(i);
|
||||
++ret;
|
||||
node_ptr to_erase(i.pointed_node());
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || !node_algorithms::unique(to_erase));
|
||||
node_algorithms::erase(this->header_ptr(), to_erase);
|
||||
this->sz_traits().decrement();
|
||||
if(safemode_or_autounlink)
|
||||
@@ -2061,8 +2054,7 @@ class bstree_impl
|
||||
typedef typename get_node_checker<AlgoType, ValueTraits, nodeptr_comp_t, ExtraChecker>::type node_checker_t;
|
||||
typename node_checker_t::return_type checker_return;
|
||||
node_algorithms::check(this->header_ptr(), node_checker_t(nodeptr_comp, extra_checker), checker_return);
|
||||
if (constant_time_size)
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(this->sz_traits().get_size() == checker_return.node_count);
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!constant_time_size || this->sz_traits().get_size() == checker_return.node_count);
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Asserts the integrity of the container.
|
||||
|
@@ -83,10 +83,8 @@ struct bstree_node_checker
|
||||
const return_type& check_return_left, const return_type& check_return_right,
|
||||
return_type& check_return)
|
||||
{
|
||||
if (check_return_left.max_key_node_ptr)
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!comp_(p, check_return_left.max_key_node_ptr));
|
||||
if (check_return_right.min_key_node_ptr)
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!comp_(check_return_right.min_key_node_ptr, p));
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!check_return_left.max_key_node_ptr || !comp_(p, check_return_left.max_key_node_ptr));
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!check_return_right.min_key_node_ptr || !comp_(check_return_right.min_key_node_ptr, p));
|
||||
check_return.min_key_node_ptr = node_traits::get_left(p)? check_return_left.min_key_node_ptr : p;
|
||||
check_return.max_key_node_ptr = node_traits::get_right(p)? check_return_right.max_key_node_ptr : p;
|
||||
check_return.node_count = check_return_left.node_count + check_return_right.node_count + 1;
|
||||
|
@@ -447,8 +447,7 @@ class sgtree_impl
|
||||
iterator insert_equal(reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
std::size_t max_tree_size = (std::size_t)this->max_tree_size_;
|
||||
node_ptr p = node_algorithms::insert_equal_upper_bound
|
||||
(this->tree_type::header_ptr(), to_insert, this->key_node_comp(this->key_comp())
|
||||
@@ -462,8 +461,7 @@ class sgtree_impl
|
||||
iterator insert_equal(const_iterator hint, reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
std::size_t max_tree_size = (std::size_t)this->max_tree_size_;
|
||||
node_ptr p = node_algorithms::insert_equal
|
||||
( this->tree_type::header_ptr(), hint.pointed_node(), to_insert, this->key_node_comp(this->key_comp())
|
||||
@@ -545,8 +543,7 @@ class sgtree_impl
|
||||
iterator insert_unique_commit(reference value, const insert_commit_data &commit_data)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
std::size_t max_tree_size = (std::size_t)this->max_tree_size_;
|
||||
node_algorithms::insert_unique_commit
|
||||
( this->tree_type::header_ptr(), to_insert, commit_data
|
||||
@@ -575,8 +572,7 @@ class sgtree_impl
|
||||
iterator insert_before(const_iterator pos, reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
std::size_t max_tree_size = (std::size_t)this->max_tree_size_;
|
||||
node_ptr p = node_algorithms::insert_before
|
||||
( this->tree_type::header_ptr(), pos.pointed_node(), to_insert
|
||||
@@ -590,8 +586,7 @@ class sgtree_impl
|
||||
void push_back(reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
std::size_t max_tree_size = (std::size_t)this->max_tree_size_;
|
||||
node_algorithms::push_back
|
||||
( this->tree_type::header_ptr(), to_insert
|
||||
@@ -604,8 +599,7 @@ class sgtree_impl
|
||||
void push_front(reference value)
|
||||
{
|
||||
node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));
|
||||
std::size_t max_tree_size = (std::size_t)this->max_tree_size_;
|
||||
node_algorithms::push_front
|
||||
( this->tree_type::header_ptr(), to_insert
|
||||
@@ -621,8 +615,7 @@ class sgtree_impl
|
||||
const_iterator ret(i);
|
||||
++ret;
|
||||
node_ptr to_erase(i.pointed_node());
|
||||
if(safemode_or_autounlink)
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase));
|
||||
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || !node_algorithms::unique(to_erase));
|
||||
std::size_t max_tree_size = this->max_tree_size_;
|
||||
node_algorithms::erase
|
||||
( this->tree_type::header_ptr(), to_erase, (std::size_t)this->size()
|
||||
|
@@ -1937,8 +1937,7 @@ class slist_impl
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(node_traits::get_next(header_ptr));
|
||||
if (node_traits::get_next(header_ptr) == header_ptr)
|
||||
{
|
||||
if (constant_time_size)
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == 0);
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!constant_time_size || this->priv_size_traits().get_size() == 0);
|
||||
return;
|
||||
}
|
||||
size_t node_count = 0;
|
||||
@@ -1956,15 +1955,13 @@ class slist_impl
|
||||
}
|
||||
if ((!linear && next_p == header_ptr) || (linear && !next_p))
|
||||
{
|
||||
if (cache_last)
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(get_last_node() == p);
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!cache_last || get_last_node() == p);
|
||||
break;
|
||||
}
|
||||
p = next_p;
|
||||
++node_count;
|
||||
}
|
||||
if (constant_time_size)
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == node_count);
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!constant_time_size || this->priv_size_traits().get_size() == node_count);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -53,10 +53,8 @@ struct treap_node_extra_checker
|
||||
const return_type& check_return_left, const return_type& check_return_right,
|
||||
return_type& check_return)
|
||||
{
|
||||
if (node_traits::get_left(p))
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!prio_comp_(node_traits::get_left(p), p));
|
||||
if (node_traits::get_right(p))
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!prio_comp_(node_traits::get_right(p), p));
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_traits::get_left(p) || !prio_comp_(node_traits::get_left(p), p));
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_traits::get_right(p) || !prio_comp_(node_traits::get_right(p), p));
|
||||
base_checker_t::operator()(p, check_return_left, check_return_right, check_return);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user