Skip to content

Conversation

@fergushenderson
Copy link
Contributor

Fixes to make SizeVerifier work, to fix #8579.

In particular change all the places in the Flatbuffers library
and generated code that were using Verifier to instead use
VerifierTemplate<TrackBufferSize> and wrap them all inside
template <bool TrackBufferSize = false>.

Also add unit tests for SizeVerifier.

In particular change all the places in the Flatbuffers library
and generated code that were using `Verifier` to instead use
`VerifierTemplate<TrackBufferSize>` and wrap them all inside
`template <bool TrackBufferSize = false>`.

Also add unit tests for SizeVerifier.
@github-actions github-actions bot added c++ codegen Involving generating code from schema labels Oct 27, 2025
@thejtshow
Copy link
Contributor

this looks fine, I'm curious why you chose to template on the bool and not on the verifier everywhere though

@fergushenderson
Copy link
Contributor Author

this looks fine, I'm curious why you chose to template on the bool and not on the verifier everywhere though

I chose to template on the bool since that's the minimum amount of generality needed to cover the cases we want to support; since this is a broadly visible API, I prefer to avoid unnecessary generality in the API which might overly constrain the future evolution of the implementation.

Also, if we template on the verifier, then to do it well, we need to be careful about documenting exactly which properties
we want the verifier type to have, and verifying that the type has those properties, and in the absence of support for C++20 constraints and concepts, that's difficult, and last time I checked, we weren't using C++20 in FlatBuffers yet,
and even if we were, the Google style guide discourages defining concepts in header files.

@thejtshow
Copy link
Contributor

All makes sense. Thank you for sharing your decision and analysis!

@dbaileychess
Copy link
Collaborator

Looks like the generated code must be out dated?

dbaileychess
dbaileychess previously approved these changes Nov 8, 2025
Copy link
Collaborator

@dbaileychess dbaileychess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine as its fixing something. A little verbose now with all the template parameters, I left one comment about maybe shortening it.

I think we should independently look at how the VerifierTemplate base is working, as the size calculation is only affecting a few methods, I'm not totally seeing why the whole class needs to be templated. But we can discuss elsewhere.

@fergushenderson
Copy link
Contributor Author

Looks like the generated code must be out dated?

I think that should be fixed now. Please take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CPP] Unable to pass SIzeVerifier to root verifier

3 participants