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

1.5k Views Asked by At

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?

1

There are 1 best solutions below

1
On BEST ANSWER

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