[odb-users] Compile error with shared_ptr to db value
Stroud, Sean T
ststrou at sandia.gov
Wed Oct 3 15:32:57 EDT 2012
Hi,
I am getting errors trying to compile the odb-generated code for the example below:
#include <odb/core.hxx>
#include <string>
#include <tr1/memory>
#include <memory>
#pragma db value
class job
{
public:
job();
private:
friend class odb::access;
std::string m_name;
std::string m_description;
};
#pragma db object
class person
{
public:
person();
private:
friend class odb::access;
#pragma db id
int m_id;
// With this one, the generated person-odb.cxx file fails to compile
std::tr1::shared_ptr<job> m_job_shared_ptr;
// But this one is fine
std::auto_ptr<job> m_job_auto_ptr;
};
After I run the odb compiler on person.h, I get errors trying to compile the resulting person-odb.cxx file:
person-odb.cxx: In static member function ‘static bool odb::access::object_traits<person>::init(odb::access::object_traits<person>::image_type&, const person&, odb::pgsql::statement_kind)’:
person-odb.cxx:355: error: incomplete type ‘odb::wrapper_traits<std::tr1::shared_ptr<job> >’ used in nested name specifier
person-odb.cxx: In static member function ‘static void odb::access::object_traits<person>::init(person&, const odb::access::object_traits<person>::image_type&, odb::database*)’:
person-odb.cxx:404: error: incomplete type ‘odb::wrapper_traits<std::tr1::shared_ptr<job> >’ used in nested name specifier
However if I comment out the declaration of the "m_job_shared_ptr" member then I do not get these errors.
Since auto_ptr compiles fine, I would expect shared_ptr to compile fine as well. Possibly a bug? IF not,
what am I doing wrong?
Thanks,
Sean
More information about the odb-users
mailing list