Conversation
Member
|
@FranciscoThiesen Let me prepare a PR on top of your PR. |
…nd using concepts instead! Credit goes to Lemire for pointing this out and suggesting a concepts based approach here.
Reflection based serialization now relying on optional concept
Member
Author
|
@lemire do you feel that this one is good to go now that we have concepts for optional types? |
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.
[AI generated summary]
🚀 C++26 Static Reflection Features Added
Files Modified:
What was added:
Example:
std::optionalstd::string opt = "hello";
// Serializes to: "hello"
std::optionalstd::string null_opt;
// Serializes to: null
Files Modified:
What was added:
Example:
std::unique_ptr ptr = std::make_unique();
// Serializes the pointed-to object
std::unique_ptr null_ptr;
// Serializes to: null
Files Modified:
What was added:
Key Implementation:
// Serialization using P2996R12 expand pattern
[:expand(std::meta::enumerators_of(^^T)):] >> [&]{
if (e == [:enum_val:]) {
result = std::meta::identifier_of(enum_val);
}
};
// Deserialization
[:expand(std::meta::enumerators_of(^^T)):] >> [&]{
if (!found && str == std::meta::identifier_of(enum_val)) {
out = [:enum_val:];
found = true;
}
};
Example:
enum class Color { Red, Green, Blue };
struct Obj { Color color; };
Obj test{Color::Red};
auto json = simdjson::builder::to_json_string(test);
// Result: {"color":"Red"} ✅
std::string input = "{"color":"Blue"}";
auto obj = parser.iterate(input).get();
// Result: obj.color == Color::Blue ✅
Files Modified:
What was fixed:
Files Modified:
What was updated:
Files Created/Modified:
Test Coverage:
📊 Performance Impact
🔧 Compatibility
This branch transforms simdjson's C++26 reflection support from basic struct serialization to a comprehensive type system supporting optionals, smart pointers, and human-readable
string-based enums, making it production-ready for modern C++ applications.