Topic: is_iterator<T> type trait


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 10 Jun 2015 13:34:44 -0700 (PDT)
Raw View
------=_Part_1205_1423959536.1433968484191
Content-Type: multipart/alternative;
 boundary="----=_Part_1206_930159384.1433968484191"

------=_Part_1206_930159384.1433968484191
Content-Type: text/plain; charset=UTF-8

Sometimes its useful to know if a given type T is an iterator, particularly
for implementing data structures which have constructors that accept
iterator pairs which can conflict with other constructors. This can also be
useful for algorithms with accept iterators. With is_iterator<T>, we can
use SFINAE to limit overload conflicts.

Here is one possible implementation:

#include <type_traits>

#include <iterator>
#include <vector>
#include <utility>

template <typename T>
  struct is_iterator {
  static char test(...);

  template <typename U,
    typename=typename std::iterator_traits<U>::difference_type,
    typename=typename std::iterator_traits<U>::pointer,
    typename=typename std::iterator_traits<U>::reference,
    typename=typename std::iterator_traits<U>::value_type,
    typename=typename std::iterator_traits<U>::iterator_category
  > static long test(U&&);

  static bool value = std::is_same<decltype(test(std::declval<T>())),long>::value;
};


Do you think something like this is worth having in the standard library?
Or will such a construct be completely obsoleted by concepts?

--

---
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_1206_930159384.1433968484191
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Sometimes its useful to know if a given type T is an itera=
tor, particularly for implementing data structures which have constructors =
that accept iterator pairs which can conflict with other constructors. This=
 can also be useful for algorithms with accept iterators. With is_iterator&=
lt;T&gt;, we can use SFINAE to limit overload conflicts.<br><br>Here is one=
 possible implementation:<br><br><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #800;" class=3D=
"styled-by-prettify">#include</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">&lt;type_traits&gt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><pre style=3D"" class=3D"lang-cpp prettyprint=
 prettyprinted"><code><span style=3D"color: #800;" class=3D"styled-by-prett=
ify">#include</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;it=
erator&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">#inclu=
de</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;vector&gt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;utility&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> is_iterator </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">static</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cha=
r</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> test</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(...);</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">template</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> U</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">iterator_traits</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">U</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&gt;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d=
ifference_type</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">typename</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typena=
me</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">iterator_traits</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">U</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&gt;::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">pointer</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">iterator_traits</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">U</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&gt;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">refe=
rence</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">typena=
me</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">iterator_traits</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">U</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">value_type</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">=3D</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">iterator_traits</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">U</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">iterator_c=
ategory<br>&nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">static<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">long</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> test</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">U</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&amp;&amp;);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br>&nbsp; </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">static</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> value </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">is_same</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">test</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">declval</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;())),</span><span style=3D"color: #008;" class=3D"styled-by-prettify">lo=
ng</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;::</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">value</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">};</span></code></pre></div></co=
de></div><br>Do you think something like this is worth having in the standa=
rd library? Or will such a construct be completely obsoleted by concepts?<b=
r><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&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_1206_930159384.1433968484191--
------=_Part_1205_1423959536.1433968484191--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 11 Jun 2015 08:23:06 +0800
Raw View
--Apple-Mail=_6D47A342-BC6B-4D3F-9E68-FED34D467BFC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9306=E2=80=9311, at 4:34 AM, Matthew Fioravante <fmatthew58=
76@gmail.com> wrote:
>=20
> Here is one possible implementation:

What class is going to define iterator_traits<T>::iterator_category without=
 intending to be an iterator?

Just use std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, std:=
:iterator_traits<T>::iterator_category > >.

Or output_iterator_tag. Seldom does anything take an input or an output wit=
hout caring which, but you can OR such conditions together to be explicit a=
bout the ambiguity.

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--Apple-Mail=_6D47A342-BC6B-4D3F-9E68-FED34D467BFC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9306=
=E2=80=9311, at 4:34 AM, Matthew Fioravante &lt;<a href=3D"mailto:fmatthew5=
876@gmail.com" class=3D"">fmatthew5876@gmail.com</a>&gt; wrote:</div><br cl=
ass=3D"Apple-interchange-newline"><div class=3D""><span style=3D"font-famil=
y: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; fo=
nt-weight: normal; letter-spacing: normal; line-height: normal; orphans: au=
to; text-align: start; text-indent: 0px; text-transform: none; white-space:=
 normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; f=
loat: none; display: inline !important;" class=3D"">Here is one possible im=
plementation:</span><br style=3D"font-family: Helvetica; font-size: 12px; f=
ont-style: normal; font-variant: normal; font-weight: normal; letter-spacin=
g: normal; line-height: normal; orphans: auto; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; widows: auto; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></div></blockquote></=
div><br class=3D""><div class=3D"">What class is going to define <font face=
=3D"Courier" class=3D"">iterator_traits&lt;T&gt;::iterator_category</font> =
without intending to be an iterator?</div><div class=3D""><br class=3D""></=
div><div class=3D"">Just use <font face=3D"Courier" class=3D"">std::enable_=
if_t&lt; std::is_base_of_v&lt; std::input_iterator_tag, std::iterator_trait=
s&lt;T&gt;::iterator_category &gt; &gt;</font>.</div><div class=3D""><br cl=
ass=3D""></div><div class=3D"">Or <font face=3D"Courier" class=3D"">output_=
iterator_tag</font>. Seldom does anything take an input or an output withou=
t caring which, but you can OR such conditions together to be explicit abou=
t the ambiguity.</div></body></html>

<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 />

--Apple-Mail=_6D47A342-BC6B-4D3F-9E68-FED34D467BFC--

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 10 Jun 2015 17:30:28 -0700 (PDT)
Raw View
------=_Part_6255_895072632.1433982628385
Content-Type: multipart/alternative;
 boundary="----=_Part_6256_362778789.1433982628385"

------=_Part_6256_362778789.1433982628385
Content-Type: text/plain; charset=UTF-8



On Wednesday, June 10, 2015 at 8:23:18 PM UTC-4, David Krauss wrote:
>
> Just use std::enable_if_t< std::is_base_of_v< std::input_iterator_tag,
> std::iterator_traits<T>::iterator_category > >.
>

I still think its better to have a usability wrapper. Your solution works
but its less obvious what its doing from a quick glance. A wrapper such as
listed below clearly states what condition is being tested and makes the
code more readable and obvious.

is_iterator
is_input_iterator
is_output_iterator
is_forward_iterator
is_bidirectional_iterator
is_random_access_iterator
is_contiguous_iterator

--

---
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_6256_362778789.1433982628385
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, June 10, 2015 at 8:23:18 PM UTC-4, D=
avid Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=
=3D"word-wrap:break-word"><div>Just use <font face=3D"Courier">std::enable_=
if_t&lt; std::is_base_of_v&lt; std::input_iterator_tag, std::iterator_trait=
s&lt;T&gt;::<wbr>iterator_category &gt; &gt;</font>.</div></div></blockquot=
e><div><br></div><div>I still think its better to have a usability wrapper.=
 Your solution works but its less obvious what its doing from a quick glanc=
e. A wrapper such as listed below clearly states what condition is being te=
sted and makes the code more readable and obvious.</div><div><br></div><div=
>is_iterator</div><div>is_input_iterator</div><div>is_output_iterator</div>=
<div>is_forward_iterator</div><div>is_bidirectional_iterator</div><div>is_r=
andom_access_iterator</div><div>is_contiguous_iterator</div><div><br></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_6256_362778789.1433982628385--
------=_Part_6255_895072632.1433982628385--

.


Author: David Krauss <david_work@me.com>
Date: Thu, 11 Jun 2015 09:19:57 +0800
Raw View
--Apple-Mail=_83A7F117-6D1E-47A7-9FF1-7F242B7D8CBC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9306=E2=80=9311, at 8:30 AM, Matthew Fioravante <fmatthew58=
76@gmail.com> wrote:
>=20
>=20
>=20
> On Wednesday, June 10, 2015 at 8:23:18 PM UTC-4, David Krauss wrote:
> Just use std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, st=
d::iterator_traits<T>::iterator_category > >.
>=20
> I still think its better to have a usability wrapper. Your solution works=
 but its less obvious what its doing from a quick glance. A wrapper such as=
 listed below clearly states what condition is being tested and makes the c=
ode more readable and obvious.

That=E2=80=99s true of any SFINAE, hence the Concepts proposal. The questio=
n is, are these predicates more common than any other SFINAE condition?

Also, note that the point of dispatch tags in the first place is to avoid S=
FINAE. (Or, since tags are an older technique, the point of enable_if is to=
 fall back when tags don=E2=80=99t work.) So you probably shouldn=E2=80=99t=
 be querying each individual category with SFINAE. An external interface wo=
uld be rather odd to treat BidirectionalIterator as an iterator but a Forwa=
rdIterator as a generic value. An internal interface should usually take an=
y iterator, break out the tags, and static_assert if the iterator isn=E2=80=
=99t good enough.

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--Apple-Mail=_83A7F117-6D1E-47A7-9FF1-7F242B7D8CBC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9306=
=E2=80=9311, at 8:30 AM, Matthew Fioravante &lt;<a href=3D"mailto:fmatthew5=
876@gmail.com" class=3D"">fmatthew5876@gmail.com</a>&gt; wrote:</div><br cl=
ass=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D=
""><br class=3D""><br class=3D"">On Wednesday, June 10, 2015 at 8:23:18 PM =
UTC-4, David Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin=
: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div=
 style=3D"word-wrap:break-word" class=3D""><div class=3D"">Just use <font f=
ace=3D"Courier" class=3D"">std::enable_if_t&lt; std::is_base_of_v&lt; std::=
input_iterator_tag, std::iterator_traits&lt;T&gt;::<wbr class=3D"">iterator=
_category &gt; &gt;</font>.</div></div></blockquote><div class=3D""><br cla=
ss=3D""></div><div class=3D"">I still think its better to have a usability =
wrapper. Your solution works but its less obvious what its doing from a qui=
ck glance. A wrapper such as listed below clearly states what condition is =
being tested and makes the code more readable and obvious.</div></div></div=
></blockquote><div><br class=3D""></div><div>That=E2=80=99s true of any SFI=
NAE, hence the Concepts proposal. The question is, are these predicates mor=
e common than any other SFINAE condition?</div><div><br class=3D""></div><d=
iv>Also, note that the point of dispatch tags in the first place is to avoi=
d SFINAE. (Or, since tags are an older technique, the point of <font face=
=3D"Courier" class=3D"">enable_if</font> is to fall back when tags don=E2=
=80=99t work.) So you probably shouldn=E2=80=99t be querying each individua=
l category with SFINAE. An external interface would be rather odd to treat =
BidirectionalIterator as an iterator but a ForwardIterator as a generic val=
ue. An internal interface should usually take any iterator, break out the t=
ags, and <font face=3D"Courier" class=3D"">static_assert</font> if the iter=
ator isn=E2=80=99t good enough.</div></div></body></html>

<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 />

--Apple-Mail=_83A7F117-6D1E-47A7-9FF1-7F242B7D8CBC--

.