From 9b3ac8d681222a082231de712a4bd4299b658f11 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Tue, 17 Mar 2020 15:02:00 -0700 Subject: [PATCH] discussed the issue with Casey Carter, the span ctor changes are accurate but the tests are not. The test require work that was done in C++17 regarding qualifier conversions to work correctly. Scoping tests for 17. --- include/gsl/span | 19 +------------------ tests/span_compatibility_tests.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/include/gsl/span b/include/gsl/span index 7c15eb4..469a2db 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -441,23 +441,6 @@ public: : storage_(KnownNotNull{arr + 0}, details::extent_type()) {} -// #define useold -#if defined(useold) - template ::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()) - {} -#else template ::value && details::is_allowed_element_type_conversion::value), int> = 0> @@ -473,7 +456,7 @@ public: 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}}; +#if __cplusplus >= 201703l + // This std::is_convertible_v fails for C++14 + // so these conversions aren't valid in C++14 { 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 } +#endif { gsl::span sp_dyn;