Add static_assert messages.

This commit is contained in:
Georgiy Guminov
2024-06-12 15:56:49 +03:00
committed by Georgy Guminov
parent 82b5c44cd3
commit 4ab19e045f
22 changed files with 189 additions and 135 deletions

View File

@ -34,7 +34,7 @@ namespace detail
struct is_numeric_impl
{
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
static_assert(std::is_integral<char>::value, "");
static_assert(std::is_integral<char>::value, "std::is_integral<char> is expected to be true");
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS

View File

@ -136,13 +136,15 @@ struct iterator_category_with_traversal
!std::is_convertible<
typename iterator_category_to_traversal<Category>::type
, Traversal
>::value, "");
>::value,
"Category transformed to corresponding traversal must be convertible to Traversal."
);
static_assert(is_iterator_category<Category>::value, "");
static_assert(!is_iterator_category<Traversal>::value, "");
static_assert(!is_iterator_traversal<Category>::value, "");
static_assert(is_iterator_category<Category>::value, "Category must be an STL iterator category.");
static_assert(!is_iterator_category<Traversal>::value, "Traversal must not be an STL iterator category.");
static_assert(!is_iterator_traversal<Category>::value, "Category must not be a traversal tag.");
# if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
static_assert(is_iterator_traversal<Traversal>::value, "");
static_assert(is_iterator_traversal<Traversal>::value, "Traversal must be a traversal tag.");
# endif
};
@ -151,7 +153,7 @@ struct iterator_category_with_traversal
template <class Traversal, class ValueParam, class Reference>
struct facade_iterator_category_impl
{
static_assert(!is_iterator_category<Traversal>::value, "");
static_assert(!is_iterator_category<Traversal>::value, "Traversal must not be an STL iterator category.");
typedef typename iterator_facade_default_category<
Traversal,ValueParam,Reference

View File

@ -69,7 +69,7 @@ namespace iterators {
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
// Don't allow use of this constructor if Predicate is a
// function pointer type, since it will be 0.
static_assert(std::is_class<Predicate>::value, "");
static_assert(std::is_class<Predicate>::value, "Predicate must be a class.");
#endif
satisfy_predicate();
}

View File

@ -155,13 +155,6 @@ namespace iterators {
>
type;
};
// workaround for aC++ CR JAGaf33512
template <class Tr1, class Tr2>
inline void iterator_adaptor_assert_traversal ()
{
static_assert(std::is_convertible<Tr1, Tr2>::value, "");
}
}
//
@ -260,12 +253,12 @@ namespace iterators {
typename super_t::iterator_category
>::type my_traversal;
# define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \
boost::iterators::detail::iterator_adaptor_assert_traversal<my_traversal, cat>();
void advance(typename super_t::difference_type n)
{
BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag)
static_assert(
std::is_convertible<my_traversal, random_access_traversal_tag>::value,
"Super iterator must have a random_access_traversal_tag."
);
m_iterator += n;
}
@ -273,7 +266,10 @@ namespace iterators {
void decrement()
{
BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(bidirectional_traversal_tag)
static_assert(
std::is_convertible<my_traversal, bidirectional_traversal_tag>::value,
"Super iterator must have a bidirectional_traversal_tag."
);
--m_iterator;
}
@ -283,7 +279,10 @@ namespace iterators {
typename super_t::difference_type distance_to(
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const
{
BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag)
static_assert(
std::is_convertible<my_traversal, random_access_traversal_tag>::value,
"Super iterator must have a random_access_traversal_tag."
);
// Maybe readd with same_distance
// BOOST_STATIC_ASSERT(
// (detail::same_category_and_difference<Derived,OtherDerived>::value)
@ -291,8 +290,6 @@ namespace iterators {
return y.base() - m_iterator;
}
# undef BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL
private: // data members
Base m_iterator;
};

View File

@ -324,7 +324,7 @@ struct iterator_access_archetype_impl<
template <class Value>
struct archetype
{
static_assert(!std::is_const<Value>::value, "");
static_assert(!std::is_const<Value>::value, "Value type must be const.");
typedef void value_type;
typedef void reference;
typedef void pointer;
@ -375,7 +375,7 @@ struct iterator_access_archetype_impl<archetypes::writable_lvalue_iterator_t>
Value, archetypes::readable_lvalue_iterator_t
>
{
static_assert(!std::is_const<Value>::value, "");
static_assert(!std::is_const<Value>::value, "Value type must be const.");
};
};

View File

@ -104,7 +104,7 @@ namespace detail
template <class Cat>
struct iterator_category_to_traversal
: mpl::eval_if< // if already convertible to a traversal tag, we're done.
std::is_convertible<Cat,incrementable_traversal_tag>
std::is_convertible<Cat, incrementable_traversal_tag>
, mpl::identity<Cat>
, boost::iterators::detail::old_category_to_traversal<Cat>
>

View File

@ -136,8 +136,8 @@ namespace boost_concepts
{
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
static_assert(std::is_integral<difference_type>::value, "");
static_assert(std::numeric_limits<difference_type>::is_signed, "");
static_assert(std::is_integral<difference_type>::value, "difference_type must be integral.");
static_assert(std::numeric_limits<difference_type>::is_signed, "difference_type must be signed.");
BOOST_CONCEPT_ASSERT((
boost::Convertible<

View File

@ -907,7 +907,10 @@ namespace iterators {
BOOST_ITERATOR_FACADE_INTEROP_HEAD(inline, op, result_type) \
{ \
/* For those compilers that do not support enable_if */ \
static_assert(is_interoperable<Derived1, Derived2>::value, ""); \
static_assert( \
is_interoperable<Derived1, Derived2>::value, \
"Derived1 & Derived2 types must be interoperable." \
); \
return_prefix iterator_core_access::base_op( \
*static_cast<Derived1 const*>(&lhs) \
, *static_cast<Derived2 const*>(&rhs) \
@ -934,10 +937,10 @@ namespace iterators {
{ \
/* For those compilers that do not support enable_if */ \
static_assert( \
is_interoperable< Derived1, Derived2 >::value && \
boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived1 >::type, random_access_traversal_tag >::value && \
boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived2 >::type, random_access_traversal_tag >::value, \
"" \
is_interoperable<Derived1, Derived2>::value && \
boost::iterators::detail::is_traversal_at_least<typename iterator_category<Derived1>::type, random_access_traversal_tag>::value && \
boost::iterators::detail::is_traversal_at_least<typename iterator_category<Derived2>::type, random_access_traversal_tag>::value, \
"Derived1 & Derived2 types must be interoperable and must both have random_access_traversal_tag." \
); \
return_prefix iterator_core_access::base_op( \
*static_cast<Derived1 const*>(&lhs) \

View File

@ -42,7 +42,10 @@ struct minimum_category_impl<true,true>
{
template <class T1, class T2> struct apply
{
static_assert(std::is_same<T1,T2>::value, "");
static_assert(
std::is_same<T1,T2>::value,
"Types must be same when they are convertible to each other."
);
typedef T1 type;
};
};

View File

@ -88,7 +88,7 @@ void readable_iterator_test(const Iterator i1, T v)
// I think we don't really need this as it checks the same things as
// the above code.
static_assert(is_readable_iterator<Iterator>::value, "");
static_assert(is_readable_iterator<Iterator>::value, "Iterator must be readable.");
# endif
}
@ -123,12 +123,15 @@ void constant_lvalue_iterator_test(Iterator i, T v1)
Iterator i2(i);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
static_assert(std::is_same<const value_type&, reference>::value, "");
static_assert(
std::is_same<const value_type&, reference>::value,
"reference type must be the same as const value_type& for constant lvalue iterator."
);
const T& v2 = *i2;
BOOST_TEST(v1 == v2);
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(is_lvalue_iterator<Iterator>::value, "");
static_assert(!is_non_const_lvalue_iterator<Iterator>::value, "");
static_assert(is_lvalue_iterator<Iterator>::value, "Iterator must be lvalue.");
static_assert(!is_non_const_lvalue_iterator<Iterator>::value, "Iterator must be const.");
# endif
}
@ -138,7 +141,10 @@ void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
Iterator i2(i);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
static_assert(std::is_same<value_type&, reference>::value, "");
static_assert(
std::is_same<value_type&, reference>::value,
"reference type must be the same as value_type& for non-constant lvalue iterator."
);
T& v3 = *i2;
BOOST_TEST(v1 == v3);
@ -149,8 +155,8 @@ void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
T& v4 = *i2;
BOOST_TEST(v2 == v4);
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(is_lvalue_iterator<Iterator>::value, "");
static_assert(is_non_const_lvalue_iterator<Iterator>::value, "");
static_assert(is_lvalue_iterator<Iterator>::value, "Iterator must be lvalue.");
static_assert(is_non_const_lvalue_iterator<Iterator>::value, "Iterator must be non-const.");
# endif
}

View File

@ -88,7 +88,7 @@ namespace iterators {
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
// don't provide this constructor if UnaryFunc is a
// function pointer type, since it will be 0. Too dangerous.
static_assert(std::is_class<UnaryFunc>::value, "");
static_assert(std::is_class<UnaryFunc>::value, "Transform function must not be a function pointer.");
#endif
}

View File

@ -140,9 +140,11 @@ template <bool is_pointer> struct lvalue_test
typedef typename Iterator::reference reference;
typedef typename Iterator::value_type value_type;
# endif
static_assert(std::is_reference<reference>::value, "");
static_assert(std::is_same<reference,value_type&>::value
|| std::is_same<reference,const value_type&>::value, "");
static_assert(std::is_reference<reference>::value, "reference must be a reference type.");
static_assert(
std::is_same<reference, value_type&>::value || std::is_same<reference, const value_type&>::value,
"reference must either be a reference to value_type or constant reference to value_type."
);
}
};

View File

@ -233,7 +233,7 @@ int main()
boost::iterator_traversal<filter_iter>::type
, boost::random_access_traversal_tag
>::value,
"");
"Filter interator must have a random_access_traversal_tag.");
//# endif

View File

@ -40,10 +40,10 @@ int main()
static_assert(std::is_convertible<Iter::iterator_category,
std::random_access_iterator_tag>::value,
"");
"Iter must have an STL random_access_iterator_tag.");
static_assert(std::is_convertible<boost::iterator_traversal<Iter>::type,
boost::random_access_traversal_tag>::value,
"");
"Iter must have a random_access_traversal_tag.");
}
{
typedef boost::indirect_iterator<int const**> Iter;
@ -73,10 +73,10 @@ int main()
static_assert(std::is_convertible<Iter::iterator_category,
std::random_access_iterator_tag>::value,
"");
"Iter must have an STL random_access_iterator_tag.");
static_assert(std::is_convertible<boost::iterator_traversal<Iter>::type,
boost::random_access_traversal_tag>::value,
"");
"Iter must have a random_access_traversal_tag.");
}
{
typedef boost::indirect_iterator<char**, int, std::random_access_iterator_tag, long&, short> Iter;

View File

@ -86,61 +86,96 @@ struct constant_lvalue_iterator
constant_lvalue_iterator operator++(int);
};
int main()
{
static_assert(boost::is_lvalue_iterator<v*>::value, "");
static_assert(boost::is_lvalue_iterator<v const*>::value, "");
static_assert(boost::is_lvalue_iterator<std::deque<v>::iterator>::value, "");
static_assert(boost::is_lvalue_iterator<std::deque<v>::const_iterator>::value, "");
static_assert(!boost::is_lvalue_iterator<std::back_insert_iterator<std::deque<v> > >::value, "");
static_assert(!boost::is_lvalue_iterator<std::ostream_iterator<v> >::value, "");
static_assert(!boost::is_lvalue_iterator<proxy_iterator<v> >::value, "");
static_assert(!boost::is_lvalue_iterator<proxy_iterator<int> >::value, "");
static_assert(boost::is_lvalue_iterator<v*>::value,
"boost::is_lvalue_iterator<v*>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<v const*>::value,
"boost::is_lvalue_iterator<v const*>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<std::deque<v>::iterator>::value,
"boost::is_lvalue_iterator<std::deque<v>::iterator>::value.");
static_assert(boost::is_lvalue_iterator<std::deque<v>::const_iterator>::value,
"boost::is_lvalue_iterator<std::deque<v>::const_iterator>::value is expected to be true.");
static_assert(!boost::is_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value,
"boost::is_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value is expected to be false.");
static_assert(!boost::is_lvalue_iterator<std::ostream_iterator<v>>::value,
"boost::is_lvalue_iterator<std::ostream_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_lvalue_iterator<proxy_iterator<v>>::value,
"boost::is_lvalue_iterator<proxy_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_lvalue_iterator<proxy_iterator<int>>::value,
"boost::is_lvalue_iterator<proxy_iterator<int>>::value is expected to be false.");
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(!boost::is_lvalue_iterator<value_iterator>::value, "");
static_assert(!boost::is_lvalue_iterator<value_iterator>::value,
"boost::is_lvalue_iterator<value_iterator>::value is expected to be false.");
#endif
// Make sure inaccessible copy constructor doesn't prevent
// reference binding
static_assert(boost::is_lvalue_iterator<noncopyable_iterator>::value, "");
static_assert(boost::is_lvalue_iterator<noncopyable_iterator>::value,
"boost::is_lvalue_iterator<noncopyable_iterator>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<v> >::value, "");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<int> >::value, "");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<char*> >::value, "");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<float> >::value, "");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<v>>::value,
"boost::is_lvalue_iterator<lvalue_iterator<v>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<int>>::value,
"boost::is_lvalue_iterator<lvalue_iterator<int>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<char*>>::value,
"boost::is_lvalue_iterator<lvalue_iterator<char*>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<lvalue_iterator<float>>::value,
"boost::is_lvalue_iterator<lvalue_iterator<float>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<v> >::value, "");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<int> >::value, "");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<char*> >::value, "");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<float> >::value, "");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<v>>::value,
"boost::is_lvalue_iterator<constant_lvalue_iterator<v>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<int>>::value,
"boost::is_lvalue_iterator<constant_lvalue_iterator<int>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<char*>>::value,
"boost::is_lvalue_iterator<constant_lvalue_iterator<char*>>::value is expected to be true.");
static_assert(boost::is_lvalue_iterator<constant_lvalue_iterator<float>>::value,
"boost::is_lvalue_iterator<constant_lvalue_iterator<float>>::value is expected to be true.");
static_assert(boost::is_non_const_lvalue_iterator<v*>::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<v const*>::value, "");
static_assert(boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<std::deque<v>::const_iterator>::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<std::back_insert_iterator<std::deque<v> > >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<std::ostream_iterator<v> >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<proxy_iterator<v> >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<proxy_iterator<int> >::value, "");
static_assert(boost::is_non_const_lvalue_iterator<v*>::value,
"boost::is_non_const_lvalue_iterator<v*>::value is expected to be true.");
static_assert(!boost::is_non_const_lvalue_iterator<v const*>::value,
"boost::is_non_const_lvalue_iterator<v const*>::value is expected to be false.");
static_assert(boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value,
"boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value is expected to be true.");
static_assert(!boost::is_non_const_lvalue_iterator<std::deque<v>::const_iterator>::value,
"boost::is_non_const_lvalue_iterator<std::deque<v>::const_iterator>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value,
"boost::is_non_const_lvalue_iterator<std::back_insert_iterator<std::deque<v>>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<std::ostream_iterator<v>>::value,
"boost::is_non_const_lvalue_iterator<std::ostream_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<proxy_iterator<v>>::value,
"boost::is_non_const_lvalue_iterator<proxy_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<proxy_iterator<int>>::value,
"boost::is_non_const_lvalue_iterator<proxy_iterator<int>>::value is expected to be false.");
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(!boost::is_non_const_lvalue_iterator<value_iterator>::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<value_iterator>::value,
"boost::is_non_const_lvalue_iterator<value_iterator>::value is expected to be false.");
#endif
static_assert(!boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value,
"boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value is expected to be false.");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<v> >::value, "");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<v>>::value,
"boost::is_non_const_lvalue_iterator<lvalue_iterator<v>>::value is expected to be true.");
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<int> >::value, "");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<int>>::value,
"boost::is_non_const_lvalue_iterator<lvalue_iterator<int>>::value is expected to be true.");
#endif
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<char*> >::value, "");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<float> >::value, "");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<char*>>::value,
"boost::is_non_const_lvalue_iterator<lvalue_iterator<char*>>::value is expected to be true.");
static_assert(boost::is_non_const_lvalue_iterator<lvalue_iterator<float>>::value,
"boost::is_non_const_lvalue_iterator<lvalue_iterator<float>>::value is expected to be true.");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v> >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int> >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*> >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float> >::value, "");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v>>::value,
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int>>::value,
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*>>::value,
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*>>::value is expected to be false.");
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float>>::value,
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float>>::value is expected to be false.");
return 0;
}

View File

@ -76,19 +76,29 @@ struct proxy_iterator2
int main()
{
static_assert(boost::is_readable_iterator<v*>::value, "");
static_assert(boost::is_readable_iterator<v const*>::value, "");
static_assert(boost::is_readable_iterator<std::deque<v>::iterator>::value, "");
static_assert(boost::is_readable_iterator<std::deque<v>::const_iterator>::value, "");
static_assert(!boost::is_readable_iterator<std::back_insert_iterator<std::deque<v> > >::value, "");
static_assert(!boost::is_readable_iterator<std::ostream_iterator<v> >::value, "");
static_assert(boost::is_readable_iterator<proxy_iterator>::value, "");
static_assert(!boost::is_readable_iterator<proxy_iterator2>::value, "");
static_assert(boost::is_readable_iterator<value_iterator>::value, "");
static_assert(boost::is_readable_iterator<v*>::value,
"boost::is_readable_iterator<v*>::value is expected to be true.");
static_assert(boost::is_readable_iterator<v const*>::value,
"boost::is_readable_iterator<v const*>::value is expected to be true.");
static_assert(boost::is_readable_iterator<std::deque<v>::iterator>::value,
"boost::is_readable_iterator<std::deque<v>::iterator>::value is expected to be true.");
static_assert(boost::is_readable_iterator<std::deque<v>::const_iterator>::value,
"boost::is_readable_iterator<std::deque<v>::const_iterator>::value is expected to be true.");
static_assert(!boost::is_readable_iterator<std::back_insert_iterator<std::deque<v>>>::value,
"boost::is_readable_iterator<std::back_insert_iterator<std::deque<v>>>::value is expected to be false.");
static_assert(!boost::is_readable_iterator<std::ostream_iterator<v>>::value,
"boost::is_readable_iterator<std::ostream_iterator<v>>::value is expected to be false.");
static_assert(boost::is_readable_iterator<proxy_iterator>::value,
"boost::is_readable_iterator<proxy_iterator>::value is expected to be true.");
static_assert(!boost::is_readable_iterator<proxy_iterator2>::value,
"boost::is_readable_iterator<proxy_iterator2>::value is expected to be false.");
static_assert(boost::is_readable_iterator<value_iterator>::value,
"boost::is_readable_iterator<value_iterator>::value is expected to be true.");
// Make sure inaccessible copy constructor doesn't prevent
// readability
static_assert(boost::is_readable_iterator<noncopyable_iterator>::value, "");
static_assert(boost::is_readable_iterator<noncopyable_iterator>::value,
"boost::is_readable_iterator<noncopyable_iterator>::value is expected to be true.");
return 0;
}

View File

@ -209,7 +209,10 @@ main()
test = static_assert_same<Iter1::pointer, int*>::value;
test = static_assert_same<Iter1::difference_type, std::ptrdiff_t>::value;
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
static_assert(std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value, "");
static_assert(
std::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value,
"Iter1::iterator_category must be convertible to std::random_access_iterator_tag."
);
#endif
}
@ -220,9 +223,9 @@ main()
test = static_assert_same<Iter1::reference, const int&>::value;
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
static_assert(boost::is_readable_iterator<Iter1>::value, "");
static_assert(boost::is_readable_iterator<Iter1>::value, "Iter1 is expected to be readable.");
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(boost::is_lvalue_iterator<Iter1>::value, "");
static_assert(boost::is_lvalue_iterator<Iter1>::value, "Iter1 is expected to be lvalue.");
# endif
#endif
@ -243,8 +246,14 @@ main()
#endif
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(boost::is_non_const_lvalue_iterator<BaseIter>::value, "");
static_assert(boost::is_lvalue_iterator<Iter>::value, "");
static_assert(
boost::is_non_const_lvalue_iterator<BaseIter>::value,
"boost::is_non_const_lvalue_iterator<BaseIter>::value is expected to be true."
);
static_assert(
boost::is_lvalue_iterator<Iter>::value,
"boost::is_lvalue_iterator<Iter>::value is expected to be true."
);
#endif
typedef modify_traversal<BaseIter, boost::incrementable_traversal_tag> IncrementableIter;

View File

@ -10,6 +10,8 @@
#include <boost/call_traits.hpp>
#include <type_traits>
#include "static_assert_same.hpp"
// This is a really, really limited test so far. All we're doing
// right now is checking that the postfix++ proxy for single-pass
// iterators works properly.
@ -143,10 +145,6 @@ struct iterator_with_proxy_reference
{ return wrapper<int&>(m_x); }
};
template <class T, class U>
void same_type(U const&)
{ static_assert(std::is_same<T,U>::value, ""); }
template <class I, class A>
struct abstract_iterator
: boost::iterator_facade<
@ -225,7 +223,7 @@ int main()
BOOST_TEST_EQ(val.private_mutator_count, 0); // mutator() should be invoked on an object returned by value
BOOST_TEST_EQ(shared_mutator_count, 2);
same_type<input_iter::pointer>(p.operator->());
STATIC_ASSERT_SAME(input_iter::pointer, std::remove_cv<std::remove_reference<decltype(p.operator->())>::type>::type);
}
{

View File

@ -43,7 +43,6 @@ void permutation_test()
const int element_range_size = 10;
const int index_size = 7;
static_assert(index_size <= element_range_size, "");
element_range_type elements( element_range_size );
for( element_range_type::iterator el_it = elements.begin(); el_it != elements.end(); ++el_it )
{ *el_it = std::distance(elements.begin(), el_it); }

View File

@ -7,7 +7,7 @@
#include <type_traits>
#define STATIC_ASSERT_SAME( T1,T2 ) static_assert(std::is_same<T1, T2>::value, "")
#define STATIC_ASSERT_SAME( T1,T2 ) static_assert(std::is_same<T1, T2>::value, "T1 ans T2 are expected to be the same types.")
template <class T1, class T2>
struct static_assert_same

View File

@ -21,6 +21,8 @@
#include <boost/pending/iterator_tests.hpp>
#include <boost/concept_check.hpp>
#include "static_assert_same.hpp"
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace detail
{
@ -172,20 +174,20 @@ main()
{
{
typedef boost::transform_iterator<adaptable_mult_functor, int*, float> iter_t;
static_assert(boost::is_same<iter_t::reference, float>::value, "");
static_assert(boost::is_same<iter_t::value_type, float>::value, "");
STATIC_ASSERT_SAME(iter_t::reference, float);
STATIC_ASSERT_SAME(iter_t::value_type, float);
}
{
typedef boost::transform_iterator<adaptable_mult_functor, int*, boost::use_default, float> iter_t;
static_assert(boost::is_same<iter_t::reference, int>::value, "");
static_assert(boost::is_same<iter_t::value_type, float>::value, "");
STATIC_ASSERT_SAME(iter_t::reference, int);
STATIC_ASSERT_SAME(iter_t::value_type, float);
}
{
typedef boost::transform_iterator<adaptable_mult_functor, int*, float, double> iter_t;
static_assert(boost::is_same<iter_t::reference, float>::value, "");
static_assert(boost::is_same<iter_t::value_type, double>::value, "");
STATIC_ASSERT_SAME(iter_t::reference, float);
STATIC_ASSERT_SAME(iter_t::value_type, double);
}
}

View File

@ -39,31 +39,20 @@ void category_test()
using namespace boost::iterators::detail;
static_assert(
!std::is_convertible<
std::input_iterator_tag
, input_output_iterator_tag>::value,
"");
!std::is_convertible<std::input_iterator_tag, input_output_iterator_tag>::value,
"std::input_iterator_tag is not expected to be convertible to input_output_iterator_tag.");
static_assert(
!std::is_convertible<
std::output_iterator_tag
, input_output_iterator_tag
>::value,
"");
!std::is_convertible<std::output_iterator_tag , input_output_iterator_tag>::value,
"std::output_iterator_tag is not expected to be convertible to input_output_iterator_tag.");
static_assert(
std::is_convertible<
input_output_iterator_tag
, std::input_iterator_tag
>::value,
"");
std::is_convertible<input_output_iterator_tag, std::input_iterator_tag>::value,
"input_output_iterator_tag is expected to be convertible to std::input_iterator_tag.");
static_assert(
std::is_convertible<
input_output_iterator_tag
, std::output_iterator_tag
>::value,
"");
std::is_convertible<input_output_iterator_tag, std::output_iterator_tag>::value,
"input_output_iterator_tag is expected to be convertible to std::output_iterator_tag.");
#if 0 // This seems wrong; we're not advertising
// input_output_iterator_tag are we?
@ -113,4 +102,3 @@ int main()
operator_arrow_test();
return 0;
}