google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.17k stars 3.24k forks source link

Fix operator== for flatbuffers::optional #8223

Closed mikudehuane closed 4 months ago

mikudehuane commented 8 months ago

flatbuffers::Optional behaves different from std::optional when both lhs and rhs are nullopt

flatbuffers::Optional<int> lhs = flatbuffers::nullopt;
flatbuffers::Optional<int> rhs = flatbuffers::nullopt;
std::cout << (lhs == rhs) << std::endl;  // false

std::optional<int> lhs = std::nullopt;
std::optional<int> rhs = std::nullopt;
std::cout << (lhs == rhs) << std::endl;  // true

This pull request simply modifies operator==

google-cla[bot] commented 8 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.