【发布时间】:2016-06-27 17:02:09
【问题描述】:
我正在使用 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");
//compile error for this call "too many arguments provided to function-like macro invocation" assert([val1,val2]()-> bool { return val1 < val2; }() && "Test is failed");
我为什么会得到
提供给类函数宏调用的参数过多
当我使用断言宏并在捕获列表中定义具有多个参数的 lambda 时编译错误?
【问题讨论】:
标签: c++ xcode c++11 lambda macros