220 34920 <c5ef6d4a-b54b-4398-ba57-cc22c34323e1@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:03:26 -0700 (PDT)
Lines: 220
Approved: news@gmane.org
Message-ID: <c5ef6d4a-b54b-4398-ba57-cc22c34323e1@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_14650_499460897.1508000606998"
X-Trace: blaine.gmane.org 1508000610 10385 195.159.176.226 (14 Oct 2017 17:03:30 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 14 Oct 2017 17:03:30 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDPYX6PYRQNBBX4GRHHQKGQEPWI6O6A@isocpp.org Sat Oct 14 19:03:24 2017
Return-path: <std-proposals+bncBDPYX6PYRQNBBX4GRHHQKGQEPWI6O6A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f69.google.com ([209.85.213.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDPYX6PYRQNBBX4GRHHQKGQEPWI6O6A@isocpp.org>)
	id 1e3PqL-0001bK-R2
	for gclcip-std-proposals@m.gmane.org; Sat, 14 Oct 2017 19:03:22 +0200
Original-Received: by mail-vk0-f69.google.com with SMTP id c76sf4507780vkd.14
        for <gclcip-std-proposals@m.gmane.org>; Sat, 14 Oct 2017 10:03:29 -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=m9AsJj6xhWnlfe5W9wBblvHUYipzmQjVbgrJPXrU1vU=;
        b=sxj/18qJ7ufZmfc/RDpFnEUqKxAiRKTd3q7aRVIrpJyPl98Sl3IdvGNeQVMXa1KTW/
         8JabE3jCL9Xvrc4++WEcRev2sRF8Gbde7lQ15YONvqCxQOFFN98VAwnA1oAuPEBR2AI/
         gP12bmZChQ+f7JY5ciH5MyaUgLcL6rQkc9q0vkPi5HlB2EfhnBYnZwol/OFe+GbafrOh
         mUOumOjGZYGjw2B5+v/Vpjs3O7eWeyTL96ilVZxKNprbvA3zWEZRLcNLwKhVz8eowV0H
         BbBa8D+clKZwPp2tAGGFQ9I7CaRIl0opBbHe+e/T+AH5e2WbB/21ec81s2zDb/FEDv3c
         rEfg==
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=m9AsJj6xhWnlfe5W9wBblvHUYipzmQjVbgrJPXrU1vU=;
        b=VoPykDW79esQFdquJdhC5iBhStM60M8c40PsvB5jjWPf31aKCbZNOZmGPfYp3UV3CX
         pTGH0U7/kaKsLGfri0Nu9Fb1kektfZ7Cpd4OKiNOivAm3ibwQlsytWJpX+5bzNdfHyWU
         tvKP75Jwq68ZcHNsdN6PbXY1hpXvR6sZTkwbqLpPwon12OVIa/OnaXT5iptW7M9qX2+2
         vZ5N5tKweTE1V1w+RY3rKIxBrXrEkY3hKHFw5Q1lwILbHmPM+aa3qnWB2Ny3QxAPYjWX
         ezj0koDvum8VXBFpHAjfD+fzYkvyi3wA1XIHDrza9pJzWvnW4NrAmS6A59fnmqAyPm0/
         JGzQ==
X-Gm-Message-State: AMCzsaUvB7iHZyryrpLox0/Rogbc1EECHK03WsICaTUoID7Oz9wO+TAS
	jApXnts9U5PUGkLzQMtmWU/Fug==
X-Google-Smtp-Source: AOwi7QDcP6pYiVUQYKHCGMOg50jfmxNpr4/EBrIBx5xK+AK03AAU2mGDzfD/EpsHez5N9yWz4F6DNw==
X-Received: by 10.31.138.75 with SMTP id m72mr2488316vkd.123.1508000608956;
        Sat, 14 Oct 2017 10:03:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.176.77.90 with SMTP id k26ls850958uag.3.gmail; Sat, 14 Oct
 2017 10:03:27 -0700 (PDT)
X-Received: by 10.31.201.3 with SMTP id z3mr320360vkf.0.1508000607467;
        Sat, 14 Oct 2017 10:03:27 -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:34920
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34920>

------=_Part_14650_499460897.1508000606998
Content-Type: multipart/alternative; 
	boundary="----=_Part_14651_280075224.1508000606999"

------=_Part_14651_280075224.1508000606999
Content-Type: text/plain; charset="UTF-8"

Of course. However, std::array does not solve my problem.

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/c5ef6d4a-b54b-4398-ba57-cc22c34323e1%40isocpp.org.

------=_Part_14651_280075224.1508000606999
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Of course. However, std::array does not solve my problem.<=
br><br>On Saturday, October 14, 2017 at 12:44:17 PM UTC-4, Ren Industries w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto">Do you =
happen to know of std::array?</div><div><br><div class=3D"gmail_quote">On O=
ct 14, 2017 11:40,  &lt;<a onmousedown=3D"this.href=3D&#39;javascript:&#39;=
;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;" h=
ref=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailt=
o=3D"RXc8AkAXAQAJ">eulo...@live.com</a>&gt; wrote:<br type=3D"attribution">=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Saturday, Octobe=
r 14, 2017 at 11:26:58 AM UTC-4, Nicol Bolas wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left: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"m=
argin: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 oth=
er C style/OOP style implementation.</div></div></blockquote><div><br></div=
><div>... no, it&#39;s not.</div><div><br></div><div>The main purpose of st=
andard library containers is to be useful to C++ programmers. To provide va=
lue to the language by having lingua franca types that users can use where =
appropriate for common programming issues.<br></div><div>=C2=A0</div></div>=
</blockquote><div>No. If vector&lt;T&gt; does not have same performance as =
T* c style array. C-style array will just live forever. That is why std::ve=
ctor is implemented as templates, not OOP/</div><div>=C2=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px=
 #ccc solid;padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex"><div dir=3D"ltr"><div>If you add if check for [], that would en=
courage 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 reas=
on to write 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 t=
he container design was not to make it so that nobody would ever use any ot=
her container. It was to make it so that people would only use other contai=
ners in exceptional circumstances.</div><div><br></div><div>There is no one=
-size-fits-all approach here, and trying to build one will only end in tear=
s.<br></div><div><br></div><div>That&#39;s not to say that I wouldn&#39;t m=
ind having unchecked push-back operations on `vector`. I think it&#39;s asi=
nine to say that we don&#39;t need one because optimizers will remove it wh=
en 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"><code><div><span style=3D"color:#008">int</span><span style=3D"color:#=
000"> count</span><span style=3D"color:#660">;</span><span style=3D"color:#=
000"><br>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;i=
nt&gt;</span><span style=3D"color:#000"> vec</span><span style=3D"color:#66=
0">;</span><span style=3D"color:#000"><br>vec</span><span style=3D"color:#6=
60">.</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:#6=
60">);</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:#0=
08">auto</span><span style=3D"color:#000"> x </span><span style=3D"color:#6=
60">:</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:#6=
60">))</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">{</span><span style=3D"color:#000"><br>=C2=A0 vec</span><span style=3D"c=
olor:#660">.</span><span style=3D"color:#000">emplace_back</span><span styl=
e=3D"color:#660">();</span><span style=3D"color:#000"><br>=C2=A0 file_strea=
m </span><span style=3D"color:#660">&gt;&gt;</span><span style=3D"color:#00=
0"> vec</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 i=
mportantly, 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><d=
iv>Pretty hard.</div><div>Also we should not expect optimizer to remove tes=
t. They have different behaviors. Before C++11, you might even expect optim=
izer to 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/c5ef6d4a-b54b-4398-ba57-cc22c34323e1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c5ef6d4a-b54b-4398-ba57-cc22c34323e1=
%40isocpp.org</a>.<br />

------=_Part_14651_280075224.1508000606999--

------=_Part_14650_499460897.1508000606998--

.
