Chris@16
|
1 // Copyright David Abrahams 2003. Use, modification and distribution is
|
Chris@16
|
2 // subject to the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
4 #ifndef IS_READABLE_ITERATOR_DWA2003112_HPP
|
Chris@16
|
5 # define IS_READABLE_ITERATOR_DWA2003112_HPP
|
Chris@16
|
6
|
Chris@16
|
7 #include <boost/mpl/bool.hpp>
|
Chris@16
|
8 #include <boost/detail/iterator.hpp>
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/type_traits/detail/bool_trait_def.hpp>
|
Chris@16
|
11 #include <boost/iterator/detail/any_conversion_eater.hpp>
|
Chris@16
|
12
|
Chris@16
|
13 // should be the last #include
|
Chris@16
|
14 #include <boost/iterator/detail/config_def.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_NO_IS_CONVERTIBLE
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost {
|
Chris@101
|
19
|
Chris@101
|
20 namespace iterators {
|
Chris@101
|
21
|
Chris@16
|
22 namespace detail
|
Chris@16
|
23 {
|
Chris@16
|
24 // Guts of is_readable_iterator. Value is the iterator's value_type
|
Chris@16
|
25 // and the result is computed in the nested rebind template.
|
Chris@16
|
26 template <class Value>
|
Chris@16
|
27 struct is_readable_iterator_impl
|
Chris@16
|
28 {
|
Chris@16
|
29 static char tester(Value&, int);
|
Chris@16
|
30 static char (& tester(any_conversion_eater, ...) )[2];
|
Chris@101
|
31
|
Chris@16
|
32 template <class It>
|
Chris@16
|
33 struct rebind
|
Chris@16
|
34 {
|
Chris@16
|
35 static It& x;
|
Chris@101
|
36
|
Chris@16
|
37 BOOST_STATIC_CONSTANT(
|
Chris@16
|
38 bool
|
Chris@16
|
39 , value = (
|
Chris@16
|
40 sizeof(
|
Chris@16
|
41 is_readable_iterator_impl<Value>::tester(*x, 1)
|
Chris@16
|
42 ) == 1
|
Chris@16
|
43 )
|
Chris@16
|
44 );
|
Chris@16
|
45 };
|
Chris@16
|
46 };
|
Chris@16
|
47
|
Chris@16
|
48 #undef BOOST_READABLE_PRESERVER
|
Chris@101
|
49
|
Chris@16
|
50 //
|
Chris@16
|
51 // void specializations to handle std input and output iterators
|
Chris@16
|
52 //
|
Chris@16
|
53 template <>
|
Chris@16
|
54 struct is_readable_iterator_impl<void>
|
Chris@16
|
55 {
|
Chris@16
|
56 template <class It>
|
Chris@16
|
57 struct rebind : boost::mpl::false_
|
Chris@16
|
58 {};
|
Chris@16
|
59 };
|
Chris@16
|
60
|
Chris@16
|
61 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
Chris@16
|
62 template <>
|
Chris@16
|
63 struct is_readable_iterator_impl<const void>
|
Chris@16
|
64 {
|
Chris@16
|
65 template <class It>
|
Chris@16
|
66 struct rebind : boost::mpl::false_
|
Chris@16
|
67 {};
|
Chris@16
|
68 };
|
Chris@16
|
69
|
Chris@16
|
70 template <>
|
Chris@16
|
71 struct is_readable_iterator_impl<volatile void>
|
Chris@16
|
72 {
|
Chris@16
|
73 template <class It>
|
Chris@16
|
74 struct rebind : boost::mpl::false_
|
Chris@16
|
75 {};
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78 template <>
|
Chris@16
|
79 struct is_readable_iterator_impl<const volatile void>
|
Chris@16
|
80 {
|
Chris@16
|
81 template <class It>
|
Chris@16
|
82 struct rebind : boost::mpl::false_
|
Chris@16
|
83 {};
|
Chris@16
|
84 };
|
Chris@16
|
85 #endif
|
Chris@16
|
86
|
Chris@16
|
87 //
|
Chris@16
|
88 // This level of dispatching is required for Borland. We might save
|
Chris@16
|
89 // an instantiation by removing it for others.
|
Chris@16
|
90 //
|
Chris@16
|
91 template <class It>
|
Chris@16
|
92 struct is_readable_iterator_impl2
|
Chris@16
|
93 : is_readable_iterator_impl<
|
Chris@16
|
94 BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
|
Chris@16
|
95 >::template rebind<It>
|
Chris@16
|
96 {};
|
Chris@16
|
97 } // namespace detail
|
Chris@16
|
98
|
Chris@16
|
99 // Define the trait with full mpl lambda capability and various broken
|
Chris@16
|
100 // compiler workarounds
|
Chris@16
|
101 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
|
Chris@101
|
102 is_readable_iterator,T,::boost::iterators::detail::is_readable_iterator_impl2<T>::value)
|
Chris@101
|
103
|
Chris@101
|
104 } // namespace iterators
|
Chris@101
|
105
|
Chris@101
|
106 using iterators::is_readable_iterator;
|
Chris@101
|
107
|
Chris@16
|
108 } // namespace boost
|
Chris@16
|
109
|
Chris@16
|
110 #endif
|
Chris@16
|
111
|
Chris@16
|
112 #include <boost/iterator/detail/config_undef.hpp>
|
Chris@16
|
113
|
Chris@16
|
114 #endif // IS_READABLE_ITERATOR_DWA2003112_HPP
|