Increase verbosity of size static asserts #256
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Size static asserts currently tell you the type and the expected size in the log. This is a bit limited as the only bit of invisible information there is the actual size. Layer the static assert behind a struct so the error message is more descriptive.
Annoyingly this does make the message more verbose (3 "lines" of errors rather than 1). I think we can get it back down to 1 if a macro is used to construct a custom static assert message, but this way seemed more C++ friendly.
Test plan
New example:
Shows the two numbers in the first static assert. The middle "note" gives all of the information in one place (name, actual size, expected size). The bottom one is useless.
Old example: