mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Add as_span(iterator start, iterator last).
This commit is contained in:
parent
a9f865900d
commit
0e14b5b306
@ -1688,6 +1688,12 @@ constexpr auto as_span(T* const& ptr, dim<Dimensions>... args)
|
||||
details::static_as_span_helper<static_bounds<Dimensions...>>(args..., details::Sep{})};
|
||||
}
|
||||
|
||||
template<typename Span>
|
||||
constexpr Span as_span(contiguous_span_iterator<Span> start, contiguous_span_iterator<Span> last)
|
||||
{
|
||||
return { &*start, static_cast<typename Span::size_type>(last - start)};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr auto as_span(T* arr, std::ptrdiff_t len) ->
|
||||
typename details::SpanArrayTraits<T, dynamic_range>::type
|
||||
|
@ -1193,7 +1193,7 @@ SUITE(span_tests)
|
||||
}
|
||||
|
||||
{
|
||||
int a[3][4][5];
|
||||
int a[3][4][5] = {};
|
||||
auto av = as_span(a);
|
||||
const int(*b)[4][5];
|
||||
b = a;
|
||||
@ -1209,6 +1209,9 @@ SUITE(span_tests)
|
||||
auto dv = as_span(vec);
|
||||
(void) dv;
|
||||
|
||||
auto av2 = as_span(av.begin(), av.end());
|
||||
CHECK(av2 == av);
|
||||
|
||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||
auto dv2 = as_span(std::move(vec));
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user