[span.cons] (original) (raw)

23 Containers library [containers]

23.7 Views [views]

23.7.2 Contiguous access [views.contiguous]

23.7.2.2 Class template span [views.span]

23.7.2.2.2 Constructors, copy, and assignment [span.cons]

constexpr span() noexcept;

Constraints: Extent == dynamic_extent || Extent == 0 is true.

Postconditions: size() == 0 && data() == nullptr.

template<class It> constexpr explicit(extent != dynamic_extent) span(It first, size_type count);

Constraints: Let U be remove_reference_t<iter_reference_t<It>>.

Preconditions:

Hardened preconditions: If extent is not equal to dynamic_extent, then count == extent is true.

Effects: Initializes data_ with to_address(first) and_size__ with count.

template<class It, class End> constexpr explicit(extent != dynamic_extent) span(It first, End last);

Constraints: Let U be remove_reference_t<iter_reference_t<It>>.

Preconditions:

Hardened preconditions: If extent is not equal to dynamic_extent, then (last - first) == extent is true.

Effects: Initializes data_ with to_address(first) and_size__ with last - first.

Throws: When and what last - first throws.

template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;

Constraints: Let U be remove_pointer_t<decltype(std​::​data(arr))>.

Effects: Constructs a span that is a view over the supplied array.

[Note 4:

type_identity_t affects class template argument deduction.

— _end note_]

Postconditions: size() == N && data() == std​::​data(arr) is true.

template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);

Constraints: Let U be remove_reference_t<ranges​::​range_reference_t<R>>.

Preconditions:

Hardened preconditions: If extent is not equal to dynamic_extent, then ranges​::​size(r) == extent is true.

Effects: Initializes data_ with ranges​::​data(r) and_size__ with ranges​::​size(r).

Throws: What and when ranges​::​data(r) and ranges​::​size(r) throw.

constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il);

Constraints: is_const_v<element_type> is true.

Hardened preconditions: If extent is not equal to dynamic_extent, then il.size() == extent is true.

Effects: Initializes data_ with il.begin() and_size__ with il.size().

constexpr span(const span& other) noexcept = default;

Postconditions: other.size() == size() && other.data() == data().

template<class OtherElementType, size_t OtherExtent> constexpr explicit(_see below_) span(const span<OtherElementType, OtherExtent>& s) noexcept;

Constraints:

Hardened preconditions: If extent is not equal to dynamic_extent, then s.size() == extent is true.

Effects: Constructs a span that is a view over the range [s.data(), s.data() + s.size()).

Postconditions: size() == s.size() && data() == s.data().

Remarks: The expression inside explicit is equivalent to:extent != dynamic_extent && OtherExtent == dynamic_extent

constexpr span& operator=(const span& other) noexcept = default;

Postconditions: size() == other.size() && data() == other.data().