Topic: range-for should call for_each function if it
Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Tue, 9 Oct 2018 16:56:11 +0100
Raw View
--0000000000007f18660577cdc793
Content-Type: text/plain; charset="UTF-8"
Matthew: thanks for the QED :)
On Tue, Oct 9, 2018 at 3:52 PM <euloanty@live.com> wrote:
> throw an exception and catch it :)
>
> lol. better just use a coroutine.
>
> On Tuesday, October 9, 2018 at 10:27:40 PM UTC+8, Matthew Woehlke wrote:
>>
>> On 09/10/2018 08.05, eulo...@live.com wrote:
>> > I think it is painful and noisy to write iterators in order to support
>> > range-for loop.
>> > [...]
>> > bst<std::size_t> b;
>> > std::size_t sum(0);
>> > for(const auto &ele : b) // will check whether the "for_each"
>> function
>> > is defined for the container. If it does have one, call this first.
>> > sum+=ele;
>> >
>> > this will be equivalent to:
>> >
>> > bst<std::size_t> b;
>> > std::size_t sum(0);
>> > for_each(b,[&](const auto &ele)
>> > {
>> > sum+=ele;
>> > });
>>
>> ...and how, exactly, will you implement a `break` with this? Especially
>> if your implementation of `for_each` is using recursive calls?
>>
>> --
>> Matthew
>>
> --
> 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/24692d6c-c68a-414e-9f65-6f25f21169e6%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/24692d6c-c68a-414e-9f65-6f25f21169e6%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/CAANG%3DkWTBBNuZ%2Bpb93mngbvGnExdM_00TYg-y9P76-AY0SSe5g%40mail.gmail.com.
--0000000000007f18660577cdc793
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Matthew: thanks for the QED :)</div><br><div class=3D"gmai=
l_quote"><div dir=3D"ltr">On Tue, Oct 9, 2018 at 3:52 PM <<a href=3D"mai=
lto:euloanty@live.com">euloanty@live.com</a>> wrote:<br></div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr">throw an exception and catch it :)<di=
v><br></div><div>lol. better just use a coroutine.<br><br>On Tuesday, Octob=
er 9, 2018 at 10:27:40 PM UTC+8, Matthew Woehlke wrote:<blockquote class=3D=
"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc soli=
d;padding-left:1ex">On 09/10/2018 08.05, <a rel=3D"nofollow">eulo...@live.c=
om</a> wrote:
<br>> I think it is painful and noisy to write iterators in order to sup=
port=20
<br>> range-for loop.
<br>> [...]
<br>> bst<std::size_t> b;=20
<br>> std::size_t sum(0);
<br>> for(const auto &ele : b) =C2=A0 =C2=A0// will check whether th=
e "for_each" function=20
<br>> is defined for the container. If it does have one, call this first=
..
<br>> =C2=A0 =C2=A0 sum+=3Dele;
<br>>=20
<br>> this will be equivalent to:
<br>>=20
<br>> bst<std::size_t> b;=20
<br>> std::size_t sum(0);
<br>> for_each(b,[&](const auto &ele)
<br>> {
<br>> =C2=A0 =C2=A0 sum+=3Dele;
<br>> });
<br>
<br>...and how, exactly, will you implement a `break` with this? Especially
<br>if your implementation of `for_each` is using recursive calls?
<br>
<br>--=20
<br>Matthew
<br></blockquote></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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@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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/24692d6c-c68a-414e-9f65-6f25f21169e6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/24692d6c-c68a-=
414e-9f65-6f25f21169e6%40isocpp.org</a>.<br>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CAANG%3DkWTBBNuZ%2Bpb93mngbvGnExdM_00=
TYg-y9P76-AY0SSe5g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWTBB=
NuZ%2Bpb93mngbvGnExdM_00TYg-y9P76-AY0SSe5g%40mail.gmail.com</a>.<br />
--0000000000007f18660577cdc793--
.