mardi 28 mai 2019

How to switch templates in C++11 at runtime?

I created a Socket Wrapper. It can be instantiated with two templates:

Socket<asio::ip::udp>
Socket<asio::ip::tcp>

In a Singleton class I want to instantiate one of the two, but I get a runtime parameter which makes the choice. How do I instantiate one of the tow at runtime?

I'm aware of boost::variant, is there a way without?

Aucun commentaire:

Enregistrer un commentaire