General Purpose library for Freestanding C++ and POSIX systems
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.

71 rivejä
1.1 KiB

4 vuotta sitten
  1. #pragma once
  2. #include "gp/algorithm/tmp_manip.hpp"
  3. namespace gp{
  4. template<typename T>
  5. concept IsSubstractible = requires(T a, T b)
  6. {
  7. {a - b} -> std::integral;
  8. };
  9. template<typename it, bool Enable = IsSubstractible<it>>
  10. class nameless_range;
  11. template<typename it>
  12. class nameless_range<it, false>
  13. {
  14. it _begin;
  15. it _end;
  16. friend nameless_range<it, true>;
  17. public:
  18. using associated_iterator = it;
  19. nameless_range() = delete;
  20. template<typename othT>
  21. nameless_range(const nameless_range<othT>& oth)
  22. : _begin(oth._begin)
  23. , _end(oth._end)
  24. {}
  25. nameless_range(it sbegin, it send)
  26. : _begin(sbegin)
  27. , _end(send)
  28. {}
  29. it begin() const
  30. {
  31. return _begin;
  32. }
  33. it end() const
  34. {
  35. return _end;
  36. }
  37. };
  38. template<typename it>
  39. class nameless_range<it, true> : public nameless_range<it, false>
  40. {
  41. public:
  42. nameless_range() = delete;
  43. template<typename othT>
  44. nameless_range(const nameless_range<othT>& oth)
  45. : nameless_range<it,false>(oth._begin,oth._end)
  46. {}
  47. nameless_range(it sbegin, it send)
  48. : nameless_range<it,false>(sbegin, send)
  49. {}
  50. std::size_t size() const
  51. {
  52. return this->_end-this->_begin;
  53. }
  54. };
  55. }