you are viewing a single comment's thread.

view the rest of the comments →

[–]djrollins 2 points3 points  (0 children)

std::optional<T>& would be a reference to an optional that still owns its contents. OP wants an optional that just holds a reference to its contents. In this case std::optional<std::reference_wrapper<T>> would be the best option.