On 18 June 2013 08:33, Thomas Heller wrote:
On Mon, Jun 17, 2013 at 11:54 PM, Niall Douglas
wrote: Now, nothing in proposed Boost.AFIO uses variadic templates in a way not replaceable with preprocessor programming. However it very /nearly/ did: I had this neato bit of evil variadic instantiation which let you convert an unknown set of trailing args into a std::tuple<> for storage, then /unpack/ said std::tuple<> back into an unknown set of trailing args, all with perfect forwarding. Effectively it was a compile-time std::function<> implementation.
That is *very* easily achievable with the preprocessor. The outstanding feature here, IMHO, is the perfect forwarding, which is of course not possible with C++03. In any case, I couldn't think of how you'd unpack the tuple to call the function without the preprocessor. Could you please show me a code snippet how this could be done?
Very, very easily, see the apply() example in [intseq.general] in the C++14 draft, taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3658.html Doing that with the preprocessor instead would be ... I don't have a polite way to say it.