51 :
Slice(0, std::numeric_limits<int>::max(), 1) {}
60 this->stop = (start == -1) ? std::numeric_limits<int>::max() : start + 1;
70 template <
typename Start,
typename Stop>
71 requires(std::same_as<Start, slicing::none_t> ||
72 std::convertible_to<Start, int>) &&
73 (std::same_as<Stop, slicing::none_t> ||
74 std::convertible_to<Stop, int>)
75 constexpr Slice(Start start, Stop stop)
76 :
Slice(std::move(start), std::move(stop), 1) {}
85 template <
typename Start,
typename Stop,
typename Step>
86 requires(std::same_as<Start, slicing::none_t> ||
87 std::convertible_to<Start, int>) &&
88 (std::same_as<Stop, slicing::none_t> ||
89 std::convertible_to<Stop, int>) &&
90 (std::same_as<Step, slicing::none_t> ||
91 std::convertible_to<Step, int>)
92 constexpr Slice(Start start, Stop stop, Step step) {
93 if constexpr (std::same_as<Step, slicing::none_t>) {
96 slp_assert(step != 0);
102 if (this->step == std::numeric_limits<int>::min()) {
103 this->step = -std::numeric_limits<int>::max();
106 if constexpr (std::same_as<Start, slicing::none_t>) {
107 if (this->step < 0) {
108 this->start = std::numeric_limits<int>::max();
116 if constexpr (std::same_as<Stop, slicing::none_t>) {
117 if (this->step < 0) {
118 this->stop = std::numeric_limits<int>::min();
120 this->stop = std::numeric_limits<int>::max();
135 slp_assert(step != 0);
136 slp_assert(step >= -std::numeric_limits<int>::max());
142 start = (step < 0) ? -1 : 0;
144 }
else if (start >= length) {
145 start = (step < 0) ? length - 1 : length;
152 stop = (step < 0) ? -1 : 0;
154 }
else if (stop >= length) {
155 stop = (step < 0) ? length - 1 : length;
160 return (start - stop - 1) / -step + 1;
166 return (stop - start - 1) / step + 1;