Topic: new std::vector::insert


Author: Daniel Cooke <dan.cooke89@gmail.com>
Date: Tue, 17 Feb 2015 09:22:20 -0800 (PST)
Raw View
------=_Part_534_359455148.1424193740885
Content-Type: multipart/alternative;
 boundary="----=_Part_535_491173425.1424193740885"

------=_Part_535_491173425.1424193740885
Content-Type: text/plain; charset=UTF-8

I think it would be useful, from a user perspective, but also potentially
from a performance perspective, to allow for a unary operator parameter in
std::vector::insert. I have recently posed two questions on SO addressing
this issue (see here
<http://stackoverflow.com/questions/28545184/what-is-the-optimal-way-to-concatenate-two-vectors-whilst-transforming-elements/28561234#28561234>,
and here
<http://stackoverflow.com/questions/28551380/inserting-a-vector-transformation/28559270#28559270>
).

The form of the function should be:

template <class InputIterator, class UnaryOperation>
iterator insert (const_iterator position, InputIterator first, InputIterator last, UnaryOperation op);


While it is not clear to me if this would have any significant performance advantage over the methods discussed on SO, it would in-any-case remove uncertainty of cost.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_535_491173425.1424193740885
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think it would be useful, from a user perspective, but a=
lso potentially from a performance perspective, to allow for a unary operat=
or parameter in <font face=3D"courier new, monospace">std::vector::insert</=
font>. I have recently posed two questions on SO addressing this issue (see=
 <a href=3D"http://stackoverflow.com/questions/28545184/what-is-the-optimal=
-way-to-concatenate-two-vectors-whilst-transforming-elements/28561234#28561=
234">here</a>, and <a href=3D"http://stackoverflow.com/questions/28551380/i=
nserting-a-vector-transformation/28559270#28559270">here</a>).<div><br></di=
v><div><font face=3D"arial, sans-serif">The form of the function should be:=
</font></div><div><br></div><div><pre style=3D"font-size: 12px;"><font face=
=3D"courier new, monospace" color=3D"#000000">template &lt;class InputItera=
tor, class UnaryOperation&gt;
iterator insert (const_iterator position, InputIterator first, InputIterato=
r last,&nbsp;UnaryOperation op);</font></pre><pre style=3D"font-size: 12px;=
"><font face=3D"courier new, monospace" color=3D"#000000"><br></font></pre>=
<pre><font face=3D"arial, sans-serif">While it is not clear to me if this w=
ould have any significant performance advantage over the methods discussed =
on SO, it would in-any-case remove uncertainty of cost.</font></pre></div><=
/div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_535_491173425.1424193740885--
------=_Part_534_359455148.1424193740885--

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Wed, 18 Feb 2015 19:36:29 +0000
Raw View
--001a11353506a2a0c0050f61efe0
Content-Type: text/plain; charset=UTF-8

I am not following the ranges proposals, but this is something I would hope
to be handled there. Basically the same solution that one of the answers
provides in the form of transform_iterator, except that it would come with
standard blessings.

I am not familiar with transform_iterator, but if it maintains the category
of the underlying iterators (in particular, given a random access iterator,
the adapted transform_iterator is also a random access iterator --and I
don't see any reason why this would not be the case), that will be as
efficient as can be (assuming a good implementation, it has enough
information to reserve the space upfront and move/copy every object only
once into the final location).

I don't think the addition of that additional insert overload would help.

     David

On Tue Feb 17 2015 at 12:22:21 PM Daniel Cooke <dan.cooke89@gmail.com>
wrote:

> I think it would be useful, from a user perspective, but also potentially
> from a performance perspective, to allow for a unary operator parameter in
> std::vector::insert. I have recently posed two questions on SO addressing
> this issue (see here
> <http://stackoverflow.com/questions/28545184/what-is-the-optimal-way-to-concatenate-two-vectors-whilst-transforming-elements/28561234#28561234>,
> and here
> <http://stackoverflow.com/questions/28551380/inserting-a-vector-transformation/28559270#28559270>
> ).
>
> The form of the function should be:
>
> template <class InputIterator, class UnaryOperation>
> iterator insert (const_iterator position, InputIterator first, InputIterator last, UnaryOperation op);
>
>
> While it is not clear to me if this would have any significant performance advantage over the methods discussed on SO, it would in-any-case remove uncertainty of cost.
>
>  --
>
> ---
> 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.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
> proposals/.
>

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11353506a2a0c0050f61efe0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I am not following the ranges proposals, but this is somet=
hing I would hope to be handled there. Basically the same solution that one=
 of the answers provides in the form of transform_iterator, except that it =
would come with standard blessings.<br><br>I am not familiar with transform=
_iterator, but if it maintains the category of the underlying iterators (in=
 particular, given a random access iterator, the adapted transform_iterator=
 is also a random access iterator --and I don&#39;t see any reason why this=
 would not be the case), that will be as efficient as can be (assuming a go=
od implementation, it has enough information to reserve the space upfront a=
nd move/copy every object only once into the final location).<br><br>I don&=
#39;t think the addition of that additional insert overload would help.<br>=
<br>=C2=A0 =C2=A0 =C2=A0David<br><br><div class=3D"gmail_quote">On Tue Feb =
17 2015 at 12:22:21 PM Daniel Cooke &lt;<a href=3D"mailto:dan.cooke89@gmail=
..com" target=3D"_blank">dan.cooke89@gmail.com</a>&gt; wrote:<br><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr">I think it would be useful, from a use=
r perspective, but also potentially from a performance perspective, to allo=
w for a unary operator parameter in <font face=3D"courier new, monospace">s=
td::vector::insert</font>. I have recently posed two questions on SO addres=
sing this issue (see <a href=3D"http://stackoverflow.com/questions/28545184=
/what-is-the-optimal-way-to-concatenate-two-vectors-whilst-transforming-ele=
ments/28561234#28561234" target=3D"_blank">here</a>, and <a href=3D"http://=
stackoverflow.com/questions/28551380/inserting-a-vector-transformation/2855=
9270#28559270" target=3D"_blank">here</a>).<div><br></div><div><font face=
=3D"arial, sans-serif">The form of the function should be:</font></div><div=
><br></div><div><pre style=3D"font-size:12px"><font face=3D"courier new, mo=
nospace" color=3D"#000000">template &lt;class InputIterator, class UnaryOpe=
ration&gt;
iterator insert (const_iterator position, InputIterator first, InputIterato=
r last,=C2=A0UnaryOperation op);</font></pre><pre style=3D"font-size:12px">=
<font face=3D"courier new, monospace" color=3D"#000000"><br></font></pre><p=
re><font face=3D"arial, sans-serif">While it is not clear to me if this wou=
ld have any significant performance advantage over the methods discussed on=
 SO, it would in-any-case remove uncertainty of cost.</font></pre></div></d=
iv>

<p></p>

-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+unsubscribe@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</blockquote></div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11353506a2a0c0050f61efe0--

.