将std :: experimental :: optional<支持参考? [英] Will std::experimental::optional<> support references?

查看:81
本文介绍了将std :: experimental :: optional<支持参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前, boost :: optional<> 支持引用,但libstdc ++上我系统上的 std :: experimental :: optional<> 尚不支持.这是否反映了它可能成为标准的原因?

At the moment, boost::optional<> supports references but the std::experimental::optional<> on my system from libstdc++ does not. Is this reflective of what might make it into the standard?

我知道,可选建议书的作者将可选参考文献作为单独的建议书分离出来,以便主要的可选建议书有更大的机会被接受.关于可选引用的建议是否被拒绝或停止了工作?

I know that the optional proposal author spun off optional references as a separate proposal so that the main optional proposal would have a better chance of being accepted. Was the proposal for optional references rejected or did work on it stop?

推荐答案

这是否反映了它可能成为标准的原因?

Is this reflective of what might make it into the standard?

从工作草案中摘录( [20.5.2/1] ):

From the working draft ([20.5.2/1]):

需要为引用类型实例化可选模板的程序格式不正确.

A program that necessitates the instantiation of template optional for a reference type [...] is ill-formed.

我想这是对您的问题的答复.

I guess this replies to your question.

请注意,您仍然可以使用 std :: reference_wrapper 来解决该问题,如@bobah在评论中所述.

Note that you can still work around it by using std::reference_wrapper, as mentioned by @bobah in the comments.

这篇关于将std :: experimental :: optional&lt;支持参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆