From 6b01a0488b1157a2c49805b85becd09e1fe84f57 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Fri, 14 Feb 2020 16:25:25 -0800 Subject: [PATCH] Update span_compatibility_tests.cpp some fixes. --- tests/span_compatibility_tests.cpp | 35 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/span_compatibility_tests.cpp b/tests/span_compatibility_tests.cpp index d4cde0c..57a85e7 100644 --- a/tests/span_compatibility_tests.cpp +++ b/tests/span_compatibility_tests.cpp @@ -41,13 +41,6 @@ static_assert(std::is_convertible::value, "std::is_convertible< static_assert(!std::is_convertible::value, "!std::is_convertible"); -template -static constexpr bool AsWritableBytesCompilesFor = false; - -template -static constexpr bool AsWritableBytesCompilesFor()))>> = - true; - TEST(span_compatibility_tests, assertion_tests) { int arr[3]{10, 20, 30}; @@ -501,15 +494,6 @@ TEST(span_compatibility_tests, assertion_tests) static_assert(noexcept(as_writable_bytes(sp_dyn)), "noexcept(as_writable_bytes(sp_dyn))"); static_assert(noexcept(as_writable_bytes(sp_nine)), "noexcept(as_writable_bytes(sp_nine))"); - static_assert(AsWritableBytesCompilesFor>, - "AsWritableBytesCompilesFor>"); - static_assert(AsWritableBytesCompilesFor>, - "AsWritableBytesCompilesFor>"); - static_assert(!AsWritableBytesCompilesFor>, - "!AsWritableBytesCompilesFor>"); - static_assert(!AsWritableBytesCompilesFor>, - "!AsWritableBytesCompilesFor>"); - auto sp_1 = as_bytes(sp_dyn); auto sp_2 = as_bytes(sp_nine); auto sp_3 = as_bytes(sp_const_dyn); @@ -1064,3 +1048,22 @@ static_assert(std::is_convertible&, gsl::span>::va static_assert(std::is_convertible&, gsl::span>::value, "std::is_convertible&, gsl::span>"); + + +#if __cplusplus >= 201703l +template +inline constexpr bool AsWritableBytesCompilesFor = false; + +template +inline constexpr bool AsWritableBytesCompilesFor()))>> = + true; + +static_assert(AsWritableBytesCompilesFor>, + "AsWritableBytesCompilesFor>"); +static_assert(AsWritableBytesCompilesFor>, + "AsWritableBytesCompilesFor>"); +static_assert(!AsWritableBytesCompilesFor>, + "!AsWritableBytesCompilesFor>"); +static_assert(!AsWritableBytesCompilesFor>, + "!AsWritableBytesCompilesFor>"); +#endif // __cplusplus >= 201703l