Skip to content

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

@boyism80

Description

@boyism80

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);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions