is_lvalue_iterator.hpp 1.9 KB

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