1 // (C) Copyright Jeremy Siek 2004.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // 03 Jan 2004 Jeremy Siek
11 #include <boost/config.hpp>
14 #include <boost/iterator/indirect_iterator.hpp>
15 #include <boost/static_assert.hpp>
16 #include "static_assert_same.hpp"
17 #include <boost/type_traits/same_traits.hpp>
22 typedef zow
const element_type
;
23 zow
const& operator*() const;
24 // typedef const zow& reference;
25 // typedef const zow* pointer;
26 // typedef void difference_type;
27 // typedef boost::no_traversal_tag iterator_category;
31 // Borland 5.6.4 and earlier drop const all over the place, so this
32 // test will fail in the lines marked with (**)
37 typedef boost::indirect_iterator
<int**> Iter
;
38 STATIC_ASSERT_SAME(Iter::value_type
, int);
39 STATIC_ASSERT_SAME(Iter::reference
, int&);
40 STATIC_ASSERT_SAME(Iter::pointer
, int*);
41 STATIC_ASSERT_SAME(Iter::difference_type
, std::ptrdiff_t);
43 BOOST_STATIC_ASSERT((boost::is_convertible
<Iter::iterator_category
,
44 std::random_access_iterator_tag
>::value
));
45 BOOST_STATIC_ASSERT((boost::is_convertible
<boost::iterator_traversal
<Iter
>::type
,
46 boost::random_access_traversal_tag
>::value
));
49 typedef boost::indirect_iterator
<int const**> Iter
;
50 STATIC_ASSERT_SAME(Iter::value_type
, int);
51 STATIC_ASSERT_SAME(Iter::reference
, const int&);
52 STATIC_ASSERT_SAME(Iter::pointer
, const int*); // (**)
55 typedef boost::indirect_iterator
<int**, int> Iter
;
56 STATIC_ASSERT_SAME(Iter::value_type
, int);
57 STATIC_ASSERT_SAME(Iter::reference
, int&);
58 STATIC_ASSERT_SAME(Iter::pointer
, int*);
61 typedef boost::indirect_iterator
<int**, const int> Iter
;
62 STATIC_ASSERT_SAME(Iter::value_type
, int);
63 STATIC_ASSERT_SAME(Iter::reference
, const int&);
64 STATIC_ASSERT_SAME(Iter::pointer
, const int*); // (**)
67 typedef boost::indirect_iterator
<my_ptr
*> Iter
;
68 STATIC_ASSERT_SAME(Iter::value_type
, zow
);
69 STATIC_ASSERT_SAME(Iter::reference
, const zow
&); // (**)
70 STATIC_ASSERT_SAME(Iter::pointer
, const zow
*); // (**)
72 STATIC_ASSERT_SAME(Iter::difference_type
, std::ptrdiff_t);
74 BOOST_STATIC_ASSERT((boost::is_convertible
<Iter::iterator_category
,
75 std::random_access_iterator_tag
>::value
));
76 BOOST_STATIC_ASSERT((boost::is_convertible
<boost::iterator_traversal
<Iter
>::type
,
77 boost::random_access_traversal_tag
>::value
));
80 typedef boost::indirect_iterator
<char**, int, std::random_access_iterator_tag
, long&, short> Iter
;
81 STATIC_ASSERT_SAME(Iter::value_type
, int);
82 STATIC_ASSERT_SAME(Iter::reference
, long&);
83 STATIC_ASSERT_SAME(Iter::pointer
, int*);
84 STATIC_ASSERT_SAME(Iter::difference_type
, short);