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
+1 -1
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
+4 -4
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;
+72 -37
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;
}
+20 -10
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;
}
+14 -5
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;
+3 -5
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);
}
{
-1
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); }
+1 -1
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
+8 -6
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);
}
}
+8 -20
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;
}