Hacker News new | past | comments | ask | show | jobs | submit login

Could this be leveraged to emit a parser that is specialized for the provided type that can be used at runtime? Afaik .NET does something like that using code generators.

The advantage being that the parser is tailored to the specific type that is deserialized and it writes directly to the struct's fields instead of going through some dictionary.




This lib does something like that:

https://github.com/beached/daw_json_link


It seems that you have to maintain hand-coded mappings for each type. Maybe this could be solved by using C++23's compile-time reflections.


Yes, the nonconstexpr version does just that, unless I misunderstood your question. See also boost::spirit for a 'big' version of this




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: