相关疑难解决方法(0)

在Xcode中定义lambda(assert.h)中的lambda时,为类似函数的宏调用编译错误提供了太多参数[c ++]

我在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)
//compile error for this call "too many arguments provided to function-like macro invocation"
assert([val1,val2]()-> bool
       {
           return val1 < val2;
       }() && "Test is failed");
Run Code Online (Sandbox Code Playgroud)

为什么我要来

提供给类似函数的宏调用的参数太多了

当我使用assert宏并在捕获列表中定义带有多个参数的lambda时,编译错误?

c++ macros lambda xcode c++11

7
推荐指数
1
解决办法
6027
查看次数

标签 统计

c++ ×1

c++11 ×1

lambda ×1

macros ×1

xcode ×1