Is there a way to create user-defined attributes in C++11 or later?
For example,
[[noreturn]] void exit();
is a compiler-defined C++11 attribute.
I'd like to define something like:
[[comingsoon]] int function(int);
Is there a mechanism for this?
Edit: I should mention I'm using Clang.
User Defined Attributes are a user customized property of elements and panels. This could be amongst other things; A Name to define things such as Notes, Finish, Specification etc. A Number to define things such as Class, Phase etc.
Attributes are a mechanism by which the developer can attach extra information to language entities with a generalized syntax, instead of introducing new syntactic constructs or keywords for each feature.
From the Administration tab, expand Roles > Default > Business Objects > Request. Click Attributes, and in the Attributes screen for the Request business object, click Create Attribute. Enter the name of the user-defined attribute.
Everything in C++ is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake. Attributes and methods are basically variables and functions that belongs to the class.
For now it's not possible to define user-attributes.
There is, as far as i know, no information about if this feature is planned or not. However, look at this FAQ answer from Stroustrup : https://isocpp.org/wiki/faq/cpp11-language-misc#attributes, especially this part :
One planned use for attributes is improved support for OpenMP. For example:
for [ [ omp::parallel() ] ] (int i=0; i<v.size(); ++i) {
// ...
}
It could mean that they plan to allow programmer to define it's own attribute. Wait & see.
The language provides no way of adding attributes.
Of course, if you are using Clang, you can edit the source of Clang, and add any attributes you like.
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