如何在C 中调用此lambda功能
How to call this Lambda function in C++
i在受保护的void 函数
class Tetris: protected TetrisArea<true>
{
public:
Tetris(unsigned rx) : TetrisArea(rx), seq(),hiscore(0),hudtimer(0) {}
virtual ~Tetris() { }
protected:
// These variables should be local to GameLoop(),
// but because of coroutines, they must be stored
// in a persistent wrapper instead. Such persistent
// wrapper is provided by the game object itself.
Piece seq[4];
lambda功能,
auto fx = [&seq]() { seq[0].x=4; seq[0].y=-1;
seq[1].x=Width; seq[1].y=Height-4;
seq[2].x=Width+4; seq[2].y=Height-4; };
所以这是问题。我有这些错误:
error: capture of non-variable 'Tetris::seq'
auto fx = [&seq]() { seq[0].x=4; seq[0].y=-1;
error: 'this' was not captured for this lambda function
auto fx = [&seq]() { seq[0].x=4; seq[0].y=-1;
..,以及随后在功能中的seq [n]引用。
我试图直接在受保护的void 函数中键入代码,但是尽管它编译了,但它似乎并不能正常工作,因为该程序来自他的Tetris DOS游戏中的YouTube Channel Bisqwit。
时,您会尝试捕获对象的成员而不捕获对象本身。将[&seq]
更改为[this]
,看看会发生什么。
相关文章:
- "lambda capture"正常功能?
- 传递具有移动捕获功能的 lambda
- Lambda的功能C++奇怪的行为
- 将带捕获功能的 lambda 传递给模板化函数
- 基于lambda arity的专门功能模板
- 使用lambda在功能指针铸造时双免费
- 如何将功能机体转换为lambda
- 如何在C 中调用此lambda功能
- 如何将通用lambda传递到功能中
- 为什么在传递lambda而不是功能指针时不能推断模板参数
- 如何使用C lambda将成员功能指针转换为普通功能指针,以用作回调
- 如何将lambda功能传递给通用参数作为参数
- 未评估上下文中的默认模板参数和 lambda:错误还是功能?
- 为什么我的按钮类项目共享相同的lambda功能
- 用C 中的lambda替换功能
- Lambda通过参考传递的功能
- 如何否定lambda功能结果
- 如何更新嵌套lambda功能(C )中的变量
- 嵌套C lambda功能的标题
- Lambda功能,防止分段故障