[libc++][optional] Applied `[[nodiscard]]` (#170045)
`[[nodiscard]]` should be applied to functions where discarding the
return value is most likely a correctness issue.
- https://libcxx.llvm.org/CodingGuidelines.html
- https://wg21.link/optional
---------
Co-authored-by: William Tran-Viet <wtranviet@proton.me>