<div dir="ltr">I'm curious: did anybody ever consider using variadic templates for the highly redundant overloads in ArgList.cpp? It's a very textbook <a href="http://eli.thegreenplace.net/2014/variadic-templates-in-c/">use-case</a>.<div><br></div><div>"Templates are confusing to many programmers" is a perfectly valid answer.<br><div><br></div><div>Code like seven of these:</div><div><br></div><div><div>Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,</div><div>                         OptSpecifier Id2, OptSpecifier Id3,</div><div>                         OptSpecifier Id4, OptSpecifier Id5,</div><div>                         OptSpecifier Id6, OptSpecifier Id7) const;</div></div><div><br></div><div>...could be replaced by code that looks something like this:</div><div><br></div><div>//In llvm/Option/Option.h</div><div>template<typename Opt><br></div><div>bool Option::matches(T Opt0) const {<br></div><div>  return Option::matches<OptSpecifier>(Opt0);</div><div>}</div><div><br></div><div>template<typename T, typename... Opts><br></div><div>bool Option::matches(T Opt0, Opts... opts) const {<br></div><div>  return Option::matches<OptSpecifier>(Opt0) || matches(opts...);<br></div><div>}</div><div><br></div><div>//In llvm/Option/ArgList.cpp</div><div>template<typename... Ids></div><div><div>Arg *ArgList::getLastArg(Ids... ids) const {</div></div><div>[...loop here...]</div><div>  if((*it)->getOption().matches(ids...))</div><div>  Res = *it;</div><div>  Res->claim();</div><div>[etc...]</div><div><br></div><div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Sincerely,<br>Alexander Riccio<br>--<br>"Change the world or go home."<div><a href="http://about.me/ariccio" target="_blank">about.me/ariccio</a></div><div><a href="http://about.me/ariccio" target="_blank"><br></a></div><div>If left to my own devices, I will build more.</div><div>⁂<br></div></div></div></div></div></div></div>
</div></div></div>