What does <void (void)> mean in template arguments

I found this code in the project I am working on:

template<typename T> class SomeClass { }; typedef SomeClass<void(void)> SomeType; 

What does the <void(void)> construct mean? Could you explain a simple example of how such a construction can be used?

+4
source share
2 answers

This means that the type parameter is a type of function (note, not the function pointer, but the type of function), which takes no parameters and does not return a value.

You can even define function parameters this way:

 void f (void(void)); 

This will decay to the function pointer during transmission (just like an array parameter decays to a pointer).

+6
source

T Here is a function type that returns nothing and takes no arguments.

+1
source

All Articles