C++17 有带初始化器的选择语句
status_code foo() {
if (status_code c = bar(); c != SUCCESS) {
return c;
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
我想写一个while-loop 和一个范围仅限于循环的变量,并且在第一次迭代之前只初始化一次。
// fake example, doesn't compile, is doable in many ways
while (bool keep_trying = foo(); keep_trying) {
// do stuff
if (something)
keep_trying = false;
}
Run Code Online (Sandbox Code Playgroud)
在 C++17 或 C++2a 中有什么可以解决的吗?
我正在运行我的第一个renode 演示。stm32f4_discovery.resc到目前为止一切顺利,我在 sysbus.uart4 窗口中看到了来自 Contiki 的公告,并在终端中看到了以太网数据包。
我怎样才能“推动”UserButton并“查看”是否UserLED打开?
stm32f4_discovery.repl:
UserButton: Miscellaneous.Button @ gpioPortA
-> gpioPortA@0
UserLED: Miscellaneous.LED @ gpioPortD
gpioPortD:
12 -> gpioPortD@0
Run Code Online (Sandbox Code Playgroud)
到目前为止我发现的最接近的例子是I2C 温度。
demo-.elf 的来源可以在某处找到吗?
http://antmicro.com/projects/renode/stm32f4discovery.elf-s_445441-and.so.on ...
这个有效:
d1:`t1`t2`idx!(2017.01.01;2018.01.01;42)
Run Code Online (Sandbox Code Playgroud)
但是这个失败了(类型错误):
d2:()!()
d2[`t1]:2017.01.01
d2[`t2]:2018.01.01
d2[`idx]:42
Run Code Online (Sandbox Code Playgroud)
有解决方法吗?为了更好的可读性,我想逐键(逐行)填充字典。实际上,它更长。