- Remove config_begin.hpp/config_end.hpp includes in tests to avoid disabling warnings.

- Fixes #30 ("(void) C-cast is a non-portable way of suppressing compiler warnings").
This commit is contained in:
Ion Gaztañaga
2020-10-20 11:28:27 +02:00
parent 01d8832c9e
commit e4c47fcb90
26 changed files with 101 additions and 182 deletions
+2 -4
View File
@@ -98,16 +98,14 @@ inline void adaptive_merge_final_merge( RandIt first
, typename iterator_traits<RandIt>::size_type len2
, typename iterator_traits<RandIt>::size_type collected
, typename iterator_traits<RandIt>::size_type l_intbuf
, typename iterator_traits<RandIt>::size_type l_block
, bool use_internal_buf
, typename iterator_traits<RandIt>::size_type //l_block
, bool //use_internal_buf
, bool xbuf_used
, Compare comp
, XBuf & xbuf
)
{
typedef typename iterator_traits<RandIt>::size_type size_type;
(void)l_block;
(void)use_internal_buf;
size_type n_keys = collected-l_intbuf;
size_type len = len1+len2;
if (!xbuf_used || n_keys) {
+3 -2
View File
@@ -14,6 +14,7 @@
#include <boost/move/detail/config_begin.hpp>
#include <boost/move/algo/detail/adaptive_sort_merge.hpp>
#include <boost/core/ignore_unused.hpp>
namespace boost {
namespace movelib {
@@ -165,7 +166,7 @@ void adaptive_sort_combine_blocks
, Compare comp
, bool merge_left)
{
(void)xbuf;
boost::ignore_unused(xbuf);
typedef typename iterator_traits<RandIt>::size_type size_type;
size_type const l_reg_combined = 2*l_prev_merged;
@@ -174,7 +175,7 @@ void adaptive_sort_combine_blocks
size_type const n_reg_combined = len/l_reg_combined;
RandIt combined_first = first;
(void)l_total_combined;
boost::ignore_unused(l_total_combined);
BOOST_ASSERT(l_total_combined <= len);
size_type const max_i = n_reg_combined + (l_irreg_combined != 0);
@@ -52,6 +52,7 @@
#include <boost/move/algo/detail/heap_sort.hpp>
#include <boost/move/algo/detail/merge.hpp>
#include <boost/move/algo/detail/is_sorted.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
@@ -312,7 +313,8 @@ void merge_blocks_bufferless
, Compare comp)
{
typedef typename iterator_traits<RandIt>::size_type size_type;
size_type const key_count = needed_keys_count(n_block_a, n_block_b); (void)key_count;
size_type const key_count = needed_keys_count(n_block_a, n_block_b);
::boost::ignore_unused(key_count);
//BOOST_ASSERT(n_block_a || n_block_b);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted_and_unique(key_first, key_first + key_count, key_comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(!n_block_b || n_block_a == count_if_with(key_first, key_first + key_count, key_comp, key_first[n_block_a]));
@@ -602,7 +604,8 @@ void unstable_sort( RandIt first, RandIt last
, Comp comp
, XBuf & xbuf)
{
heap_sort(first, last, comp);(void)xbuf;
heap_sort(first, last, comp);
::boost::ignore_unused(xbuf);
}
template<class RandIt, class Compare, class XBuf>
@@ -943,13 +946,15 @@ OutputIt op_merge_blocks_with_irreg
max_check = min_value<size_type>(max_value<size_type>(max_check, next_key_idx+size_type(2)), n_block_left);
RandIt const last_reg = first_reg + l_block;
RandIt first_min = first_reg + next_key_idx*l_block;
RandIt const last_min = first_min + l_block; (void)last_min;
RandIt const last_min = first_min + l_block;
boost::ignore_unused(last_min);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first_reg, last_reg, comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(!next_key_idx || boost::movelib::is_sorted(first_min, last_min, comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT((!next_key_idx || !comp(*first_reg, *first_min )));
OutputIt orig_dest = dest; (void)orig_dest;
OutputIt orig_dest = dest;
boost::ignore_unused(orig_dest);
dest = next_key_idx ? op_partial_merge_and_swap(first_irr, last_irr, first_reg, last_reg, first_min, dest, comp, op, is_stable)
: op_partial_merge (first_irr, last_irr, first_reg, last_reg, dest, comp, op, is_stable);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(orig_dest, dest, comp));
@@ -995,7 +1000,9 @@ void op_merge_blocks_left
, Compare comp, Op op)
{
typedef typename iterator_traits<RandIt>::size_type size_type;
size_type const key_count = needed_keys_count(n_block_a, n_block_b); (void)key_count;
size_type const key_count = needed_keys_count(n_block_a, n_block_b);
boost::ignore_unused(key_count);
// BOOST_ASSERT(n_block_a || n_block_b);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted_and_unique(key_first, key_first + key_count, key_comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(!n_block_b || n_block_a == count_if_with(key_first, key_first + key_count, key_comp, key_first[n_block_a]));
@@ -1023,7 +1030,9 @@ void op_merge_blocks_left
size_type const next_key_idx = find_next_block(key_range2, key_comp, first2, l_block, min_check, max_check, comp);
max_check = min_value<size_type>(max_value<size_type>(max_check, next_key_idx+size_type(2)), n_block_left);
RandIt const first_min = first2 + next_key_idx*l_block;
RandIt const last_min = first_min + l_block; (void)last_min;
RandIt const last_min = first_min + l_block;
boost::ignore_unused(last_min);
RandIt const last2 = first2 + l_block;
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first1, last1, comp));
@@ -1068,7 +1077,8 @@ void op_merge_blocks_left
unmerged = op_partial_merge_and_save
(buffer, buffer+(last1-first1), first2, last2, first_min, buf_beg, buf_end, comp, op, is_range1_A);
}
(void)unmerged;
boost::ignore_unused(unmerged);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first-l_block, unmerged, comp));
swap_and_update_key( key_next, key_range2, key_mid, first2, last2
@@ -1126,7 +1136,8 @@ void op_merge_blocks_left
buffer = op_merge_blocks_with_irreg
( key_range2, key_mid, key_comp, first2, first_irr2, last_irr2
, buffer, l_block, n_block_left, min_check, max_check, comp, false, op);
buffer = op(forward_t(), first_irr2, last_irr2, buffer);(void)buffer;
buffer = op(forward_t(), first_irr2, last_irr2, buffer);
boost::ignore_unused(buffer);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first-l_block, buffer, comp));
}
@@ -1216,7 +1227,8 @@ void op_merge_blocks_with_buf
, RandItBuf const buf_first)
{
typedef typename iterator_traits<RandIt>::size_type size_type;
size_type const key_count = needed_keys_count(n_block_a, n_block_b); (void)key_count;
size_type const key_count = needed_keys_count(n_block_a, n_block_b);
boost::ignore_unused(key_count);
//BOOST_ASSERT(n_block_a || n_block_b);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted_and_unique(key_first, key_first + key_count, key_comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(!n_block_b || n_block_a == count_if_with(key_first, key_first + key_count, key_comp, key_first[n_block_a]));
@@ -1233,7 +1245,8 @@ void op_merge_blocks_with_buf
RandIt first2 = last1;
RandIt const first_irr2 = first2 + n_block_left*l_block;
bool is_range1_A = true;
const size_type len = l_block * n_block_a + l_block * n_block_b + l_irreg1 + l_irreg2; (void)len;
const size_type len = l_block * n_block_a + l_block * n_block_b + l_irreg1 + l_irreg2;
boost::ignore_unused(len);
RandItKeys key_range2(key_first);
@@ -1246,10 +1259,12 @@ void op_merge_blocks_with_buf
size_type const next_key_idx = find_next_block(key_range2, key_comp, first2, l_block, min_check, max_check, comp);
max_check = min_value<size_type>(max_value<size_type>(max_check, next_key_idx+size_type(2)), n_block_left);
RandIt first_min = first2 + next_key_idx*l_block;
RandIt const last_min = first_min + l_block; (void)last_min;
RandIt const last_min = first_min + l_block;
boost::ignore_unused(last_min);
RandIt const last2 = first2 + l_block;
bool const buffer_empty = buffer == buffer_end; (void)buffer_empty;
bool const buffer_empty = buffer == buffer_end;
boost::ignore_unused(buffer_empty);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(buffer_empty ? boost::movelib::is_sorted(first1, last1, comp) : boost::movelib::is_sorted(buffer, buffer_end, comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first2, last2, comp));
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(!n_block_left || boost::movelib::is_sorted(first_min, last_min, comp));
@@ -1270,7 +1285,8 @@ void op_merge_blocks_with_buf
RandIt res = op(forward_t(), buffer, buffer_end, first1);
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" merge_blocks_w_fwd: ", len);
buffer = buffer_end = buf_first;
BOOST_ASSERT(buffer_empty || res == last1); (void)res;
BOOST_ASSERT(buffer_empty || res == last1);
boost::ignore_unused(res);
//swap_and_update_key(key_next, key_range2, key_mid, first2, last2, first_min);
buffer_end = buffer_and_update_key(key_next, key_range2, key_mid, first2, last2, first_min, buffer = buf_first, op);
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" merge_blocks_w_swp: ", len);
@@ -1307,7 +1323,8 @@ void op_merge_blocks_with_buf
last1 += l_block;
first2 = last2;
}
RandIt res = op(forward_t(), buffer, buffer_end, first1); (void)res;
RandIt res = op(forward_t(), buffer, buffer_end, first1);
boost::ignore_unused(res);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first, res, comp));
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" merge_blocks_w_fwd: ", len);
+4 -48
View File
@@ -11,6 +11,7 @@
#ifndef BOOST_MOVE_MERGE_HPP
#define BOOST_MOVE_MERGE_HPP
#include <boost/core/ignore_unused.hpp>
#include <boost/move/algo/move.hpp>
#include <boost/move/adl_move_swap.hpp>
#include <boost/move/algo/detail/basic_op.hpp>
@@ -680,7 +681,7 @@ void op_merge_with_right_placed
if (r_first == r_last) {
InputOutIterator end = op(forward_t(), first, last, dest_first);
BOOST_ASSERT(end == r_last);
(void)end;
boost::ignore_unused(end);
return;
}
else if (comp(*r_first, *first)) {
@@ -717,7 +718,7 @@ void op_merge_with_left_placed
if(first == last) {
BidirOutIterator res = op(backward_t(), r_first, r_last, dest_last);
BOOST_ASSERT(last == res);
(void)res;
boost::ignore_unused(res);
return;
}
--r_last;
@@ -781,7 +782,7 @@ void uninitialized_merge_with_right_placed
d.release();
InputOutIterator end = ::boost::move(first, last, original_r_first);
BOOST_ASSERT(end == r_last);
(void)end;
boost::ignore_unused(end);
return;
}
else if (comp(*r_first, *first)) {
@@ -800,51 +801,6 @@ void uninitialized_merge_with_right_placed
merge_with_right_placed(first, last, original_r_first, r_first, r_last, comp);
}
/*
// [r_first, r_last) are already in the right part of the destination range.
// [dest_first, r_first) is uninitialized memory
template <class Compare, class BidirOutIterator, class BidirIterator>
void uninitialized_merge_with_left_placed
( BidirOutIterator dest_first, BidirOutIterator r_first, BidirOutIterator r_last
, BidirIterator first, BidirIterator last
, Compare comp)
{
BOOST_ASSERT((last - first) == (r_last - r_first));
typedef typename iterator_traits<BidirOutIterator>::value_type value_type;
BidirOutIterator const original_r_last = r_last;
destruct_n<value_type> d(&*dest_last);
while ( first != last && dest_first != original_r_first ) {
if (r_first == r_last) {
for(; dest_first != original_r_first; ++dest_first, ++first){
::new(&*dest_first) value_type(::boost::move(*first));
d.incr();
}
d.release();
BidirOutIterator end = ::boost::move(first, last, original_r_first);
BOOST_ASSERT(end == r_last);
(void)end;
return;
}
else if (comp(*r_first, *first)) {
::new(&*dest_first) value_type(::boost::move(*r_first));
d.incr();
++r_first;
}
else {
::new(&*dest_first) value_type(::boost::move(*first));
d.incr();
++first;
}
++dest_first;
}
d.release();
merge_with_right_placed(first, last, original_r_first, r_first, r_last, comp);
}
*/
/// This is a helper function for the merge routines.
template<typename BidirectionalIterator1, typename BidirectionalIterator2>
BidirectionalIterator1