220 37123 <4b81b3b8-5def-4003-b073-89af676e837a@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: jsaintmartin356@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: pseudo constness
Date: Wed, 28 Feb 2018 12:30:40 -0800 (PST)
Lines: 149
Approved: news@gmane.org
Message-ID: <4b81b3b8-5def-4003-b073-89af676e837a@isocpp.org>
References: <f202be10-efb5-4f1a-ab6a-18bf6ac873ee@isocpp.org>
 <CAC+0CCPGJ2J=y3x-2voHCffyXTqsPVwWyyjR99v6R-XgyU1V4w@mail.gmail.com>
 <CAC+0CCPu0dEAb9B=KmpiT8NwYd4xgSBuUWYcTRrui_Xj5K+WFA@mail.gmail.com>
 <CAC+0CCNyfhb7L2dk4N0pyu3d=T7q1L5m+nOU2yG05XXj4dH_vg@mail.gmail.com>
 <1519283315.58210.23.camel@gmail.com> <CAC+0CCNYk37F3bivpoKcLLUvEwi+sJAn2O_DF9cP7ZfjBSjHVg@mail.gmail.com>
 <CAC4OUEa2Zk9Wv4YtqbT0w-sUhMqF2mZu36QhQW7e=r-X2+asjQ@mail.gmail.com>
 <0a7e7e42-aa28-4632-8e66-56b0633755ba@isocpp.org> <ca3be727-ed85-4f73-b7f4-72c45c25c913@isocpp.org>
 <b70bf443-bc3b-41ac-9325-bf2456e555ad@isocpp.org> <d108c82b-b76b-4d04-adf8-665ea444a98e@isocpp.org>
 <27b5c95c-5b44-4089-bb14-b2d1b806093b@isocpp.org> <CAC4OUEY+wHXvW-WaiOiV09t3=hoPCdruR-VPGULNixvuvJdF7A@mail.gmail.com>
 <CAC+0CCPg3HbEktBJu+x0r2A0xw0Eg7cMUS=XSy5guSnr8RfcGA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6126_1363222138.1519849840991"
X-Trace: blaine.gmane.org 1519849721 24496 195.159.176.226 (28 Feb 2018 20:28:41 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 28 Feb 2018 20:28:41 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD2KVY7D7YJBB4NC3TKAKGQERZLWMOI@isocpp.org Wed Feb 28 21:28:37 2018
Return-path: <std-proposals+bncBD2KVY7D7YJBB4NC3TKAKGQERZLWMOI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f198.google.com ([209.85.217.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD2KVY7D7YJBB4NC3TKAKGQERZLWMOI@isocpp.org>)
	id 1er8L7-0005s6-3q
	for gclcip-std-proposals@m.gmane.org; Wed, 28 Feb 2018 21:28:37 +0100
Original-Received: by mail-ua0-f198.google.com with SMTP id g9sf2243315ual.8
        for <gclcip-std-proposals@m.gmane.org>; Wed, 28 Feb 2018 12:30:43 -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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=YqT75ANFQvSIPj8coXah5iUTHBLb6NAWsIJEg2h660g=;
        b=sz1uHPXjKjVMizQ2J1Z/tEbi5JPhiDUcWuY6eB9AiccSX3TDgMKsAkewBl7Ik689RF
         MbOkRhEuwG/bFKd4FWaRhor6quoZJvExQlIS7sXVLAVfodRxMXcuMNf/qdloofe7iz67
         t04SbzJ86tUPEftCVdinB6ARxLgU97GglAi7uUr7hb9zjG667x3+K2QURq2D/owhPcp2
         HE96tdLse4u7WcwNyvdqn9SyfTNLTyvPz9L8v/uay/Nn0NoBWOnS9gh63nY8VW9reak0
         Ka22/sAz9fTisDFSgZ6fNXRaVMQs5KznnwiS9mzD+llAnZa8Shzoy46fFp3A2q03Db/p
         N3pg==
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=YqT75ANFQvSIPj8coXah5iUTHBLb6NAWsIJEg2h660g=;
        b=cpyI5AKqkSqslaVx6blyIuSNFLfj2BUS3K88hJsUnwF/K8ZdbrGymhg0hUbSH0uEin
         rrMPqTJhENeaSP/LQD5npgCamwmLBKY3fJUE6+JtOUjUvX+dlNc6qtOk4ORu/EcWF+du
         XGrqEKkzQ42EIbgvt7jfIeGTZRwbgAVoIGNY8E4DUpvVa1gK0J5E7MLFEiABWJQU/AbO
         ibL2SYsp2nM0DFh+BUZIHgpN4VcKbZOdhnNmvlUXYcW8TirsdRbhpgC3NBqM7LyWHh4R
         ENQs52Nd5pe0CcCowNy5mAs6y2Lased+LEgLTJPRK0l1XK8aaTOb46n+1O8KWsUZLYtt
         mldA==
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=YqT75ANFQvSIPj8coXah5iUTHBLb6NAWsIJEg2h660g=;
        b=G/cJU9W2YA6fwjCrXKOvfcCfz7VJVK/1gE0KO7/F/YQ5+qPo8lNYl7xNHstnL0SNfF
         elsEjydDORAhMfJA2zt8FVYG8bsI65NnJSzvM7EqB5qvbk0aOqKs5j9/WVze4jTmTeP6
         PBs9TWNAZ8Ffdx/f2xFWMMsC6GI8GmIuJSxBh8uD319iLA0zjQ7HYsGGgqxQVe3Ixmy/
         MmMSfbfwMmFWrfD1pWsxl2WjCH73NbU0dFqUREmmiKHclxwhLcwV+X/s0Pv9G0AXgp27
         FmALF2TDCFE4P/+CaV7zOrWDqnYfhjk5qGn7yFowWoHeOpY9yoLgAA8a67p1tz7Pg9kB
         dqQA==
X-Gm-Message-State: APf1xPDJvKZc0uKY4k85OJ3gIbosIp5pfzUlPvb1ybeGZiSiH2oKFcDn
	oMmjfkJ/Am8XGoQtU/9T3Qqiug==
X-Google-Smtp-Source: AG47ELsgHOpE/L+THb7/7co6nRtVsVqXgQHMOh9Q8hSPnl50S4Qz/DRAauP1094eqvVNshqFNh69lQ==
X-Received: by 10.176.9.208 with SMTP id e16mr7776697uah.27.1519849843256;
        Wed, 28 Feb 2018 12:30:43 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.196.71 with SMTP id u68ls2409951vkf.5.gmail; Wed, 28 Feb
 2018 12:30:41 -0800 (PST)
X-Received: by 10.31.180.79 with SMTP id d76mr1934494vkf.7.1519849841575;
        Wed, 28 Feb 2018 12:30:41 -0800 (PST)
In-Reply-To: <CAC+0CCPg3HbEktBJu+x0r2A0xw0Eg7cMUS=XSy5guSnr8RfcGA@mail.gmail.com>
X-Original-Sender: jsaintmartin356@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:37123
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37123>

------=_Part_6126_1363222138.1519849840991
Content-Type: multipart/alternative; 
	boundary="----=_Part_6127_928035103.1519849840992"

------=_Part_6127_928035103.1519849840992
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Another use of pseudoconst / reversible would allow to use hint to find an=
=20
element in map within a pseudo const method. As far as I know,
m.insert (ihint, p) exists,=20
but not map.find (ihint, p)

With peudo const, you could write your pseudoconst find,  like this, if you=
=20
are certain -1 is not a second existing in the map, and map.erase (i) was=
=20
defined as the reverse of insert (i) :

std::map<size_t, size_t>::iterator find (std::map<size_t, size_t>& m,=20
std::pair<size_t, size_t>& p)  reversible {
  std::pair<size_t, size_t> p2 .(p.first, (size_t) -1);
  m.insert (ihint, p);
  if (ihint->second =3D=3D (size_t) -1) {
    m.erase (ihint);
    ihint =3D m.end ();
  }
  return ihint;
}
 =20


"
On Friday, February 23, 2018 at 1:27:03 PM UTC+1, Jake Arkinstall wrote:
>
> On 23 Feb 2018 08:58, "J=C3=A9r=C3=B4me Saint-Martin" <jsaintm...@gmail.c=
om=20
> <javascript:>> wrote:
>
> pseudo const Is an indication to users : "the method should not change th=
e=20
> object".=20
>
>
> *Const* is an *guarantee* to users: the method *does* not change the=20
> object. A pseudoconst method would also have to guarantee this or the=20
> proposal wouldn't be useful at all. So, once again, come up with a way of=
=20
> guranteeing that a modification is reversed. A "reversible" or similar=20
> keyword would be more interesting. All it needs to do is only permit a=20
> series of commands and functions that are themselves reversible (ones tha=
t=20
> lose no information, so type limitations must be considered - see, for=20
> example, http://cpp.sh/9fet5 and http://cpp.sh/9redh ), in the same way=
=20
> that const only permits use of operations that are also const. Then you=
=20
> need something built into the language that does the reversing.
>
> This could be useful in a variety of situations. One of which would be an=
=20
> enforceable pseudoconst.
>
"=20

--=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/4b81b3b8-5def-4003-b073-89af676e837a%40isocpp.or=
g.

------=_Part_6127_928035103.1519849840992
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Another use of pseudoconst / reversible would allow to use=
 hint to find an element in map within a pseudo const method. As far as I k=
now,<br>m.insert (ihint, p) exists, <br>but not map.find (ihint, p)<br><br>=
With peudo const, you could write your pseudoconst find,=C2=A0 like this, i=
f you are certain -1 is not a second existing in the map, and map.erase (i)=
 was defined as the reverse of insert (i) :<br><br>std::map&lt;size_t, size=
_t&gt;::iterator find (std::map&lt;size_t, size_t&gt;&amp; m, std::pair&lt;=
size_t, size_t&gt;&amp; p)=C2=A0 reversible {<br>=C2=A0 std::pair&lt;size_t=
, size_t&gt; p2 .(p.first, (size_t) -1);<br>=C2=A0 m.insert (ihint, p);<br>=
=C2=A0 if (ihint-&gt;second =3D=3D (size_t) -1) {<br>=C2=A0=C2=A0=C2=A0 m.e=
rase (ihint);<br>=C2=A0=C2=A0=C2=A0 ihint =3D m.end ();<br>=C2=A0 }<br>=C2=
=A0 return ihint;<br>}<br>=C2=A0 <br><br><br>&quot;<br>On Friday, February =
23, 2018 at 1:27:03 PM UTC+1, Jake Arkinstall wrote:<blockquote class=3D"gm=
ail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc soli=
d;padding-left: 1ex;"><div dir=3D"auto"><div><div><div class=3D"gmail_quote=
">On 23 Feb 2018 08:58, &quot;J=C3=A9r=C3=B4me Saint-Martin&quot; &lt;<a hr=
ef=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"WqpozgUTAAAJ"=
 rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return t=
rue;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">jsaintm...=
@gmail.com</a>&gt; wrote:<br type=3D"attribution"><blockquote style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"=
>pseudo const Is an indication to users : &quot;the method should not chang=
e the object&quot;.=C2=A0</div></blockquote></div></div></div><div dir=3D"a=
uto"><br></div><div dir=3D"auto"><i>Const</i> is an <i>guarantee</i> to use=
rs: the method <i>does</i>=C2=A0not change the object. A pseudoconst method=
 would also have to guarantee this or the proposal wouldn&#39;t be useful a=
t all. So, once again, come up with a way of guranteeing that a modificatio=
n is reversed. A &quot;reversible&quot; or similar keyword would be more in=
teresting. All it needs to do is only permit a series of commands and funct=
ions that are themselves reversible (ones that lose no information, so type=
 limitations must be considered - see, for example, <a href=3D"http://cpp.s=
h/9fet5" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39=
;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcpp.sh%2F9fet5\x26sa\x3dD\x26s=
ntz\x3d1\x26usg\x3dAFQjCNGsOlE-ePVnks77rm2pF2hvT8zUkA&#39;;return true;" on=
click=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcpp.s=
h%2F9fet5\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGsOlE-ePVnks77rm2pF2hvT8z=
UkA&#39;;return true;">http://cpp.sh/9fet5</a> and <a href=3D"http://cpp.sh=
/9redh" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fcpp.sh%2F9redh\x26sa\x3dD\x26sn=
tz\x3d1\x26usg\x3dAFQjCNGXDPCUOcwWbKeaQxa7t7nZSpb9VQ&#39;;return true;" onc=
lick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcpp.sh=
%2F9redh\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGXDPCUOcwWbKeaQxa7t7nZSpb9=
VQ&#39;;return true;">http://cpp.sh/9redh</a> ), in the same way that const=
 only permits use of operations that are also const. Then you need somethin=
g built into the language that does the reversing.</div><div dir=3D"auto"><=
br></div><div dir=3D"auto">This could be useful in a variety of situations.=
 One of which would be an enforceable pseudoconst.</div></div></blockquote>=
<div>&quot; <br></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/4b81b3b8-5def-4003-b073-89af676e837a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4b81b3b8-5def-4003-b073-89af676e837a=
%40isocpp.org</a>.<br />

------=_Part_6127_928035103.1519849840992--

------=_Part_6126_1363222138.1519849840991--

.
