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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -