I need a macro/templated function that will wrap function call of some method on specific object, ie
a.Destroy()
where a can be of any type as well as Destroy and Destroy may or may not take 0 to n parameters. Inside this wrapper I need to do some checks.
I would like to be able to call this function as a wrapper:
DESTROY_CHECK(a.Destroy(p1,p2,...))
or
DESTROY_CHECK(a, Destroy(p1,p2,...))
How can I achieve this?
You can consider variadic macro :
#define identifier( parameters, ... ) replacement-list
... defines a function-like macro with variable number of arguments. The additional arguments can be accessed using
__VA_ARGS__
identifier, which is then replaced with arguments, supplied with the identifier to be replaced.
#define DESTROY_CHECK(x, ...) assert(x.Destroy(__VA_ARGS__))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.