]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/iterator/test/indirect_iter_member_types.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / iterator / test / indirect_iter_member_types.cpp
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)
5
6 // Revision History
7 // 03 Jan 2004 Jeremy Siek
8 // First draft.
9
10
11 #include <boost/config.hpp>
12 #include <iostream>
13
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>
18
19 struct zow { };
20
21 struct my_ptr {
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;
28 };
29
30
31 // Borland 5.6.4 and earlier drop const all over the place, so this
32 // test will fail in the lines marked with (**)
33
34 int main()
35 {
36 {
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);
42
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));
47 }
48 {
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*); // (**)
53 }
54 {
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*);
59 }
60 {
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*); // (**)
65 }
66 {
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*); // (**)
71
72 STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
73
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));
78 }
79 {
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);
85 }
86 return 0;
87 }