Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix
skip_null_membersforglaze_value_twrapping nullable typesFixes #2397
When a struct field uses
glaze::valueto expose a nullable inner type (e.g.std::optional,std::unique_ptr), theskip_null_membersoption was not skipping the field during writing. The null check was only performed on the outer wrapper type, which is not itself nullable.Changes
include/glaze/core/reflect.hppglaze_value_is_nullable<V>()— compile-time check for whether aglaze_value_twraps a nullable inner type.is_glaze_value_field_null<T, I>(value, t)— runtime null check that unwraps the value type and tests the inner value.maybe_skippedto recognize nullable value types so the skip code path is entered.include/glaze/json/write.hpp,cbor/write.hpp,beve/write.hppelse ifbranch in each object-member write loop that calls the new helpers to skip null value-type fields. CBOR and BEVE each have two sites (member-count pass and write pass).Tests
std::optional<int>inner type — null skipped, non-null writtenstd::unique_ptr<int>inner type — exercises the!bool()null-check pathskip_null_members = false— null explicitly written asnull