I was given a piece of code that uses void()
as an argument. The code doesn\'t compile... obviously?
Can we instantiate anything of type void
You can use void()
as a callable type, as an example std::function
is a valid statement.
Moreover, as from 8.3.5/4:
A parameter list consisting of a single unnamed parameter of non-dependent type void is equivalent to an empty parameter list.
That means that this is valid:
template
struct F;
template
struct F { };
int main () {
F s;
}
Here you are not instantiating anything of type void
, but you are using it (let me say) as a parameter list of a callable type.
Not sure if this replies to your question, I've not clear what the question actually is.