Praxeolitic
Praxeolitic

Reputation: 24039

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?

Upvotes: 11

Views: 780

Answers (1)

skypjack
skypjack

Reputation: 50540

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.

Upvotes: 8

Related Questions