From 1dd1320c8b29099fe5bba591d1b0dba367fa68d7 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Tue, 17 Mar 2020 13:53:13 -0700 Subject: [PATCH] test commit to get extra eyes on the problem --- include/gsl/span | 18 ++++++++++++++++++ tests/span_compatibility_tests.cpp | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/gsl/span b/include/gsl/span index 23c58c9..7c15eb4 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -441,6 +441,8 @@ public: : storage_(KnownNotNull{arr + 0}, details::extent_type()) {} +// #define useold +#if defined(useold) template ::value, int> = 0> constexpr span(std::array& arr) noexcept @@ -455,7 +457,23 @@ public: constexpr span(const std::array& arr) noexcept : storage_(KnownNotNull{arr.data()}, details::extent_type()) {} +#else + template ::value && + details::is_allowed_element_type_conversion::value), int> = 0> + constexpr span(std::array& arr) noexcept + : storage_(KnownNotNull{arr.data()}, details::extent_type()) + {} + template ::value && + details::is_allowed_element_type_conversion::value), + int> = 0> + constexpr span(const std::array& arr) noexcept + : storage_(KnownNotNull{arr.data()}, details::extent_type()) + {} +#endif // NB: the SFINAE here uses .data() as an incomplete/imperfect proxy for the requirement // on Container to be a contiguous sequence container. template stl{{100, 200, 300}}; + std::array stl_nullptr{{nullptr,nullptr,nullptr}}; + + { + gsl::span 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 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); + static_assert(std::is_same); +#endif + } { gsl::span sp_dyn;