Possible Duplicate:
C++ invoke explicit template constructor
First imagine I have a class Data with a templated member function :-
class Data
{
public:
template <class Loader> void load(const std::string& filename);
};
I can use this like this -
Data data;
data.load<SomeLoader>(filename);
and all works fine. I can select at compiler time via the template parameter which class I want my Data object to use to load some data.
However I can't work out how to do this with constructors...
class Data
{
public:
template <class Loader> Data(const std::string& filename);
};
That seems to compile perfectly well, but I can't seem to work out how to actually call the function.
Data<SomeLoader> data;
That doesn't work because that would invoke a class template, not a templated constructor.
Is there some syntax I'm missing here? ( If I add a constructor paramater of SomeLoader type, then the compiler correctly infers the class to use, but that's not what I need to do here)