What you're talking about is called attribute specifiers . This is an attempt to standardize various platform-specific qualifiers:
As you can see in the attached doc link, the only qualifiers supported in C ++ 11 are:
[[noreturn]][[carries_dependency]]
and in C ++ 14:
[[deprecated]] (also supported as: [[deprecated("reason")]] )
So the answer is no, this is not possible using only C ++ 11 functions .
If you are not only interested in portable solutions, this may be so. The C ++ standard does not limit this list:
The C ++ standard defines only the following attributes. All other attributes are implementation specific.
Different compilers may support some non-standard specifiers. For example, you can read this page to find out that Clang supports:
Your version of GCC may also support this specifier. This page contains an error report that references generic attribute support. [[gnu::unused]] .
source share