is_readable_iterator.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include <iterator>
  7. #include <type_traits>
  8. namespace boost {
  9. namespace iterators {
  10. namespace detail {
  11. // Guts of is_readable_iterator. It is the iterator type and
  12. // Value is the iterator's value_type.
  13. template< typename It, typename Value >
  14. struct is_readable_iterator_impl :
  15. public std::is_convertible<
  16. decltype(*std::declval< It& >()),
  17. typename std::add_lvalue_reference< Value >::type
  18. >
  19. {
  20. };
  21. //
  22. // void specializations to handle std input and output iterators
  23. //
  24. template< typename It >
  25. struct is_readable_iterator_impl< It, void > :
  26. public std::false_type
  27. {
  28. };
  29. template< typename It >
  30. struct is_readable_iterator_impl< It, const void > :
  31. public std::false_type
  32. {
  33. };
  34. template< typename It >
  35. struct is_readable_iterator_impl< It, volatile void > :
  36. public std::false_type
  37. {
  38. };
  39. template< typename It >
  40. struct is_readable_iterator_impl< It, const volatile void > :
  41. public std::false_type
  42. {
  43. };
  44. } // namespace detail
  45. template< typename T >
  46. struct is_readable_iterator :
  47. public iterators::detail::is_readable_iterator_impl<
  48. T,
  49. typename std::iterator_traits< T >::value_type const
  50. >::type
  51. {
  52. };
  53. } // namespace iterators
  54. using iterators::is_readable_iterator;
  55. } // namespace boost
  56. #endif // IS_READABLE_ITERATOR_DWA2003112_HPP