[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 <[email protected]>
NOKEYCHECK=True
GitOrigin-RevId: 63ea393f969b9fe8be3f80b38eb2b47063aa6d40
5 files changed