Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | language‎ | attributes
m (use templates)
m (notes)
Line 1: Line 1:
{{cpp/attribute/title|deprecated}}
+
{{cpp/attribute/title|deprecated|notes={{mark since c++14}}}}
 
{{cpp/attribute/navbar}}
 
{{cpp/attribute/navbar}}
  

Revision as of 04:22, 24 June 2018

Template:cpp/attribute/title Template:cpp/attribute/navbar

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

Syntax

class-key [[deprecatedreason(optional)]] class-name ; (1)
class-key [[deprecatedreason(optional)]] class-name final(optional) base-clause(optional) { member-specification } (2)
using identifier [[deprecatedreason(optional)]] = defining-type-id ; (3)
[[deprecatedreason(optional)]] declaration (4)
declarator-id [[deprecatedreason(optional)]] (5)
inline(optional) namespace [[deprecatedreason(optional)]] name { namespace-body } (6)
enum-key [[deprecatedreason(optional)]] enumeration-name enum-base(optional) ; (7)
enum-key [[deprecatedreason(optional)]] enumeration-name enum-base(optional) { enumerator-list } (8)
enumerator [[deprecatedreason(optional)]] (9)

reason, if present, has the form ( string-literal ).

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