[odb-users] weak_ptr relations

Boris Kolpackov boris at codesynthesis.com
Fri Mar 18 12:06:33 EDT 2016


Hi Dieter,

dieter.govaerts at bricsys.com <dieter.govaerts at bricsys.com> writes:

> Concerning the initial example of "6.4 Lazy Pointers", it explains that when
> loading an employee object then the associated employer object and in turn
> all employer associated employees get loaded. I understand that. But the
> employer.employees_ vector uses std::weak_ptr, thus where are the actual
> employee objects kept, or are these indirectly loaded employees directly
> send into oblivion?

They are "kept" in the session. Also, ODB detects the situation where
you are loading an object into weak_ptr that nobody else points to and
throws the odb::session_required exception (it is discussed in Section
6.2, "Bidirectional Relationships").

Boris



More information about the odb-users mailing list