#include template auto get_cost(const T &); template using Vertex = typename Graph::vertex_descriptor; template using Label = std::tuple>; template struct Label1: std::tuple> { }; template struct Label2 { std::tuple> t; }; template struct Label3 { Vertex m_v; }; template auto get_cost(const Label &l) { return std::get<0>(l); } template auto get_cost(const Label1 &l) { return std::get<0>(l); } template auto get_cost(const Label2 &l) { return std::get<0>(l.t); } template auto get_cost(const Label3 &l) { return l.m_v; } struct graph { using vertex_descriptor = unsigned; }; template void callme(const T &t) { get_cost(t); } template<> auto get_cost(const Label &l) { return std::get<0>(l); } // auto // get_cost(const Label &l) // { // return std::get<0>(l); // } int main() { Label l; Label1 l1; Label2 l2; Label3 l3; get_cost(l); get_cost(l1); get_cost(l2); get_cost(l3); callme(l); callme(l1); callme(l2); callme(l3); }