In [dcl.attr.depend]/1, I read:
The attribute[...]
carries_dependency
[...] may be applied to thedeclarator-id
of aparameter-declaration
in a function declaration or lambda, in which case it specifies that the initialization of the parameter carries a dependency to (1.10) each lvalue-to-rvalue conversion (4.1) of that object. The attribute may also be applied to thedeclarator-id
of a function declaration, in which case it specifies that the return value, if any, carries a dependency to the evaluation of the function call expression.
What I'm missing is a way to apply the attribute to the implicit this
parameter.
By way of example, consider this free function:
void fun(int i, Foo * [[carries_dependency]] f);
and it's equivalent (but for the attribute) member version:
void Foo::fun(int i); // can't add [[carries_dependency]] here?
I'm not certain and don't have a compiler with support for this to test, but here's a swing at a possibility: I think the grammar [gram.decl] indicates that you should be able put it ("attribute-specifier_opt") in the same spot you'd put "const" to indicate a constant this pointer ("cv-qualifier-seq_opt"), which would make sense:
parameters-and-qualifiers:
( parameter-declaration-clause ) attribute-specifier_opt cv-qualifier-seq_opt
ref-qualifier_opt exception-specification_opt
E.g.
struct X{
void f(int i) [[carries_dependency]];
};
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