[odb-users] Lazy pointer question

Boris Kolpackov boris at codesynthesis.com
Tue Mar 13 09:22:24 EDT 2018


Paul Stath <PStath at jmawireless.com> writes:

> How does one determine if object B is linked to object C without calling
> the lazy_weak_ptr<C>::load() method?

If you have a lazy_weak_ptr that you have loaded from the database (i.e.,
it is either NULL [in the database sense] or contains a valid object id),
then to check whether it is NULL you lock it to obtain lazy_shared_ptr
and then check if it is NULL:

lazy_shared_ptr<C> p = w.lock ();

if (p != nullptr)
{
}

Boris



More information about the odb-users mailing list