I know that you can use static_cast<void>
, but it just seems too verbose for me, and not reflecting the original intent that I want to discard a return value, not to cast it to anything.
Recently I stumbled upon std::ignore
, which can accept a value of any type, the name is clear and readable, and to me it seems fitting.
I know that the initial intent was to use std::ignore
alongside with std::tie
to discard any unwanted values, but I guess the original intent of static_cast
was to actually cast values for some better reasons than discarding values so the compiler won't complain.
So, is it OK to use std::ignore
for the purpose I described in the question?
For example:
std::ignore = std::transform(...);