Cast it to void
:
[[nodiscard]] int foo ()
{
return 0;
}
int main ()
{
static_cast<void>(foo());
}
This basically tells the compiler “Yes I know I’m discarding this, yes I’m sure of it.“
Cast it to void
:
[[nodiscard]] int foo ()
{
return 0;
}
int main ()
{
static_cast<void>(foo());
}
This basically tells the compiler “Yes I know I’m discarding this, yes I’m sure of it.“