Passing around reference of structure is invalidated

The problem is the lifetime of the Geometry object created for insertion in the map, i.e. this line:

    map.insert({"geometry-id-1", {"id1", std::move(geometry)}});

The map stores only a reference to the object, but the object itself does not live after this line.

Replacing it with the following should make it work as you expected:

    Geometry g = {"id1", std::move(geometry)};
    map.insert({"geometry-id-1", g});