[span.sub]

# 23 Containers library [[containers]](./#containers)

## 23.7 Views [[views]](views#span.sub)

### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.sub)

#### 23.7.2.2 Class template span [[views.span]](views.span#span.sub)

#### 23.7.2.2.4 Subviews [span.sub]

[ð](#lib:span,first)

`template<size_t Count> constexpr span<element_type, Count> first() const;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20640)

*Mandates*: Count <= Extent is true[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20644)

*Hardened preconditions*: Count <= size() is true[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20648)

*Effects*: Equivalent to: return R{data(), Count}; where R is the return type[.](#3.sentence-1)

[ð](#lib:span,last)

`template<size_t Count> constexpr span<element_type, Count> last() const;
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20660)

*Mandates*: Count <= Extent is true[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20664)

*Hardened preconditions*: Count <= size() is true[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20668)

*Effects*: Equivalent to: return R{data() + (size() - Count), Count}; where R is the return type[.](#6.sentence-1)

[ð](#lib:span,subspan)

`template<size_t Offset, size_t Count = dynamic_extent>
  constexpr span<element_type, see below> subspan() const;
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20681)

*Mandates*: Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset) is true[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20688)

*Hardened preconditions*: Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset) is true[.](#8.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20695)

*Effects*: Equivalent to:return span<ElementType, *see below*>( data() + Offset, Count != dynamic_extent ? Count : size() - Offset);

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20703)

*Remarks*: The second template argument of the returned span type is:Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : dynamic_extent)

[ð](#lib:span,first_)

`constexpr span<element_type, dynamic_extent> first(size_type count) const;
`

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20719)

*Hardened preconditions*: count <= size() is true[.](#11.sentence-1)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20723)

*Effects*: Equivalent to: return {data(), count};

[ð](#lib:span,last_)

`constexpr span<element_type, dynamic_extent> last(size_type count) const;
`

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20734)

*Hardened preconditions*: count <= size() is true[.](#13.sentence-1)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20738)

*Effects*: Equivalent to: return {data() + (size() - count), count};

[ð](#lib:span,subspan_)

`constexpr span<element_type, dynamic_extent> subspan(
  size_type offset, size_type count = dynamic_extent) const;
`

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20750)

*Hardened preconditions*: offset <= size() && (count == dynamic_extent || count <= size() - offset) is true[.](#15.sentence-1)

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20757)

*Effects*: Equivalent to:return {data() + offset, count == dynamic_extent ? size() - offset : count};
