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/mpl/aux_/lambda_support.hpp>
9 #include <boost/detail/iterator.hpp>
10 #include <boost/type_traits/add_lvalue_reference.hpp>
12 #include <boost/iterator/detail/any_conversion_eater.hpp>
14 // should be the last #include
15 #include <boost/type_traits/integral_constant.hpp>
16 #include <boost/iterator/detail/config_def.hpp>
18 #ifndef BOOST_NO_IS_CONVERTIBLE
26 // Guts of is_readable_iterator. Value is the iterator's value_type
27 // and the result is computed in the nested rebind template.
28 template <class Value>
29 struct is_readable_iterator_impl
31 static char tester(typename add_lvalue_reference<Value>::type, int);
32 static char (& tester(any_conversion_eater, ...) )[2];
39 BOOST_STATIC_CONSTANT(
43 is_readable_iterator_impl<Value>::tester(*x, 1)
50 #undef BOOST_READABLE_PRESERVER
53 // void specializations to handle std input and output iterators
56 struct is_readable_iterator_impl<void>
59 struct rebind : boost::mpl::false_
63 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
65 struct is_readable_iterator_impl<const void>
68 struct rebind : boost::mpl::false_
73 struct is_readable_iterator_impl<volatile void>
76 struct rebind : boost::mpl::false_
81 struct is_readable_iterator_impl<const volatile void>
84 struct rebind : boost::mpl::false_
90 // This level of dispatching is required for Borland. We might save
91 // an instantiation by removing it for others.
94 struct is_readable_iterator_impl2
95 : is_readable_iterator_impl<
96 BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
97 >::template rebind<It>
101 template< typename T > struct is_readable_iterator
102 : public ::boost::integral_constant<bool,::boost::iterators::detail::is_readable_iterator_impl2<T>::value>
105 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_readable_iterator,(T))
108 } // namespace iterators
110 using iterators::is_readable_iterator;
116 #include <boost/iterator/detail/config_undef.hpp>
118 #endif // IS_READABLE_ITERATOR_DWA2003112_HPP