27 using span_type = std::span<T>;
28 using const_iterator =
typename std::array<span_type, 2>::const_iterator;
35 : segments_{segment, {}}, segment_count_(segment.empty() ? 0 : 1) {}
38 constexpr SplitSpan(span_type first, span_type second) {
43 segments_ = {first, second};
44 segment_count_ =
static_cast<std::size_t
>(!first.empty()) +
45 static_cast<std::size_t
>(!second.empty());
49 constexpr std::size_t
size() const noexcept {
50 return segments_[0].size() + segments_[1].size();
54 constexpr bool empty() const noexcept {
return segment_count_ == 0; }
58 return segment_count_;
62 constexpr const_iterator
begin() const noexcept {
return segments_.begin(); }
65 constexpr const_iterator
end() const noexcept {
66 return segments_.begin() +
static_cast<std::ptrdiff_t
>(segment_count_);
70 std::array<span_type, 2> segments_{};
71 std::size_t segment_count_ = 0;
constexpr const_iterator begin() const noexcept
Iterate over the non-empty physical segments in logical order.
Definition split_span.h:62
constexpr std::size_t segment_count() const noexcept
Return the number of non-empty physical segments.
Definition split_span.h:57
constexpr const_iterator end() const noexcept
Return the end iterator for the non-empty physical segments.
Definition split_span.h:65
constexpr std::size_t size() const noexcept
Return the total number of logical elements.
Definition split_span.h:49
constexpr SplitSpan(span_type first, span_type second)
Construct a range stored in up to two physical spans.
Definition split_span.h:38
constexpr SplitSpan()=default
Construct an empty logical range.
constexpr SplitSpan(span_type segment)
Construct a range stored in one physical span.
Definition split_span.h:34
constexpr bool empty() const noexcept
Return whether the logical range is empty.
Definition split_span.h:54