Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will std::experimental::optional<> support references?

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?

like image 311
Praxeolitic Avatar asked Jun 19 '16 08:06

Praxeolitic


1 Answers

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.

like image 132
skypjack Avatar answered Oct 03 '22 10:10

skypjack