Skip to content

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

@mzoll

Description

@mzoll

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions