cjdb added a comment.
>> With [[discardable]] one just needs to push/pop at the extremes of a file
>> (and if a future version of module maps supports global pragmas for a
>> module, there too, but that's a discussion that requires a design doc).
>
> I understood that, I just don't think that's a good thing. This is basically
> an attribute that says "I know we said we wanted everything here to be
> nodiscard, but JUST KIDDING not this one!" which is not a very clean approach
> to writing headers.
@aaron.ballman Ugh, I've finally come up with a good use-case for
`[[discardable]]`.
class [[nodiscard]] iterator {
public:
// usual iterator stuff
[[clang::discardable]] iterator operator++(int);
[[clang::discardable]] iterator operator--(int);
};
I hate it, but the alternative is to decorate everything else with
`[[nodiscard]]` just to facilitate these two operators. It's a compelling
use-case, but I'm not sure if it's compelling enough on its own. WDYT?
(I personally think that those two should be nodiscard, but `i++` is pervasive
enough that it might never be practical to correct.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129835/new/
https://reviews.llvm.org/D129835
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits