引用类型的 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.
相关文章