From 3e6796ab9120f8fe98ad4200135e7de57203d021 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Feb 2001 23:35:26 +0000 Subject: [PATCH] Fixed lvalue test [SVN r8934] --- include/boost/pending/iterator_tests.hpp | 44 +++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/include/boost/pending/iterator_tests.hpp b/include/boost/pending/iterator_tests.hpp index 13b83de..2694da5 100644 --- a/include/boost/pending/iterator_tests.hpp +++ b/include/boost/pending/iterator_tests.hpp @@ -1,5 +1,5 @@ #ifndef BOOST_ITERATOR_TESTS_HPP -#define BOOST_ITERATOR_TESTS_HPP +# define BOOST_ITERATOR_TESTS_HPP // This is meant to be the beginnings of a comprehensive, generic // test suite for STL concepts such as iterators and containers. @@ -8,8 +8,10 @@ // 04 Feb 2001 Added lvalue test, corrected preconditions // (David Abrahams) -#include -#include +# include +# include +# include +# include namespace boost { @@ -87,21 +89,47 @@ void input_iterator_test(Iterator i, T v1, T v2) // how to test output iterator? + +template struct lvalue_test +{ + template static void check(Iterator) + { +# ifndef BOOST_NO_STD_ITERATOR_TRAITS + typedef typename std::iterator_traits::reference reference; + typedef typename std::iterator_traits::value_type value_type; +# else + typedef typename Iterator::reference reference; + typedef typename Iterator::value_type value_type; +# endif + BOOST_STATIC_ASSERT(boost::is_reference::value); + BOOST_STATIC_ASSERT((boost::is_same::value + || boost::is_same::value + )); + } +}; + +# ifdef BOOST_NO_STD_ITERATOR_TRAITS +template <> struct lvalue_test { + template static void check(T) {} +}; +#endif + template void forward_iterator_test(Iterator i, T v1, T v2) { input_iterator_test(i, v1, v2); - - // Test for lvalue - const T* p = &*i; - (void)p; + + // borland doesn't allow non-type template parameters +# if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551) + lvalue_test<(boost::is_pointer::value)>::check(i); +#endif } // Preconditions: *i == v1, *++i == v2, --i template void bidirectional_iterator_test(Iterator i, T v1, T v2) { - input_iterator_test(i, v1, v2); + forward_iterator_test(i, v1, v2); ++i; Iterator i1 = i, i2 = i;