[odb-users] Issue with std::weak_ptr in Bidirectional
Relationship with ODB Classes
Boris Kolpackov
boris at codesynthesis.com
Thu Aug 15 01:51:12 EDT 2024
xuewen wang <xuewen.ok at gmail.com> writes:
> /usr/include/c++/10/bits/shared_ptr.h:707:30: required by substitution of
> ‘template<class _Yp, class>
> std::weak_ptr<database::IrradianceProfileDb>::weak_ptr(const
> std::weak_ptr<_Tp>&) [with _Yp = database::IrradianceProfileDb;
> <template-parameter-1-2> = <missing>]’
This suggests that the definition is needed when calling the
weak_ptr's copy constructor (and likely other functions, like
the destructor). I suggest that you try to move definitions of
all your functions in the two classes after both are defined.
Something along these lines:
class B;
class A
{
std::weak_ptr<B> b;
A (const A&);
};
class B
{
std::shared_ptr<A> b;
};
inline A::A (const A&)
: ...
{
}
If you still cannot make it work, please provide a minimal but
complete reproducer (header file plus the ODB compiler command
line to compile it).
More information about the odb-users
mailing list