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