Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::optional<std::reference_wrapper<T>> - is it OK?

Is

std::optional<std::reference_wrapper<some_type>>

is conforming to the Standard (or draft) of C++17?

The Standard explicitly says, that std::optional for a reference type is ill-formed. But does it include reference_wrapper?

like image 898
vladon Avatar asked Dec 30 '16 08:12

vladon


1 Answers

Yes. That is OK. It does not include reference_wrapper because reference_wapper isn't a reference type. Only actual reference types are disallowed.

like image 192
EricWF Avatar answered Oct 11 '22 16:10

EricWF