fix doc example typo
[boost.git] / boost / iterator / is_readable_iterator.hpp
blob60d6ff07f52ddc9dad1c93985783f0c484c3dc79
1 // Copyright David Abrahams 2003. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #ifndef IS_READABLE_ITERATOR_DWA2003112_HPP
5 # define IS_READABLE_ITERATOR_DWA2003112_HPP
7 #include <boost/mpl/bool.hpp>
8 #include <boost/detail/iterator.hpp>
10 #include <boost/type_traits/detail/bool_trait_def.hpp>
11 #include <boost/iterator/detail/any_conversion_eater.hpp>
13 // should be the last #include
14 #include <boost/iterator/detail/config_def.hpp>
16 #ifndef BOOST_NO_IS_CONVERTIBLE
18 namespace boost {
20 namespace detail
22 // Guts of is_readable_iterator. Value is the iterator's value_type
23 // and the result is computed in the nested rebind template.
24 template <class Value>
25 struct is_readable_iterator_impl
27 static char tester(Value&, int);
28 static char (& tester(any_conversion_eater, ...) )[2];
30 template <class It>
31 struct rebind
33 static It& x;
35 BOOST_STATIC_CONSTANT(
36 bool
37 , value = (
38 sizeof(
39 is_readable_iterator_impl<Value>::tester(*x, 1)
40 ) == 1
46 #undef BOOST_READABLE_PRESERVER
49 // void specializations to handle std input and output iterators
51 template <>
52 struct is_readable_iterator_impl<void>
54 template <class It>
55 struct rebind : boost::mpl::false_
56 {};
59 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
60 template <>
61 struct is_readable_iterator_impl<const void>
63 template <class It>
64 struct rebind : boost::mpl::false_
65 {};
68 template <>
69 struct is_readable_iterator_impl<volatile void>
71 template <class It>
72 struct rebind : boost::mpl::false_
73 {};
76 template <>
77 struct is_readable_iterator_impl<const volatile void>
79 template <class It>
80 struct rebind : boost::mpl::false_
81 {};
83 #endif
86 // This level of dispatching is required for Borland. We might save
87 // an instantiation by removing it for others.
89 template <class It>
90 struct is_readable_iterator_impl2
91 : is_readable_iterator_impl<
92 BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
93 >::template rebind<It>
94 {};
95 } // namespace detail
97 // Define the trait with full mpl lambda capability and various broken
98 // compiler workarounds
99 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
100 is_readable_iterator,T,::boost::detail::is_readable_iterator_impl2<T>::value)
102 } // namespace boost
104 #endif
106 #include <boost/iterator/detail/config_undef.hpp>
108 #endif // IS_READABLE_ITERATOR_DWA2003112_HPP