Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] can't insert null value in vector #8424

Open
boyism80 opened this issue Oct 10, 2024 · 0 comments
Open

[C++] can't insert null value in vector #8424

boyism80 opened this issue Oct 10, 2024 · 0 comments

Comments

@boyism80
Copy link

boyism80 commented Oct 10, 2024

it's same issue (#7846) but not fixed in c++

table nullable_uint {
  value: uint;
}

table ping {
  id_list: [nullable_uint];
}
auto CreateId(flatbuffers::FlatBufferBuilder& builder) const
{
    auto result = std::vector<flatbuffers::Offset<nullable_uint>>();
    for (auto& x : this->id)
    {
        if (x.has_value())
        {
            auto nullable_builder = nullable_uintBuilder(builder);
            nullable_builder.add_value(x.value());
            result.push_back(nullable_builder.Finish());
        }
        else
        {
            result.push_back(0);
        }
    }

    return builder.CreateVector(result);
}
boyism80 added a commit to boyism80/flatbuffers that referenced this issue Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant