Note, I'm aware of this question, but what I want is different.
My current code (the sum total of my main.cpp
) looks like this standard boilerplate for making a class into an executable:
#include <MyHeader.h>
int main(int argc, char **argv)
{
return MyTemplate<MyClass>(argc, argv);
}
This works quite happily, but it would be even better if I could do just:
#include <MyMainWrapper.h>
// UPDATE: commented out... MyMainWrapper<MyTemplate, MyClass> main;
MyMainWrapper<MyTemplate, MyClass> someObjectThatGeneratesMain;
And that would expand to the code above. It could of course be easily done with a macro, but I'm interested to see if there is a template solution, or if not, why not?
UPDATE: I imagine a function template that might somehow do:
template<...>
extern "C" int main(int argc, char **argv)
{
//...
}
But I see that templates cannot be extern "C"
.