I saw such codes in LLVM source codes:
template <typename PassT, typename IRUnitT, typename AnalysisManagerT,
typename... ArgTs, size_t... Ns>
typename PassT::Result
getAnalysisResultUnpackTuple(AnalysisManagerT &AM, IRUnitT &IR,
std::tuple<ArgTs...> Args,
std::index_sequence<Ns...>) {
(void)Args;
return AM.template getResult<PassT>(IR, std::get<Ns>(Args)...);
}
It seems not to need to explain the context, because all of the arguments are template arguments. What confuses me is the body of this function. First, I really can't get what does the first statement do:
(void)Args;
To my knowledge, this just cast Args
to void to a temporary variable. And the temporary variable will be desconstructed immediately after this statement. It seems like totally meanningless.
And the second statement confuses me about its grammer:
return AM.template getResult<PassT>(IR, std::get<Ns>(Args)...);
I really don't know what is the meaning of .template
stand for. I searched .template
in the search engine but get nothing. I don't know what does the .template
do here. And I am wondering why don't implement it just like:
return AM.getResult<PassT>(IR, std::get<Ns>(Args)...);
What's the difference?