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/type_traits/add_lvalue_reference.hpp>
11 #include <boost/iterator/detail/any_conversion_eater.hpp>
15 // should be the last #include
16 #include <boost/type_traits/integral_constant.hpp>
17 #include <boost/iterator/detail/config_def.hpp>
19 #ifndef BOOST_NO_IS_CONVERTIBLE
27 // Guts of is_readable_iterator. Value is the iterator's value_type
28 // and the result is computed in the nested rebind template.
29 template <class Value>
30 struct is_readable_iterator_impl
32 static char tester(typename add_lvalue_reference<Value>::type, int);
33 static char (& tester(any_conversion_eater, ...) )[2];
40 BOOST_STATIC_CONSTANT(
44 is_readable_iterator_impl<Value>::tester(*x, 1)
51 #undef BOOST_READABLE_PRESERVER
54 // void specializations to handle std input and output iterators
57 struct is_readable_iterator_impl<void>
60 struct rebind : boost::mpl::false_
64 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
66 struct is_readable_iterator_impl<const void>
69 struct rebind : boost::mpl::false_
74 struct is_readable_iterator_impl<volatile void>
77 struct rebind : boost::mpl::false_
82 struct is_readable_iterator_impl<const volatile void>
85 struct rebind : boost::mpl::false_
91 // This level of dispatching is required for Borland. We might save
92 // an instantiation by removing it for others.
95 struct is_readable_iterator_impl2
96 : is_readable_iterator_impl<
97 BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type const
98 >::template rebind<It>
100 } // namespace detail
102 template< typename T > struct is_readable_iterator
103 : public ::boost::integral_constant<bool,::boost::iterators::detail::is_readable_iterator_impl2<T>::value>
106 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_readable_iterator,(T))
109 } // namespace iterators
111 using iterators::is_readable_iterator;
117 #include <boost/iterator/detail/config_undef.hpp>
119 #endif // IS_READABLE_ITERATOR_DWA2003112_HPP