220 38741 <077d3c60-6cc4-42aa-9b18-5dbb593b107b@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Charles Salvia <charles.a.salvia@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal for generic rebind template
Date: Tue, 19 Jun 2018 18:30:05 -0700 (PDT)
Lines: 221
Approved: news@gmane.org
Message-ID: <077d3c60-6cc4-42aa-9b18-5dbb593b107b@isocpp.org>
References: <824bd50b-55f9-4ca5-b17f-db5ba21245dd@isocpp.org>
 <CAM76qmvuEgiO-NXjNMesTJuRnMpx4=ueot7i_RL27UY_WbiO3w@mail.gmail.com>
 <eefbbc29-477c-403c-8cc1-361a17dc2653@isocpp.org>
 <7f5b55e9-e935-421a-b0ab-3b5cbbb1c624@isocpp.org>
 <17d39779-2bb9-4073-ab3f-4b14eef2d0de@isocpp.org>
 <600a547b-484d-4c2e-812e-cf3d9762ea71@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_27087_463653750.1529458205129"
X-Trace: blaine.gmane.org 1529458081 27253 195.159.176.226 (20 Jun 2018 01:28:01 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 20 Jun 2018 01:28:01 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDY6DLOFSEPBBHW4U3MQKGQEBFQDICQ@isocpp.org Wed Jun 20 03:27:57 2018
Return-path: <std-proposals+bncBDY6DLOFSEPBBHW4U3MQKGQEBFQDICQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f198.google.com ([209.85.213.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDY6DLOFSEPBBHW4U3MQKGQEBFQDICQ@isocpp.org>)
	id 1fVRue-0006yC-HJ
	for gclcip-std-proposals@m.gmane.org; Wed, 20 Jun 2018 03:27:56 +0200
Original-Received: by mail-yb0-f198.google.com with SMTP id d1-v6sf994350ybq.16
        for <gclcip-std-proposals@m.gmane.org>; Tue, 19 Jun 2018 18:30:07 -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:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=JDf3+nYsHp+kqXQY6QZPsMnfPSWJl+f+CqPTD48p4ZQ=;
        b=VuJ6sKQ0FUPRa3I97OTyC/kvm3AvvHmU3my7kTQQO0vhRQ9QArfYFZLtZHM6ps48z/
         Kl8gAgXjIjcenJTcdNXHEOO1G9e4WAxtHz9OytB5rrAWG9Tterh0xSTcx0R0MrikN0mc
         BPgBMge8aDBXEPCAHtoICUiE8GQmw9WvjXipZ4y7LC65NLIJT0UXsbRg8Lo5qeXFN8Xa
         uHzmBXo5vUDRvqVSchknspD/MIjYpzy4ymvlrSiBOkyB6OycY9s1KpnOieLFjibBRBsh
         fbBaAKcjEB80dc5nxTRJWI/aW/8K0BjnScQS+IcdHzzrAAKA8GSbCNpWwzD9VZIiJYEc
         F1lg==
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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=JDf3+nYsHp+kqXQY6QZPsMnfPSWJl+f+CqPTD48p4ZQ=;
        b=t6X4Y0oO5AyNWdwr95wawV815Cw2Y+rRxwfOfuEKJFJq5jgVAN0MxSkNwuEQvgERCa
         y/bVGoJvpwNGWOVid//MEML+AMDnYt7SHaNr2oIMjRVVKiVFT3pIeCtMsI9U4oLAC1aF
         tvL4/Rq1k6OB3YoeOFu+xH0BdUHuQYPCE1LJy9ugLdvsf/+VtdEgcXDyUvGtxd6sYppP
         16lMMw7/+tG87PdaeTouKJPyLWQSLB17F6+wlxzQ84fHK1/7ZQYWlVPM3+/NhUme42ge
         WozTz1OzUQof56CiyZR9vx0+oBi3V2/qom44oi7Y6eLw+ICEQopKB5K0BUvRyz3NSNGe
         srzA==
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=JDf3+nYsHp+kqXQY6QZPsMnfPSWJl+f+CqPTD48p4ZQ=;
        b=WiSuBiOPFxmwgx1MEN3qVBxtJFIK7ohzHuOsppMfXXfDtbFLRdrr9cDlT0aP83+8M+
         H8f1TeDi6J+e5VuUYM1nNbul6xweZnHZalBM6G46qfN5drrRKAqrffR4fcdbnLfQiien
         JWoLYCGOpeWc4euCi7S4QozF3riuj+CE/dBYuJbq8pEZFkhhdXs15GHeuogELJtyWkmq
         C6MRrd9zztwdrR41rX3Ni+sMuxLSOUj0CZeKmTz4u7mq6iibTSA/+01zPfATDhdfJOBU
         5ff94UHUq+AlSc+YniguHXbARCyonunhelPEtUGz7/SUzyzkCtbo3vb4NZ7V+zcML98F
         q4BQ==
X-Gm-Message-State: APt69E2An4HAKsbIKyvKaxBr036M7OOFBGEeBEbPSEg83zTwiGCajnUR
	DNKoPijUQcLUTNzyO8COO4IeQQ==
X-Google-Smtp-Source: ADUXVKLj5/1ps2CjlqBtaqs0bmPUczYNw/Wj1of9ZjYNaotM89+Z3oMqFgXkYOD/ja9mS0VwAAbVsA==
X-Received: by 2002:a81:3e03:: with SMTP id l3-v6mr5828441ywa.60.1529458207351;
        Tue, 19 Jun 2018 18:30:07 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:6e82:: with SMTP id j124-v6ls164182ywc.42.gmail; Tue, 19
 Jun 2018 18:30:06 -0700 (PDT)
X-Received: by 2002:a0d:dd09:: with SMTP id g9-v6mr947967ywe.6.1529458205736;
        Tue, 19 Jun 2018 18:30:05 -0700 (PDT)
In-Reply-To: <600a547b-484d-4c2e-812e-cf3d9762ea71@isocpp.org>
X-Original-Sender: charles.a.salvia@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:38741
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38741>

------=_Part_27087_463653750.1529458205129
Content-Type: multipart/alternative; 
	boundary="----=_Part_27088_1789772432.1529458205129"

------=_Part_27088_1789772432.1529458205129
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Yeah, I see what you mean.  I suppose it's unclear to me actually if that's=
=20
bad.  The default argument for template parameter 2 in std::vector is=20
std::allocator, not std::pmr::polymorphic_allocator.  Default arguments are=
=20
really a property of the *template*, not a particular instantiation - so=20
naturally, if you omit the second parameter in the rebind expression,=20
relying on the default parameter, then it would of course have to use the=
=20
default parameter used by the *template*, which is std::allocator.  So, I=
=20
guess you could argue this is to be the expected behavior.  You'd need to=
=20
explicitly spell out the second argument if you wanted to use a different=
=20
allocator type.

Regardless, I agree with you that cases like this certainly call into=20
question the overall usefulness of an attempt to write a generic rebind=20
template.

On Tuesday, June 19, 2018 at 6:20:54 PM UTC-4, Arthur O'Dwyer wrote:
>
> On Tuesday, June 19, 2018 at 2:57:36 PM UTC-7, Charles Salvia wrote:
>>
>> Right.  In that case it wouldn't do the expected thing, because=20
>> std::pmr::vector is defined as an alias template rather than a class=20
>> template.
>>
>
> Even if you spell out the type, your "rebind" STILL does the wrong thing.
>
>     using V =3D std::vector<int, std::pmr::polymorphic_allocator<int>>;
>     using W =3D rebind_t<V, double>;
>     static_assert(is_same_v<W, std::vector<double,=20
> std::pmr::polymorphic_allocator<int>>>); // Oops!
>
> =E2=80=93Arthur
>
> =20
>
>> On Tuesday, June 19, 2018 at 1:20:10 PM UTC-4, Arthur O'Dwyer wrote:
>>>
>>> On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salvia wrote:
>>>>
>>>> *Updated draft proposal for generic rebind template:*
>>>>
>>>> http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html
>>>>
>>>> Implementation files:
>>>>
>>>> https://github.com/charles-salvia/std-proposal-generic-template-rebind=
=20
>>>> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-sal=
via%2Fstd-proposal-generic-template-rebind&sa=3DD&sntz=3D1&usg=3DAFQjCNFd63=
xmUN5MQyW_aWJBKDNIE-w9NA>
>>>>
>>>> This is a proposal to create a generic mechanism for rebinding templat=
e=20
>>>> parameters (std::rebind_t), to remove the need for ad-hoc rebind templ=
ates,=20
>>>> such as std::allocator_traits::rebind_alloc, etc.=20
>>>>
>>>
>>> This is a bad idea for several philosophical reasons (and I say that as=
=20
>>> the presenter of this talk <https://www.youtube.com/watch?v=3D0MdSJsCTR=
kY>=20
>>> on a similar subject. The difference is that I don't want any "generic"=
=20
>>> rebind facility, I just want a greater number of special-purpose rebind=
ers).
>>>
>>> However, your idea doesn't work anyway. Try it on some library types:
>>>
>>>     using V =3D std::pmr::vector<int>;
>>>     using W =3D rebind_t<V, double>;
>>>     static_assert(std::is_same_v<W, std::pmr::vector<double>>);  //=20
>>> error!
>>>
>>> Since it's a bad idea *and* doesn't work, I think you should give it up=
..
>>>
>>> However, it's also much easier to implement as a pure library extension=
=20
>>> than you thought it was. I can do it in 28 lines and I bet it can be do=
ne=20
>>> in fewer.
>>> https://wandbox.org/permlink/pRIQ8lJaf8irznwK
>>>
>>> =E2=80=93Arthur
>>>
>>

--=20
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 e=
mail 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/077d3c60-6cc4-42aa-9b18-5dbb593b107b%40isocpp.or=
g.

------=_Part_27088_1789772432.1529458205129
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yeah, I see what you mean.=C2=A0 I suppose it&#39;s unclea=
r to me actually if that&#39;s bad.=C2=A0 The default argument for template=
 parameter 2 in std::vector is std::allocator, not std::pmr::polymorphic_al=
locator.=C2=A0 Default arguments are really a property of the <i>template</=
i>, not a particular instantiation - so naturally, if you omit the second p=
arameter in the rebind expression, relying on the default parameter, then i=
t would of course have to use the default parameter used by the *template*,=
 which is std::allocator.=C2=A0 So, I guess you could argue this is to be t=
he expected behavior.=C2=A0 You&#39;d need to explicitly spell out the seco=
nd argument if you wanted to use a different allocator type.<div><div><br><=
/div><div>Regardless, I agree with you that cases like this certainly call =
into question the overall usefulness of an attempt to write a generic rebin=
d template.<br></div><div><div><br>On Tuesday, June 19, 2018 at 6:20:54 PM =
UTC-4, Arthur O&#39;Dwyer wrote:<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">On Tuesday, June 19, 2018 at 2:57:36 PM UTC-7, Charles S=
alvia wrote:<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">Right.=
=C2=A0 In that case it wouldn&#39;t do the expected thing, because std::pmr=
::vector is defined as an alias template rather than a class template.<br><=
/div></blockquote><div><br></div><div>Even if you spell out the type, your =
&quot;rebind&quot; STILL does the wrong thing.</div><div><br></div><div>=C2=
=A0 =C2=A0 using V =3D std::vector&lt;int, std::pmr::polymorphic_<wbr>alloc=
ator&lt;int&gt;&gt;;</div><div>=C2=A0 =C2=A0 using W =3D rebind_t&lt;V, dou=
ble&gt;;</div><div>=C2=A0 =C2=A0 static_assert(is_same_v&lt;W, std::vector&=
lt;double, std::pmr::polymorphic_<wbr>allocator&lt;int&gt;&gt;&gt;); // Oop=
s!</div><div><br></div><div>=E2=80=93Arthur</div><div><br></div><div>=C2=A0=
</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">On Tuesday, =
June 19, 2018 at 1:20:10 PM UTC-4, Arthur O&#39;Dwyer wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr">On Monday, June 18, 2018 at 9:03:=
12 AM UTC-7, Charles Salvia wrote:<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"><b>Updated draft proposal for generic rebind template:</b=
><div><br></div><div><a href=3D"http://charles-salvia.github.io/CPP-REBIND-=
PROPOSAL.html" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=
=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.i=
o%2FCPP-REBIND-PROPOSAL.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1=
gu_d1Sr0hoqq7swlsWak1g&#39;;return true;" onclick=3D"this.href=3D&#39;http:=
//www.google.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FCPP-REBIN=
D-PROPOSAL.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7=
swlsWak1g&#39;;return true;">http://charles-salvia.github.<wbr>io/CPP-REBIN=
D-PROPOSAL.html</a></div><div><br></div><div>Implementation files:</div><di=
v><br></div><div><a href=3D"https://www.google.com/url?q=3Dhttps%3A%2F%2Fgi=
thub.com%2Fcharles-salvia%2Fstd-proposal-generic-template-rebind&amp;sa=3DD=
&amp;sntz=3D1&amp;usg=3DAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA" rel=3D"nofollow=
" target=3D"_blank" onmousedown=3D"this.href=3D&#39;https://www.google.com/=
url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-generic-t=
emplate-rebind\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKD=
NIE-w9NA&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.=
com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-gener=
ic-template-rebind\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aW=
JBKDNIE-w9NA&#39;;return true;">https://github.com/charles-<wbr>salvia/std-=
proposal-generic-<wbr>template-rebind</a></div><div><br></div><div>This is =
a proposal to create a generic mechanism for rebinding template parameters =
(std::rebind_t), to remove the need for ad-hoc rebind templates, such as st=
d::allocator_traits::rebind_<wbr>alloc, etc.=C2=A0</div></div></blockquote>=
<div><br></div><div>This is a bad idea for several philosophical reasons (a=
nd I say that as the presenter of <a href=3D"https://www.youtube.com/watch?=
v=3D0MdSJsCTRkY" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.hre=
f=3D&#39;https://www.youtube.com/watch?v\x3d0MdSJsCTRkY&#39;;return true;" =
onclick=3D"this.href=3D&#39;https://www.youtube.com/watch?v\x3d0MdSJsCTRkY&=
#39;;return true;">this talk</a> on a similar subject. The difference is th=
at I don&#39;t want any &quot;generic&quot; rebind facility, I just want a =
greater number of special-purpose rebinders).</div><div><br></div><div>Howe=
ver, your idea doesn&#39;t work anyway. Try it on some library types:</div>=
<div><br></div><div>=C2=A0 =C2=A0 using V =3D std::pmr::vector&lt;int&gt;;<=
/div><div>=C2=A0 =C2=A0 using W =3D rebind_t&lt;V, double&gt;;</div><div>=
=C2=A0 =C2=A0 static_assert(std::is_same_v&lt;<wbr>W, std::pmr::vector&lt;d=
ouble&gt;&gt;); =C2=A0// error!</div><div><br></div><div>Since it&#39;s a b=
ad idea <b><i>and</i></b> doesn&#39;t work, I think you should give it up.<=
/div><div><br></div><div>However, it&#39;s also much easier to implement as=
 a pure library extension than you thought it was. I can do it in 28 lines =
and I bet it can be done in fewer.</div><div><a href=3D"https://wandbox.org=
/permlink/pRIQ8lJaf8irznwK" rel=3D"nofollow" target=3D"_blank" onmousedown=
=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwandbox.=
org%2Fpermlink%2FpRIQ8lJaf8irznwK\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE=
7TQ5WnDEbqIXY5r9llFNLTY8laQ&#39;;return true;" onclick=3D"this.href=3D&#39;=
https://www.google.com/url?q\x3dhttps%3A%2F%2Fwandbox.org%2Fpermlink%2FpRIQ=
8lJaf8irznwK\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7TQ5WnDEbqIXY5r9llFNL=
TY8laQ&#39;;return true;">https://wandbox.org/permlink/<wbr>pRIQ8lJaf8irznw=
K</a><br></div><div><br></div><div>=E2=80=93Arthur</div></div></blockquote>=
</div></blockquote></div></blockquote></div></div></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/077d3c60-6cc4-42aa-9b18-5dbb593b107b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/077d3c60-6cc4-42aa-9b18-5dbb593b107b=
%40isocpp.org</a>.<br />

------=_Part_27088_1789772432.1529458205129--

------=_Part_27087_463653750.1529458205129--

.
