sentinel.h 588 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // sentinel.h
  3. // stream
  4. //
  5. // Created by Sam Jaffe on 4/8/23.
  6. //
  7. #pragma once
  8. #include <iterator/sentinel.h>
  9. #include <stream/forward.h>
  10. #include <stream/detail/traits.h>
  11. #include <stream/detail/macro.h>
  12. namespace stream::ranges {
  13. constexpr sentinel_t sentinel{};
  14. template <typename Self, typename Base, typename... Args>
  15. auto sentinel_end(Self *, Base && base, Args &&... args) {
  16. if constexpr (detail::has_sentinal_v<Base>) {
  17. return FWD(base).end();
  18. } else {
  19. return detail::begin_t<Self>(FWD(base).end(), FWD(args)...);
  20. }
  21. }
  22. }
  23. #include <stream/detail/undef.h>