问题
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?
回答1:
Is this reflective of what might make it into the standard?
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.
Note that you can still work around it by using std::reference_wrapper
, as mentioned by @bobah in the comments.
来源:https://stackoverflow.com/questions/37905409/will-stdexperimentaloptional-support-references