As Arthur wrote, you probably do not want to have [[maybe_unused]] active for SOME_PLATFORM, too.

 

Of course you could also #ifdef the maybe_unused attribute in this specific example as an alternative solution, which arguably would not make it more readable.
 

-----Ursprüngliche Nachricht-----
Von: Giuseppe D‘Angelo via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Do 12.10.2023 15:48
Betreff: Re: [std-proposals] Attribute [[discard]] and attributes on expressions
Anlage: untitled
An: std-proposals@lists.isocpp.org;
CC: Giuseppe D‘Angelo <giuseppe.dangelo@kdab.com>;
On 12/10/2023 15:12, Sebastian Wittmeier via Std-Proposals wrote:
> template <typename... Args>
> void foo_other_platform([[maybe_unused]] Args... args)
> {
> }
>
> template <typename... Args>
> void foo(Args... args)
> {
> #if SOME_PLATFORM
>        use(args...);
> #else
>        foo_other_platform(args...);
> #endif
> }

I don't get it -- why having `foo_other_platform` at all?
[[maybe_unused]] is already doing the right thing, just put it on
`foo`'s arguments?

--
Giuseppe D'Angelo
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals