Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom converter for non default-constructable data-types #993

Open
mzoll opened this issue Apr 28, 2021 · 1 comment · May be fixed by #1010 or #1087
Open

custom converter for non default-constructable data-types #993

mzoll opened this issue Apr 28, 2021 · 1 comment · May be fixed by #1010 or #1087

Comments

@mzoll
Copy link

mzoll commented Apr 28, 2021

It seems in the current implementation it is not possible to convert YAML-nodes directly into non default-constructable data-types.

The actual breaking point seems to be in 'impl.h:130', where an bare mantle object of the desired type is instantiated on the stack T t;, where T is the template-arg for the to-be-read custom-class. I guess the next instructions are invocing the customized struct bool YAML::convert<T>::decode(Node&, T&), which are to fill the fields of the object with sensible data, by modifying the reference as the second argument.

Wouldn't it be more sensible to define the decoding function as T YAML::convert<T>::decode(Node&) throw() ; thus instead of using the bool as function-return as indicator for successful conversion, rather wrap the decode in an try-except block and so have the possibility to allocate the object on the stack inside the function-body itself?

@mzoll
Copy link
Author

mzoll commented Apr 28, 2021

As I just wanted to see how complicated it would be to make this work, i implemented it in a fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant