[odb-users] unable to map C++ type '::__gnu_cxx::new_allocator< ::std::weak_ptr< ... error in One-to-Many relationships

Boris Kolpackov boris at codesynthesis.com
Fri Sep 6 07:59:19 EDT 2019


Monika Idzik <moni.idzik at gmail.com> writes:

> 1. I put those two classes into one file -> still the same error.
> 2. I just copied relationship example into my project from examples
>    provided on the website -> still the same error.

I copied the two classes from the manual to test.hpp and adjusted
it to match your example:

//---------------------------------------------------
#include <memory>
#include <vector>

class employee;

#pragma db object
class position
{
public:
  #pragma db id
  unsigned long id_;

  #pragma db inverse(position_)
  std::vector<std::weak_ptr<employee>> employee_;
};

#pragma db object
class employee
{
public:
  #pragma db id
  unsigned long id_;

  #pragma db not_null
  std::shared_ptr<position> position_;
};
//---------------------------------------------------

I could then successfully compile it like this:

$ odb -d mysql --std c++11 test.hpp

$ odb --version
ODB object-relational mapping (ORM) compiler for C++ 2.5.0-b.16



More information about the odb-users mailing list