220 29860 <6911ac18-c144-4e4b-9fad-fe360fbb4c55@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Jared Grubb <jared.grubb@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: New smart pointer: CopyConstructible and
 CopyAssignable flavor of unique_ptr
Date: Fri, 16 Dec 2016 18:43:31 -0800 (PST)
Lines: 400
Approved: news@gmane.org
Message-ID: <6911ac18-c144-4e4b-9fad-fe360fbb4c55@isocpp.org>
References: <13702f32-32c2-447f-9996-3624fd678675@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2494_1330130897.1481942611913"
X-Trace: blaine.gmane.org 1481942614 28856 195.159.176.226 (17 Dec 2016 02:43:34 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 17 Dec 2016 02:43:34 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDVKDF4E7IDRBVGM2LBAKGQEFPDENRI@isocpp.org Sat Dec 17 03:43:30 2016
Return-path: <std-proposals+bncBDVKDF4E7IDRBVGM2LBAKGQEFPDENRI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f199.google.com ([209.85.161.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDVKDF4E7IDRBVGM2LBAKGQEFPDENRI@isocpp.org>)
	id 1cI4y9-0006a0-HU
	for gclcip-std-proposals@m.gmane.org; Sat, 17 Dec 2016 03:43:29 +0100
Original-Received: by mail-yw0-f199.google.com with SMTP id t125sf77509115ywc.4
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Dec 2016 18:43:34 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=BFBrMirxKKMIDa4UPvg3MDsoBHF03pkLD0ufjLk+8cY=;
        b=ndGbdlxfMlpd4eRxPrbhQ/uGNrpTCaHSC85/kGGeuhvWhZlHVehBl3KlrSqvVQ7vTJ
         eEv3Rv6VKh3g9hjcfkZPpmgQ4eTuS2KFOMkJaTNttCTghZksvyHfWd4LRINAH8krcEXq
         6aPdn+rJRdYnZJn6wHZaHjq9M5wP/lk/b6buTOhbahaQWZO1SqWSTgIOz4a2l7i/2lb5
         C5mVlevNZKvd20R2wsDhJZxPCaZtK/lUiOjSk9b2q3vVc/wRoghh+D2kCErSnDki2Nqu
         HZ4VOvPk+Fa+ZOu33BcifCHVu+IlJHVMocdhEk3wIm4fq0CebX17azs+Bn26TZRagh0m
         9iMg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=BFBrMirxKKMIDa4UPvg3MDsoBHF03pkLD0ufjLk+8cY=;
        b=jYDvxzruIl3vzgTP4h90L668rJ1sivwjWWYtET4im/6VfvDRpnqXP/IZRH7/kaBWA5
         ZdXrkGUl8Idy3wXaN8Oa6hOAfOh5yVFOPcopLBtVtsOI4apwWToXMb4hnzlm0Q0KQybu
         pIQ8Vws7DX+tqOUj0pv0yRwIE7DCxmn1xHa/TiUVRUtxVyKfg1MhD/CnCYb3Nc8iX/e1
         S1rpWYt9WDYPzYDYAWlNGE0THOk2DQMEiVOYMZUdGkwHs/E+h392EuIFsbLTNrvI9lSS
         slOwAfbdNw884TngErO27/Xkmu2u2DxS2UwCgnX/L7mMA7+jR/w0fM6zOeF3CAPe9V3T
         m6Og==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=BFBrMirxKKMIDa4UPvg3MDsoBHF03pkLD0ufjLk+8cY=;
        b=ByfiPw+5MQl4qLyfl3+SyvomMg0mH9LD/3xcgAH3fIIeezmyOPo6RJ7UypClAJe2Oq
         Nyw2pVddrMspNOlBgFhor7TcVnUBY6E5v5fexyJvJOB2JaP9hUS9A0ihQW/s/hO4njEy
         pVP/NvcTtIfg6agSnq4z7TGXsuLur5B44yyKLeViHIWczalxdjsUWTsdD5p6SbtY7k5s
         AbKVYgdfd7CNfYBHoqZ1si5wKscHf/vOsx6dcvUjQq0cfORhLgcOAxHRNRUAmfo0YSby
         qQoblBoASUU9TyCJca0/cEpiSPHQ/CxlKHZekKwgIw03dObvm4aogSzyty/DAdaauKBv
         YzjA==
X-Gm-Message-State: AKaTC00VSmbYLf7xKeNBgjhwaaqsygMgqyOxH8CyDTJx1bW/ELZgT66XKOeyNrCyDSyvMg==
X-Received: by 10.13.236.12 with SMTP id v12mr1427074ywe.128.1481942613537;
        Fri, 16 Dec 2016 18:43:33 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.46.13 with SMTP id q13ls9601058otb.20.gmail; Fri, 16 Dec
 2016 18:43:32 -0800 (PST)
X-Received: by 10.157.11.248 with SMTP id 111mr371714oth.4.1481942612729;
        Fri, 16 Dec 2016 18:43:32 -0800 (PST)
In-Reply-To: <13702f32-32c2-447f-9996-3624fd678675@isocpp.org>
X-Original-Sender: jared.grubb@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:29860
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29860>

------=_Part_2494_1330130897.1481942611913
Content-Type: multipart/alternative; 
	boundary="----=_Part_2495_93022081.1481942611913"

------=_Part_2495_93022081.1481942611913
Content-Type: text/plain; charset=UTF-8



On Friday, December 16, 2016 at 3:32:25 AM UTC-8, Alexandre Isoard wrote:
>
> *Proposal*
>
> template<class T,
>     class Cloner = std::default_clone<T>,
>     class Deleter = std::default_delete 
> <http://en.cppreference.com/w/cpp/memory/default_delete><T>
> > class copy_ptr
>
> std::copy_ptr is a smart pointer that owns and manages another object 
> through a pointer and disposes of that object when the copy_ptr goes out 
> of scope.
> Additionally, it allocates a clone of the underlying object when it is 
> copied from, ensuring one copy_ptr manages each allocated object.
>
> The object is disposed of using the associated deleter when either of the 
> following happens:
>
>    - the managing copy_ptr object is destroyed
>    - the managing copy_ptr object is assigned another pointer via 
>    operator= 
>    <http://en.cppreference.com/w/cpp/memory/unique_ptr/operator%3D> or 
>    reset() <http://en.cppreference.com/w/cpp/memory/unique_ptr/reset>.
>
> The object is disposed of using a potentially user-supplied deleter by 
> calling get_deleter()(ptr). The default deleter uses the delete operator, 
> which destroys the object and deallocates the memory.
>
> The object is cloned using the associated cloner when either of the 
> following happens:
>
>    - an other copy_ptr object is copy constructed from the managing 
>    copy_ptr
>    - an other copy_ptr object is copy assigned from the managing copy_ptr
>
> The object is cloned using a potentially user-supplied cloner by calling 
> get_cloner()(ptr). The default cloner uses the new operator and the copy 
> constructor of the underlying type, which allocate a new object and copy 
> its original content.
>
> A copy_ptr may alternatively own no object, in which case it is called 
> empty.
>
> The class satisfies the requirements of MoveConstructible 
> <http://en.cppreference.com/w/cpp/concept/MoveConstructible>, 
> MoveAssignable <http://en.cppreference.com/w/cpp/concept/MoveAssignable>, 
> CopyConstructible 
> <http://en.cppreference.com/w/cpp/concept/CopyConstructible> and 
> CopyAssignable <http://en.cppreference.com/w/cpp/concept/CopyAssignable> (the 
> later two may require T to be CopyConstructible).
>
> *Member Types*
>
>    - pointer: T*
>    - element_type: T, the type of the object managed by this copy_ptr
>    - cloner_type: Cloner, the function object or lvalue reference to 
>    function or to function object, to be called from the copy constructor and 
>    copy assignment operators
>    - deleter_type: Deleter, the function object or lvalue reference to 
>    function or to function object, to be called from the destructor
>
>
> *Member Functions*
>
>    - operator=: assigns the copy_ptr
>    - release: returns a pointer to the managed object and releases 
>    ownership
>    - reset: replaces the managed object
>    - swap: swaps the managed objects
>    - get: returns a pointer to the managed object
>    - get_cloner: returns the cloner that is used for copy the managed 
>    object
>    - get_deleter: returns the deleter that is used for destruction of the 
>    managed object
>    - operator bool: checks if there is an associated managed object
>    - operator*, operator->: dereferences pointer to the managed object
>    - make_copy: creates a copy pointer that manages a new object
>    - operator==, operator!=, etc: compares to an other copy_ptr or with 
>    nullptr
>
> You have a major issue with equality that is fatal to the proposal, IMO.

Copying creates a new object. If equality is defined on the pointer, then 
copies are *never* equal to their original (except nullptr case). If you 
define equality by the value-type, then you have confusingly different 
semantics from the other smart-pointer types.

You could delete the equality operators (maybe keep 
"operator==(std::nullptr_t)" only), but that also sounds like a fatal flaw.

>
>    - std::swap: specializes the std::swap algorithm
>    - std::hash<std::copy_ptr>: hash support for std::copy_ptr
>
> *Example*
>
> #include<iostream>
> #include<memory>
>
> struct Foo
> {
>     Foo()             { std::cout << "Foo::Foo()\n"; }
>     Foo(const Foo& o) { std::cout << "Foo::Foo(const Foo&)\n"; }
>     ~Foo()            { std::cout << "Foo::~Foo()\n"; }
>     void bar()        { std::cout << "Foo::bar()\n"; }
> }
>
> void f(const Foo&)
> {
>     std::cout << "f(const Foo&)\n";
> }
>
> int main()
> {
>     std::copy_ptr<Foo> p1(new Foo);  // p1 owns Foo
>     if (p1) p1->bar();
>  
>     {
>         std::copy_ptr<Foo> p2(std::move(p1));  // now p2 owns Foo
>         f(*p2);
>  
>         p1 = p2;  // cloned into p1
>         std::cout << "destroying p2...\n";
>     }
>  
>     if (p1) p1->bar();
>  
>     // Second Foo instance is destroyed when p1 goes out of scope
> }
>
> Output:
>
> Foo::Foo()
> Foo::bar()
> f(const Foo&)
> Foo::Foo(const Foo&)
> destroying p2...
> Foo::~Foo()
> Foo::bar()
> Foo::~Foo()
>
>

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6911ac18-c144-4e4b-9fad-fe360fbb4c55%40isocpp.org.

------=_Part_2495_93022081.1481942611913
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, December 16, 2016 at 3:32:25 AM UTC-8, =
Alexandre Isoard wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><b>Proposal</b><div><br></div><div style=3D"background-color:rgb(=
250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:=
1px;word-wrap:break-word"><code><div><span style=3D"color:#008">template</s=
pan><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">class<=
/span><span style=3D"color:#000"> T</span><span style=3D"color:#660">,</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#008">class</span><span style=3D"color:#000"> </span><span style=3D"color:#=
606">Cloner</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> std</span><span style=3D"color:#=
660">::</span><span style=3D"color:#000">default_clone</span><span style=3D=
"color:#660">&lt;</span><span style=3D"color:#000">T</span><span style=3D"c=
olor:#660">&gt;,</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><=
span style=3D"color:#606">Deleter</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><a =
href=3D"http://en.cppreference.com/w/cpp/memory/default_delete" target=3D"_=
blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.c=
om/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fmemory%2Fdefault_d=
elete\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHtNWhNDR8JsARzrVNyDZKv9uIz6Q&=
#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\=
x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fmemory%2Fdefault_delete\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHtNWhNDR8JsARzrVNyDZKv9uIz6Q&#39;;retu=
rn true;"><span style=3D"color:#000">std</span><span style=3D"color:#660">:=
:</span><span style=3D"color:#000">default_delete</span></a><span style=3D"=
color:#660">&lt;</span><span style=3D"color:#000">T</span><span style=3D"co=
lor:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#660">&gt;</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#008">class</span><span style=3D"color:#000"> copy_ptr</span></div></cod=
e></div><br><font face=3D"courier new, monospace">std::copy_ptr</font> is a=
 smart pointer that owns and manages another object through a pointer and d=
isposes of that object when the <font face=3D"courier new, monospace">copy_=
ptr </font>goes out of scope.<div>Additionally, it allocates a clone of the=
 underlying object when it is copied from, ensuring one <font face=3D"couri=
er new, monospace">copy_ptr </font>manages each allocated object.<br><br>Th=
e object is disposed of using the associated deleter when either of the fol=
lowing happens:<br><ul><li>the managing <font face=3D"courier new, monospac=
e">copy_ptr </font>object is destroyed<br></li><li>the managing <font face=
=3D"courier new, monospace">copy_ptr </font>object is assigned another poin=
ter via <a href=3D"http://en.cppreference.com/w/cpp/memory/unique_ptr/opera=
tor%3D" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2=
Fmemory%2Funique_ptr%2Foperator%253D\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQj=
CNFkMowHwWb-CXJYRuER8z4Vdi0Qtg&#39;;return true;" onclick=3D"this.href=3D&#=
39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcp=
p%2Fmemory%2Funique_ptr%2Foperator%253D\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dA=
FQjCNFkMowHwWb-CXJYRuER8z4Vdi0Qtg&#39;;return true;">operator=3D</a> or <a =
href=3D"http://en.cppreference.com/w/cpp/memory/unique_ptr/reset" target=3D=
"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google=
..com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fmemory%2Funique_=
ptr%2Freset\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGzmYfVvPXt1P7rhK2lyVW-j=
6bH8A&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/=
url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fmemory%2Funique_ptr%2=
Freset\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGzmYfVvPXt1P7rhK2lyVW-j6bH8A=
&#39;;return true;">reset()</a>.</li></ul>The object is disposed of using a=
 potentially user-supplied deleter by calling <font face=3D"courier new, mo=
nospace">get_deleter()(ptr)</font>. The default deleter uses the <font face=
=3D"courier new, monospace">delete </font>operator, which destroys the obje=
ct and deallocates the memory.</div><div><br></div><div>The object is clone=
d using the associated cloner when either of the following happens:</div><d=
iv><ul><li>an other <font face=3D"courier new, monospace">copy_ptr </font>o=
bject is copy constructed from the managing copy_ptr</li><li>an other <font=
 face=3D"courier new, monospace">copy_ptr </font>object is copy assigned fr=
om the managing copy_ptr</li></ul><div>The object is cloned using a potenti=
ally user-supplied cloner by calling <font face=3D"courier new, monospace">=
get_cloner()(ptr)</font>. The default cloner uses the <font face=3D"courier=
 new, monospace">new </font>operator and the copy constructor of the underl=
ying type, which allocate a new object and copy its original content.</div>=
<br>A <font face=3D"courier new, monospace">copy_ptr </font>may alternative=
ly own no object, in which case it is called empty.<div><br></div>The class=
 satisfies the requirements of <a href=3D"http://en.cppreference.com/w/cpp/=
concept/MoveConstructible" target=3D"_blank" rel=3D"nofollow" onmousedown=
=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cpprefe=
rence.com%2Fw%2Fcpp%2Fconcept%2FMoveConstructible\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNG9q1JBaTNiZ7Vh_C9K1hefbHQWoA&#39;;return true;" onclick=3D"t=
his.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference=
..com%2Fw%2Fcpp%2Fconcept%2FMoveConstructible\x26sa\x3dD\x26sntz\x3d1\x26usg=
\x3dAFQjCNG9q1JBaTNiZ7Vh_C9K1hefbHQWoA&#39;;return true;">MoveConstructible=
</a>,=C2=A0<a href=3D"http://en.cppreference.com/w/cpp/concept/MoveAssignab=
le" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http=
://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fcon=
cept%2FMoveAssignable\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6GrlYRYGOufF=
ABxI-2LHYYuUHzA&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.g=
oogle.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fconcept%2FM=
oveAssignable\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6GrlYRYGOufFABxI-2LH=
YYuUHzA&#39;;return true;">MoveAssigna<wbr>ble</a>, <a href=3D"http://en.cp=
preference.com/w/cpp/concept/CopyConstructible" target=3D"_blank" rel=3D"no=
follow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp=
%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fconcept%2FCopyConstructible\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG-iAn9ftcEFUQ6NfvI6mNqhZH_Aw&#39;;return =
true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2=
F%2Fen.cppreference.com%2Fw%2Fcpp%2Fconcept%2FCopyConstructible\x26sa\x3dD\=
x26sntz\x3d1\x26usg\x3dAFQjCNG-iAn9ftcEFUQ6NfvI6mNqhZH_Aw&#39;;return true;=
">CopyConstructible</a> and=C2=A0<a href=3D"http://en.cppreference.com/w/cp=
p/concept/CopyAssignable" target=3D"_blank" rel=3D"nofollow" onmousedown=3D=
"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreferen=
ce.com%2Fw%2Fcpp%2Fconcept%2FCopyAssignable\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNHv92JdHik3TE576sBvuu5aQBH_9g&#39;;return true;" onclick=3D"this.hr=
ef=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2=
Fw%2Fcpp%2Fconcept%2FCopyAssignable\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NHv92JdHik3TE576sBvuu5aQBH_9g&#39;;return true;">CopyAssignable</a>=C2=A0(t=
he later two may require T to be CopyConstructible).<br></div><div><br></di=
v><div><b>Member Types</b></div><div><ul><li><font face=3D"courier new, mon=
ospace">pointer</font>: <font face=3D"courier new, monospace">T*</font></li=
><li><font face=3D"courier new, monospace">element_type</font>: <font face=
=3D"courier new, monospace">T</font>, the type of the object managed by thi=
s <font face=3D"courier new, monospace">copy_ptr</font></li><li><font face=
=3D"courier new, monospace">cloner_type</font>:=C2=A0<font face=3D"courier =
new, monospace">Cloner</font>, the function object or lvalue reference to f=
unction or to function object, to be called from the copy constructor and c=
opy assignment operators</li><li><font face=3D"courier new, monospace">dele=
ter_type</font>:=C2=A0<font face=3D"courier new, monospace">Deleter</font>,=
 the function object or lvalue reference to function or to function object,=
 to be called from the destructor</li></ul></div><div><br></div><div><b>Mem=
ber Functions</b></div><div><ul><li>operator=3D: assigns the copy_ptr</li><=
li>release: returns a pointer to the managed object and releases ownership<=
/li><li>reset: replaces the managed object</li><li>swap: swaps the managed =
objects</li><li>get: returns a pointer to the managed object</li><li>get_cl=
oner: returns the cloner that is used for copy the managed object</li><li>g=
et_deleter: returns the deleter that is used for destruction of the managed=
 object</li><li>operator bool: checks if there is an associated managed obj=
ect</li><li>operator*, operator-&gt;: dereferences pointer to the managed o=
bject</li><li>make_copy: creates a copy pointer that manages a new object</=
li><li>operator=3D=3D, operator!=3D, etc: compares to an other copy_ptr or =
with nullptr</li></ul></div></div></blockquote><div>You have a major issue =
with equality that is fatal to the proposal, IMO.<br><br>Copying creates a =
new object. If equality is defined on the pointer, then copies are <i>never=
</i> equal to their original (except nullptr case). If you define equality =
by the value-type, then you have confusingly different semantics from the o=
ther smart-pointer types.<br><br>You could delete the equality operators (m=
aybe keep &quot;operator=3D=3D(std::nullptr_t)&quot; only), but that also s=
ounds like a fatal flaw.<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div><ul><li>std::swap: specializes the std::swap al=
gorithm</li><li>std::hash&lt;std::copy_ptr&gt;: hash support for std::copy_=
ptr</li></ul></div><div><b>Example</b></div><div><br></div><div><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px;word-wrap:break-word"><code><div><font color=
=3D"#660066"><span style=3D"color:#800">#include</span><span style=3D"color=
:#080">&lt;iostream&gt;</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#800">#include</span><span style=3D"color:#080">&lt;memory&gt=
;</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#008=
">struct</span><span style=3D"color:#000"> </span><span style=3D"color:#606=
">Foo</span><span style=3D"color:#000"><br></span><span style=3D"color:#660=
">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#606">Foo</span><span style=3D"color:#660">()</span><span style=
=3D"color:#000"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"> std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span style=
=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#080">&quot;Foo::Foo()\n&quot;</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</s=
pan><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r:#606">Foo</span><span style=3D"color:#660">(</span><span style=3D"color:#=
008">const</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
06">Foo</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#=
000"> o</span><span style=3D"color:#660">)</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">cout =
</span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080">&quot;Foo::Foo(const Foo&amp;)\n&quot;<=
/span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#660">~</span><span style=3D"color:#606"=
>Foo</span><span style=3D"color:#660">()</span><span style=3D"color:#000"> =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#660">=
{</span><span style=3D"color:#000"> std</span><span style=3D"color:#660">::=
</span><span style=3D"color:#000">cout </span><span style=3D"color:#660">&l=
t;&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#080">=
&quot;Foo::~Foo()\n&quot;</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">void</s=
pan><span style=3D"color:#000"> bar</span><span style=3D"color:#660">()</sp=
an><span style=3D"color:#000"> =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#000"> std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span style=
=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#080">&quot;Foo::bar()\n&quot;</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</spa=
n><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">void=
</span><span style=3D"color:#000"> f</span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#008">const</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#606">Foo</span><span style=3D"color:#660">&amp;)</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"col=
or:#660">::</span><span style=3D"color:#000">cout </span><span style=3D"col=
or:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#080">&quot;f(const Foo&amp;)\n&quot;</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}=
</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#008"=
>int</span><span style=3D"color:#000"> main</span><span style=3D"color:#660=
">()</span><span style=3D"color:#000"><br></span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"><br></span><span style=3D"color:#000"><=
div>=C2=A0 =C2=A0 std::copy_ptr&lt;Foo&gt; p1(new Foo); =C2=A0// p1 owns Fo=
o</div><div>=C2=A0 =C2=A0 if (p1) p1-&gt;bar();</div><div>=C2=A0</div><div>=
=C2=A0 =C2=A0 {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std::copy_ptr&lt;Foo&=
gt; p2(std::move(p1)); =C2=A0// now p2 owns Foo</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 f(*p2);</div><div>=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 p=
1 =3D p2; =C2=A0// cloned into p1</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std=
::cout &lt;&lt; &quot;destroying p2...\n&quot;;</div><div>=C2=A0 =C2=A0 }</=
div><div>=C2=A0</div><div>=C2=A0 =C2=A0 if (p1) p1-&gt;bar();</div><div>=C2=
=A0</div><div>=C2=A0 =C2=A0 // Second Foo instance is destroyed when p1 goe=
s out of scope</div></span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br></span></font></div></code></div><br>Output:</div><div>=
<br></div><font face=3D"courier new, monospace">Foo::Foo()</font><div><font=
 face=3D"courier new, monospace">Foo::bar()</font></div><div><font face=3D"=
courier new, monospace">f(const Foo&amp;)</font></div><div><font face=3D"co=
urier new, monospace">Foo::Foo(const Foo&amp;)</font></div><div><font face=
=3D"courier new, monospace">destroying p2...</font></div><div><font face=3D=
"courier new, monospace">Foo::~Foo()</font></div><div><font face=3D"courier=
 new, monospace">Foo::bar()</font></div><div><font face=3D"courier new, mon=
ospace">Foo::~Foo()</font><br><div><br></div></div></div></blockquote></div=
>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6911ac18-c144-4e4b-9fad-fe360fbb4c55%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6911ac18-c144-4e4b-9fad-fe360fbb4c55=
%40isocpp.org</a>.<br />

------=_Part_2495_93022081.1481942611913--

------=_Part_2494_1330130897.1481942611913--

.
