I am just learning data structure of graph.And i'm trapped in such a situation.
I have written my Graph class like
template <char... Args>
class Graph{};
where the Args of type char means the vertex of my Graph.
However, when i want to search in my Graph,i need to insert each vertex of char and its index in Args as a std::pair<char,size_t> into a std::map<char,size_t>.What i have done is that i constructed a std::tuple like
std::tuple<decltype(Args)...> t(Args...);
Then i want to do like this
for(size_t i =0;i<sizeof...(Args);++i)
Map.insert({0,std::get<i>(t)});
which Map means a std::map<size_t,char>.
It certainly doesn't work because the i used in std::get<> is not a constexpr.
What can i do now is to insert into the Map one by one like
Map.insert({0,std::get<0>(t)});
Map.insert({1,std::get<1>(t)});
Map.insert({2,std::get<2>(t)});
But it is not the result i want.So are there any other solutions for me?
Thanks for any help!