std::optional specialization for reference types(引用类型的 std::optional 特化)
问题描述
为什么std::optional(目前libc++中的std::experimental::optional)没有引用类型的特化(与 boost::optional 相比)?
Why std::optional (std::experimental::optional in libc++ at the moment) does not have specialization for reference types (compared with boost::optional)?
我认为这将是非常有用的选择.
I think it would be very useful option.
在STL中是否有一些对象引用可能已经存在的对象语义?
Is there some object with reference to maybe already existing object semantics in STL?
推荐答案
When n3406(提案的第 2 修订版)进行了讨论,一些委员会成员对可选的参考资料感到不舒服.在 n3527 (修订版 #3),作者决定将可选引用作为辅助建议,以增加获得批准的可选值并将其放入 C++14 的机会.虽然由于其他各种原因,可选没有完全进入 C++14,但委员会并没有拒绝可选引用,并且如果有人提出它,将来可以自由添加可选引用.
When n3406 (revision #2 of the proposal) was discussed, some committee members were uncomfortable with optional references. In n3527 (revision #3), the authors decided to make optional references an auxiliary proposal, to increase the chances of getting optional values approved and put into what became C++14. While optional didn't quite make it into C++14 for various other reasons, the committee did not reject optional references and is free to add optional references in the future should someone propose it.
这篇关于引用类型的 std::optional 特化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:引用类型的 std::optional 特化
基础教程推荐
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
