Namespaces
Variants
Actions

Talk:cpp/language/attributes/deprecated

From cppreference.com

It looks like during the reformatting between [104386 and 104484], there was a typo introduced in where the [[deprecated]] attribute can appear. According to the standard, [[deprecated]] cannot appear in the declaration of a static data member.

Should this be corrected?

hawkinsw (talk) 23:44, 12 January 2024 (PST)hawkinsw

A static data member is a variable, and thus can have this attribute.
The standard says "a variable or a non-static data member" which is a bit misleading, but it actually does include static data members. --D41D8CD98F (talk) 00:19, 13 January 2024 (PST)

Thanks! The only reason I mention this is because there is a paper making its way through the committee that disagrees with that interpretation: [P2552]. I have emailed the author about the discrepancy.

In addition, I 100% agree that "variable" generally includes static data members, but the standard does not always use it consistently that way. For instance, in [list initialization] it says that a variable can be list initialized but that clearly does not hold for static data members.

Update: Sorry! I will continue to think out loud here. In the previous example I specified, I see that they used the word "definition" and that is in distinction to declaration which resolves the conflict that I was seeing in an example such as https://godbolt.org/z/EMscssY6T.

I guess my overall question is, "If the authors meant it to apply to declarations of both static and non-static data members, why did they specifically add non-static data member to the list? Variable seems like it would have sufficed."

hawkinsw (talk) 12:55, 13 January 2024 (PST)hawkinsw

Thank you for the disambiguating edit, User:Space_Mission!

hawkinsw (talk) 14:41, 13 January 2024 (PST)hawkinsw