Skip to content

Workaround for Const Members? #1557

Answered by stephenberry
WanZhiQiu-ac asked this question in Q&A
Discussion options

You must be logged in to vote

1 - What is the underlying design philosophy behind the error_on_const_read option?

Typically error_on_const_read is kept off and const members are skipped. Sometimes we want to error when an attempt is made to read into the const variable, so we know when we are discarding input data, therefore this option exists. It seems like you have a firm grasp of these.

Notes on read_json API

Your core question has to do with initializing structs with const members from JSON input. This syntax: auto s = glz::read_json<my_struct>(buffer); uses default construction so that we start with the default values of the struct and then modify these values based on the input JSON. This is very useful, as it a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@WanZhiQiu-ac
Comment options

Answer selected by WanZhiQiu-ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants