Let's say I have a Server class, with a template argument. I need to ensure that the argument is a subclass of another Client class. Is it possible in C++?
For example, given something like this:
template <typename CLIENT>
class Server {
void addClient(CLIENT client);
};
I'm expecting something like this:
template <typename CLIENT : Client>
class Server {
void addClient(CLIENT client);
}
I want to have LoginServer and GameServer, both based on Server class, but each will work with different Client subclass.
class LoginServer : public Server<LoginClient>
class GameServer : public Server<GameClient>
I don't want to retype all Client types to LoginClient inside the LoginServer, otherwise compiler will throws error because of undefined methods etc. (LoginClient can have methods that Client hasn't, it's subclass).