Advertisement
Masadow

How to avoid variadics

Nov 5th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. class DiscordInterface : public NetworkInterface
  2. {
  3. public:
  4.     struct Options {
  5.         const char *client_id;
  6.     };
  7.  
  8. public:
  9.     DiscordInterface(Options &options);
  10.     ~DiscordInterface();
  11. };
  12.  
  13. //Some other class's method
  14. template<class NetworkClass>
  15. void initNetwork(typename NetworkClass::Options opt)
  16. {
  17.     _network = std::make_unique<NetworkClass>(opt);
  18. }
  19.  
  20. //Caller
  21. game.initNetwork<DiscordInterface>({.client_id = "5090046****195668"});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement