Skip to content

More use of move semantics in deserialization #786

Description

@SylvainCorlay

Short version

For certain cases, where copying things is an issue (as the one described below), I would like to favor examples similar to move_only_type over the creation of a from_json function, but specializations of adl_serializer does not seem to work with containers of types for which the specialization exist.

Ideally, I would like to have a "return by value" version of from_json. The STL container of those types would be built by emplacing the values returned by from_json into the container.

Long version / context

We currently use your library (vendoring the json header for now) in xeus, a native C++ implementation of the Jupyter protocol.

In this work, some of the classes that we deserialize from json have a value semantics and implement the RAII pattern. Basically, constructor and destructors amount to acquiring and freeing the resources. Any non-move copy acquires a new version of the resource (with a different id). Move constructor and assignment transfers the resource to the moved-to object.

This is a context in which being able to move things to a container would make a lot of sense...

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