[3428] | 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 |
---|
| 6 | |
---|
| 7 | #include <boost/mpl/bool.hpp> |
---|
| 8 | #include <boost/detail/iterator.hpp> |
---|
| 9 | |
---|
| 10 | #include <boost/type_traits/detail/bool_trait_def.hpp> |
---|
| 11 | #include <boost/iterator/detail/any_conversion_eater.hpp> |
---|
| 12 | |
---|
| 13 | // should be the last #include |
---|
| 14 | #include <boost/iterator/detail/config_def.hpp> |
---|
| 15 | |
---|
| 16 | #ifndef BOOST_NO_IS_CONVERTIBLE |
---|
| 17 | |
---|
| 18 | namespace boost { |
---|
| 19 | |
---|
| 20 | namespace detail |
---|
| 21 | { |
---|
| 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 |
---|
| 26 | { |
---|
| 27 | static char tester(Value&, int); |
---|
| 28 | static char (& tester(any_conversion_eater, ...) )[2]; |
---|
| 29 | |
---|
| 30 | template <class It> |
---|
| 31 | struct rebind |
---|
| 32 | { |
---|
| 33 | static It& x; |
---|
| 34 | |
---|
| 35 | BOOST_STATIC_CONSTANT( |
---|
| 36 | bool |
---|
| 37 | , value = ( |
---|
| 38 | sizeof( |
---|
| 39 | is_readable_iterator_impl<Value>::tester(*x, 1) |
---|
| 40 | ) == 1 |
---|
| 41 | ) |
---|
| 42 | ); |
---|
| 43 | }; |
---|
| 44 | }; |
---|
| 45 | |
---|
| 46 | #undef BOOST_READABLE_PRESERVER |
---|
| 47 | |
---|
| 48 | // |
---|
| 49 | // void specializations to handle std input and output iterators |
---|
| 50 | // |
---|
| 51 | template <> |
---|
| 52 | struct is_readable_iterator_impl<void> |
---|
| 53 | { |
---|
| 54 | template <class It> |
---|
| 55 | struct rebind : boost::mpl::false_ |
---|
| 56 | {}; |
---|
| 57 | }; |
---|
| 58 | |
---|
| 59 | #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS |
---|
| 60 | template <> |
---|
| 61 | struct is_readable_iterator_impl<const void> |
---|
| 62 | { |
---|
| 63 | template <class It> |
---|
| 64 | struct rebind : boost::mpl::false_ |
---|
| 65 | {}; |
---|
| 66 | }; |
---|
| 67 | |
---|
| 68 | template <> |
---|
| 69 | struct is_readable_iterator_impl<volatile void> |
---|
| 70 | { |
---|
| 71 | template <class It> |
---|
| 72 | struct rebind : boost::mpl::false_ |
---|
| 73 | {}; |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | template <> |
---|
| 77 | struct is_readable_iterator_impl<const volatile void> |
---|
| 78 | { |
---|
| 79 | template <class It> |
---|
| 80 | struct rebind : boost::mpl::false_ |
---|
| 81 | {}; |
---|
| 82 | }; |
---|
| 83 | #endif |
---|
| 84 | |
---|
| 85 | // |
---|
| 86 | // This level of dispatching is required for Borland. We might save |
---|
| 87 | // an instantiation by removing it for others. |
---|
| 88 | // |
---|
| 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 |
---|
| 96 | |
---|
| 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) |
---|
| 101 | |
---|
| 102 | } // namespace boost |
---|
| 103 | |
---|
| 104 | #endif |
---|
| 105 | |
---|
| 106 | #include <boost/iterator/detail/config_undef.hpp> |
---|
| 107 | |
---|
| 108 | #endif // IS_READABLE_ITERATOR_DWA2003112_HPP |
---|