Improve C++ output to help with templating?

27 views
Skip to first unread message

James Mansion

unread,
Jun 12, 2016, 4:25:07 PM6/12/16
to FlatBuffers
Is there any particular reason why these functions:

inline const msg::in::Hello *GetHello(const void *buf) { return flatbuffers::GetRoot<msg::in::Hello>(buf); }

inline bool VerifyHelloBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<msg::in::Hello>(); }

inline bool HelloBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier(buf, HelloIdentifier()); }


are free functions rather than static methods of struct Hello?

It would be convenient for template programming to have them as static methods with standard names.  (Would need the Identifier to be static as well)

Wouter van Oortmerssen

unread,
Jun 13, 2016, 4:42:02 PM6/13/16
to James Mansion, FlatBuffers
No particular reason other than that at the time GetHello() seemed more natural than Hello::Get().

I can see there's use cases where having them be static members would be helpful, though probably not worth breaking the API over. We could consider adding them also, and indirecting for the moment.

Note that there is a GetRoot<T>() and VerifyBuffer<T> already, for example, that you can use in your templates.

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages