Jump to content
  • Advertisement
Sign in to follow this  
lride

decltype

This topic is 1855 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

I'm trying to make a convenient function template to retrieve different type of objects using tuple.


class Apple;
class Banana;
class Cherry;

typedef std::tuple<Apple, Banana, Cherry> Fruits;
Fruits fruits;

enum
{
  APPLE,
  BANANA,
  CHERRY
};


//When I try to use this, I get "Failed to specialize function template" error
template<std::size_t i>
decltype(std::get<i>(fruits)) getFruit()
{
   return std::get<i>(fruits)
}
ex) getFruit<APPLE>(); //error

 

 

 

 

 

 

 


 

Edited by lride

Share this post


Link to post
Share on other sites
Advertisement
I think the class types that you use in the tuple has to be defined and not just forward declared.

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!