type like
"1", typeClass1
"2",typeClass2
...
Now depending on the string I want to call the function of mapped type, is it possible to do it using templates and not a if then else tree ?
Looking for one liner or short templated form of the if then else tree I would create matching the string and routing to specific type..
So how to generate the actual map and compressed templates router
You could test something like: template <typename T> void foo(std::string s, T t) { std::map<std::string, T> mp; // ... } And inside the function check for properties of the T using e.g., requires. This page has useful info: https://akrzemi1.wordpress.com/2020/01/29/requires-expression/
You can't use a std::string. You can use a class that you create which has compile time properties that allows string comparison and then use that class as the key for the map
Обсуждают сегодня