Replaced type_traits.hpp with more fine-grained includes. Replaced assert with BOOST_ASSERT.

This commit is contained in:
Andrey Semashev
2017-10-02 01:18:17 +03:00
parent 0a08203107
commit a36ed0f35d

View File

@ -20,12 +20,14 @@
// (David Abrahams) // (David Abrahams)
# include <iterator> # include <iterator>
# include <assert.h> # include <boost/assert.hpp>
# include <boost/type_traits.hpp>
# include <boost/static_assert.hpp> # include <boost/static_assert.hpp>
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor # include <boost/concept_archetype.hpp> // for detail::dummy_constructor
# include <boost/implicit_cast.hpp> # include <boost/implicit_cast.hpp>
# include <boost/core/ignore_unused.hpp> # include <boost/core/ignore_unused.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_pointer.hpp>
# include <boost/type_traits/is_reference.hpp>
namespace boost { namespace boost {
@ -51,28 +53,28 @@ template <class Iterator, class T>
void trivial_iterator_test(const Iterator i, const Iterator j, T val) void trivial_iterator_test(const Iterator i, const Iterator j, T val)
{ {
Iterator k; Iterator k;
assert(i == i); BOOST_ASSERT(i == i);
assert(j == j); BOOST_ASSERT(j == j);
assert(i != j); BOOST_ASSERT(i != j);
#ifdef BOOST_NO_STD_ITERATOR_TRAITS #ifdef BOOST_NO_STD_ITERATOR_TRAITS
T v = *i; T v = *i;
#else #else
typename std::iterator_traits<Iterator>::value_type v = *i; typename std::iterator_traits<Iterator>::value_type v = *i;
#endif #endif
assert(v == val); BOOST_ASSERT(v == val);
boost::ignore_unused(v); boost::ignore_unused(v);
#if 0 #if 0
// hmm, this will give a warning for transform_iterator... perhaps // hmm, this will give a warning for transform_iterator... perhaps
// this should be separated out into a stand-alone test since there // this should be separated out into a stand-alone test since there
// are several situations where it can't be used, like for // are several situations where it can't be used, like for
// integer_range::iterator. // integer_range::iterator.
assert(v == i->foo()); BOOST_ASSERT(v == i->foo());
#endif #endif
k = i; k = i;
assert(k == k); BOOST_ASSERT(k == k);
assert(k == i); BOOST_ASSERT(k == i);
assert(k != j); BOOST_ASSERT(k != j);
assert(*k == val); BOOST_ASSERT(*k == val);
boost::ignore_unused(k); boost::ignore_unused(k);
} }
@ -92,8 +94,8 @@ void input_iterator_test(Iterator i, T v1, T v2)
{ {
Iterator i1(i); Iterator i1(i);
assert(i == i1); BOOST_ASSERT(i == i1);
assert(!(i != i1)); BOOST_ASSERT(!(i != i1));
// I can see no generic way to create an input iterator // I can see no generic way to create an input iterator
// that is in the domain of== of i and != i. // that is in the domain of== of i and != i.
@ -102,24 +104,24 @@ void input_iterator_test(Iterator i, T v1, T v2)
// //
// Iterator i2; // Iterator i2;
// //
// assert(i != i2); // BOOST_ASSERT(i != i2);
// assert(!(i == i2)); // BOOST_ASSERT(!(i == i2));
assert(*i1 == v1); BOOST_ASSERT(*i1 == v1);
assert(*i == v1); BOOST_ASSERT(*i == v1);
// we cannot test for equivalence of (void)++i & (void)i++ // we cannot test for equivalence of (void)++i & (void)i++
// as i is only guaranteed to be single pass. // as i is only guaranteed to be single pass.
assert(*i++ == v1); BOOST_ASSERT(*i++ == v1);
boost::ignore_unused(i1); boost::ignore_unused(i1);
i1 = i; i1 = i;
assert(i == i1); BOOST_ASSERT(i == i1);
assert(!(i != i1)); BOOST_ASSERT(!(i != i1));
assert(*i1 == v2); BOOST_ASSERT(*i1 == v2);
assert(*i == v2); BOOST_ASSERT(*i == v2);
boost::ignore_unused(i1); boost::ignore_unused(i1);
// i is dereferencable, so it must be incrementable. // i is dereferencable, so it must be incrementable.
@ -162,15 +164,15 @@ void forward_iterator_test(Iterator i, T v1, T v2)
Iterator i1 = i, i2 = i; Iterator i1 = i, i2 = i;
assert(i == i1++); BOOST_ASSERT(i == i1++);
assert(i != ++i2); BOOST_ASSERT(i != ++i2);
trivial_iterator_test(i, i1, v1); trivial_iterator_test(i, i1, v1);
trivial_iterator_test(i, i2, v1); trivial_iterator_test(i, i2, v1);
++i; ++i;
assert(i == i1); BOOST_ASSERT(i == i1);
assert(i == i2); BOOST_ASSERT(i == i2);
++i1; ++i1;
++i2; ++i2;
@ -192,15 +194,15 @@ void bidirectional_iterator_test(Iterator i, T v1, T v2)
Iterator i1 = i, i2 = i; Iterator i1 = i, i2 = i;
assert(i == i1--); BOOST_ASSERT(i == i1--);
assert(i != --i2); BOOST_ASSERT(i != --i2);
trivial_iterator_test(i, i1, v2); trivial_iterator_test(i, i1, v2);
trivial_iterator_test(i, i2, v2); trivial_iterator_test(i, i2, v2);
--i; --i;
assert(i == i1); BOOST_ASSERT(i == i1);
assert(i == i2); BOOST_ASSERT(i == i2);
++i1; ++i1;
++i2; ++i2;
@ -224,30 +226,30 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
boost::ignore_unused<value_type>(); boost::ignore_unused<value_type>();
for (c = 0; c < N-1; ++c) { for (c = 0; c < N-1; ++c) {
assert(i == j + c); BOOST_ASSERT(i == j + c);
assert(*i == vals[c]); BOOST_ASSERT(*i == vals[c]);
assert(*i == boost::implicit_cast<value_type>(j[c])); BOOST_ASSERT(*i == boost::implicit_cast<value_type>(j[c]));
assert(*i == *(j + c)); BOOST_ASSERT(*i == *(j + c));
assert(*i == *(c + j)); BOOST_ASSERT(*i == *(c + j));
++i; ++i;
assert(i > j); BOOST_ASSERT(i > j);
assert(i >= j); BOOST_ASSERT(i >= j);
assert(j <= i); BOOST_ASSERT(j <= i);
assert(j < i); BOOST_ASSERT(j < i);
} }
Iterator k = j + N - 1; Iterator k = j + N - 1;
for (c = 0; c < N-1; ++c) { for (c = 0; c < N-1; ++c) {
assert(i == k - c); BOOST_ASSERT(i == k - c);
assert(*i == vals[N - 1 - c]); BOOST_ASSERT(*i == vals[N - 1 - c]);
assert(*i == boost::implicit_cast<value_type>(j[N - 1 - c])); BOOST_ASSERT(*i == boost::implicit_cast<value_type>(j[N - 1 - c]));
Iterator q = k - c; Iterator q = k - c;
boost::ignore_unused(q); boost::ignore_unused(q);
assert(*i == *q); BOOST_ASSERT(*i == *q);
assert(i > j); BOOST_ASSERT(i > j);
assert(i >= j); BOOST_ASSERT(i >= j);
assert(j <= i); BOOST_ASSERT(j <= i);
assert(j < i); BOOST_ASSERT(j < i);
--i; --i;
} }
} }
@ -256,16 +258,16 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
template <class Iterator, class ConstIterator> template <class Iterator, class ConstIterator>
void const_nonconst_iterator_test(Iterator i, ConstIterator j) void const_nonconst_iterator_test(Iterator i, ConstIterator j)
{ {
assert(i != j); BOOST_ASSERT(i != j);
assert(j != i); BOOST_ASSERT(j != i);
ConstIterator k(i); ConstIterator k(i);
assert(k == i); BOOST_ASSERT(k == i);
assert(i == k); BOOST_ASSERT(i == k);
k = i; k = i;
assert(k == i); BOOST_ASSERT(k == i);
assert(i == k); BOOST_ASSERT(i == k);
boost::ignore_unused(k); boost::ignore_unused(k);
} }