mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
test commit to get extra eyes on the problem
This commit is contained in:
parent
d90fefea6d
commit
1dd1320c8b
@ -441,6 +441,8 @@ public:
|
||||
: storage_(KnownNotNull{arr + 0}, details::extent_type<N>())
|
||||
{}
|
||||
|
||||
// #define useold
|
||||
#if defined(useold)
|
||||
template <std::size_t N,
|
||||
std::enable_if_t<details::is_allowed_extent_conversion<N, Extent>::value, int> = 0>
|
||||
constexpr span(std::array<element_type, N>& arr) noexcept
|
||||
@ -455,7 +457,23 @@ public:
|
||||
constexpr span(const std::array<value_type, N>& arr) noexcept
|
||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||
{}
|
||||
#else
|
||||
template <class T, std::size_t N,
|
||||
std::enable_if_t<(details::is_allowed_extent_conversion<N, Extent>::value &&
|
||||
details::is_allowed_element_type_conversion<T, element_type>::value), int> = 0>
|
||||
constexpr span(std::array<T, N>& arr) noexcept
|
||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||
{}
|
||||
|
||||
template <class T, std::size_t N,
|
||||
std::enable_if_t<(details::is_allowed_extent_conversion<N, Extent>::value &&
|
||||
details::is_allowed_element_type_conversion<const T,
|
||||
element_type>::value),
|
||||
int> = 0>
|
||||
constexpr span(const std::array<T, N>& arr) noexcept
|
||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||
{}
|
||||
#endif
|
||||
// NB: the SFINAE here uses .data() as an incomplete/imperfect proxy for the requirement
|
||||
// on Container to be a contiguous sequence container.
|
||||
template <class Container,
|
||||
|
@ -46,6 +46,22 @@ TEST(span_compatibility_tests, assertion_tests)
|
||||
{
|
||||
int arr[3]{10, 20, 30};
|
||||
std::array<int, 3> stl{{100, 200, 300}};
|
||||
std::array<int*, 3> stl_nullptr{{nullptr,nullptr,nullptr}};
|
||||
|
||||
{
|
||||
gsl::span<const int* const> sp_const_nullptr_1{stl_nullptr};
|
||||
EXPECT_TRUE(sp_const_nullptr_1.data() == stl_nullptr.data());
|
||||
EXPECT_TRUE(sp_const_nullptr_1.size() == 3);
|
||||
|
||||
#if __cplusplus >= 201703l
|
||||
span<const int* const> sp_const_nullptr_2{std::as_const(stl_nullptr)};
|
||||
EXPECT_TRUE(sp_const_nullptr_2.data() == stl_nullptr.data());
|
||||
EXPECT_TRUE(sp_const_nullptr_2.size() == 3);
|
||||
|
||||
static_assert(std::is_same<decltype(span{stl_nullptr}), span<int*, 3>);
|
||||
static_assert(std::is_same<decltype(span{std::as_const(stl_nullptr)}), span<int* const, 3>);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
gsl::span<int> sp_dyn;
|
||||
|
Loading…
Reference in New Issue
Block a user