I got sent a link describing a [[deprecated]]
attribute in C++11. This sound pretty convenient, and I would like to have more information about it - which compilers support it, full documentation on it, etc.
I spent 20 minutes or so googling around, but apart from the linked website, I couldn't find infos on this anywhere. Partly, this was complicated by other uses of the word "deprecated" in connection with C++11, and search engines not recognizing [[
. I didn't find this in draft standards linked to in various SO answers, either. I don't have access to the full, paid, standard.
Does anybody have more information about this [[deprecated]]
attribute?
P.S.: If you're curious, I'd use this as a better alternative to https://stackoverflow.com/a/295229/599884
The [[deprecated]]
attribute has made its way into the draft of C++14 (see section 7.6.5 [dcl.attr.deprecated] of the October 2013 draft).
The attribute-token
deprecated
can be used to mark names and entities whose use is still allowed, but is discouraged for some reason.
For example, the following function foo
is deprecated:
[[deprecated]]
void foo(int);
It is possible to provide a message that describes why the name or entity was deprecated:
[[deprecated("Replaced by bar, which has an improved interface")]]
void foo(int);
The message must be a string literal.
First, things in [[]]
are not keywords; they are attributes.
Second, there is no [[deprecated]]
attribute defined by the C++11 standard. The link you're referring to is either in error or referring to a specific compiler (C++Builder, perhaps?) that implements this attribute.
Attributes are (usually) compiler specific. Like #pragma
s, compilers are supposed to ignore any attribute they don't support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With