[odb-users] Problem with many-to-many example

Tom Stoffer tomstoffer at gmail.com
Wed Jul 13 06:32:54 EDT 2016


Thanks for the clear reply Boris. Would it not make sense to update the
documentation in the relationships chapter to include the "

pragma db object pointer(std::shared_ptr)" for those classes so the code
can compile?

On Wed, Jul 13, 2016 at 11:21 AM, Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Hi Tom,
>
> Tom Stoffer <tomstoffer at gmail.com> writes:
>
> > The one thing that does get it to compile is if I add:
> > pointer(std::shared_ptr) To the pragma for employee, but I’m not sure
> why,
> > and actually I don’t think this will work for my situation as the class
> > which will be needed to have a many-to-many also inheriting from an
> abstract
> > polymorphism. As soon as I introduce this change, I start getting other
> > compiler errors to do with shared_ptr not being supported.
>
> If you want to use bi-directional relationships like these then you will
> need the shared_ptr/weak_ptr semantics and you will have to make shared_ptr
> the object pointer for all the objects involved. I would just make all the
> objects consistently use shared_ptr, it should get rid of any compile
> errors.
> See Section 3.3, "Object and View Pointers" in the manual for details.
>
> Boris
>


More information about the odb-users mailing list