[odb-users] weak pointer gets erased during update

Boris Kolpackov boris at codesynthesis.com
Mon Jul 29 06:09:00 EDT 2013


Hi Jeff,

Jeff Waller <truthset at gmail.com> writes:

> It's not quite clear to me when a weak_ptr can become invalid.

This is not really an ODB-specific question. In a few words, if
there is no shared_ptr somewhere in the application pointing to
the same object, then weak_ptr is invalid.

When loading object from the database, session should be used
in order to correctly load relationships with weak pointers.
When, however, constructing the object model from scratch (
which, it seems, is what you are doing in your example), it
is your reponsibilty to make sure that objects pointed-to by
weak_ptr's are still valid.

Boris



More information about the odb-users mailing list