1

I am trying to make some magic function that can handle unlimited arguments(like in printf) and different types, like:

MagicFun(signed int(-1), "Hello!", __int16(200), glm::vec2(2, 2));

And I want that function to detect the type of it like if its int, const char* or vec2/3... and I want to get the values of them.

Is it really possible? I heard about template <typename T> but I am in a confusion about how do I use it. Thanks.

viktor.488
  • 115
  • 5
  • 4
    You could use a [variadic template](https://en.cppreference.com/w/cpp/language/parameter_pack) – Cory Kramer Nov 25 '19 at 17:50
  • 4
    Yes, you can. See https://en.cppreference.com/w/cpp/language/parameter_pack. – R Sahu Nov 25 '19 at 17:50
  • Reading more about templates might be a good start, because then you can continue to *template parameter packs* which could help solve your problem. – Some programmer dude Nov 25 '19 at 17:50
  • Possible duplicate of [What are the rules for the "..." token in the context of variadic templates?](https://stackoverflow.com/questions/17652412/what-are-the-rules-for-the-token-in-the-context-of-variadic-templates) – Davis Herring Nov 26 '19 at 14:45

0 Answers0