diff --git a/tests/span_compatibility_tests.cpp b/tests/span_compatibility_tests.cpp index 4be3c4d..e344e88 100644 --- a/tests/span_compatibility_tests.cpp +++ b/tests/span_compatibility_tests.cpp @@ -42,14 +42,11 @@ static_assert(std::is_convertible::value, "std::is_convertible< static_assert(!std::is_convertible::value, "!std::is_convertible"); -TEST(span_compatibility_tests, assertion_tests) +template +void ArrayConvertibilityCheck() { - int arr[3]{10, 20, 30}; - std::array stl{{100, 200, 300}}; - #if __cplusplus >= 201703l - // This std::is_convertible_v fails for C++14 - // so these conversions aren't valid in C++14 + if constexpr (std::is_convertible::value) { std::array stl_nullptr{{nullptr, nullptr, nullptr}}; gsl::span sp_const_nullptr_1{stl_nullptr}; @@ -60,11 +57,22 @@ TEST(span_compatibility_tests, assertion_tests) 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); - static_assert(std::is_same < decltype(span{std::as_const(stl_nullptr)}), - span); + static_assert(std::is_same>::value, + "std::is_same< decltype(span{stl_nullptr}), span>::value"); + static_assert( + std::is_same>::value, + "std::is_same< decltype(span{std::as_const(stl_nullptr)}), span>::value"); } #endif +} + +TEST(span_compatibility_tests, assertion_tests) +{ + int arr[3]{10, 20, 30}; + std::array stl{{100, 200, 300}}; + + ArrayConvertibilityCheck(); { gsl::span sp_dyn;