Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Variadic templates and tuples of wrapped types

$
0
0
What I want to do is make a variadic class template that instantiates (as a member variable) a std::tuple of objects, one entry in the tuple for each type in the parameter pack of the variadic template. There is one wrinkle: the tuple is not composed of the raw types directly, but rather a map of them: template <typename... Ts> class Bag { // This is fine: template <typename T> using TypedMap = std::map<std::string, T>; // This is the tricky bit (obviously wrong as written): std::tuple<TypedMap<T>, TypedMap<...>> Storage; }; I'm having an end-of-week mental block on the best approach for this. I'm close to just defining my own recursive template instead of using std::tuple directly, and writing the glue by hand. Any better suggestions?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>