[odb-users] Create New Object

Tarik BENZ tenchu.tarik at hotmail.fr
Mon Jun 24 07:59:43 EDT 2013


Hello Boris,

Thanks for your answer,
I have changed my code to use the lazy pointers,
but I have this error when I am trying to call "load()" method :

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

this is how I use it :

const std::shared_ptr<Foo> getRefFoo() const
    {
        return this->currentObject->getRefFoo().load();
    }

const odb::lazy_shared_ptr<Foo> getRefFoo() const
    {
        return this->ref_Foo;
    }

Can you  tell me what I am doing wrong here?

Thank you,
Tarik

> Date: Mon, 24 Jun 2013 12:47:57 +0200
> From: boris at codesynthesis.com
> To: tenchu.tarik at hotmail.fr
> CC: odb-users at codesynthesis.com
> Subject: Re: [odb-users] Create New Object
> 
> Hi Tarik,
> 
> Tarik BENZ <tenchu.tarik at hotmail.fr> writes:
> 
> > class MyClass
> > {
> >      std::shared_ptr<MyOtherClass> foo;
> > }
> > 
> > To create a new "MyClass" object, do I need to retrieve the data
> > into "MyOtherClass" from the database then affect this object to "foo"
> > or I can just use the "ID" of the "MyOtherClass"?
> 
> Lazy pointers allow you to create "unloaded" pointers with just the
> object id. See Section 6.4, "Lazy Pointers" in the ODB manual, 
> specifically, the example at the end of this section.
> 
> Boris
 		 	   		  


More information about the odb-users mailing list