Conversation
Member
|
Yes this is a good idea, and we could add a ... or, we could directly call namespace simdjson {
// ...
template <typename T>
consteval auto is_convertible_type() {
for (std::meta::info field : nonstatic_data_members_of(^T)) {
if (deserializable(type_of(field))) return false;
}
return true;
}
template <typename T>
requires (is_convertible_type<T>()) // all of its fields MUST be deserializable as well
constexpr error_code tag_invoke(deserialize_tag, auto& value, T& out) {
return [: expand_all(nonstatic_data_members_of(^T)) :] >> [&]<auto... members>{
simdjson::ondemand::object obj;
if (auto error = value.get_object().get(obj); error) {
return error;
}
return obj.extract(to(std::meta::identifier_of(members), out.[:members:])...);
};
}
} |
Member
Author
|
I have some concerns regarding the performance of extract, see simdjson/simdjson#2274 |
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.
Suppose that you want to do something of the sort...
You have a function (@the-moisrex) that can be called like so...
given...
See simdjson/simdjson#2247
Right?
Now can I do it by reflection?
That is. I have
my_struct xand I want to automatically, at compile time, call...... without having to write
"key1"and so forth.See #29
The answer is positive.
All I need is a helper function which (by reflection) turns any struct into a tuple (
struct_to_tuple)... that is, something that is effectively capable of the following...... and then I can call
std::apply...