220 25983 <7c02ff86-424d-48aa-bd5e-a2f768bd5484@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: pohilets@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Pointer casts with move semantics
Date: Sat, 21 May 2016 10:19:59 -0700 (PDT)
Lines: 419
Approved: news@gmane.org
Message-ID: <7c02ff86-424d-48aa-bd5e-a2f768bd5484@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3165_1371086206.1463851199841"
X-Trace: ger.gmane.org 1463851203 7762 80.91.229.3 (21 May 2016 17:20:03 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 21 May 2016 17:20:03 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDT6TQHDA4IMBMMCXICRUBEAXT4BM@isocpp.org Sat May 21 19:20:02 2016
Return-path: <std-proposals+bncBDT6TQHDA4IMBMMCXICRUBEAXT4BM@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f199.google.com ([209.85.213.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDT6TQHDA4IMBMMCXICRUBEAXT4BM@isocpp.org>)
	id 1b4AZG-0006yx-Bf
	for gclcip-std-proposals@m.gmane.org; Sat, 21 May 2016 19:20:02 +0200
Original-Received: by mail-ig0-f199.google.com with SMTP id u5sf38266766igk.2
        for <gclcip-std-proposals@m.gmane.org>; Sat, 21 May 2016 10:20:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id: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=Yv+iDio3d38OaP4jTkHfQzzvukJNOtsUy6P2WKqaaqY=;
        b=z3NQQ7G8Q45ruhGlSpbcFDBd3MspiEW5ELyp4pzrTPlQofApuaPK78im4kNgLgF1Ih
         ABkRsl51rfZv5h79cyCFMdEOypO92Zps2Ud863gwWZ4HRMpQTer/Q36bvlQQziWICIDA
         XUeE4v4VgmPcouPpfdNbUA0KqMhG/S3FY0ngsQu6Aw4mOPfMExviAp9YmPRYoP7gNSz6
         J3gOvbPiuH10CwGsLkoKGstlrB2K2eVIDBRgc6PUJcBwAtaCiryLWtCjy2QGgAmy/Cta
         nXfri4aJkEIniLXTKW9rO+NnYkfoRvuoWrUAwOpHmSuEgUL3d5m57k12IrtX51Bk4j9P
         Esew==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id: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=Yv+iDio3d38OaP4jTkHfQzzvukJNOtsUy6P2WKqaaqY=;
        b=S1kXZMGHV3BJr2EkJIxjuN4JZdA9jVlhVwP7eT5VXMzA/nX0kp+8KryN1SgboaJIUE
         tjeIxFhyXwT7Cb0pcrHkXpvTAgKsQ9jKHLIuRGTt+Cs6GWQts7zxP62xzUD/VPWXmelO
         4iemUiBzUmvFFJWmD2Sny7AOwNmmsw2Fm80IomMNLoBZjlA2SUsmnnsfZrN/pX0fteJx
         hiZgeXSntx+b5p54FCBW7R6bR6Xh8Xi5kUdyvfF0Cc/Dm3kwvy4jsxj3rYiODmpw/YO3
         P5zaJD7ouRAiJ0U3kNNPnHBZIEMq9eEYrR0SePN9S1JW+mK07NYwxxkko+OapMNb2D0W
         oiyg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id: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=Yv+iDio3d38OaP4jTkHfQzzvukJNOtsUy6P2WKqaaqY=;
        b=amZGgp0a8Sg9Vq5U7ady+H1lwYUgNXl4v2rctqmDZApeNAl6cGhGvg2H/j8NeFS1no
         +4jhNoj9qnFaGKENDgxC2/3wDp7fI4e/g0tS/WdsO/LpkofdWwSZEQwzFaICamr0jDYA
         gsK/TtCKnmHySDXk7ElBKsqy1+o72wdDrusGdpOk0jlt/PBHTRKEg2sQvgtQ+buu3Zbm
         tAVMw4WA0QjKKDDlWtUSzYCrQvmRJcFCLkj60Dk2ZzkituNanlWZX0/uX619glFhsUYt
         MB7nSEf2H4amKiUbHS2EI1IajjMUCcYZ6PUfOd/5dT1kunChQdchrOYNHTH1wnBEt8Jn
         Mkrg==
X-Gm-Message-State: AOPr4FV/jvK1FzmxIf61++SVkJ3AOGVn7HgZNJ6qKHydicovZ14xHzIrKA8QC17TuI7Ujg==
X-Received: by 10.157.27.226 with SMTP id v31mr6251373otv.44.1463851201246;
        Sat, 21 May 2016 10:20:01 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.109.195 with SMTP id l61ls263397qgf.1.gmail; Sat, 21 May
 2016 10:20:00 -0700 (PDT)
X-Received: by 10.140.44.9 with SMTP id f9mr284419qga.20.1463851200317;
        Sat, 21 May 2016 10:20:00 -0700 (PDT)
X-Original-Sender: pohilets@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:25983
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/25983>

------=_Part_3165_1371086206.1463851199841
Content-Type: multipart/alternative; 
	boundary="----=_Part_3166_828223911.1463851199842"

------=_Part_3166_828223911.1463851199842
Content-Type: text/plain; charset=UTF-8

Recently I was optimizing reference counting in a tight loop, and was 
surprised to discover that all pointer cast functions take their argument 
by const reference and there are no versions that would take argument by 
value or by rvalue reference. As a result, the following code makes a 
completely unnecessary atomic increment and decrement:

   struct Foo {};

   struct Bar : public Foo {};

   std::shared_ptr<Foo> foo();

   auto bar = std::static_pointer_cast<Bar>(foo());


An obvious solution would be add versions that take parameter by rvalue 
reference:


template<class T, class U> std::shared_ptr<T> static_pointer_cast(const std
::shared_ptr<U>& r);      // since C++11

template<class T, class U> std::shared_ptr<T> dynamic_pointer_cast(const std
::shared_ptr<U>& r);     // since C++11

template<class T, class U> std::shared_ptr<T> const_pointer_cast(const std::
shared_ptr<U>& r);       // since C++11

template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const 
std::shared_ptr<U>& r); // since C++17


template<class T, class U> std::shared_ptr<T> static_pointer_cast(std::
shared_ptr<U>&& r);      // proposed addition

template<class T, class U> std::shared_ptr<T> dynamic_pointer_cast(std::
shared_ptr<U>&& r);     // proposed addition

template<class T, class U> std::shared_ptr<T> const_pointer_cast(std::
shared_ptr<U>&& r);       // proposed addition

template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(std::
shared_ptr<U>&& r); // proposed addition


Or just have a single version of each function, that takes argument by 
value:


template<class T, class U> std::shared_ptr<T> static_pointer_cast(std::
shared_ptr<U> r);      // proposed replacement

template<class T, class U> std::shared_ptr<T> dynamic_pointer_cast(std::
shared_ptr<U> r);     // proposed replacement

template<class T, class U> std::shared_ptr<T> const_pointer_cast(std::
shared_ptr<U> r);       // proposed replacement

template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(std::
shared_ptr<U> r); // proposed replacement


The later makes a redundant increment/decrement in one case: when doing 
dynamic_pointer_cast on a l-value and cast fails



-- 
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/7c02ff86-424d-48aa-bd5e-a2f768bd5484%40isocpp.org.

------=_Part_3166_828223911.1463851199842
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Recently I was optimizing reference counting in a tight lo=
op, and was surprised to discover that all pointer cast functions take thei=
r argument by const reference and there are no versions that would take arg=
ument by value or by rvalue reference. As a result, the following code make=
s a completely unnecessary atomic increment and decrement:<div><p style=3D"=
font-size: 11px; line-height: normal; font-family: Menlo;"><span style=3D"f=
ont-variant-ligatures: no-common-ligatures; color: #bb2ca2">=C2=A0 =C2=A0st=
ruct</span><span style=3D"font-variant-ligatures: no-common-ligatures"> Foo=
 {};</span></p>
<p style=3D"font-size: 11px; line-height: normal; font-family: Menlo;"><spa=
n style=3D"font-variant-ligatures: no-common-ligatures; color: #bb2ca2">=C2=
=A0 =C2=A0struct</span><span style=3D"font-variant-ligatures: no-common-lig=
atures"> Bar : </span><span style=3D"font-variant-ligatures: no-common-liga=
tures; color: #bb2ca2">public</span><span style=3D"font-variant-ligatures: =
no-common-ligatures"> </span><span style=3D"font-variant-ligatures: no-comm=
on-ligatures; color: #4f8187">Foo</span><span style=3D"font-variant-ligatur=
es: no-common-ligatures"> {};</span></p>
<p style=3D"font-size: 11px; line-height: normal; font-family: Menlo; color=
: rgb(112, 61, 170);"><span style=3D"font-variant-ligatures: no-common-liga=
tures"><span style=3D"color: rgb(187, 44, 162);">=C2=A0 =C2=A0</span>std</s=
pan><span style=3D"font-variant-ligatures: no-common-ligatures; color: #000=
000">::</span><span style=3D"font-variant-ligatures: no-common-ligatures">s=
hared_ptr</span><span style=3D"font-variant-ligatures: no-common-ligatures;=
 color: #000000">&lt;</span><span style=3D"font-variant-ligatures: no-commo=
n-ligatures; color: #4f8187">Foo</span><span style=3D"font-variant-ligature=
s: no-common-ligatures; color: #000000">&gt; foo();</span></p>
<p style=3D"font-size: 11px; line-height: normal; font-family: Menlo; color=
: rgb(61, 29, 129);"><span style=3D"font-variant-ligatures: no-common-ligat=
ures; color: #bb2ca2">=C2=A0 =C2=A0auto</span><span style=3D"font-variant-l=
igatures: no-common-ligatures; color: #000000"> bar =3D </span><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: #703daa">std</span>=
<span style=3D"font-variant-ligatures: no-common-ligatures; color: #000000"=
>::</span><span style=3D"font-variant-ligatures: no-common-ligatures">stati=
c_pointer_cast</span><span style=3D"font-variant-ligatures: no-common-ligat=
ures; color: #000000">&lt;</span><span style=3D"font-variant-ligatures: no-=
common-ligatures; color: #4f8187">Bar</span><span style=3D"font-variant-lig=
atures: no-common-ligatures; color: #000000">&gt;(</span><span style=3D"fon=
t-variant-ligatures: no-common-ligatures; color: #31595d">foo</span><span s=
tyle=3D"font-variant-ligatures: no-common-ligatures; color: #000000">());</=
span></p><p style=3D"font-size: 11px; line-height: normal; font-family: Men=
lo; color: rgb(61, 29, 129);"><span style=3D"font-variant-ligatures: no-com=
mon-ligatures; color: #000000"><br></span></p><p style=3D"font-size: 11px; =
line-height: normal; font-family: Menlo;"><span style=3D"font-family: Arial=
, Helvetica, sans-serif; font-size: 13px;">An obvious solution would be add=
 versions that take parameter by rvalue reference</span><span style=3D"font=
-family: Arial, Helvetica, sans-serif; font-size: 13px;">:</span></p><p sty=
le=3D"font-size: 11px; line-height: normal; font-family: Menlo;"><span styl=
e=3D"font-family: Arial, Helvetica, sans-serif; font-size: 13px;"><br></spa=
n></p><p style=3D"font-size: 11px; line-height: normal; font-family: Menlo;=
"><span style=3D"font-variant-ligatures: no-common-ligatures; color: #bb2ca=
2">template</span><span style=3D"font-variant-ligatures: no-common-ligature=
s">&lt;</span><span style=3D"font-variant-ligatures: no-common-ligatures; c=
olor: #bb2ca2">class</span><span style=3D"font-variant-ligatures: no-common=
-ligatures"> T, </span><span style=3D"font-variant-ligatures: no-common-lig=
atures; color: #bb2ca2">class</span><span style=3D"font-variant-ligatures: =
no-common-ligatures"> U&gt; </span><span style=3D"font-variant-ligatures: n=
o-common-ligatures; color: #703daa">std</span><span style=3D"font-variant-l=
igatures: no-common-ligatures">::</span><span style=3D"font-variant-ligatur=
es: no-common-ligatures; color: #703daa">shared_ptr</span><span style=3D"fo=
nt-variant-ligatures: no-common-ligatures">&lt;T&gt; static_pointer_cast(</=
span><span style=3D"font-variant-ligatures: no-common-ligatures; color: #bb=
2ca2">const</span><span style=3D"font-variant-ligatures: no-common-ligature=
s"> </span><span style=3D"font-variant-ligatures: no-common-ligatures; colo=
r: #703daa">std</span><span style=3D"font-variant-ligatures: no-common-liga=
tures">::</span><span style=3D"font-variant-ligatures: no-common-ligatures;=
 color: #703daa">shared_ptr</span><span style=3D"font-variant-ligatures: no=
-common-ligatures">&lt;U&gt;&amp; r);=C2=A0 =C2=A0 =C2=A0 </span><span styl=
e=3D"font-variant-ligatures: no-common-ligatures; color: #008400">// since =
C++11</span></p><p style=3D"font-size: 11px; line-height: normal; font-fami=
ly: Menlo;"><span style=3D"font-variant-ligatures: no-common-ligatures; col=
or: #bb2ca2">template</span><span style=3D"font-variant-ligatures: no-commo=
n-ligatures">&lt;</span><span style=3D"font-variant-ligatures: no-common-li=
gatures; color: #bb2ca2">class</span><span style=3D"font-variant-ligatures:=
 no-common-ligatures"> T, </span><span style=3D"font-variant-ligatures: no-=
common-ligatures; color: #bb2ca2">class</span><span style=3D"font-variant-l=
igatures: no-common-ligatures"> U&gt; </span><span style=3D"font-variant-li=
gatures: no-common-ligatures; color: #703daa">std</span><span style=3D"font=
-variant-ligatures: no-common-ligatures">::</span><span style=3D"font-varia=
nt-ligatures: no-common-ligatures; color: #703daa">shared_ptr</span><span s=
tyle=3D"font-variant-ligatures: no-common-ligatures">&lt;T&gt; dynamic_poin=
ter_cast(</span><span style=3D"font-variant-ligatures: no-common-ligatures;=
 color: #bb2ca2">const</span><span style=3D"font-variant-ligatures: no-comm=
on-ligatures"> </span><span style=3D"font-variant-ligatures: no-common-liga=
tures; color: #703daa">std</span><span style=3D"font-variant-ligatures: no-=
common-ligatures">::</span><span style=3D"font-variant-ligatures: no-common=
-ligatures; color: #703daa">shared_ptr</span><span style=3D"font-variant-li=
gatures: no-common-ligatures">&lt;U&gt;&amp; r); =C2=A0 =C2=A0 </span><span=
 style=3D"font-variant-ligatures: no-common-ligatures; color: #008400">// s=
ince C++11</span></p><p style=3D"font-size: 11px; line-height: normal; font=
-family: Menlo;"><span style=3D"font-variant-ligatures: no-common-ligatures=
; color: #bb2ca2">template</span><span style=3D"font-variant-ligatures: no-=
common-ligatures">&lt;</span><span style=3D"font-variant-ligatures: no-comm=
on-ligatures; color: #bb2ca2">class</span><span style=3D"font-variant-ligat=
ures: no-common-ligatures"> T, </span><span style=3D"font-variant-ligatures=
: no-common-ligatures; color: #bb2ca2">class</span><span style=3D"font-vari=
ant-ligatures: no-common-ligatures"> U&gt; </span><span style=3D"font-varia=
nt-ligatures: no-common-ligatures; color: #703daa">std</span><span style=3D=
"font-variant-ligatures: no-common-ligatures">::</span><span style=3D"font-=
variant-ligatures: no-common-ligatures; color: #703daa">shared_ptr</span><s=
pan style=3D"font-variant-ligatures: no-common-ligatures">&lt;T&gt; const_p=
ointer_cast(</span><span style=3D"font-variant-ligatures: no-common-ligatur=
es; color: #bb2ca2">const</span><span style=3D"font-variant-ligatures: no-c=
ommon-ligatures"> </span><span style=3D"font-variant-ligatures: no-common-l=
igatures; color: #703daa">std</span><span style=3D"font-variant-ligatures: =
no-common-ligatures">::</span><span style=3D"font-variant-ligatures: no-com=
mon-ligatures; color: #703daa">shared_ptr</span><span style=3D"font-variant=
-ligatures: no-common-ligatures">&lt;U&gt;&amp; r); =C2=A0 =C2=A0 =C2=A0 </=
span><span style=3D"font-variant-ligatures: no-common-ligatures; color: #00=
8400">// since C++11</span></p><p style=3D"font-size: 11px; line-height: no=
rmal; font-family: Menlo;"><span style=3D"font-variant-ligatures: no-common=
-ligatures; color: #bb2ca2">template</span><span style=3D"font-variant-liga=
tures: no-common-ligatures">&lt;</span><span style=3D"font-variant-ligature=
s: no-common-ligatures; color: #bb2ca2">class</span><span style=3D"font-var=
iant-ligatures: no-common-ligatures"> T, </span><span style=3D"font-variant=
-ligatures: no-common-ligatures; color: #bb2ca2">class</span><span style=3D=
"font-variant-ligatures: no-common-ligatures"> U&gt; </span><span style=3D"=
font-variant-ligatures: no-common-ligatures; color: #703daa">std</span><spa=
n style=3D"font-variant-ligatures: no-common-ligatures">::</span><span styl=
e=3D"font-variant-ligatures: no-common-ligatures; color: #703daa">shared_pt=
r</span><span style=3D"font-variant-ligatures: no-common-ligatures">&lt;T&g=
t; reinterpret_pointer_cast(</span><span style=3D"font-variant-ligatures: n=
o-common-ligatures; color: #bb2ca2">const</span><span style=3D"font-variant=
-ligatures: no-common-ligatures"> </span><span style=3D"font-variant-ligatu=
res: no-common-ligatures; color: #703daa">std</span><span style=3D"font-var=
iant-ligatures: no-common-ligatures">::</span><span style=3D"font-variant-l=
igatures: no-common-ligatures; color: #703daa">shared_ptr</span><span style=
=3D"font-variant-ligatures: no-common-ligatures">&lt;U&gt;&amp; r); </span>=
<span style=3D"font-variant-ligatures: no-common-ligatures; color: #008400"=
>// since C++17</span></p><p style=3D"font-size: 11px; line-height: normal;=
 font-family: Menlo; min-height: 13px;"><span style=3D"font-variant-ligatur=
es: no-common-ligatures"></span><br></p><p style=3D"font-size: 11px; line-h=
eight: normal; font-family: Menlo;"><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #bb2ca2">template</span><span style=3D"font-var=
iant-ligatures: no-common-ligatures">&lt;</span><span style=3D"font-variant=
-ligatures: no-common-ligatures; color: #bb2ca2">class</span><span style=3D=
"font-variant-ligatures: no-common-ligatures"> T, </span><span style=3D"fon=
t-variant-ligatures: no-common-ligatures; color: #bb2ca2">class</span><span=
 style=3D"font-variant-ligatures: no-common-ligatures"> U&gt; </span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #703daa">std</=
span><span style=3D"font-variant-ligatures: no-common-ligatures">::</span><=
span style=3D"font-variant-ligatures: no-common-ligatures; color: #703daa">=
shared_ptr</span><span style=3D"font-variant-ligatures: no-common-ligatures=
">&lt;T&gt; static_pointer_cast(</span><span style=3D"font-variant-ligature=
s: no-common-ligatures; color: #703daa">std</span><span style=3D"font-varia=
nt-ligatures: no-common-ligatures">::</span><span style=3D"font-variant-lig=
atures: no-common-ligatures; color: #703daa">shared_ptr</span><span style=
=3D"font-variant-ligatures: no-common-ligatures">&lt;U&gt;&amp;&amp; r); =
=C2=A0 =C2=A0 =C2=A0</span><span style=3D"font-variant-ligatures: no-common=
-ligatures; color: #008400">// proposed addition</span></p><p style=3D"font=
-size: 11px; line-height: normal; font-family: Menlo;"><span style=3D"font-=
variant-ligatures: no-common-ligatures; color: #bb2ca2">template</span><spa=
n style=3D"font-variant-ligatures: no-common-ligatures">&lt;</span><span st=
yle=3D"font-variant-ligatures: no-common-ligatures; color: #bb2ca2">class</=
span><span style=3D"font-variant-ligatures: no-common-ligatures"> T, </span=
><span style=3D"font-variant-ligatures: no-common-ligatures; color: #bb2ca2=
">class</span><span style=3D"font-variant-ligatures: no-common-ligatures"> =
U&gt; </span><span style=3D"font-variant-ligatures: no-common-ligatures; co=
lor: #703daa">std</span><span style=3D"font-variant-ligatures: no-common-li=
gatures">::</span><span style=3D"font-variant-ligatures: no-common-ligature=
s; color: #703daa">shared_ptr</span><span style=3D"font-variant-ligatures: =
no-common-ligatures">&lt;T&gt; dynamic_pointer_cast(</span><span style=3D"f=
ont-variant-ligatures: no-common-ligatures; color: #703daa">std</span><span=
 style=3D"font-variant-ligatures: no-common-ligatures">::</span><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: #703daa">shared_ptr=
</span><span style=3D"font-variant-ligatures: no-common-ligatures">&lt;U&gt=
;&amp;&amp; r);=C2=A0 =C2=A0 =C2=A0</span><span style=3D"font-variant-ligat=
ures: no-common-ligatures; color: #008400">// proposed addition</span></p><=
p style=3D"font-size: 11px; line-height: normal; font-family: Menlo;"><span=
 style=3D"font-variant-ligatures: no-common-ligatures; color: #bb2ca2">temp=
late</span><span style=3D"font-variant-ligatures: no-common-ligatures">&lt;=
</span><span style=3D"font-variant-ligatures: no-common-ligatures; color: #=
bb2ca2">class</span><span style=3D"font-variant-ligatures: no-common-ligatu=
res"> T, </span><span style=3D"font-variant-ligatures: no-common-ligatures;=
 color: #bb2ca2">class</span><span style=3D"font-variant-ligatures: no-comm=
on-ligatures"> U&gt; </span><span style=3D"font-variant-ligatures: no-commo=
n-ligatures; color: #703daa">std</span><span style=3D"font-variant-ligature=
s: no-common-ligatures">::</span><span style=3D"font-variant-ligatures: no-=
common-ligatures; color: #703daa">shared_ptr</span><span style=3D"font-vari=
ant-ligatures: no-common-ligatures">&lt;T&gt; const_pointer_cast(</span><sp=
an style=3D"font-variant-ligatures: no-common-ligatures; color: #703daa">st=
d</span><span style=3D"font-variant-ligatures: no-common-ligatures">::</spa=
n><span style=3D"font-variant-ligatures: no-common-ligatures; color: #703da=
a">shared_ptr</span><span style=3D"font-variant-ligatures: no-common-ligatu=
res">&lt;U&gt;&amp;&amp; r);=C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: #008400">// propose=
d addition</span></p><p style=3D"font-size: 11px; line-height: normal; font=
-family: Menlo; color: rgb(187, 44, 162);">







</p><p style=3D"font-size: 11px; line-height: normal; font-family: Menlo;">=
<span style=3D"font-variant-ligatures: no-common-ligatures; color: #bb2ca2"=
>template</span><span style=3D"font-variant-ligatures: no-common-ligatures"=
>&lt;</span><span style=3D"font-variant-ligatures: no-common-ligatures; col=
or: #bb2ca2">class</span><span style=3D"font-variant-ligatures: no-common-l=
igatures"> T, </span><span style=3D"font-variant-ligatures: no-common-ligat=
ures; color: #bb2ca2">class</span><span style=3D"font-variant-ligatures: no=
-common-ligatures"> U&gt; </span><span style=3D"font-variant-ligatures: no-=
common-ligatures; color: #703daa">std</span><span style=3D"font-variant-lig=
atures: no-common-ligatures">::</span><span style=3D"font-variant-ligatures=
: no-common-ligatures; color: #703daa">shared_ptr</span><span style=3D"font=
-variant-ligatures: no-common-ligatures">&lt;T&gt; reinterpret_pointer_cast=
(</span><span style=3D"font-variant-ligatures: no-common-ligatures; color: =
#703daa">std</span><span style=3D"font-variant-ligatures: no-common-ligatur=
es">::</span><span style=3D"font-variant-ligatures: no-common-ligatures; co=
lor: #703daa">shared_ptr</span><span style=3D"font-variant-ligatures: no-co=
mmon-ligatures">&lt;U&gt;&amp;&amp; r);=C2=A0</span><span style=3D"font-var=
iant-ligatures: no-common-ligatures; color: #008400">// proposed addition</=
span></p><p style=3D"font-size: 11px; line-height: normal; font-family: Men=
lo;"><span style=3D"font-variant-ligatures: no-common-ligatures; color: #00=
8400"><br></span></p><p style=3D"font-size: 11px; line-height: normal; font=
-family: Menlo;"><span style=3D"font-variant-ligatures: no-common-ligatures=
; color: #008400"><span style=3D"color: rgb(34, 34, 34); font-family: Arial=
, Helvetica, sans-serif; font-size: 13px;">Or just have a single version of=
 each function, that takes argument by value:</span><br></span></p><p style=
=3D"font-size: 11px; line-height: normal; font-family: Menlo;"><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: #008400"><span styl=
e=3D"color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; fon=
t-size: 13px;"><br></span></span></p><p style=3D"font-size: 11px; line-heig=
ht: normal; font-family: Menlo;"><span style=3D"font-variant-ligatures: no-=
common-ligatures; color: rgb(187, 44, 162);">template</span><span style=3D"=
font-variant-ligatures: no-common-ligatures;">&lt;</span><span style=3D"fon=
t-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">class<=
/span><span style=3D"font-variant-ligatures: no-common-ligatures;">=C2=A0T,=
=C2=A0</span><span style=3D"font-variant-ligatures: no-common-ligatures; co=
lor: rgb(187, 44, 162);">class</span><span style=3D"font-variant-ligatures:=
 no-common-ligatures;">=C2=A0U&gt;=C2=A0</span><span style=3D"font-variant-=
ligatures: no-common-ligatures; color: rgb(112, 61, 170);">std</span><span =
style=3D"font-variant-ligatures: no-common-ligatures;">::</span><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);"=
>shared_ptr</span><span style=3D"font-variant-ligatures: no-common-ligature=
s;">&lt;T&gt; static_pointer_cast(</span><span style=3D"font-variant-ligatu=
res: no-common-ligatures; color: rgb(112, 61, 170);">std</span><span style=
=3D"font-variant-ligatures: no-common-ligatures;">::</span><span style=3D"f=
ont-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">shar=
ed_ptr</span><span style=3D"font-variant-ligatures: no-common-ligatures;">&=
lt;U&gt; r);=C2=A0=C2=A0 =C2=A0 =C2=A0</span><span style=3D"font-variant-li=
gatures: no-common-ligatures; color: rgb(0, 132, 0);">// proposed replaceme=
nt</span></p><p style=3D"font-size: 11px; line-height: normal; font-family:=
 Menlo;"><span style=3D"font-variant-ligatures: no-common-ligatures; color:=
 rgb(187, 44, 162);">template</span><span style=3D"font-variant-ligatures: =
no-common-ligatures;">&lt;</span><span style=3D"font-variant-ligatures: no-=
common-ligatures; color: rgb(187, 44, 162);">class</span><span style=3D"fon=
t-variant-ligatures: no-common-ligatures;">=C2=A0T,=C2=A0</span><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);"=
>class</span><span style=3D"font-variant-ligatures: no-common-ligatures;">=
=C2=A0U&gt;=C2=A0</span><span style=3D"font-variant-ligatures: no-common-li=
gatures; color: rgb(112, 61, 170);">std</span><span style=3D"font-variant-l=
igatures: no-common-ligatures;">::</span><span style=3D"font-variant-ligatu=
res: no-common-ligatures; color: rgb(112, 61, 170);">shared_ptr</span><span=
 style=3D"font-variant-ligatures: no-common-ligatures;">&lt;T&gt; dynamic_p=
ointer_cast(</span><span style=3D"font-variant-ligatures: no-common-ligatur=
es; color: rgb(112, 61, 170);">std</span><span style=3D"font-variant-ligatu=
res: no-common-ligatures;">::</span><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: rgb(112, 61, 170);">shared_ptr</span><span styl=
e=3D"font-variant-ligatures: no-common-ligatures;">&lt;U&gt; r);=C2=A0 =C2=
=A0 =C2=A0</span><span style=3D"font-variant-ligatures: no-common-ligatures=
; color: rgb(0, 132, 0);">// proposed=C2=A0</span><span style=3D"color: rgb=
(0, 132, 0);">replacement</span></p><p style=3D"font-size: 11px; line-heigh=
t: normal; font-family: Menlo;"><span style=3D"font-variant-ligatures: no-c=
ommon-ligatures; color: rgb(187, 44, 162);">template</span><span style=3D"f=
ont-variant-ligatures: no-common-ligatures;">&lt;</span><span style=3D"font=
-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">class</=
span><span style=3D"font-variant-ligatures: no-common-ligatures;">=C2=A0T,=
=C2=A0</span><span style=3D"font-variant-ligatures: no-common-ligatures; co=
lor: rgb(187, 44, 162);">class</span><span style=3D"font-variant-ligatures:=
 no-common-ligatures;">=C2=A0U&gt;=C2=A0</span><span style=3D"font-variant-=
ligatures: no-common-ligatures; color: rgb(112, 61, 170);">std</span><span =
style=3D"font-variant-ligatures: no-common-ligatures;">::</span><span style=
=3D"font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);"=
>shared_ptr</span><span style=3D"font-variant-ligatures: no-common-ligature=
s;">&lt;T&gt; const_pointer_cast(</span><span style=3D"font-variant-ligatur=
es: no-common-ligatures; color: rgb(112, 61, 170);">std</span><span style=
=3D"font-variant-ligatures: no-common-ligatures;">::</span><span style=3D"f=
ont-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">shar=
ed_ptr</span><span style=3D"font-variant-ligatures: no-common-ligatures;">&=
lt;U&gt; r);=C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"font-variant-l=
igatures: no-common-ligatures; color: rgb(0, 132, 0);">// proposed=C2=A0</s=
pan><span style=3D"color: rgb(0, 132, 0);">replacement</span></p><p style=
=3D"font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(18=
7, 44, 162);"></p><p style=3D"font-size: 11px; line-height: normal; font-fa=
mily: Menlo;"><span style=3D"font-variant-ligatures: no-common-ligatures; c=
olor: #008400"></span></p><p style=3D"font-size: 11px; line-height: normal;=
 font-family: Menlo;"><span style=3D"font-variant-ligatures: no-common-liga=
tures; color: rgb(187, 44, 162);">template</span><span style=3D"font-varian=
t-ligatures: no-common-ligatures;">&lt;</span><span style=3D"font-variant-l=
igatures: no-common-ligatures; color: rgb(187, 44, 162);">class</span><span=
 style=3D"font-variant-ligatures: no-common-ligatures;">=C2=A0T,=C2=A0</spa=
n><span style=3D"font-variant-ligatures: no-common-ligatures; color: rgb(18=
7, 44, 162);">class</span><span style=3D"font-variant-ligatures: no-common-=
ligatures;">=C2=A0U&gt;=C2=A0</span><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: rgb(112, 61, 170);">std</span><span style=3D"fo=
nt-variant-ligatures: no-common-ligatures;">::</span><span style=3D"font-va=
riant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">shared_ptr=
</span><span style=3D"font-variant-ligatures: no-common-ligatures;">&lt;T&g=
t; reinterpret_pointer_cast(</span><span style=3D"font-variant-ligatures: n=
o-common-ligatures; color: rgb(112, 61, 170);">std</span><span style=3D"fon=
t-variant-ligatures: no-common-ligatures;">::</span><span style=3D"font-var=
iant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">shared_ptr<=
/span><span style=3D"font-variant-ligatures: no-common-ligatures;">&lt;U&gt=
; r);=C2=A0</span><span style=3D"font-variant-ligatures: no-common-ligature=
s; color: rgb(0, 132, 0);">// proposed=C2=A0</span><span style=3D"color: rg=
b(0, 132, 0);">replacement</span></p><p style=3D"font-size: 11px; line-heig=
ht: normal; font-family: Menlo;"><span style=3D"color: rgb(0, 132, 0);"><br=
></span></p><p style=3D"line-height: normal;">The later makes a=C2=A0redund=
ant=C2=A0increment/decrement in one case: when doing=C2=A0<span style=3D"fo=
nt-family: Menlo; font-size: 11px;">dynamic_pointer_cast=C2=A0</span>on a l=
-value and cast fails<span style=3D"font-family: Menlo; font-size: 11px; co=
lor: rgb(0, 132, 0);"><br></span></p><p style=3D"line-height: normal;"><br>=
</p><p style=3D"line-height: normal;"><br></p></div></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/7c02ff86-424d-48aa-bd5e-a2f768bd5484%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7c02ff86-424d-48aa-bd5e-a2f768bd5484=
%40isocpp.org</a>.<br />

------=_Part_3166_828223911.1463851199842--

------=_Part_3165_1371086206.1463851199841--

.
