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? I believed the answer was no, with the exception of a void*. For example:
- Writing the function
void askVoid(void param) {}errors:
A parameter may not have
voidtype
- Writing the function
void askNaught() {}and calling it with askNaught(void())` errors:
error C2660:
takeNaught: function does not take 1 arguments
- Writing the templatized function
template <typename T> void takeGeneric(T param) {}and calling it withtakeGeneric(void())errors:
error C2893: Failed to specialize function template
void takeGeneric(T)
- Declaring
void voidTypeerrors:
Incomplete type is not allowed
- Declaring
auto autoVoid = void()errors:
Cannot deduce
autotype
- Declaring
void* voidPtrworks fine, butremove_pointer_t<decltype(voidPtr)> decltypeVoiderrors:
error C2182:
decltypeVoid: illegal use of typevoid
That's it, right? There is no place for void() in C++ is there? This is just bad code I've been given, right?