Avoid dependency on Boost.Core only due to "ignore_unused"

This commit is contained in:
Ion Gaztañaga
2023-01-14 23:52:10 +01:00
parent 0a1cb78c95
commit b33190fbab
10 changed files with 68 additions and 69 deletions

View File

@ -9,8 +9,6 @@
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/core/ignore_unused.hpp>
//[move_return_example
#include "movable.hpp"
#include "copymovable.hpp"
@ -61,7 +59,7 @@ int main()
copyable c = lock_wrapper(factory_functor<copyable> ());
non_copy_movable &mr = lock_wrapper(return_reference ());
//<-
boost::ignore_unused(m); boost::ignore_unused(cm); boost::ignore_unused(c); boost::ignore_unused(mr);
boost::movelib::ignore(m); boost::movelib::ignore(cm); boost::movelib::ignore(c); boost::movelib::ignore(mr);
//->
return 0;
}

View File

@ -15,7 +15,6 @@
#include <boost/move/detail/config_begin.hpp>
#include <boost/move/algo/detail/adaptive_sort_merge.hpp>
#include <boost/core/ignore_unused.hpp>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
@ -172,7 +171,7 @@ void adaptive_sort_combine_blocks
, Compare comp
, bool merge_left)
{
boost::ignore_unused(xbuf);
boost::movelib::ignore(xbuf);
typedef typename iter_size<RandIt>::type size_type;
size_type const l_reg_combined = size_type(2u*l_prev_merged);
@ -181,7 +180,7 @@ void adaptive_sort_combine_blocks
size_type const n_reg_combined = len/l_reg_combined;
RandIt combined_first = first;
boost::ignore_unused(l_total_combined);
boost::movelib::ignore(l_total_combined);
BOOST_ASSERT(l_total_combined <= len);
size_type const max_i = size_type(n_reg_combined + (l_irreg_combined != 0));

View File

@ -53,7 +53,6 @@
#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>
#include <limits.h>
@ -323,7 +322,7 @@ void merge_blocks_bufferless
{
typedef typename iter_size<RandIt>::type size_type;
size_type const key_count = needed_keys_count(n_block_a, n_block_b);
::boost::ignore_unused(key_count);
::boost::movelib::ignore(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]));
@ -627,7 +626,7 @@ void unstable_sort( RandIt first, RandIt last
, XBuf & xbuf)
{
heap_sort(first, last, comp);
::boost::ignore_unused(xbuf);
::boost::movelib::ignore(xbuf);
}
template<class RandIt, class Compare, class XBuf>
@ -969,14 +968,14 @@ OutputIt op_merge_blocks_with_irreg
RandIt const last_reg = first_reg + l_block;
RandIt first_min = first_reg + size_type(next_key_idx*l_block);
RandIt const last_min = first_min + l_block;
boost::ignore_unused(last_min);
boost::movelib::ignore(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;
boost::ignore_unused(orig_dest);
boost::movelib::ignore(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));
@ -1027,7 +1026,7 @@ void op_merge_blocks_left
typedef typename iter_size<RandIt>::type size_type;
size_type const key_count = needed_keys_count(n_block_a, n_block_b);
boost::ignore_unused(key_count);
boost::movelib::ignore(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));
@ -1058,7 +1057,7 @@ void op_merge_blocks_left
RandIt const first_min = first2 + size_type(next_key_idx*l_block);
RandIt const last_min = first_min + l_block;
boost::ignore_unused(last_min);
boost::movelib::ignore(last_min);
RandIt const last2 = first2 + l_block;
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first1, last1, comp));
@ -1104,7 +1103,7 @@ void op_merge_blocks_left
(buffer, buffer+(last1-first1), first2, last2, first_min, buf_beg, buf_end, comp, op, is_range1_A);
}
boost::ignore_unused(unmerged);
boost::movelib::ignore(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
@ -1167,7 +1166,7 @@ void op_merge_blocks_left
( 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);
boost::ignore_unused(buffer);
boost::movelib::ignore(buffer);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first-l_block, buffer, comp));
}
@ -1259,7 +1258,7 @@ void op_merge_blocks_with_buf
{
typedef typename iter_size<RandIt>::type size_type;
size_type const key_count = needed_keys_count(n_block_a, n_block_b);
boost::ignore_unused(key_count);
boost::movelib::ignore(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]));
@ -1277,7 +1276,7 @@ void op_merge_blocks_with_buf
RandIt const first_irr2 = first2 + size_type(n_block_left*l_block);
bool is_range1_A = true;
const size_type len = size_type(l_block * n_block_a + l_block * n_block_b + l_irreg1 + l_irreg2);
boost::ignore_unused(len);
boost::movelib::ignore(len);
RandItKeys key_range2(key_first);
@ -1291,11 +1290,11 @@ void op_merge_blocks_with_buf
max_check = min_value(max_value(max_check, size_type(next_key_idx+2)), n_block_left);
RandIt first_min = first2 + size_type(next_key_idx*l_block);
RandIt const last_min = first_min + l_block;
boost::ignore_unused(last_min);
boost::movelib::ignore(last_min);
RandIt const last2 = first2 + l_block;
bool const buffer_empty = buffer == buffer_end;
boost::ignore_unused(buffer_empty);
boost::movelib::ignore(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));
@ -1317,7 +1316,7 @@ void op_merge_blocks_with_buf
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" merge_blocks_w_fwd: ", len);
buffer = buffer_end = buf_first;
BOOST_ASSERT(buffer_empty || res == last1);
boost::ignore_unused(res);
boost::movelib::ignore(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);
@ -1359,7 +1358,7 @@ void op_merge_blocks_with_buf
max_check = size_type(max_check - (max_check != 0));
}
RandIt res = op(forward_t(), buffer, buffer_end, first1);
boost::ignore_unused(res);
boost::movelib::ignore(res);
BOOST_MOVE_ADAPTIVE_SORT_INVARIANT(boost::movelib::is_sorted(first, res, comp));
BOOST_MOVE_ADAPTIVE_SORT_PRINT_L2(" merge_blocks_w_fwd: ", len);

View File

@ -11,8 +11,6 @@
#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>
#include <boost/move/detail/iterator_traits.hpp>
@ -641,7 +639,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);
boost::ignore_unused(end);
boost::movelib::ignore(end);
return;
}
else if (comp(*r_first, *first)) {
@ -678,7 +676,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);
boost::ignore_unused(res);
boost::movelib::ignore(res);
return;
}
--r_last;
@ -742,7 +740,7 @@ void uninitialized_merge_with_right_placed
d.release();
InputOutIterator end = ::boost::move(first, last, original_r_first);
BOOST_ASSERT(end == r_last);
boost::ignore_unused(end);
boost::movelib::ignore(end);
return;
}
else if (comp(*r_first, *first)) {

View File

@ -44,7 +44,6 @@
#include <boost/winapi/get_last_error.hpp>
#include <boost/winapi/error_codes.hpp>
#include <boost/assert.hpp>
#include <boost/core/ignore_unused.hpp>
namespace boost { namespace move_detail {
@ -55,7 +54,7 @@ struct QPFHolder
{
boost::winapi::LARGE_INTEGER_ freq;
boost::winapi::BOOL_ r = boost::winapi::QueryPerformanceFrequency( &freq );
boost::ignore_unused(r);
boost::movelib::ignore(r);
BOOST_ASSERT(r != 0 && "Boost::Move - get_nanosecs_per_tic Internal Error");
return double(1000000000.0L / freq.QuadPart);

View File

@ -68,4 +68,14 @@
#define BOOST_MOVE_FORCEINLINE BOOST_FORCEINLINE
#endif
namespace boost {
namespace movelib {
template <typename T1>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore(T1 const&)
{}
}} //namespace boost::movelib {
#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP

View File

@ -4,7 +4,6 @@
#include <iostream>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/ignore_unused.hpp>
#ifdef NO_MOVE
# undef BOOST_COPY_ASSIGN_REF
@ -148,7 +147,7 @@ X ternary( bool y )
int main(int argc, char* argv[])
{
::boost::ignore_unused(argv);
::boost::movelib::ignore(argv);
// Double parens prevent "most vexing parse"
CHECK_COPIES( X a(( lvalue() )), 1U, 1U, "Direct initialization from lvalue");
CHECK_COPIES( X a(( rvalue() )), 0U, 1U, "Direct initialization from rvalue");

View File

@ -10,7 +10,6 @@
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/move/utility_core.hpp>
#include <boost/core/ignore_unused.hpp>
#include "../example/movable.hpp"
#include "../example/copymovable.hpp"
#include <boost/static_assert.hpp>
@ -110,40 +109,40 @@ int main()
movable m2(boost::move(m));
movable m3(function(movable(boost::move(m2))));
movable m4(function(boost::move(m3)));
::boost::ignore_unused(m);::boost::ignore_unused(m2);::boost::ignore_unused(m3);::boost::ignore_unused(m4);
::boost::movelib::ignore(m);::boost::movelib::ignore(m2);::boost::movelib::ignore(m3);::boost::movelib::ignore(m4);
}
{
movable m;
movable m2(boost::move(m));
movable m3(functionr(movable(boost::move(m2))));
movable m4(functionr(boost::move(m3)));
::boost::ignore_unused(m);::boost::ignore_unused(m2);::boost::ignore_unused(m3);::boost::ignore_unused(m4);
::boost::movelib::ignore(m);::boost::movelib::ignore(m2);::boost::movelib::ignore(m3);::boost::movelib::ignore(m4);
}
{
movable m;
movable m2(boost::move(m));
movable m3(function2(movable(boost::move(m2))));
movable m4(function2(boost::move(m3)));
::boost::ignore_unused(m);::boost::ignore_unused(m2);::boost::ignore_unused(m3);::boost::ignore_unused(m4);
::boost::movelib::ignore(m);::boost::movelib::ignore(m2);::boost::movelib::ignore(m3);::boost::movelib::ignore(m4);
}
{
movable m;
movable m2(boost::move(m));
movable m3(function2r(movable(boost::move(m2))));
movable m4(function2r(boost::move(m3)));
::boost::ignore_unused(m);::boost::ignore_unused(m2);::boost::ignore_unused(m3);::boost::ignore_unused(m4);
::boost::movelib::ignore(m);::boost::movelib::ignore(m2);::boost::movelib::ignore(m3);::boost::movelib::ignore(m4);
}
{
movable m;
movable m2(boost::move(m));
movable m3(move_return_function());
::boost::ignore_unused(m);::boost::ignore_unused(m2);::boost::ignore_unused(m3);
::boost::movelib::ignore(m);::boost::movelib::ignore(m2);::boost::movelib::ignore(m3);
}
{
movable m;
movable m2(boost::move(m));
movable m3(move_return_function2());
::boost::ignore_unused(m);::boost::ignore_unused(m2);::boost::ignore_unused(m3);
::boost::movelib::ignore(m);::boost::movelib::ignore(m2);::boost::movelib::ignore(m3);
}
{
//movable
@ -151,9 +150,9 @@ int main()
m = factory_wrapper<movable>(factory<movable>());
movable&mr(factory_wrapper<movable&>(factory<movable&>()));
movable&mr2 = factory_wrapper<movable&>(factory<movable&>());
::boost::ignore_unused(mr);
::boost::ignore_unused(mr2);
::boost::ignore_unused(m);
::boost::movelib::ignore(mr);
::boost::movelib::ignore(mr2);
::boost::movelib::ignore(m);
}
{
//copyable
@ -161,9 +160,9 @@ int main()
c = factory_wrapper<copyable>(factory<copyable>());
copyable&cr(factory_wrapper<copyable&>(factory<copyable&>()));
copyable&cr2 = factory_wrapper<copyable&>(factory<copyable&>());
::boost::ignore_unused(cr);
::boost::ignore_unused(cr2);
::boost::ignore_unused(c);
::boost::movelib::ignore(cr);
::boost::movelib::ignore(cr2);
::boost::movelib::ignore(c);
}
{
@ -172,9 +171,9 @@ int main()
c = factory_wrapper<copy_movable>(factory<copy_movable>());
copy_movable&cr(factory_wrapper<copy_movable&>(factory<copy_movable&>()));
copy_movable&cr2 = factory_wrapper<copy_movable&>(factory<copy_movable&>());
::boost::ignore_unused(cr);
::boost::ignore_unused(cr2);
::boost::ignore_unused(c);
::boost::movelib::ignore(cr);
::boost::movelib::ignore(cr2);
::boost::movelib::ignore(c);
}
return 0;

View File

@ -11,7 +11,6 @@
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/move/utility_core.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/move/unique_ptr.hpp>
#include <boost/static_assert.hpp>
#include <boost/move/adl_move_swap.hpp>
@ -89,7 +88,7 @@ void test()
bml::unique_ptr<A> p(new A);
BOOST_TEST(A::count == 1);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset();
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -99,7 +98,7 @@ void test()
bml::unique_ptr<A> p(new A);
BOOST_TEST(A::count == 1);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new A);
BOOST_TEST(A::count == 1);
}
@ -108,7 +107,7 @@ void test()
bml::unique_ptr<A> p(new A);
BOOST_TEST(A::count == 1);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(0);
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -122,7 +121,7 @@ void test()
bml::unique_ptr<A[]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset();
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -132,7 +131,7 @@ void test()
bml::unique_ptr<A[]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new A[3]);
BOOST_TEST(A::count == 3);
}
@ -141,7 +140,7 @@ void test()
bml::unique_ptr<A[]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(0);
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -155,7 +154,7 @@ void test()
bml::unique_ptr<A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset();
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -165,7 +164,7 @@ void test()
bml::unique_ptr<A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new A[3]);
BOOST_TEST(A::count == 3);
}
@ -174,7 +173,7 @@ void test()
bml::unique_ptr<A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(0);
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -200,7 +199,7 @@ void test()
BOOST_TEST(A::count == 1);
BOOST_TEST(B::count == 0);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new B);
BOOST_TEST(A::count == 1);
BOOST_TEST(B::count == 1);
@ -212,7 +211,7 @@ void test()
BOOST_TEST(A::count == 1);
BOOST_TEST(B::count == 1);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new B);
BOOST_TEST(A::count == 1);
BOOST_TEST(B::count == 1);
@ -225,7 +224,7 @@ void test()
bml::unique_ptr<const volatile A[2]> p(new const A[2]);
BOOST_TEST(A::count == 2);
const volatile A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new volatile A[3]);
BOOST_TEST(A::count == 3);
}
@ -234,7 +233,7 @@ void test()
bml::unique_ptr<const A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
const A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new const A[3]);
BOOST_TEST(A::count == 3);
}
@ -245,7 +244,7 @@ void test()
bml::unique_ptr<const volatile A[2]> p(new const A[2]);
BOOST_TEST(A::count == 2);
const volatile A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new volatile A[3]);
BOOST_TEST(A::count == 3);
}
@ -254,7 +253,7 @@ void test()
bml::unique_ptr<const A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
const A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(new const A[3]);
BOOST_TEST(A::count == 3);
}

View File

@ -11,7 +11,6 @@
//
//////////////////////////////////////////////////////////////////////////////
#include <boost/move/utility_core.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/move/unique_ptr.hpp>
#include <boost/static_assert.hpp>
#include <boost/core/lightweight_test.hpp>
@ -108,7 +107,7 @@ void test()
bml::unique_ptr<A> p(new A);
BOOST_TEST(A::count == 1);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(nullptr);
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -118,7 +117,7 @@ void test()
bml::unique_ptr<A> p(new A);
BOOST_TEST(A::count == 1);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p = nullptr;
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -144,7 +143,7 @@ void test()
bml::unique_ptr<A[]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(nullptr);
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -154,7 +153,7 @@ void test()
bml::unique_ptr<A[]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p = nullptr;
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -179,7 +178,7 @@ void test()
bml::unique_ptr<A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p.reset(nullptr);
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);
@ -189,7 +188,7 @@ void test()
bml::unique_ptr<A[2]> p(new A[2]);
BOOST_TEST(A::count == 2);
A* i = p.get();
::boost::ignore_unused(i);
::boost::movelib::ignore(i);
p = nullptr;
BOOST_TEST(A::count == 0);
BOOST_TEST(p.get() == 0);