widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02825
Re: unique_ptr question
That is exactly what it means. The object owns the pointer and deletes it. Much safer than dealing with bare pointers yourself.
> Am 06.10.2014 um 09:23 schrieb Tibor Bamhor <tiborb95@xxxxxxxxx>:
>
> This I read.
>
> "The lifetime of an object managed by const std::unique_ptr is limited to the scope in which the pointer was created."
>
> It implies that no delete of anything is needed, but I was not sure.
>
>
>
> 2014-10-06 9:13 GMT+02:00 Holger Rapp <HolgerRapp@xxxxxxx>:
>> rtfm:
>> http://en.cppreference.com/w/cpp/memory/unique_ptr
>>
>>
>>> On 06.10.2014, at 09:08, Tibor Bamhor <tiborb95@xxxxxxxxx> wrote:
>>>
>>> Hi,
>>>
>>> small question, I am using unique pointer, this way:
>>>
>>> std::unique_ptr<Path> path2 (new Path());
>>>
>>> Is it necessary to call any 'delete' on the end of scope (end of curly braces)?
>>>
>>> Probably not, I think.....
>>>
>>> Thanks
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~widelands-dev
>>> Post to : widelands-dev@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~widelands-dev
>>> More help : https://help.launchpad.net/ListHelp
>
References