[odb-users] How to use the lazy_weak_ptr?
黄奕
ruffian_hy at 126.com
Fri Nov 15 00:07:32 EST 2019
I currently have two odb model like below:
A.hpp
class A
{
...
private:
odb::lazy_shared_ptr<B> m_b;
...
};
#pragma db object(A) pointer(std::shared_ptr)
#pragma db member(m_b)
B.hpp
class B
{
...
private:
odb::lazy_shared_ptr<A> m_a;
...
};
#pragma db object(B) pointer(std::shared_ptr)
#pragma db member(m_a)
They obviously have circular reference, and I want to use lazy_weak_ptr to fix it by the codes below:
A.hpp
class A
{
...
private:
odb::lazy_shared_ptr<B> m_b;
...
};
#pragma db object(A) pointer(std::shared_ptr)
#pragma db member(m_b)
B.hpp
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”.
It seems like I use the lazy_weak_ptr in a wrong way, is there anyone can help me?
More information about the odb-users
mailing list