6

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?

stijn
  • 34,664
  • 13
  • 111
  • 163
vladon
  • 8,158
  • 2
  • 47
  • 91

1 Answers1

8

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

EricWF
  • 1,005
  • 7
  • 8
  • This could use a clarification, that 'it' refers to the standards ban on reference types in `std::optional` – sp2danny Jun 12 '19 at 10:28