c++ - Variadic function calling a variadic macro -
i have inline variadic function inline int foo(...)
i need foo() call macro (let's call macro), variadic.
need foo() pass input parameters macro. redefining foo() macro easy solution because of __va_args__ option, need foo() return value.
note: trying interface 2 parts of written code , not allowed change them. foo(...) used in first part of code , macro defined in second part. thing supposed define foo() uses macro , can't because both variadic.
make foo macro contains lambda returns value, , invokes lambda.
#define foo(...) \ [&](auto&&...args){ \ /* args, or __va_args__ */ \ macro(__va_args__); \ return 7; \ }(__va_args__) now int x = foo(a, b, c); both call lambda inside foo, , inside lambda call macro on (a, b, c), , can return value.
i pity whomever maintains code next.
Comments
Post a Comment