Re: get/set wrap methods.

On 23 February 2018 at 14:55, Pavlo Solntsev wrote:

now it is clear. I didn't and still don't understand exactly how internal data members are represented in the generated class (I have no access to my code now) but the situation I have by returning a reference is clear. BTW does it make sense to think about shared_ptr as returned value for getter? 

No, because unless you keep a copy of the shared_ptr as a member, you will get a new shared_ptr each time you call it, which doesn't share ownership with the previous ones.

So now you have the shared_ptr overhead (reference counting) and inconvenience (needing to use operator* to access the value), without any sharing.

You might as well just return by value, or have a Glib::ustring member.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]