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)
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>) {
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();
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;
#define slp_assert(condition)
Abort in C++.
Definition assert.hpp:26
Represents a sequence of elements in an iterable object.
Definition slice.hpp:31
constexpr Slice()=default
Constructs a Slice.
constexpr Slice(Start start, Stop stop)
Constructs a slice.
Definition slice.hpp:75
constexpr Slice(slicing::none_t)
Constructs a slice.
Definition slice.hpp:50
constexpr int adjust(int length)
Adjusts start and end slice indices assuming a sequence of the specified length.
Definition slice.hpp:134
constexpr Slice(Start start, Stop stop, Step step)
Constructs a slice.
Definition slice.hpp:92
constexpr Slice(int start)
Constructs a slice.
Definition slice.hpp:58
static constexpr none_t _
Designates an omitted argument of the slice.
Definition slice.hpp:24
Definition expression_graph.hpp:11
Definition PointerIntPair.h:280
Type tag used to designate an omitted argument of the slice.
Definition slice.hpp:19
#define SLEIPNIR_DLLEXPORT
Definition symbol_exports.hpp:34