diff --git a/README.md b/README.md index a3ff066..bd28ca0 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,6 @@ span_p | & [u32zstring](docs/headers.md#user-content-H-zstring) | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of `char32_t` [cu32zstring](docs/headers.md#user-content-H-zstring) | ☑ | An alias to `basic_zstring` with dynamic extent and a char type of `const char32_t` [**2. Owners**][cg-owners] | | -[unique_ptr](docs/headers.md#user-content-H-pointers-unique_ptr) | ☑ | An alias to `std::unique_ptr` -[shared_ptr](docs/headers.md#user-content-H-pointers-shared_ptr) | ☑ | An alias to `std::shared_ptr` stack_array | ☐ | A stack-allocated array dyn_array | ☐ | A heap-allocated array [**3. Assertions**][cg-assertions] | | @@ -49,13 +47,11 @@ dyn_array | & [Ensures](docs/headers.md#user-content-H-assert-ensures) | ☑ | A postcondition assertion; on failure it terminates [**4. Utilities**][cg-utilities] | | move_owner | ☐ | A helper function that moves one `owner` to the other -[byte](docs/headers.md#user-content-H-byte-byte) | ☑ | Either an alias to `std::byte` or a byte type [final_action](docs/headers.md#user-content-H-util-final_action) | ☑ | A RAII style class that invokes a functor on its destruction [finally](docs/headers.md#user-content-H-util-finally) | ☑ | A helper function instantiating [final_action](docs/headers.md#user-content-H-util-final_action) [GSL_SUPPRESS](docs/headers.md#user-content-H-assert-gsl_suppress) | ☑ | A macro that takes an argument and turns it into `[[gsl::suppress(x)]]` or `[[gsl::suppress("x")]]` [[implicit]] | ☐ | A "marker" to put on single-argument constructors to explicitly make them non-explicit [index](docs/headers.md#user-content-H-util-index) | ☑ | A type to use for all container and array indexing (currently an alias for `std::ptrdiff_t`) -joining_thread | ☐ | A RAII style version of `std::thread` that joins [narrow](docs/headers.md#user-content-H-narrow-narrow) | ☑ | A checked version of `narrow_cast`; it can throw [narrowing_error](docs/headers.md#user-content-H-narrow-narrowing_error) [narrow_cast](docs/headers.md#user-content-H-util-narrow_cast) | ☑ | A narrowing cast for values and a synonym for `static_cast` [narrowing_error](docs/headers.md#user-content-H-narrow-narrowing_error) | ☑ | A custom exception type thrown by [narrow](docs/headers.md#user-content-H-narrow-narrow) @@ -77,6 +73,14 @@ cu16string_span | ☐ | Deprecated. An alias to `basic u32string_span | ☐ | Deprecated. An alias to `basic_string_span` with a char type of `char32_t` cu32string_span | ☐ | Deprecated. An alias to `basic_string_span` with a char type of `const char32_t` +## The following features have been adopted by WG21. They are deprecated in GSL. +Feature | Deprecated Since | Notes +-----------------------------------|------------------|------ +gsl::unique_ptr | C++11 | Use std::unique_ptr instead. +gsl::shared_ptr | C++11 | Use std::shared_ptr instead. +gsl::byte | C++17 | Use std::byte instead. +gsl:joining_thread | C++20 (Note: Not yet implemented in GSL) | Use std::jthread instead. + This is based on [CppCoreGuidelines semi-specification](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gsl-guidelines-support-library). [cg-views]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gslview-views diff --git a/include/gsl/byte b/include/gsl/byte index 72044bb..cb3e632 100644 --- a/include/gsl/byte +++ b/include/gsl/byte @@ -17,6 +17,8 @@ #ifndef GSL_BYTE_H #define GSL_BYTE_H +#include "./util" // for GSL_DEPRECATED + #include #ifdef _MSC_VER @@ -80,8 +82,10 @@ namespace gsl { #if GSL_USE_STD_BYTE -using std::byte; -using std::to_integer; +using byte GSL_DEPRECATED("Use std::byte instead.") = std::byte; + +template +using to_integer GSL_DEPRECATED("Use std::to_integer instead.") = std::to_integer; #else // GSL_USE_STD_BYTE diff --git a/include/gsl/pointers b/include/gsl/pointers index 425133e..28f997c 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -18,6 +18,7 @@ #define GSL_POINTERS_H #include "./assert" // for Ensures, Expects +#include "./util" // for GSL_DEPRECATED #include // for ptrdiff_t, nullptr_t, size_t #include // for less, greater @@ -62,8 +63,11 @@ namespace details // // GSL.owner: ownership pointers // -using std::shared_ptr; -using std::unique_ptr; +template +using shared_ptr GSL_DEPRECATED("Use std::shared_ptr instead") = std::shared_ptr; + +template +using unique_ptr GSL_DEPRECATED("Use std::unique_ptr instead") = std::unique_ptr; // // owner diff --git a/include/gsl/span_ext b/include/gsl/span_ext index c92334b..8b2c2c9 100644 --- a/include/gsl/span_ext +++ b/include/gsl/span_ext @@ -123,14 +123,14 @@ constexpr span make_span(const Container& } template -[[deprecated("This function is deprecated. See GSL issue #1092.")]] +GSL_DEPRECATED("This function is deprecated. See GSL issue #1092.") constexpr span make_span(Ptr& cont, std::size_t count) { return span(cont, count); } template -[[deprecated("This function is deprecated. See GSL issue #1092.")]] +GSL_DEPRECATED("This function is deprecated. See GSL issue #1092.") constexpr span make_span(Ptr& cont) { return span(cont); diff --git a/include/gsl/util b/include/gsl/util index c2ca79b..7a3caed 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -60,6 +60,32 @@ #define GSL_INLINE #endif +#if defined(__has_cpp_attribute) +#if __has_cpp_attribute(deprecated) +#define GSL_DEPRECATED(msg) [[deprecated(msg)]] +#endif // __has_cpp_attribute(deprecated) +#endif // defined(__has_cpp_attribute) + +#if !defined(GSL_DEPRECATED) +#if defined(__cplusplus) +#if __cplusplus >= 201309L +#define GSL_DEPRECATED(msg) [[deprecated(msg)]] +#endif // __cplusplus >= 201309L +#endif // defined(__cplusplus) +#endif // !defined(GSL_DEPRECATED) + +#if !defined(GSL_DEPRECATED) +#if defined(_MSC_VER) +#define GSL_DEPRECATED(msg) __declspec(deprecated(msg)) +#elif defined(__GNUC__) +#define GSL_DEPRECATED(msg) __attribute__((deprecated(msg))) +#endif // defined(_MSC_VER) +#endif // !defined(GSL_DEPRECATED) + +#if !defined(GSL_DEPRECATED) +#define GSL_DEPRECATED(msg) +#endif // !defined(GSL_DEPRECATED) + namespace gsl { //