Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/language/attributes/deprecated"

From cppreference.com
< cpp‎ | language‎ | attributes
m (Text replace - "cpp/attribute" to "cpp/language/attributes")
(don't put surrounding context in syntax)
Line 7: Line 7:
 
{{sdsc begin}}
 
{{sdsc begin}}
 
{{sdsc|num=1|1=
 
{{sdsc|num=1|1=
{{spar|class-key}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{spar|class-name}} {{ttb|;}}
+
{{ttb|<nowiki>[[</nowiki>deprecated}}{{ttb|<nowiki>]]</nowiki>}}
 
}}
 
}}
 
{{sdsc|num=2|1=
 
{{sdsc|num=2|1=
{{spar|class-key}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{spar|class-name}} {{spar|final}}{{mark optional}} {{spar|base-clause}}{{mark optional}} {{ttb|{}} {{spar|member-specification}} {{ttb|} }}
+
{{ttb|<nowiki>[[</nowiki>deprecated(}} {{spar|string-literal}} {{ttb|)<nowiki>]]</nowiki>}}
}}
+
{{sdsc|num=3|1=
+
{{ttb|using}} {{spar|identifier}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{ttb|{{=}}}} {{spar|defining-type-id}} {{ttb|;}}
+
}}
+
{{sdsc|num=4|1=
+
{{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{spar|declaration}}
+
}}
+
{{sdsc|num=5|1=
+
{{spar|declarator-id}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}}
+
}}
+
{{sdsc|num=6|1=
+
{{ttb|inline}}{{mark optional}} {{ttb|namespace}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{spar|name}} {{ttb|{}} {{spar|namespace-body}} {{ttb|} }}
+
}}
+
{{sdsc|num=7|1=
+
{{spar|enum-key}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{spar|enumeration-name}} {{spar|enum-base}}{{mark optional}} {{ttb|;}}
+
}}
+
{{sdsc|num=8|1=
+
{{spar|enum-key}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}} {{spar|enumeration-name}} {{spar|enum-base}}{{mark optional}} {{ttb|{}} {{spar|enumerator-list}} {{ttb|} }}
+
}}
+
{{sdsc|num=9|1=
+
{{spar|enumerator}} {{ttb|<nowiki>[[</nowiki>deprecated}}{{spar|reason}}{{mark optional}}{{ttb|<nowiki>]]</nowiki>}}
+
 
}}
 
}}
 
{{sdsc end}}
 
{{sdsc end}}
 
{{spar|reason}}, if present, has the form {{ttb|(}} {{spar|string-literal}} {{ttb|)}}.
 
  
 
===Explanation===
 
===Explanation===
Line 41: Line 18:
  
 
This attribute is allowed in declarations of classes, typedef-names, variables, non-static data members, functions, namespaces, enumerations, enumerators, and template specializations.
 
This attribute is allowed in declarations of classes, typedef-names, variables, non-static data members, functions, namespaces, enumerations, enumerators, and template specializations.
 +
 +
{{todo|illustrate placement here or in the example}}
  
 
A name declared non-deprecated may be redeclared deprecated. A name declared deprecated cannot be un-deprecated by redeclaring it without this attribute.
 
A name declared non-deprecated may be redeclared deprecated. A name declared deprecated cannot be un-deprecated by redeclaring it without this attribute.

Revision as of 07:57, 24 June 2018

 
 
C++ language
General topics
Flow control
Conditional execution statements
if
Iteration statements (loops)
for
range-for (C++11)
Jump statements
Functions
Function declaration
Lambda function expression
inline specifier
Dynamic exception specifications (until C++17*)
noexcept specifier (C++11)
Exceptions
Namespaces
Types
Specifiers
const/volatile
decltype (C++11)
auto (C++11)
constexpr (C++11)
consteval (C++20)
constinit (C++20)
Storage duration specifiers
Initialization
Expressions
Alternative representations
Literals
Boolean - Integer - Floating-point
Character - String - nullptr (C++11)
User-defined (C++11)
Utilities
Attributes (C++11)
Types
typedef declaration
Type alias declaration (C++11)
Casts
Memory allocation
Classes
Class-specific function properties
explicit (C++11)
static

Special member functions
Templates
Miscellaneous
 
 
Attributes
(C++23)
deprecated
(C++14)
(C++20)
(C++17)
(C++11)
(C++20)
 

Indicates that the use of the name or entity declared with this attribute is allowed, but discouraged for some reason.

Syntax

[[deprecated]] (1)
[[deprecated( string-literal )]] (2)

Explanation

Indicates that the use of the name or entity declared with this attribute is allowed, but discouraged for some reason.

This attribute is allowed in declarations of classes, typedef-names, variables, non-static data members, functions, namespaces, enumerations, enumerators, and template specializations.

A name declared non-deprecated may be redeclared deprecated. A name declared deprecated cannot be un-deprecated by redeclaring it without this attribute.

Example