Article View: pl.comp.lang.c
Article #309189Re: Przykłady sprytnych wskaźników
From: artiun
Date: Thu, 23 Feb 2017 19:20
Date: Thu, 23 Feb 2017 19:20
43 lines
2600 bytes
2600 bytes
W dniu 2017-02-22 o 20:34, Andyy pisze:
> W dniu 22.02.2017 o 19:25, Borneq pisze:
>> Szukam krótkich kawałków kodów ilustrujących własności
>> - unique_ptr
>> - shared_ptr
>> - weak_ptr
>> Coś co można by sprawdzić przez stronę https://godbolt.org/
>
> Działa std::move,
> #include <memory>
> int main()
> {
> std::unique_ptr<int[]> uptr1 = std::make_unique<int[]>(5);
> std::unique_ptr<int[]> uptr2;
> uptr2 = std::move(uptr1);
> }
>
> ale gdy zadeklaruję std::shared_ptr<int[]> sptr1;
> to nie działają:
> #include <memory>
> int main()
> {
> std::unique_ptr<int[]> uptr1 = std::make_unique<int[]>(5);
> std::shared_ptr<int[]> sptr1, sptr2;
> sptr1 = std::move(uptr1);
> }
>
> #include <memory>
> int main()
> {
> std::unique_ptr<int[]> uptr1 = std::make_unique<int[]>(5);
> std::shared_ptr<int[]> sptr1, sptr2;
> sptr1 = std::make_shared(uptr1);
> }
>
> Jako przekonwertować unique na shared + weak?
Komputer, jego sruktura nie ma czeoś takiego. Jest adres i koniec. INNy ŚWIAt?
Mieszajcie dalej, to nikt już nie zrozumie. IDIOCI. Masz procaa i masz assm
do niego, to co pokazujesz to głupota, mieszanie, hamstwo.
--
Artur
Technical Details
Message-ID:
<58af3812$1$5140$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!wsisiz.edu.pl!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailReferences:
<o8kl2g$p18$1@node1.news.atman.pl> <o8kp4a$tel$1@node1.news.atman.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!wsisiz.edu.pl!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail Subject: Re: Przykłady sprytnych wskaźników Newsgroups: pl.comp.lang.c References: <o8kl2g$p18$1@node1.news.atman.pl> <o8kp4a$tel$1@node1.news.atman.pl> From: artiun <artiun@spam.wp.pl> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAAFXRFWHRDcmVhdGlvbiBUaW1l AAfVBwEUExQxoOF6AAAAB3RJTUUH1QcBFCMjg1qR9gAAAAlwSFlzAAAK8AAACvABQqw0mAAAAAZQ TFRFAAAA////pdmf3QAAAHZJREFUeNpj+A8GDFSjHoOpf8xg6oA8iPrHAJb7wQ+mPtSDqYcQDc+f I1MPW/hB1AMGMPWDGSTY+F+ujvk/QwOjAQ8DP8MBBgEWBkaGj//kVP6z43AEM4QCGtIPpBoYGOfU M/x//IFxDkTJHghVC6F+U9HvQAAATjr8CsUXDxIAAAAASUVORK5CYII= Date: Thu, 23 Feb 2017 20:20:08 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; pl-PL; rv:1.8.1.3) Gecko/20070326 Thunderbird/2.0.0.0 Mnenhy/0.7.5.0 MIME-Version: 1.0 In-Reply-To: <o8kp4a$tel$1@node1.news.atman.pl> Lines: 43 Message-ID: <58af3812$1$5140$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 83.29.52.155 X-Trace: 1487878163 unt-rea-a-01.news.neostrada.pl 5140 83.29.52.155:1307 X-Complaints-To: abuse@news.neostrada.pl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit