Topic: How does contiguous_iterator_tag break code?
Author: jgottman6@gmail.com
Date: Mon, 29 Sep 2014 18:40:35 -0700 (PDT)
Raw View
------=_Part_3808_643439396.1412041235601
Content-Type: text/plain; charset=UTF-8
The paper Contiguous Iterators <https://isocpp.org/files/papers/n4132.html>
claims that adding a contiguous_iterator_tag that inherits from
random_access_iterator_tag would break code. What kind of code would it
break? If we don't define a contiguous_iterator_tag, there will be no way
for use different algorithms for contiguous and non-contiguous iterators.
Joe Gottman
--
---
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_3808_643439396.1412041235601
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The paper <a href=3D"https://isocpp.org/files/papers/n4132=
..html">Contiguous Iterators</a> claims that adding a contiguous_iterator_ta=
g that inherits from random_access_iterator_tag would break code. Wha=
t kind of code would it break? If we don't define a contiguous_iterat=
or_tag, there will be no way for use different algorithms for contiguous an=
d non-contiguous iterators.<br><br>Joe Gottman<br></div>
<p></p>
-- <br />
<br />
--- <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 />
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_3808_643439396.1412041235601--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 30 Sep 2014 10:26:04 -0500
Raw View
--f46d04462e5ec9862f05044a027d
Content-Type: text/plain; charset=UTF-8
On 29 September 2014 20:40, <jgottman6@gmail.com> wrote:
> The paper Contiguous Iterators
> <https://isocpp.org/files/papers/n4132.html> claims that adding a
> contiguous_iterator_tag that inherits from random_access_iterator_tag would
> break code. What kind of code would it break?
>
Code which assumes that random_access_iterator_tag is the most refined type
and checks for that exact type instead of doing tag dispatching.
While I wasn't in Issaquah for the discussion of my paper, I am convinced
that LEWG is correct in this assessment.
> If we don't define a contiguous_iterator_tag, there will be no way for
> use different algorithms for contiguous and non-contiguous iterators.
>
We just need a different tag to use, possibly in a different trait. While
not ideal, it will solve the problem. As I mentioned in my original paper,
I'd also like a way to convert from a contiguous iterator to a pointer
without requiring external information (such as a range, container it
belongs to, etc.), as that makes it useful in things like string_view,
array_view, etc.
Hopefully I can finish up v2 of my paper this week for Urbana...
Nevin :-)
>
> Joe Gottman
>
> --
>
> ---
> 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/.
>
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--f46d04462e5ec9862f05044a027d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 29 September 2014 20:40, <span dir=3D"ltr"><<a href=
=3D"mailto:jgottman6@gmail.com" target=3D"_blank">jgottman6@gmail.com</a>&g=
t;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
#ccc solid;padding-left:1ex"><div dir=3D"ltr">The paper <a href=3D"https:/=
/isocpp.org/files/papers/n4132.html" target=3D"_blank">Contiguous Iterators=
</a> claims that adding a contiguous_iterator_tag that inherits from random=
_access_iterator_tag would break code.=C2=A0 What kind of code would it bre=
ak?</div></blockquote><div><br></div><div>Code which assumes that random_ac=
cess_iterator_tag is the most refined type and checks for that exact type i=
nstead of doing tag dispatching.</div><div><br></div><div>While I wasn'=
t in Issaquah for the discussion of my paper, I am convinced that LEWG is c=
orrect in this assessment.</div><div>=C2=A0</div><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr">=C2=A0 If we don't define a contiguous_iterator_t=
ag, there will be no way for use different algorithms for contiguous and no=
n-contiguous iterators.<br></div></blockquote><div><br></div><div>We just n=
eed a different tag to use, possibly in a different trait.=C2=A0 While not =
ideal, it will solve the problem.=C2=A0 As I mentioned in my original paper=
, I'd also like a way to convert from a contiguous iterator to a pointe=
r without requiring external information (such as a range, container it bel=
ongs to, etc.), as that makes it useful in things like string_view, array_v=
iew, etc.</div><div><br></div><div>Hopefully I can finish up v2 of my paper=
this week for Urbana...</div><div>=C2=A0Nevin :-)</div><div>=C2=A0</div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"ltr"><br>Joe Gottman<span><font co=
lor=3D"#888888"><br></font></span></div><span><font color=3D"#888888">
<p></p>
-- <br>
<br>
--- <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>
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/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r>=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto:nevi=
n@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=C2=A0 =
<a href=3D"tel:%28847%29%20691-1404" value=3D"+18476911404" target=3D"_blan=
k">(847) 691-1404</a>
</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" 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 />
--f46d04462e5ec9862f05044a027d--
.
Author: Eric Niebler <eric.niebler@gmail.com>
Date: Mon, 06 Oct 2014 18:08:16 -0700
Raw View
On 9/30/2014 8:26 AM, Nevin Liber wrote:
> As I mentioned in my original paper, I'd also like a way to convert from
> a contiguous iterator to a pointer without requiring external
> information (such as a range, container it belongs to, etc.), as that
> makes it useful in things like string_view, array_view, etc.
I think there's a way to do this portably without the need for any
special utility. How about this:
template<typename I>
std::pair<
remove_reference_t<typename iterator_traits<I>::reference> *,
remove_reference_t<typename iterator_traits<I>::reference> *
// or typename iterator_traits<I>::pointer?
>
as_contiguous_range(I first, I last)
{
// static_assert(is_contiguous<I>::value, "");
if(first == last)
return {nullptr, nullptr};
else
return {addressof(*first),
addressof(*first) + (last - first)};
}
\e
--
---
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/.
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Mon, 6 Oct 2014 20:16:10 -0500
Raw View
--f46d043c81aa3854cb0504caf428
Content-Type: text/plain; charset=UTF-8
On 6 October 2014 20:08, Eric Niebler <eric.niebler@gmail.com> wrote:
> On 9/30/2014 8:26 AM, Nevin Liber wrote:
> > As I mentioned in my original paper, I'd also like a way to convert from
> > a contiguous iterator to a pointer without requiring external
> > information (such as a range, container it belongs to, etc.), as that
> > makes it useful in things like string_view, array_view, etc.
>
> I think there's a way to do this portably without the need for any
> special utility. How about this:
>
> template<typename I>
> std::pair<
> remove_reference_t<typename iterator_traits<I>::reference> *,
> remove_reference_t<typename iterator_traits<I>::reference> *
> // or typename iterator_traits<I>::pointer?
> >
> as_contiguous_range(I first, I last)
> {
> // static_assert(is_contiguous<I>::value, "");
> if(first == last)
> return {nullptr, nullptr};
> else
> return {addressof(*first),
> addressof(*first) + (last - first)};
> }
>
That requires two iterators. You should be able to do it from just one
iterator. Pairs of things are rather clunky to use, both calling and
returning. Otherwise, people will just fall back on "&*i".
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--f46d043c81aa3854cb0504caf428
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 6 October 2014 20:08, Eric Niebler <span dir=3D"ltr">&l=
t;<a href=3D"mailto:eric.niebler@gmail.com" target=3D"_blank">eric.niebler@=
gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div class=3D=
"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On 9/30/2014 =
8:26 AM, Nevin Liber wrote:<br>
> As I mentioned in my original paper, I'd also like a way to conver=
t from<br>
> a contiguous iterator to a pointer without requiring external<br>
> information (such as a range, container it belongs to, etc.), as that<=
br>
> makes it useful in things like string_view, array_view, etc.<br>
<br>
</span>I think there's a way to do this portably without the need for a=
ny<br>
special utility. How about this:<br>
<br>
=C2=A0 =C2=A0 template<typename I><br>
=C2=A0 =C2=A0 std::pair<<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 remove_reference_t<typename iterator_traits&=
lt;I>::reference> *,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 remove_reference_t<typename iterator_traits&=
lt;I>::reference> *<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // or typename iterator_traits<I>::pointe=
r?<br>
=C2=A0 =C2=A0 ><br>
=C2=A0 =C2=A0 as_contiguous_range(I first, I last)<br>
=C2=A0 =C2=A0 {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // static_assert(is_contiguous<I>::value,=
"");<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if(first =3D=3D last)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return {nullptr, nullptr};<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 else<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return {addressof(*first),<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 addre=
ssof(*first) + (last - first)};<br>
=C2=A0 =C2=A0 }<br></blockquote><div><br></div><div>That requires two itera=
tors.=C2=A0 You should be able to do it from just one iterator.=C2=A0 Pairs=
of things are rather clunky to use, both calling and returning.=C2=A0 Othe=
rwise, people will just fall back on "&*i".=C2=A0</div></div>=
-- <br>=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto=
:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=
=C2=A0 (847) 691-1404
</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" 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 />
--f46d043c81aa3854cb0504caf428--
.
Author: Eric Niebler <eric.niebler@gmail.com>
Date: Mon, 06 Oct 2014 19:07:34 -0700
Raw View
On 10/6/2014 6:16 PM, Nevin Liber wrote:
> On 6 October 2014 20:08, Eric Niebler wrote:
>> On 9/30/2014 8:26 AM, Nevin Liber wrote:
>>> As I mentioned in my original paper, I'd also like a way to
>>> convert from a contiguous iterator to a pointer without requiring
>>> external information (such as a range, container it belongs to,
>>> etc.), as that makes it useful in things like string_view,
>>> array_view, etc.
>>
>> I think there's a way to do this portably without the need for any
>> special utility. How about this:
>>
>> template<typename I>
>> std::pair<
>> remove_reference_t<typename iterator_traits<I>::reference> *,
>> remove_reference_t<typename iterator_traits<I>::reference> *
>> // or typename iterator_traits<I>::pointer?
>> >
>> as_contiguous_range(I first, I last)
>> {
>> // static_assert(is_contiguous<I>::value, "");
>> if(first == last)
>> return {nullptr, nullptr};
>> else
>> return {addressof(*first),
>> addressof(*first) + (last - first)};
>> }
>
> That requires two iterators. You should be able to do it from just
> one iterator. Pairs of things are rather clunky to use, both calling
> and returning. Otherwise, people will just fall back on "&*i".
True. But with ranges, it's a very natural interface. :-)
\e
--
---
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/.
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 7 Oct 2014 00:24:13 -0500
Raw View
--f46d043be1b85315e10504ce6bf3
Content-Type: text/plain; charset=UTF-8
On 6 October 2014 21:07, Eric Niebler <eric.niebler@gmail.com> wrote:
> True. But with ranges, it's a very natural interface. :-)
I totally agree with that, and am looking forward to ranges moving forward.
Nevin :-)
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--f46d043be1b85315e10504ce6bf3
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 6 October 2014 21:07, Eric Niebler <span dir=3D"ltr">&l=
t;<a href=3D"mailto:eric.niebler@gmail.com" target=3D"_blank">eric.niebler@=
gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div class=3D=
"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex">True. But with ranges, it'=
s a very natural interface. :-)</blockquote></div><div><br></div><div>I tot=
ally agree with that, and am looking forward to ranges moving forward.</div=
><div>=C2=A0Nevin :-)</div>-- <br>=C2=A0Nevin ":-)" Liber=C2=A0 &=
lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin=
@eviloverlord.com</a>>=C2=A0 (847) 691-1404
</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" 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 />
--f46d043be1b85315e10504ce6bf3--
.