From 926aaeca5618931097a7626ffe4a0f87623e1cd8 Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Tue, 11 Feb 2020 16:36:07 -0800 Subject: [PATCH] reviewed the pr in its entirety and made some slight modifications. Removed all members and fields marked as deprecated. --- include/gsl/span | 26 ++++---------------------- include/gsl/string_span | 2 +- tests/span_tests.cpp | 8 ++++---- tests/string_span_tests.cpp | 4 ++-- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/include/gsl/span b/include/gsl/span index 6c2b4de..8f73b1c 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -71,11 +71,7 @@ namespace gsl { // [views.constants], constants -#if (defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND)) constexpr const std::size_t dynamic_extent = static_cast(-1); -#else -constexpr std::size_t dynamic_extent = static_cast(-1); -#endif template class span; @@ -137,7 +133,7 @@ namespace details #ifdef _MSC_VER using _Unchecked_type = pointer; -#endif +#endif // _MSC_VER constexpr span_iterator() = default; constexpr span_iterator(pointer begin, pointer end, pointer current) @@ -348,14 +344,14 @@ namespace details public: using size_type = std::size_t; - static_assert(Ext != dynamic_extent, "A fixed-size span must be >= 0 in size."); + static_assert(Ext != dynamic_extent, "A fixed-size span must not have size == dynamic_extent"); constexpr extent_type() noexcept {} template constexpr extent_type(extent_type ext) { - static_assert(Other == Ext || Other == dynamic_extent, + static_assert(Other == Ext, "Mismatch between fixed-size extent and size of initializing data."); Expects(ext.size() == Ext); } @@ -415,8 +411,6 @@ public: using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - using index_type [[deprecated("use size_type instead of index_type")]] = size_type; - #if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND) static constexpr const size_type extent{Extent}; #else @@ -805,18 +799,6 @@ as_writable_bytes(span s) noexcept return {reinterpret_cast(s.data()), s.size_bytes()}; } -template ::value, int> = 0> -[[deprecated( - "use as_writable_bytes")]] span::value> -as_writeable_bytes(span s) noexcept -{ - // clang-format off - GSL_SUPPRESS(type.1) // NO-FORMAT: attribute - // clang-format on - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - // // make_span() - Utility functions for creating spans // @@ -868,7 +850,7 @@ constexpr ElementType& at(span s, index i) { // No bounds checking here because it is done in span::operator[] called below Ensures(i >= 0); - return s[narrow_cast(i)]; + return s[static_cast(i)]; } // [span.obs] Free observer functions diff --git a/include/gsl/string_span b/include/gsl/string_span index 27b8977..cc0588e 100644 --- a/include/gsl/string_span +++ b/include/gsl/string_span @@ -381,7 +381,7 @@ as_bytes(basic_string_span s) noexcept template ::value>> basic_string_span::value> -as_writeable_bytes(basic_string_span s) noexcept +as_writable_bytes(basic_string_span s) noexcept { GSL_SUPPRESS(type.1) // NO-FORMAT: attribute return {reinterpret_cast(s.data()), s.size_bytes()}; diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 1f5020b..ab437a5 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -1485,7 +1485,7 @@ TEST(span_test, from_array_constructor) } } - TEST(span_test, as_writeable_bytes) + TEST(span_test, as_writable_bytes) { int a[] = {1, 2, 3, 4}; @@ -1494,7 +1494,7 @@ TEST(span_test, from_array_constructor) // you should not be able to get writeable bytes for const objects span s = a; EXPECT_TRUE(s.size() == 4); - span bs = as_writeable_bytes(s); + span bs = as_writable_bytes(s); EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); EXPECT_TRUE(bs.size() == s.size_bytes()); #endif @@ -1502,7 +1502,7 @@ TEST(span_test, from_array_constructor) { span s; - const auto bs = as_writeable_bytes(s); + const auto bs = as_writable_bytes(s); EXPECT_TRUE(bs.size() == s.size()); EXPECT_TRUE(bs.size() == 0); EXPECT_TRUE(bs.size_bytes() == 0); @@ -1512,7 +1512,7 @@ TEST(span_test, from_array_constructor) { span s = a; - const auto bs = as_writeable_bytes(s); + const auto bs = as_writable_bytes(s); EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); EXPECT_TRUE(bs.size() == s.size_bytes()); } diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index c1f8cf4..7a9f7fb 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -1206,12 +1206,12 @@ TEST(string_span_tests, as_bytes) EXPECT_TRUE(bs.size() == s.size_bytes()); } -TEST(string_span_tests, as_writeable_bytes) +TEST(string_span_tests, as_writable_bytes) { wchar_t buf[]{L"qwerty"}; wzstring_span<> v(buf); const auto s = v.as_string_span(); - const auto bs = as_writeable_bytes(s); + const auto bs = as_writable_bytes(s); EXPECT_TRUE(static_cast(bs.data()) == static_cast(s.data())); EXPECT_TRUE(bs.size() == s.size_bytes()); }