Skip to content

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

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

Closed
boyism80 opened this issue Oct 10, 2024 · 2 comments
Closed

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

boyism80 opened this issue Oct 10, 2024 · 2 comments
Labels

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
Copy link
Contributor

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Apr 10, 2025
Copy link
Contributor

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant