- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
auto
引入关键字以简化代码。特别是,无需使用丑陋的 std::vector<MyType>::iterator
,迭代 STL 容器变得更容易和更好看。每次你想遍历它时的语法。但是,仍然可以在不使用 auto
的情况下编写代码。这将做完全相同的事情。
现在(我认为)如果没有 auto
就无法使用某些功能,特别是结构化绑定(bind):
std::tuple<int, int&> f();
auto [x, y] = f();
那么,两个问题:
[x, y]
,我说得对吗?不使用auto
(仍在使用结构化绑定(bind))?有没有办法明确地初始化它:*explicit_type* [x, y] = f();
?auto
?最佳答案
Am I correct that there's no way to initialize
[x, y]
without usingauto
(still using structured bindings)?
是的,这是正确的。语法没有指定其他方式,例如可以看出 here .
What other features require using
auto
?
一个经典的例子应该是(通用的)lambda 表达式:
auto lambda = [](auto&&...) { };
但正如评论中所述,还有一些其他示例。
关于c++ - 如果没有 'auto' ,是否有我无法使用的功能(特别是结构化绑定(bind))?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47125892/
我已经可以在其中输入一些附加文本了mydomain/wiki/Special:UserLogin。我添加了一句话: In order to apply for an account send an m
有人可以解释以下脚本输出背后的逻辑吗? import numpy if(numpy.dtype(numpy.float64) == None): print "Surprise!!!!" 谢谢
是我还是 gmail bulls**t?在 outlook/浏览器上,我的电子邮件是完美的,但在 gmail 上,2 个表之间有一个空间,为什么?!?图片:http://i.imgur.com/srJ
我是一名优秀的程序员,十分优秀!