22 Containers library [containers]

22.7 Views [views]

22.7.3 Class template span [views.span]

22.7.3.4 Subviews [span.sub]

template<size_t Count> constexpr span<element_type, Count> first() const;
Mandates: Count <= Extent is true.
Preconditions: Count <= size() is true.
Effects: Equivalent to: return {data(), Count};
template<size_t Count> constexpr span<element_type, Count> last() const;
Mandates: Count <= Extent is true.
Preconditions: Count <= size() is true.
Effects: Equivalent to: return {data() + (size() - Count), Count};
template<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see below> subspan() const;
Mandates:
Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset)
is true.
Preconditions:
Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset)
is true.
Effects: Equivalent to:
return span<ElementType, see below>(
  data() + Offset, Count != dynamic_extent ? Count : size() - Offset);
Remarks: The second template argument of the returned span type is:
Count != dynamic_extent ? Count
                        : (Extent != dynamic_extent ? Extent - Offset
                                                    : dynamic_extent)
constexpr span<element_type, dynamic_extent> first(size_type count) const;
Preconditions: count <= size() is true.
Effects: Equivalent to: return {data(), count};
constexpr span<element_type, dynamic_extent> last(size_type count) const;
Preconditions: count <= size() is true.
Effects: Equivalent to: return {data() + (size() - count), count};
constexpr span<element_type, dynamic_extent> subspan( size_type offset, size_type count = dynamic_extent) const;
Preconditions:
offset <= size() && (count == dynamic_extent || count <= size() - offset)
is true.
Effects: Equivalent to:
return {data() + offset, count == dynamic_extent ? size() - offset : count};