引用类型的 std::optional 特化

std::optional specialization for reference types(引用类型的 std::optional 特化)

本文介绍了引用类型的 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 特化

基础教程推荐