From 9f21a120f07b04e883849032bcdb2e0bf501998e Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 18 Jun 2019 17:13:00 -0300 Subject: [PATCH] Add explanation about C++14 [[deprecated]] standard attribute (#49) * Add [[deprecated]] attribute to C++14 --- CPP14.md | 10 ++++++++++ README.md | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/CPP14.md b/CPP14.md index 88a7102..3bad40e 100644 --- a/CPP14.md +++ b/CPP14.md @@ -11,6 +11,7 @@ C++14 includes the following new language features: - [decltype(auto)](#decltypeauto) - [relaxing constraints on constexpr functions](#relaxing-constraints-on-constexpr-functions) - [variable templates](#variable-templates) +- [\[\[deprecated\]\] attribute](#deprecated-attribute) C++14 includes the following new library features: - [user-defined literals for standard library types](#user-defined-literals-for-standard-library-types) @@ -146,6 +147,15 @@ template constexpr T e = T(2.7182818284590452353); ``` +### [[deprecated]] attribute +C++14 introduces the `[[deprecated]]` attribute to indicate that a unit (function, class, etc) is discouraged and likely yield compilation warnings. If a reason is provided, it will be included in the warnings. +```c++ +[[deprecated]] +void old_method(); +[[deprecated("Use new_method instead")]] +void legacy_method(); +``` + ## C++14 Library Features ### User-defined literals for standard library types diff --git a/README.md b/README.md index 2030db1..f6a80b1 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ C++14 includes the following new language features: - [decltype(auto)](#decltypeauto) - [relaxing constraints on constexpr functions](#relaxing-constraints-on-constexpr-functions) - [variable templates](#variable-templates) +- [\[\[deprecated\]\] attribute](#deprecated-attribute) C++14 includes the following new library features: - [user-defined literals for standard library types](#user-defined-literals-for-standard-library-types) @@ -751,6 +752,16 @@ template constexpr T e = T(2.7182818284590452353); ``` +### [[deprecated]] attribute +C++14 introduces the `[[deprecated]]` attribute to indicate that a unit (function, class, etc) is discouraged and likely yield compilation warnings. If a reason is provided, it will be included in the warnings. +```c++ +[[deprecated]] +void old_method(); + +[[deprecated("Use new_method instead")]] +void legacy_method(); +``` + ## C++14 Library Features ### User-defined literals for standard library types