42 template <
typename Stop>
43 requires std::same_as<Stop, slicing::none_t> ||
44 std::convertible_to<Stop, int>
46 :
Slice(slicing::_,
std::move(stop), 1) {}
54 template <
typename Start,
typename Stop>
55 requires(std::same_as<Start, slicing::none_t> ||
56 std::convertible_to<Start, int>) &&
57 (std::same_as<Stop, slicing::none_t> ||
58 std::convertible_to<Stop, int>)
59 constexpr Slice(Start start, Stop stop)
69 template <
typename Start,
typename Stop,
typename Step>
70 requires(std::same_as<Start, slicing::none_t> ||
71 std::convertible_to<Start, int>) &&
72 (std::same_as<Stop, slicing::none_t> ||
73 std::convertible_to<Stop, int>) &&
74 (std::same_as<Step, slicing::none_t> ||
75 std::convertible_to<Step, int>)
76 constexpr Slice(Start start, Stop stop, Step step) {
77 if constexpr (std::same_as<Step, slicing::none_t>) {
86 if (this->step == std::numeric_limits<int>::min()) {
87 this->step = -std::numeric_limits<int>::max();
90 if constexpr (std::same_as<Start, slicing::none_t>) {
92 this->start = std::numeric_limits<int>::max();
100 if constexpr (std::same_as<Stop, slicing::none_t>) {
101 if (this->step < 0) {
102 this->stop = std::numeric_limits<int>::min();
104 this->stop = std::numeric_limits<int>::max();
120 Assert(step >= -std::numeric_limits<int>::max());
126 start = (step < 0) ? -1 : 0;
128 }
else if (start >= length) {
129 start = (step < 0) ? length - 1 : length;
136 stop = (step < 0) ? -1 : 0;
138 }
else if (stop >= length) {
139 stop = (step < 0) ? length - 1 : length;
144 return (start - stop - 1) / -step + 1;
150 return (stop - start - 1) / step + 1;
#define Assert(condition)
Abort in C++.
Definition Assert.hpp:24