mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Make is_default_constructible work for spans.
This commit is contained in:
parent
f93d325495
commit
96eaf274f8
4
gsl/span
4
gsl/span
@ -359,6 +359,10 @@ public:
|
|||||||
constexpr static const index_type extent = Extent;
|
constexpr static const index_type extent = Extent;
|
||||||
|
|
||||||
// [span.cons], span constructors, copy, assignment, and destructor
|
// [span.cons], span constructors, copy, assignment, and destructor
|
||||||
|
template <bool Dependent = false,
|
||||||
|
// "Dependent" is needed to make "std::enable_if_t<Dependent || Extent <= 0>" SFINAE,
|
||||||
|
// since "std::enable_if_t<Extent <= 0>" is ill-formed when Extent is greater than 0.
|
||||||
|
class = std::enable_if_t<(Dependent || Extent <= 0)>>
|
||||||
constexpr span() noexcept : storage_(nullptr, details::extent_type<0>()) {}
|
constexpr span() noexcept : storage_(nullptr, details::extent_type<0>()) {}
|
||||||
|
|
||||||
constexpr span(std::nullptr_t) noexcept : span() {}
|
constexpr span(std::nullptr_t) noexcept : span() {}
|
||||||
|
@ -1557,6 +1557,13 @@ SUITE(span_tests)
|
|||||||
span<int> s{arr};
|
span<int> s{arr};
|
||||||
CHECK(at(s,0) == 1 && at(s,1) == 2);
|
CHECK(at(s,0) == 1 && at(s,1) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(default_constructible)
|
||||||
|
{
|
||||||
|
CHECK((std::is_default_constructible<span<int>>::value));
|
||||||
|
CHECK((std::is_default_constructible<span<int, 0>>::value));
|
||||||
|
CHECK((!std::is_default_constructible<span<int, 42>>::value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, const char* []) { return UnitTest::RunAllTests(); }
|
int main(int, const char* []) { return UnitTest::RunAllTests(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user