deprecate features adopted into C++ (#1198)

* deprecated features adopted into C++

1) Mark the following GSL features as deprecated:
 - gsl::unique_ptr (always)
 - gsl::shared_ptr (always)
 - gsl::byte (since c++17)
 - gsl::joining_thread (never implemented)
2) Refactor existing deprecations to use the new GSL_DEPRECATED(msg) macro.
3) Create a section in the README for deprecated features in the
   standard.

* do not deprecate gsl::to_integer because we never claim to implement it.

* do not use gsl::byte if it is deprecated
This commit is contained in:
Carson Radtke authored and GitHub committed 2025-02-14 11:24:51 -06:00
1 parent 4742bc192a
commit 7fabaa499d
6 files changed
+64 -20

No files matched your search

+7 -7
View File
@@ -18,7 +18,7 @@
#define GSL_SPAN_H
#include "./assert" // for Expects
#include "./byte" // for byte
#include "./byte" // for BYTE_TYPE
#include "./span_ext" // for span specialization of gsl::at and other span-related extensions
#include "./util" // for narrow_cast
@@ -824,28 +824,28 @@ namespace details
// [span.objectrep], views of object representation
template <class ElementType, std::size_t Extent>
span<const byte, details::calculate_byte_size<ElementType, Extent>::value>
span<const BYTE_TYPE, details::calculate_byte_size<ElementType, Extent>::value>
as_bytes(span<ElementType, Extent> s) noexcept
{
using type = span<const byte, details::calculate_byte_size<ElementType, Extent>::value>;
using type = span<const BYTE_TYPE, details::calculate_byte_size<ElementType, Extent>::value>;
// clang-format off
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
// clang-format on
return type{reinterpret_cast<const byte*>(s.data()), s.size_bytes()};
return type{reinterpret_cast<const BYTE_TYPE*>(s.data()), s.size_bytes()};
}
template <class ElementType, std::size_t Extent,
std::enable_if_t<!std::is_const<ElementType>::value, int> = 0>
span<byte, details::calculate_byte_size<ElementType, Extent>::value>
span<BYTE_TYPE, details::calculate_byte_size<ElementType, Extent>::value>
as_writable_bytes(span<ElementType, Extent> s) noexcept
{
using type = span<byte, details::calculate_byte_size<ElementType, Extent>::value>;
using type = span<BYTE_TYPE, details::calculate_byte_size<ElementType, Extent>::value>;
// clang-format off
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
// clang-format on
return type{reinterpret_cast<byte*>(s.data()), s.size_bytes()};
return type{reinterpret_cast<BYTE_TYPE*>(s.data()), s.size_bytes()};
}
} // namespace gsl