std::span
的推导指引
定义于头文件
<span> |
||
template <class It, class EndOrSize>
span(It, EndOrSize) -> span<std::remove_reference_t<std::iter_reference_t<It>>>; |
(1) | |
template<class T, std::size_t N>
span(T (&)[N]) -> span<T, N>; |
(2) | |
template<class T, std::size_t N>
span(std::array<T, N>&) -> span<T, N>; |
(3) | |
template<class T, std::size_t N>
span(const std::array<T, N>&) -> span<const T, N>; |
(4) | |
template<class R>
span(R&&) -> span<std::remove_reference_t<std::ranges::range_reference_t<R>>>; |
(5) | |
为 span
提供下列推导指引。
(1) 允许从迭代器-哨位对推导元素类型。此重载仅若 It
满足 contiguous_iterator 才参与重载决议。
(2-4) 允许从内建数组与 std::array 推导静态长度。
(5) 允许从范围推导元素类型。此重载仅若 R
满足 contiguous_range 才参与重载决议。