Hello folks,<div><br></div><div>This patch adds a generic collection of class templates to the LLVM ADT for building variadic-like functions in C++98. The idea, from the comments, is:</div><div><br></div><div><div>/// Suppose we need a variadic function like this:</div>
<div>///</div><div>/// ResultT Foo(const ArgT &A_0, const ArgT &A_1, ..., const ArgT &A_N);</div><div>///</div><div>/// Instead of many overloads of Foo(), we only need to define a helper</div><div>/// function that takes an array of arguments:</div>
<div>///</div><div>/// ResultT FooImpl(const ArgT *const Args[], int Count) {</div><div>/// // 'Count' is the number of values in the array; 'Args[i]' is a pointer</div><div>/// // to the i-th argument passed to Foo(). Therefore, write '*Args[i]'</div>
<div>/// // to access the i-th argument.</div><div>/// ...</div><div>/// }</div><div>///</div><div>/// and then define Foo() like this:</div><div>///</div><div>/// const VariadicFunction<ResultT, ArgT, FooImpl> Foo;</div>
</div><div><br></div><div>We used this pattern extensively to build up the AST matcher library on top of Clang (and so I've included cfe-commits in case anyone there is interested). In preparation for mailing patches for those matchers, I'm sending a patch that just adds the generic utility to the ADT library as that seems like a natural home for it.</div>
<div><br></div><div>Previous versions of this bit of helper code used a fully expanded source file that would be hard to maintain. I was worried about using the preprocessor to expand these constructs, but it turned out *much* easier than I had feared, and I think the result is much easier to read and maintain. That said, if anyone dislikes the preprocessor hammering, I'm happy to switch to a more manually expanded form.</div>
<div><br></div><div>I've also included Doug so that he can rant about adding hacks to LLVM/Clang to work around the absence of variadic templates. ;]</div>