[odb-users] Trouble with lazy_ptr

Miguel Revilla Rodríguez yo at miguelrevilla.com
Sun Aug 19 10:50:59 EDT 2012

Thank you, Boris. You're the best. It's amazing the amount of C++ that
one can learn just by looking at your code and your messages.

Thanks again, will put a huge THANKS in my site when it opens.


2012/8/19 Boris Kolpackov <boris at codesynthesis.com>:
> Hi Miguel,
>> /usr/include/odb/lazy-ptr.ixx:1511:5: error: no match for 'operator='
>> in 'r = ((const odb::lazy_weak_ptr<user>*)this)->odb::lazy_weak_ptr<user>::i_.odb::lazy_ptr_impl<T>::load<user>(0)'
> I believe this error is due to the incompatible canonical object
> pointer used for your 'node' and 'user' classes (see Section 3.2,
> "Object and View Pointers" for more information). Specifically,
> your 'node' class uses the raw pointer (node*) as the object pointer.
> This is incompatible with all the C++11 shared/weak pointers that
> you are using in object relationships. So what you need to do is
> use std::shared_ptr as your object pointer:
> #pragma db object polymorphic pointer(std::shared_ptr)
> class node {
>   ...
> };
> Alternatively, you may want to make all your objects use std::shared_ptr
> as object pointer by default (this way, if you add another class, you
> won't need to worry about forgetting to add the pointer pragma). This
> can be done with the --default-pointer ODB compiler option, for example:
> --default-pointer std::shared_ptr
> Boris

More information about the odb-users mailing list