Jump to content
  • Advertisement
Sign in to follow this  
ApochPiQ

C++ Variadic templates and tuples of wrapped types

This topic is 378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!