mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-25 01:01:58 -05:00
Update span_compatibility_tests.cpp
some fixes.
This commit is contained in:
parent
b6b1e9c3cf
commit
6b01a0488b
@ -41,13 +41,6 @@ static_assert(std::is_convertible<Derived*, Base*>::value, "std::is_convertible<
|
|||||||
static_assert(!std::is_convertible<Derived (*)[], Base (*)[]>::value,
|
static_assert(!std::is_convertible<Derived (*)[], Base (*)[]>::value,
|
||||||
"!std::is_convertible<Derived(*)[], Base(*)[]>");
|
"!std::is_convertible<Derived(*)[], Base(*)[]>");
|
||||||
|
|
||||||
template <typename U, typename = void>
|
|
||||||
static constexpr bool AsWritableBytesCompilesFor = false;
|
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
static constexpr bool AsWritableBytesCompilesFor<U, void_t<decltype(as_writable_bytes(declval<U>()))>> =
|
|
||||||
true;
|
|
||||||
|
|
||||||
TEST(span_compatibility_tests, assertion_tests)
|
TEST(span_compatibility_tests, assertion_tests)
|
||||||
{
|
{
|
||||||
int arr[3]{10, 20, 30};
|
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_dyn)), "noexcept(as_writable_bytes(sp_dyn))");
|
||||||
static_assert(noexcept(as_writable_bytes(sp_nine)), "noexcept(as_writable_bytes(sp_nine))");
|
static_assert(noexcept(as_writable_bytes(sp_nine)), "noexcept(as_writable_bytes(sp_nine))");
|
||||||
|
|
||||||
static_assert(AsWritableBytesCompilesFor<gsl::span<int>>,
|
|
||||||
"AsWritableBytesCompilesFor<gsl::span<int>>");
|
|
||||||
static_assert(AsWritableBytesCompilesFor<gsl::span<int, 9>>,
|
|
||||||
"AsWritableBytesCompilesFor<gsl::span<int, 9>>");
|
|
||||||
static_assert(!AsWritableBytesCompilesFor<gsl::span<const int>>,
|
|
||||||
"!AsWritableBytesCompilesFor<gsl::span<const int>>");
|
|
||||||
static_assert(!AsWritableBytesCompilesFor<gsl::span<const int, 9>>,
|
|
||||||
"!AsWritableBytesCompilesFor<gsl::span<const int, 9>>");
|
|
||||||
|
|
||||||
auto sp_1 = as_bytes(sp_dyn);
|
auto sp_1 = as_bytes(sp_dyn);
|
||||||
auto sp_2 = as_bytes(sp_nine);
|
auto sp_2 = as_bytes(sp_nine);
|
||||||
auto sp_3 = as_bytes(sp_const_dyn);
|
auto sp_3 = as_bytes(sp_const_dyn);
|
||||||
@ -1064,3 +1048,22 @@ static_assert(std::is_convertible<std::array<int, 3>&, gsl::span<const int>>::va
|
|||||||
|
|
||||||
static_assert(std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>::value,
|
static_assert(std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>::value,
|
||||||
"std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>");
|
"std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>");
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703l
|
||||||
|
template <typename U, typename = void>
|
||||||
|
inline constexpr bool AsWritableBytesCompilesFor = false;
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
inline constexpr bool AsWritableBytesCompilesFor<U, void_t<decltype(as_writable_bytes(declval<U>()))>> =
|
||||||
|
true;
|
||||||
|
|
||||||
|
static_assert(AsWritableBytesCompilesFor<gsl::span<int>>,
|
||||||
|
"AsWritableBytesCompilesFor<gsl::span<int>>");
|
||||||
|
static_assert(AsWritableBytesCompilesFor<gsl::span<int, 9>>,
|
||||||
|
"AsWritableBytesCompilesFor<gsl::span<int, 9>>");
|
||||||
|
static_assert(!AsWritableBytesCompilesFor<gsl::span<const int>>,
|
||||||
|
"!AsWritableBytesCompilesFor<gsl::span<const int>>");
|
||||||
|
static_assert(!AsWritableBytesCompilesFor<gsl::span<const int, 9>>,
|
||||||
|
"!AsWritableBytesCompilesFor<gsl::span<const int, 9>>");
|
||||||
|
#endif // __cplusplus >= 201703l
|
||||||
|
Loading…
Reference in New Issue
Block a user