我在assert.h中使用断言宏我已经定义了lambda来执行断言检查.
int val1 = 0;
int val2 = 1;
const auto check = [val1,val2]()-> bool
{
return val1 < val2;
};
// no error for this call
assert(check() && "Test is failed");
// no error for this call
assert([=]()-> bool
{
return val1 < val2;
}() && "Test is failed");
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)//compile error for this call "too many arguments provided to function-like macro invocation" assert([val1,val2]()-> bool { return val1 < val2; }() && "Test is failed");
为什么我要来
提供给类似函数的宏调用的参数太多了
当我使用assert宏并在捕获列表中定义带有多个参数的lambda时,编译错误?