You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

satisfy_boost_range.hpp 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Range v3 library
  2. //
  3. // Copyright Eric Niebler 2014-present
  4. //
  5. // Use, modification and distribution is subject to the
  6. // Boost Software License, Version 1.0. (See accompanying
  7. // file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // Project home: https://github.com/ericniebler/range-v3
  11. //
  12. #ifndef RANGES_V3_DETAIL_SATISFY_BOOST_RANGE_HPP
  13. #define RANGES_V3_DETAIL_SATISFY_BOOST_RANGE_HPP
  14. #include <meta/meta.hpp>
  15. #include <range/v3/range_fwd.hpp>
  16. #include <range/v3/range/concepts.hpp>
  17. #include <range/v3/range/traits.hpp>
  18. #ifndef RANGES_DOXYGEN_INVOKED
  19. namespace boost
  20. {
  21. /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3
  22. /// views
  23. template<typename T, typename U>
  24. struct range_mutable_iterator;
  25. /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3
  26. /// views
  27. template<typename T, typename U>
  28. struct range_const_iterator;
  29. /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3
  30. /// views
  31. template<typename T>
  32. struct range_value;
  33. /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3
  34. /// views
  35. template<typename T>
  36. struct range_size;
  37. } // namespace boost
  38. /// \brief Macro specialising Boost Range metafunctions for the specified view
  39. #define RANGES_SATISFY_BOOST_RANGE(view_name) \
  40. namespace boost \
  41. { \
  42. template<typename... Ts> \
  43. struct range_mutable_iterator< \
  44. view_name<Ts...>, \
  45. ::meta::if_c<(bool)::ranges::common_range<view_name<Ts...>>>> \
  46. { \
  47. using type = ::ranges::iterator_t<view_name<Ts...>>; \
  48. }; \
  49. template<typename... Ts> \
  50. struct range_const_iterator< \
  51. view_name<Ts...>, \
  52. ::meta::if_c<(bool)::ranges::common_range<view_name<Ts...> const>>> \
  53. { \
  54. using type = ::ranges::iterator_t<view_name<Ts...> const>; \
  55. }; \
  56. template<typename... Ts> \
  57. struct range_value<view_name<Ts...>> \
  58. { \
  59. using type = ::ranges::range_value_t<view_name<Ts...>>; \
  60. }; \
  61. template<typename... Ts> \
  62. struct range_size<view_name<Ts...>> \
  63. : ::meta::if_c<(bool)::ranges::common_range<view_name<Ts...>>, \
  64. ::meta::defer<::ranges::range_size_t, view_name<Ts...>>, \
  65. ::meta::nil_> \
  66. {}; \
  67. template<typename... Ts> \
  68. struct range_size<view_name<Ts...> const> \
  69. : ::meta::if_c<(bool)::ranges::common_range<view_name<Ts...> const>, \
  70. ::meta::defer<::ranges::range_size_t, view_name<Ts...> const>, \
  71. ::meta::nil_> \
  72. {}; \
  73. }
  74. #else
  75. #define RANGES_SATISFY_BOOST_RANGE(view_name)
  76. #endif
  77. #endif