reviewed the pr in its entirety and made some slight modifications. Removed all members and fields marked as deprecated.

This commit is contained in:
Jordan Maples [MSFT] 2020-02-11 16:36:07 -08:00
parent cce6ee563e
commit 926aaeca56
4 changed files with 11 additions and 29 deletions

View File

@ -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<std::size_t>(-1);
#else
constexpr std::size_t dynamic_extent = static_cast<std::size_t>(-1);
#endif
template <class ElementType, std::size_t Extent = dynamic_extent>
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 <size_type Other>
constexpr extent_type(extent_type<Other> 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<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_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<ElementType, Extent> s) noexcept
return {reinterpret_cast<byte*>(s.data()), s.size_bytes()};
}
template <class ElementType, std::size_t Extent,
std::enable_if_t<!std::is_const<ElementType>::value, int> = 0>
[[deprecated(
"use as_writable_bytes")]] span<byte, details::calculate_byte_size<ElementType, Extent>::value>
as_writeable_bytes(span<ElementType, Extent> s) noexcept
{
// clang-format off
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
// clang-format on
return {reinterpret_cast<byte*>(s.data()), s.size_bytes()};
}
//
// make_span() - Utility functions for creating spans
//
@ -868,7 +850,7 @@ constexpr ElementType& at(span<ElementType, Extent> s, index i)
{
// No bounds checking here because it is done in span::operator[] called below
Ensures(i >= 0);
return s[narrow_cast<std::size_t>(i)];
return s[static_cast<std::size_t>(i)];
}
// [span.obs] Free observer functions

View File

@ -381,7 +381,7 @@ as_bytes(basic_string_span<ElementType, Extent> s) noexcept
template <class ElementType, std::size_t Extent,
class = std::enable_if_t<!std::is_const<ElementType>::value>>
basic_string_span<byte, details::calculate_byte_size<ElementType, Extent>::value>
as_writeable_bytes(basic_string_span<ElementType, Extent> s) noexcept
as_writable_bytes(basic_string_span<ElementType, Extent> s) noexcept
{
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
return {reinterpret_cast<byte*>(s.data()), s.size_bytes()};

View File

@ -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<const int> s = a;
EXPECT_TRUE(s.size() == 4);
span<const byte> bs = as_writeable_bytes(s);
span<const byte> bs = as_writable_bytes(s);
EXPECT_TRUE(static_cast<void*>(bs.data()) == static_cast<void*>(s.data()));
EXPECT_TRUE(bs.size() == s.size_bytes());
#endif
@ -1502,7 +1502,7 @@ TEST(span_test, from_array_constructor)
{
span<int> 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<int> s = a;
const auto bs = as_writeable_bytes(s);
const auto bs = as_writable_bytes(s);
EXPECT_TRUE(static_cast<void*>(bs.data()) == static_cast<void*>(s.data()));
EXPECT_TRUE(bs.size() == s.size_bytes());
}

View File

@ -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<const void*>(bs.data()) == static_cast<const void*>(s.data()));
EXPECT_TRUE(bs.size() == s.size_bytes());
}