有没有办法在C++中装饰函数或方法,如python风格?
@decorator
def decorated(self, *args, **kwargs):
pass
Run Code Online (Sandbox Code Playgroud)
以宏为例:
DECORATE(decorator_method)
int decorated(int a, float b = 0)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
要么
DECORATOR_MACRO
void decorated(mytype& a, mytype2* b)
{
}
Run Code Online (Sandbox Code Playgroud)
可能吗?