payload: {"action":"opened","issue":{"url":"https://api.github.com/repos/google/flatbuffers/issues/5285","repository_url":"https://api.github.com/repos/google/flatbuffers","labels_url":"https://api.github.com/repos/google/flatbuffers/issues/5285/labels{/name}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/5285/comments","events_url":"https://api.github.com/repos/google/flatbuffers/issues/5285/events","html_url":"https://github.com/google/flatbuffers/issues/5285","id":431989469,"node_id":"MDU6SXNzdWU0MzE5ODk0Njk=","number":5285,"title":"Create() method of tables with enum vectors takes flatbuffers::Offset<flatbuffers::Vector<int8_t>> rather than flatbuffers::Offset<flatbuffers::Vector<MyEnum>> [C++, HEAD]","user":{"login":"T045T","id":871405,"node_id":"MDQ6VXNlcjg3MTQwNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/871405?v=4","gravatar_id":"","url":"https://api.github.com/users/T045T","html_url":"https://github.com/T045T","followers_url":"https://api.github.com/users/T045T/followers","following_url":"https://api.github.com/users/T045T/following{/other_user}","gists_url":"https://api.github.com/users/T045T/gists{/gist_id}","starred_url":"https://api.github.com/users/T045T/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/T045T/subscriptions","organizations_url":"https://api.github.com/users/T045T/orgs","repos_url":"https://api.github.com/users/T045T/repos","events_url":"https://api.github.com/users/T045T/events{/privacy}","received_events_url":"https://api.github.com/users/T045T/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-04-11T12:13:03Z","updated_at":"2019-04-11T12:13:03Z","closed_at":null,"author_association":"NONE","body":"It's not possible to create a table that has a vector of enum values without casting those values to the enum's underlying type manually:\r\n\r\ntest.fbs\r\n```\r\nenum Color : byte { Red , Green, Blue }\r\ntable Colors {\r\n  color_values:[Color];\r\n}\r\n```\r\n```\r\n$ flatc -c test.fbs\r\n```\r\ntest.cc\r\n```\r\n#include \"test_generated.h\"\r\n#include \"flatbuffers/flatbuffers.h\"\r\n#include <vector>\r\n\r\nint main(int argc, char** argv) {\r\n  flatbuffers::FlatBufferBuilder builder;\r\n\r\n  std::vector<Color> colors;\r\n  colors.push_back(Color_Red);\r\n  auto c = builder.CreateVector(colors);\r\n  builder.Finish(CreateColors(builder,c));\r\n}\r\n```\r\n```\r\n$ g++ test.cc\r\n\r\ntest.cc: In function 'int main(int, char**)':\r\ntest.cc:11:40: error: could not convert 'c' from 'flatbuffers::Offset<flatbuffers::Vector<Color> >' to 'flatbuffers::Offset<flatbuffers::Vector<signed char> >'\r\n   builder.Finish(CreateColors(builder,c));\r\n                                        ^\r\n```\r\n\r\nThis behavior is the same regardless of whether I pass `--scoped-enums` or not.\r\n\r\nWhat's the reasoning behind generating\r\n```\r\ninline flatbuffers::Offset<Colors> CreateColors(\r\n    flatbuffers::FlatBufferBuilder &_fbb,\r\n    flatbuffers::Offset<flatbuffers::Vector<int8_t>> color_values = 0)\r\n```\r\nrather than\r\n```\r\ninline flatbuffers::Offset<Colors> CreateColors(\r\n    flatbuffers::FlatBufferBuilder &_fbb,\r\n    flatbuffers::Offset<flatbuffers::Vector<Color>> color_values = 0)\r\n```\r\n?\r\n\r\nIf compatibility of the generated buffer with other platforms is an issue (which it only is without `--scoped-enums`), can you consider generating casts to and from the underlying type of the enum to the generated code?\r\n\r\nimho, that would be less surprising than the current behavior."}}
other: {"actor":{"display_login":"T045T"}}