I've been reading a lot of info, but templates are really too new for me at the moment, and I can't find any examples similar to what I'm trying to do.
Basically I have a template container defined like this:
template <class CMissile_Type>
class CMissileManager
{
std::vector<CMissile_Type> missiles;
};
The idea is that I can create different containers of arbitrary missile types.
e.g. CMissileManager<CMaverick> mavericks;
CMissileManager<CSidewinder> sidewinders;
But now I would like to create a static function which takes two arbitrary missile types and checks for collisions between them. Ideally it should be called something like this:
CMissileManager::HandleCollisions<CMaverick,CSidewinder>(mavericks,sidewinders);
so inside the CMissileManager class I defined it like this:
template <class CMissile_Ty1, class CMissile_Ty2>
static void HandleCollisions(CMissileManager<CMissile_Ty1>& m1, CMissileManager<CMissile_Ty2>& m2)
{
// stuff
}
but understandably it's still asking me for the original template argument when I call the function, i.e. it expects something like this:
CMissileManager<CMaverick>::HandleCollisions<CMaverick,CSidewinder>(mavericks,sidewinders);
since it's part of the original 1 argument template, right?
So is there any way I can get rid of the initial argument? Either by removing the need for it altogether or by passing in an empty argument?
I've been trying to use specialisation but I don't want to create a new template class just for one function. And now it's just getting really confusing..