为什么不可变 lambda 中的字段在捕获 const 值或 const 引用时使用“const”?
作者:Emil 提问时间:8/11/2021
如问题 lambda capture by value mutable does not work with const &?,当使用其名称或在可变 lambda 中捕获类型的值时,隐藏类中的字段会获...
语言律师 问答列表
作者:Emil 提问时间:8/11/2021
如问题 lambda capture by value mutable does not work with const &?,当使用其名称或在可变 lambda 中捕获类型的值时,隐藏类中的字段会获...
作者:Ángel 提问时间:10/8/2023
我有这个简单的小代码: #include <iostream> int Add (int x, int y) { std::cout << "In Add(), received " <<x<<...
作者:Zebrafish 提问时间:6/5/2022
我遇到了一个有趣的问题,我不明白发生了什么: /* I WANT 6 ELEMENTS */ int lvalue = 6; std::vector<int*> myvector { 6 }; /...
作者:Jan Tušil 提问时间:4/10/2017
C++ 标准明确指出,对于内置赋值运算符,不会引入左操作数的临时值。但是,我认为没有必要。引自 N4296 §13.3.1.2/4: 对于内置赋值运算符,左操作数的转换 限制如下: (4.1) —...
作者:OODAX 提问时间:5/12/2023
volatile int lhs = 1; int rhs = 2; int x = 3; x = lhs = rhs; 同化运算符是否返回 (typeof lhs)rhs ?或者它是否返回 n...
作者:Enlico 提问时间:7/27/2023
只允许使用 5 个标签,但请接受它,因为 c++20 和 c++23 也在列表中,因为我也想知道这些标准,以防自 c++17 以来发生任何变化。 标准是否指定了 a 的两个条目(不是 std::tu...
作者:Enlico 提问时间:3/10/2023
以一个简单的类为例,包装一个 ,int struct Foo { int x; } f; 以及一个包含 和 可以转换为它的类,Foo struct Bar { Foo f; operat...
作者:Zebrafish 提问时间:4/17/2018
当这不能在 C 中编译时,我感到很困惑: int main() { for (int i = 0; i < 4; ++i) int a = 5; // A dependent statement...
作者:R_Kapp 提问时间:6/22/2018
请考虑以下代码: #include <memory> #include <vector> class A { private: std::vector<std::unique_ptr<int>>...
作者:yeputons 提问时间:10/3/2021
请考虑以下 C++ 17 代码: #include <iostream> int read; int main(){ std::ios_base::sync_with_stdio(false); ...