220 34922 <ceb5fbaa-7e73-4c54-b10e-46712f604836@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: euloanty@live.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Thoughts on more methods towards containers in
 the future
Date: Sat, 14 Oct 2017 10:08:37 -0700 (PDT)
Lines: 220
Approved: news@gmane.org
Message-ID: <ceb5fbaa-7e73-4c54-b10e-46712f604836@isocpp.org>
References: <973f04da-1354-44f4-9d1f-23f04596b8dc@isocpp.org>
 <20171014085305.GA24512@fukushima.lysator.liu.se> <79c51b8c-6cc2-4872-8651-9dae513d1e21@isocpp.org>
 <1550fc17-cf97-438d-9e7a-862f729adbf5@isocpp.org> <0cc942cf-a217-4175-98b0-b466ac224dc7@isocpp.org>
 <b50be367-9a0c-4d62-a392-d2b4471d7403@isocpp.org> <e5065ef4-4802-4241-8357-cfb93ba25bae@isocpp.org>
 <e6b61d03-a64e-48fd-81b5-5a5f937f6d1a@isocpp.org> <7e04a500-ba3a-432a-a844-7d4def1fb739@isocpp.org>
 <CADtNNhgCeGu71ZU864hhiyvgNp3eFvh79HFGiVBJdaeSXDVQJA@mail.gmail.com>
 <5c1bc3ef-c3a2-4406-8a7a-f82e12155386@isocpp.org> <69a588d5-de2a-4be2-8add-9685d0b9a230@isocpp.org>
 <405f3ea9-d886-4c3f-9543-a276f8214974@isocpp.org>
 <CAMD6iD_5dpmveP_MuK=BnYAdbueXC2Z_gRRz38yje_b4m9thZA@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_14550_1672372146.1508000917616"
X-Trace: blaine.gmane.org 1508000936 368 195.159.176.226 (14 Oct 2017 17:08:56 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 14 Oct 2017 17:08:56 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDPYX6PYRQNBBFUJRHHQKGQENVUKGAA@isocpp.org Sat Oct 14 19:08:50 2017
Return-path: <std-proposals+bncBDPYX6PYRQNBBFUJRHHQKGQENVUKGAA@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+bncBDPYX6PYRQNBBFUJRHHQKGQENVUKGAA@isocpp.org>)
	id 1e3PvM-0005cR-0I
	for gclcip-std-proposals@m.gmane.org; Sat, 14 Oct 2017 19:08:32 +0200
Original-Received: by mail-ua0-f198.google.com with SMTP id 10sf5316078uav.16
        for <gclcip-std-proposals@m.gmane.org>; Sat, 14 Oct 2017 10:08:39 -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=HEcs4+fE5SJOTEOg9kOWQYt+naXvPGNQEBlUPjsFN6M=;
        b=gSQ0QwpLXhAfiZJJV8GAnzlRkgKfP7Po0b0ksh0QUCNpqCf5LTsJMjJU2V3TP40L//
         vfcA9QtAWxzpEdThLx4rIBMlabc0mO9bv5NGxn4QCnY/FPM9mj2XRSh+JDKCFE55Dax8
         1YodZEeo896zF0NvHdyI5aJkNjhVWey5PuRDoA8MPon5b/d6uTGcpVEfehZ9U2bshmBv
         WQkeY8HfSMZuHyPTGxGFEVnpQ4MrOmlVXl32cj4iMqDlKtHfcFXf1w5T241nTQBlHOgQ
         JgKFchkb+aEe/xX1EDCG6FtT53P6MfSGvGfrCZyMkzoERQQpU7+Uvw19lB6HmUchXRCp
         HlcQ==
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=HEcs4+fE5SJOTEOg9kOWQYt+naXvPGNQEBlUPjsFN6M=;
        b=kIsbnQqO6cCI9rh8WYGF97qBpvwKq1uZnECoY6w/k2bUOgN6YKT+Xs8RkLhteSeNQP
         eCEX+RSvii01walWpzoSqCWaAnGOB4BWtfQcVPbt7q3q0xooO1iPhun3l4xMCA8pvM7g
         ONzSAs8iQdW+kulbrErxREfHCRhN+iA3yFpilsK1IrObrOmVYH9PB5+iuXcosuStqa5Z
         zWEXxBRTEkFfYR8hGA1/1or8d7VYpC5KZfebnS2Hv4kavp0L+iFwNAPn47Oapnj4yaH4
         +ARdPZlOEwiM/Bz/+zWn/1yicF/kOKdXIBGYM41lIYfFAggHxwK1ufdQ/HTIDYt2b1Q6
         b9Vw==
X-Gm-Message-State: AMCzsaVh43dwboCjr9KQR9AMcNs9BNv/xEnsuhxzns8r2zsI+ROJD/cI
	8UdM7Gs8CdocRx8Dalzy8Pymfw==
X-Google-Smtp-Source: AOwi7QD2s5m9NyRHH9Axtelcrp0CZcwmMNSp1wdr8H3aNw6WOqmrUz35SHM++6K5bFD0xUTgpI6x4Q==
X-Received: by 10.159.48.74 with SMTP id i10mr2619685uab.55.1508000919306;
        Sat, 14 Oct 2017 10:08:39 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.242.130 with SMTP id q124ls2424082vkh.19.gmail; Sat, 14 Oct
 2017 10:08:38 -0700 (PDT)
X-Received: by 10.31.11.69 with SMTP id 66mr315913vkl.6.1508000918101;
        Sat, 14 Oct 2017 10:08:38 -0700 (PDT)
In-Reply-To: <CAMD6iD_5dpmveP_MuK=BnYAdbueXC2Z_gRRz38yje_b4m9thZA@mail.gmail.com>
X-Original-Sender: euloanty@live.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:34922
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34922>

------=_Part_14550_1672372146.1508000917616
Content-Type: multipart/alternative; 
	boundary="----=_Part_14551_986730312.1508000917617"

------=_Part_14551_986730312.1508000917617
Content-Type: text/plain; charset="UTF-8"

For example, I can only get my size N at runtime.

On Saturday, October 14, 2017 at 12:44:17 PM UTC-4, Ren Industries wrote:
>
> Do you happen to know of std::array?
>
> On Oct 14, 2017 11:40, <eulo...@live.com <javascript:>> wrote:
>
>>
>>
>> On Saturday, October 14, 2017 at 11:26:58 AM UTC-4, Nicol Bolas wrote:
>>>
>>> On Saturday, October 14, 2017 at 11:02:29 AM UTC-4, ejsvifq mabmip wrote:
>>>>
>>>> The main purpose of C++ containers is to compete with other C style/OOP 
>>>> style implementation.
>>>>
>>>
>>> ... no, it's not.
>>>
>>> The main purpose of standard library containers is to be useful to C++ 
>>> programmers. To provide value to the language by having lingua franca types 
>>> that users can use where appropriate for common programming issues.
>>>  
>>>
>> No. If vector<T> does not have same performance as T* c style array. 
>> C-style array will just live forever. That is why std::vector is 
>> implemented as templates, not OOP/
>>  
>>
>>> If you add if check for [], that would encourage people continue to use 
>>>> c-style-array for better performance.
>>>>
>>>> You have to do everything to make people not have a reason to write 
>>>> their own version of container (for doing the same thing).
>>>>
>>>
>>> No, we don't. The goal of the container design was not to make it so 
>>> that nobody would ever use any other container. It was to make it so that 
>>> people would only use other containers in exceptional circumstances.
>>>
>>> There is no one-size-fits-all approach here, and trying to build one 
>>> will only end in tears.
>>>
>>> That's not to say that I wouldn't mind having unchecked push-back 
>>> operations on `vector`. I think it's asinine to say that we don't need one 
>>> because optimizers will remove it when they can detect that it will always 
>>> be filled. Optimizers can't see or know everything:
>>>
>>> int count;
>>> file_stream >> count;
>>>
>>> vector<int> vec;
>>> vec.reserve(count);
>>>
>>> for(auto x : crange(count))
>>> {
>>>   vec.emplace_back();
>>>   file_stream >> vec.back();
>>> }
>>>
>>> Can an optimizer remove the test in this case? More importantly, if 
>>> you're looking at this code, is it *reasonable* to expect an optimizer 
>>> to be able to do so?
>>>
>>> Pretty hard.
>> Also we should not expect optimizer to remove test. They have different 
>> behaviors. Before C++11, you might even expect optimizer to optimize copy 
>> for vector<T>.
>>
>> -- 
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/405f3ea9-d886-4c3f-9543-a276f8214974%40isocpp.org 
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/405f3ea9-d886-4c3f-9543-a276f8214974%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/ceb5fbaa-7e73-4c54-b10e-46712f604836%40isocpp.org.

------=_Part_14551_986730312.1508000917617
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">For example, I can only get my size N at runtime.<br><br>O=
n Saturday, October 14, 2017 at 12:44:17 PM UTC-4, Ren Industries wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto">Do you happen t=
o know of std::array?</div><div><br><div class=3D"gmail_quote">On Oct 14, 2=
017 11:40,  &lt;<a onmousedown=3D"this.href=3D&#39;javascript:&#39;;return =
true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=3D"j=
avascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=3D"RXc=
8AkAXAQAJ">eulo...@live.com</a>&gt; wrote:<br type=3D"attribution"><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Saturday, October 14, 20=
17 at 11:26:58 AM UTC-4, Nicol Bolas wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr">On Saturday, October 14, 2017 at 11:02:29 AM UTC-4=
, ejsvifq mabmip 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"><div>The main purpose of C++ containers is to compete with other C sty=
le/OOP style implementation.</div></div></blockquote><div><br></div><div>..=
.. no, it&#39;s not.</div><div><br></div><div>The main purpose of standard l=
ibrary containers is to be useful to C++ programmers. To provide value to t=
he language by having lingua franca types that users can use where appropri=
ate for common programming issues.<br></div><div>=C2=A0</div></div></blockq=
uote><div>No. If vector&lt;T&gt; does not have same performance as T* c sty=
le array. C-style array will just live forever. That is why std::vector is =
implemented as templates, not OOP/</div><div>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div>If you add if check for [], that would encourage=
 people continue to use c-style-array for better performance.</div><div><br=
></div><div>You have to do everything to make people not have a reason to w=
rite their own version of container (for doing the same thing).<br></div></=
div></blockquote><div><br></div><div>No, we don&#39;t. The goal of the cont=
ainer design was not to make it so that nobody would ever use any other con=
tainer. It was to make it so that people would only use other containers in=
 exceptional circumstances.</div><div><br></div><div>There is no one-size-f=
its-all approach here, and trying to build one will only end in tears.<br><=
/div><div><br></div><div>That&#39;s not to say that I wouldn&#39;t mind hav=
ing unchecked push-back operations on `vector`. I think it&#39;s asinine to=
 say that we don&#39;t need one because optimizers will remove it when they=
 can detect that it will always be filled. Optimizers can&#39;t see or know=
 everything:</div><div><br></div><div style=3D"background-color:rgb(250,250=
,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><c=
ode><div><span style=3D"color:#008">int</span><span style=3D"color:#000"> c=
ount</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><b=
r>file_stream </span><span style=3D"color:#660">&gt;&gt;</span><span style=
=3D"color:#000"> count</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br><br>vector</span><span style=3D"color:#080">&lt;int&gt;=
</span><span style=3D"color:#000"> vec</span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"><br>vec</span><span style=3D"color:#660">.<=
/span><span style=3D"color:#000">reserve</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">count</span><span style=3D"color:#660">);=
</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#008"=
>for</span><span style=3D"color:#660">(</span><span style=3D"color:#008">au=
to</span><span style=3D"color:#000"> x </span><span style=3D"color:#660">:<=
/span><span style=3D"color:#000"> crange</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">count</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>=C2=A0 vec</span><span style=3D"color:#=
660">.</span><span style=3D"color:#000">emplace_back</span><span style=3D"c=
olor:#660">();</span><span style=3D"color:#000"><br>=C2=A0 file_stream </sp=
an><span style=3D"color:#660">&gt;&gt;</span><span style=3D"color:#000"> ve=
c</span><span style=3D"color:#660">.</span><span style=3D"color:#000">back<=
/span><span style=3D"color:#660">();</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">}</span></div></code></div><div><br></div>=
<div></div><div>Can an optimizer remove the test in this case? More importa=
ntly, if you&#39;re looking at this code, is it <i>reasonable</i> to expect=
 an optimizer to be able to do so?<br></div><br></div></blockquote><div>Pre=
tty hard.</div><div>Also we should not expect optimizer to remove test. The=
y have different behaviors. Before C++11, you might even expect optimizer t=
o optimize copy for vector&lt;T&gt;.</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 onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" o=
nclick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=3D"javascrip=
t:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=3D"RXc8AkAXAQA=
J">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;re=
turn true;" href=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obf=
uscated-mailto=3D"RXc8AkAXAQAJ">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a onmousedown=3D"this.href=3D&#39=
;https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/405f3ea9-d886=
-4c3f-9543-a276f8214974%40isocpp.org?utm_medium\x3demail\x26utm_source\x3df=
ooter&#39;;return true;" onclick=3D"this.href=3D&#39;https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/405f3ea9-d886-4c3f-9543-a276f8214974=
%40isocpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;=
" href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/405f=
3ea9-d886-4c3f-9543-a276f8214974%40isocpp.org?utm_medium=3Demail&amp;utm_so=
urce=3Dfooter" target=3D"_blank" rel=3D"nofollow">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/405f3ea9-d886-4c3f-<wbr>9543-=
a276f8214974%40isocpp.org</a><wbr>.<br>
</blockquote></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/ceb5fbaa-7e73-4c54-b10e-46712f604836%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ceb5fbaa-7e73-4c54-b10e-46712f604836=
%40isocpp.org</a>.<br />

------=_Part_14551_986730312.1508000917617--

------=_Part_14550_1672372146.1508000917616--

.
