[odb-users] Bidirectional Many-to-Many Relationship Problem

Chen Weiguang CWeiguan at dso.org.sg
Wed Feb 11 21:29:33 EST 2015


I was trying out the bidirectional many-to-many relationship example, as seen in the ODB documentation section 6.2.3<http://www.codesynthesis.com/products/odb/doc/manual.xhtml#6.2.3>. Initially I tried out using std::shared_ptr and std::weak_ptr, and ODB is able to generate the .cxx, .hxx and .ixx files. However when I tried to compile the .cxx file in Visual Studio 2013 (x64), I got a compile error that says:

error 2440: '<function-style-cast>' : cannot convert from 'X *' to 'std::weak_ptr<X>'
No constructor could take the source type, or constructor overload resolution was ambiguous.

For my example, 'X' and 'Y' are the table/struct names.

I took the same example and changed the smart pointers to odb::lazy_shared_ptr and odb::lazy_weak_ptr, and similarly ODB-compiler is able to compile. In this case, the generated .cxx file can be compiled, but when I tried calling .load() method of either the odb::lazy_shared_ptr<Y> or odb::lazy_weak_ptr<X>,  I would get compile error in my main.cpp that says:

...\odb\include\odb/lazy-ptr.ixx (1153): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Y *' (or there is no acceptable conversion) ...

May I ask if there is any other special requirement/pragma tags that I need to insert into my header files, or any thing that I need to specially note in order to make my example work? I have attached both sets of my example header files (one for std smart pointers, one for odb lazy pointers), and I am using Windows 7 (x64), Visual Studio 2013 (x64) for this example.

Thank you.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: XY-Src.zip
Type: application/x-zip-compressed
Size: 707 bytes
Desc: XY-Src.zip
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150212/70443d0e/XY-Src.bin

More information about the odb-users mailing list