forked from microsoft/GSL
Span can be constructed from empty std::array safely (#686)
* Span std::array c'tor uses arr.data() instead of &arr[0] - Fixes runtime issues when constructing from an empty std::array * Construct span with std::data if C++17 detected * Specialize span c'tor for std::array of length 0, set storage to nullptr
This commit is contained in:
committed by
Anna Gringauze
parent
2bf9f137a6
commit
c02ddae4bc
@@ -452,7 +452,13 @@ TEST_CASE("from_std_array_constructor")
|
||||
CHECK((cs.size() == narrow_cast<ptrdiff_t>(arr.size()) && cs.data() == arr.data()));
|
||||
}
|
||||
|
||||
std::array<AddressOverloaded, 4> ao_arr{};
|
||||
{
|
||||
std::array<int, 0> empty_arr{};
|
||||
span<int> s{empty_arr};
|
||||
CHECK((s.size() == 0 && s.empty()));
|
||||
}
|
||||
|
||||
std::array<AddressOverloaded, 4> ao_arr{};
|
||||
|
||||
{
|
||||
span<AddressOverloaded, 4> fs{ao_arr};
|
||||
|
||||
Reference in New Issue
Block a user