mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Extend docs and tests for span ctor (#1096)
This commit is contained in:
parent
9851b94d7e
commit
7a297d4283
@ -485,6 +485,9 @@ constexpr span(const span<OtherElementType, OtherExtent>& other) noexcept;
|
|||||||
Constructs a `span` from another `span`. This constructor is available if `OtherExtent == Extent || Extent ==`[`gsl::dynamic_extent`](#user-content-H-span_ext-dynamic_extent)` || OtherExtent ==`[`gsl::dynamic_extent`](#user-content-H-span_ext-dynamic_extent)
|
Constructs a `span` from another `span`. This constructor is available if `OtherExtent == Extent || Extent ==`[`gsl::dynamic_extent`](#user-content-H-span_ext-dynamic_extent)` || OtherExtent ==`[`gsl::dynamic_extent`](#user-content-H-span_ext-dynamic_extent)
|
||||||
and if `ElementType` and `OtherElementType` are compatible.
|
and if `ElementType` and `OtherElementType` are compatible.
|
||||||
|
|
||||||
|
If `Extent !=`[`gsl::dynamic_extent`](#user-content-H-span_ext-dynamic_extent) and `OtherExtent ==`[`gsl::dynamic_extent`](#user-content-H-span_ext-dynamic_extent),
|
||||||
|
then the constructor [`Expects`](#user-content-H-assert-expects) that `other.size() == Extent`.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
constexpr span& operator=(const span& other) noexcept = default;
|
constexpr span& operator=(const span& other) noexcept = default;
|
||||||
```
|
```
|
||||||
|
@ -681,6 +681,13 @@ TEST(span_test, from_convertible_span_constructor)
|
|||||||
static_cast<void>(avcd);
|
static_cast<void>(avcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::array<DerivedClass, 2> arr{};
|
||||||
|
span<DerivedClass> avd{arr};
|
||||||
|
using T = span<const DerivedClass, 1>;
|
||||||
|
EXPECT_DEATH(T{avd}, expected);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::array<DerivedClass, 1> arr{};
|
std::array<DerivedClass, 1> arr{};
|
||||||
span<DerivedClass> avd{arr};
|
span<DerivedClass> avd{arr};
|
||||||
|
Loading…
Reference in New Issue
Block a user