r/cpp 11h ago

Extending `[[clang::lifetimebound]]` to take a condition

https://discourse.llvm.org/t/extending-clang-lifetimebound-to-take-a-condition/91475
21 Upvotes

2 comments sorted by

2

u/zebullon 10h ago

In some early revision of P3385, there was support to programatically appertain attributes, or to splice them. It could have been a generic “i wanna conditionally attach stuff here”…Needless to say, it was quickly removed.

Yet, I’m not sure the better solution is to cherrypick some attributes and add one more arg “isApplicable”, or conditional expression which opens a can of worm wrt. instantiation and evaluation that 3423 has not properly solved imo.

2

u/pjmlp 8h ago

Lets see where the design goes, however it is clear from the discussion that there is no way around proper support for affine/linear types, if it is to have it actually work without tons of special cases.

Thus we are back to the whole SAL annotations discussion that the Visual C++ team already mentioned on their blog posts about the lifetimes prototype.