On a whim, I tried to define the main function as a template function using clang 2.9:
template <typename T = void>
int main(int argc, char **argv)
{
}
and received the following error.
error: 'main' cannot be a template
int main(int argc, char **argv)
^
Does anyone know what section of the standard forbids this, and what the relevant text is?
Well, how about this (3.6.1):
Since templates are not functions, I don’t think you have any choice in the matter. In particular, the function has to be
main, notmain<>as in your example; and yourmainisn’t a function, but a template, precluding the existence of another function calledmain.