Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[[maybe_unused]] applied to static data members

Tags:

c++

c++17

The draft standard states about [[maybe_unused]] in 10.6.6 item 2

"The attribute may be applied to the declaration of a class, a typedef-name, a variable, a non-static data member, a function, an enumeration, or an enumerator."

Is there any reason to exclude static data members from this? i.e.

struct Foo {
    [[maybe_unused]] static inline int foo = 0;
};

I ask as I have a static data member whose type has a non trivial constructor that does useful stuff but is otherwise unused.

like image 299
goneskiing Avatar asked Mar 30 '18 20:03

goneskiing


1 Answers

[basic]/6 says that any object declaration constitutes a variable. “non-static data member” appears in the list alongside “variable” because a non-static data member of reference type is not a variable.

like image 136
Davis Herring Avatar answered Oct 19 '22 11:10

Davis Herring