Jump to content
  • Advertisement
Sign in to follow this  
lride

decltype

This topic is 2028 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!