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.

unbounded.hpp 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // Copyright Eric Niebler 2014-present
  3. //
  4. // Use, modification and distribution is subject to the
  5. // Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // Project home: https://github.com/ericniebler/range-v3
  10. //
  11. #ifndef RANGES_V3_VIEW_UNBOUNDED_HPP
  12. #define RANGES_V3_VIEW_UNBOUNDED_HPP
  13. #include <range/v3/range_fwd.hpp>
  14. #include <range/v3/iterator/unreachable_sentinel.hpp>
  15. #include <range/v3/utility/static_const.hpp>
  16. #include <range/v3/view/interface.hpp>
  17. namespace ranges
  18. {
  19. /// \addtogroup group-views
  20. /// @{
  21. template<typename I>
  22. struct unbounded_view : view_interface<unbounded_view<I>, infinite>
  23. {
  24. private:
  25. I it_;
  26. public:
  27. unbounded_view() = default;
  28. constexpr explicit unbounded_view(I it)
  29. : it_(detail::move(it))
  30. {}
  31. constexpr I begin() const
  32. {
  33. return it_;
  34. }
  35. constexpr unreachable_sentinel_t end() const
  36. {
  37. return {};
  38. }
  39. };
  40. namespace views
  41. {
  42. struct unbounded_fn
  43. {
  44. template<typename I>
  45. constexpr auto operator()(I it) const -> CPP_ret(unbounded_view<I>)( //
  46. requires input_iterator<I>)
  47. {
  48. return unbounded_view<I>{detail::move(it)};
  49. }
  50. };
  51. /// \relates unbounded_fn
  52. /// \ingroup group-views
  53. RANGES_INLINE_VARIABLE(unbounded_fn, unbounded)
  54. } // namespace views
  55. /// @}
  56. } // namespace ranges
  57. #include <range/v3/detail/satisfy_boost_range.hpp>
  58. RANGES_SATISFY_BOOST_RANGE(::ranges::unbounded_view)
  59. #endif