google / flatbuffers

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

NativeTables derive from an empty base class, for no clear reason [C++] #8406

Open DaveBrantonCTCT opened 6 days ago

DaveBrantonCTCT commented 6 days ago

All the generated T suffix Native Table types for the C++ Object API derive from flatbuffers::NativeTable. There is no use-case for this that I can discern in the generated code, and the comment next to this empty class states

// Contains no functionality, purely documentative.
struct NativeTable {};

The existence of this base class means that the native table types cannot be brace-initialised without adding an additional {} at the start of the brace-initialiser list - and even that's only true since C++17.

Perhaps this empty base class could be removed, as it contains no functionality and hinders some use-cases? Since no constructor is provided for the NativeTable types, brace-initialisation is the only inline construction option for these classes.