I have a constructor prototype that looks like:
template <typename type_position> window(
const int size[2],
const char* caption="Window", const SDL_Surface* icon=NULL,
bool fullscreen=false, bool vsync=true, bool resizable=false, int multisample=0,
type_position position=type_position(0)
)
I then want to construct an instance:
new window(screen_size,"My Window",NULL,fullscreen);
The issue (I assume) is that T
cannot be specified explicitly (i.e., it could be int
or long
or short
, etc.). I get the error:
error C2660: 'window' : function does not take 4 arguments
I then tried to specify the type:
new window<int>(screen_size,"My Window",NULL,fullscreen);
But that doesn't work:
error C2512: 'window' : no appropriate default constructor available
error C2062: type 'int' unexpected
I've done some research, and about the closest I could get was similar to that is the question "C++ template function default value", except that in my case, the template parameter can be inferred from the first argument.
So, am I stuck or is there something I'm missing?