C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Attribute [[discard]] and attributes on expressions

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Thu, 12 Oct 2023 14:49:52 +0200
Hello,

On 12/10/2023 14:29, Bjorn Reese via Std-Proposals wrote:
>> The purpose of [[discard]] is really for expressions, I don't see much
>> value at discarding a pack as-is?
> template <typename... Args>
> void foo(Args... args)
> {
> #if SOME_PLATFORM
> use(args...);
> #else
> discard(args...);
> #endif
> }

But this can be spelled like this today, without discarding:

> template <typename... Args>
> void foo([[maybe_unused]] Args... args)
> {
> #if SOME_PLATFORM
> use(args...);
> #endif
> }

Thank you,
-- 
Giuseppe D'Angelo

Received on 2023-10-12 12:50:06