[odb-users] Compilation error in odb\lazy-ptr.ixx - ODB 2.4.0 - Visual C++ 12 - Windows 7

Fabrizio Maj fabrizio.maj at it.atlascopco.com
Thu Feb 18 10:36:24 EST 2016


Hello,

I am experiencing a compilation problem using odb::lazy_shared_ptr and also odb::lazy_weak_ptr.
Calls to the load() method on both types provokes compilation errors like this:

c:\projects\libsroot\libodb-2.4.0\odb-2.4.0-i686-windows\mingw\include\odb\lazy-ptr.ixx:1153:10: error: no match for 'operator=' (operand types are 'std::shared_ptr<Child>' and 'odb::object_traits<Child>::pointer_type {aka Child*}')
       p_ = i_.template load<T> (true); // Reset id.
          ^

Similar errors appears both from the ODB compiler and from the VC compiler.

The problem appears in function child() while parsing/compiling this entity class:

PRAGMA_DB(object)
class Parent
{
public:
...
    ChildPtr child() const
    {
        return m_child.load();
    }
private:
...
    odb::lazy_shared_ptr<Child>     m_child;
};

(ChildPtr is a typedef of std::shared_ptr<Child>)


I have attached the VC solution, the batch file used to invoke the ODB compiler and the complete error log.

It seems to me that the problem is that the conversion from the raw pointer returned by i_load<>() cannot be implicitly converted to a shared_ptr<T>.

Changing lines similar to the above inside lazy-ptr.ixx in the following way seems to fix the problem:

  template <class T>
  inline std::shared_ptr<T> lazy_shared_ptr<T>::
  load () const
  {
    if (!p_ && i_)
        p_ = std::shared_ptr<T>(i_.template load<T> (true)); // Reset id.   ADDED
//      p_ = i_.template load<T> (true); // Reset id.                                         REMOVED

    return p_;
  }

Do you think that this fix is correct or am I missing something?

Thank you and best regards,

Fabrizio Maj
Software Design
________________________________
Atlas Copco BLM s.r.l.

Address:




Phone:

+39 02 91084159









E-mail:

fabrizio.maj at it.atlascopco.com<mailto:fabrizio.maj at it.atlascopco.com>

Visit us at:
Follow us at:

http://www.atlascopco.com<http://www.atlascopco.com/>
Facebook <https://www.facebook.com/atlascopco> / Twitter <https://twitter.com/AtlasCopcoGroup> / LinkedIn <http://www.linkedin.com/company/atlas-copco> / YouTube<http://www.youtube.com/user/atlascopcogroup>

Committed to sustainable productivity





-------------- next part --------------
A non-text attachment was scrubbed...
Name: odb_weak_pointers_problem.zip
Type: application/x-zip-compressed
Size: 8296 bytes
Desc: odb_weak_pointers_problem.zip
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20160218/438f9e0f/odb_weak_pointers_problem.bin


More information about the odb-users mailing list