[odb-users] How to use the lazy_weak_ptr?

Boris Kolpackov boris at codesynthesis.com
Fri Nov 15 13:52:50 EST 2019


黄奕 <ruffian_hy at 126.com> writes:

> class B
> {
> ...
> private:
> #pragma db inverse(m_b)
> 
> odb::lazy_weak_ptr<A> m_a;
> ...
> };
> #pragma db object(B) pointer(std::shared_ptr)
> #pragma db member(m_a)
>  
> But I get the error of “error: object data member ‘ m_a' specified in db pragma column is inverse”.

Try to move inverse to the member(m_a) pragma:

#pragma db member(m_a) inverse(m_b)

Also, dealing with circular relationship is tricky, especially when
spread over multiple headers; see "Circular Relationships" in the
manual for details:

https://codesynthesis.com/products/odb/doc/manual.xhtml#6.3



More information about the odb-users mailing list