Topic: Non-member cbegin(), cend(), etc...


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 9 Jul 2015 10:49:30 -0700 (PDT)
Raw View
------=_Part_685_1661850830.1436464170042
Content-Type: multipart/alternative;
 boundary="----=_Part_686_44108770.1436464170044"

------=_Part_686_44108770.1436464170044
Content-Type: text/plain; charset=UTF-8

For an STL compatible container C, we usually have to define these:

C::const_iterator
C::reverse_iterator
C::const_reverse_iterator
C::cbegin()
C::cend()
C::rbegin()
C::rend()
C::crbegin()
C::crend()

In 99% of (100%?) the cases, this is just 9 lines of useless boilerplate.
Not only is it time consuming, not productive, annoying, class definition
polluting, and pointless, it also complicates things for beginners who want
to learn how to write a "correct" container class. These member functions
are not very helpful in modern C++ anyway because they can't be used
directly in foreach loops.

Instead I would propose something like the following types and free
functions:

//An iterator adapter type that dereferences to const
decltype(iterator::operator*())
template <typename Iter>
class const_iterator<Iter>;

template <typename Iter>
constexpr auto make_const_iterator(Iter it) { return const_iterator<Iter>(it
); }

template <typename Iter>
constexpr auto make_reverse_iterator(Iter it) { return reverse_iterator<Iter
>(it); }

template <typename Iter>
using const_reverse_iterator = const_iterator<reverse_iterator<Iter>>;

template <typename Iter>
constexpr auto make_const_reverse_iterator(Iter it) { return
const_reverse_iterator<Iter>(it); }

//SFINAE: return c.cbegin();
//or: return make_const_iterator(c.begin());
template <typename C>
auto std::cbegin(const C& c);

//SFINAE: return c.cend()
//or: return make_const_iterator(c.end());
template <typename C>
auto std::cend(const C& c);

//SFINAE: return c.rbegin()
//or: return make_reverse_iterator(c.end());
template <typename C>
auto std::rbegin(const C& c);

//SFINAE: return c.rend()
//or: return make_reverse_iterator(c.begin());
template <typename C>
auto std::rend(const C& c);

//SFINAE: return c.crbegin();
//or: return make_const_iterator(c.rbegin());
//or: return make_const_reverse_iterator(c.end());
template <typename C>
auto std::crbegin(const C& c);

//SFINAE: return c.crend();
//or: return make_const_iterator(c.rend());
//or: return make_const_reverse_iterator(c.end());
template <typename C>
auto std::crend(const C& c);

Now we no longer need to write these things as members of containers unless
there is some reason you really need to customize how a const_iterator or
reverse_iterator works.

As a followup range proposal, asconst() and reversed() range adapters can
be defined pretty trivially using these and then we get foreach loop
support.



--

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

<div dir=3D"ltr"><div>For an STL compatible container C, we usually have to=
 define these:</div><div>=C2=A0</div><div>C::const_iterator</div><div>C::re=
verse_iterator</div><div>C::const_reverse_iterator</div><div>C::cbegin()</d=
iv><div>C::cend()</div><div>C::rbegin()</div><div>C::rend()</div><div>C::cr=
begin()</div><div>C::crend()</div><div>=C2=A0</div><div>In 99% of (100%?) t=
he cases, this is just 9 lines of useless boilerplate. Not only is it time =
consuming,=C2=A0not productive,=C2=A0annoying,=C2=A0class definition pollut=
ing, and pointless, it also complicates things for beginners who want to le=
arn how to=C2=A0write a &quot;correct&quot; container class. These member f=
unctions are not very helpful in modern C++ anyway because they can&#39;t b=
e used directly in foreach loops. </div><div>=C2=A0</div><div>Instead I wou=
ld propose something like the following types and free functions:</div><div=
>=C2=A0</div><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap:=
 break-word; background-color: rgb(250, 250, 250);" class=3D"prettyprint"><=
code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"col=
or: rgb(136, 0, 0);" class=3D"styled-by-prettify">//An iterator adapter typ=
e that dereferences to const decltype(iterator::operator*())</span><span st=
yle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">template</spa=
n><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span=
><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">=
typename</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: rgb(102, 0, 102);" class=3D"styled-by-p=
rettify">Iter</span><span style=3D"color: rgb(102, 102, 0);" class=3D"style=
d-by-prettify">&gt;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 136);" class=3D=
"styled-by-prettify">class</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"> const_iterator</span><span style=3D"color: rgb(102=
, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: r=
gb(102, 0, 102);" class=3D"styled-by-prettify">Iter</span><span style=3D"co=
lor: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt;;</span><span styl=
e=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br><br></span><spa=
n style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&l=
t;</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify=
">typename</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: rgb(102, 0, 102);" class=3D"styled-by=
-prettify">Iter</span><span style=3D"color: rgb(102, 102, 0);" class=3D"sty=
led-by-prettify">&gt;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 136);" class=
=3D"styled-by-prettify">constexpr</span><span style=3D"color: rgb(0, 0, 0);=
" class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(0, 0, 136)=
;" class=3D"styled-by-prettify">auto</span><span style=3D"color: rgb(0, 0, =
0);" class=3D"styled-by-prettify"> make_const_iterator</span><span style=3D=
"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(</span><span style=
=3D"color: rgb(102, 0, 102);" class=3D"styled-by-prettify">Iter</span><span=
 style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> it</span><spa=
n style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">)</span><=
span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">{</span=
><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">return<=
/span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> co=
nst_iterator</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: rgb(102, 0, 102);" class=3D"=
styled-by-prettify">Iter</span><span style=3D"color: rgb(102, 102, 0);" cla=
ss=3D"styled-by-prettify">&gt;(</span><span style=3D"color: rgb(0, 0, 0);" =
class=3D"styled-by-prettify">it</span><span style=3D"color: rgb(102, 102, 0=
);" class=3D"styled-by-prettify">);</span><span style=3D"color: rgb(0, 0, 0=
);" class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102=
, 0);" class=3D"styled-by-prettify">}</span><span style=3D"color: rgb(0, 0,=
 0);" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: rgb=
(0, 0, 136);" class=3D"styled-by-prettify">template</span><span style=3D"co=
lor: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: rgb(102, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">typename</span><sp=
an style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: rgb(102, 0, 102);" class=3D"styled-by-prettify">Iter</spa=
n><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt=
;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettif=
y">constexpr</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-=
prettify"> </span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by=
-prettify">auto</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-=
by-prettify"> make_reverse_iterator</span><span style=3D"color: rgb(102, 10=
2, 0);" class=3D"styled-by-prettify">(</span><span style=3D"color: rgb(102,=
 0, 102);" class=3D"styled-by-prettify">Iter</span><span style=3D"color: rg=
b(0, 0, 0);" class=3D"styled-by-prettify"> it</span><span style=3D"color: r=
gb(102, 102, 0);" class=3D"styled-by-prettify">)</span><span style=3D"color=
: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color:=
 rgb(102, 102, 0);" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: rgb(0, 0, 136);" class=3D"styled-by-prettify">return</span><span style=
=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> reverse_iterator</s=
pan><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: rgb(102, 0, 102);" class=3D"styled-by-prett=
ify">Iter</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by=
-prettify">&gt;(</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled=
-by-prettify">it</span><span style=3D"color: rgb(102, 102, 0);" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: rgb(0, 0, 0);" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0);" class=3D=
"styled-by-prettify">}</span><span style=3D"color: rgb(0, 0, 0);" class=3D"=
styled-by-prettify"><br><br></span><span style=3D"color: rgb(0, 0, 136);" c=
lass=3D"styled-by-prettify">template</span><span style=3D"color: rgb(0, 0, =
0);" class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 10=
2, 0);" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: rgb(0=
, 0, 136);" class=3D"styled-by-prettify">typename</span><span style=3D"colo=
r: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color=
: rgb(102, 0, 102);" class=3D"styled-by-prettify">Iter</span><span style=3D=
"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt;</span><span st=
yle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><font =
color=3D"#880000"><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by=
-prettify">using</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled=
-by-prettify"> const_reverse_iterator </span><span style=3D"color: rgb(102,=
 102, 0);" class=3D"styled-by-prettify">=3D</span><span style=3D"color: rgb=
(0, 0, 0);" class=3D"styled-by-prettify"> const_iterator</span><span style=
=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span=
 style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">reverse_iterat=
or</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pretti=
fy">&lt;</span><span style=3D"color: rgb(102, 0, 102);" class=3D"styled-by-=
prettify">Iter</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styl=
ed-by-prettify">&gt;&gt;;</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"><br></span></font><span style=3D"color: rgb(0, 0, 0=
);" class=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(0, 0,=
 136);" class=3D"styled-by-prettify">template</span><span style=3D"color: r=
gb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color: rg=
b(102, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span style=3D"col=
or: rgb(0, 0, 136);" class=3D"styled-by-prettify">typename</span><span styl=
e=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=
=3D"color: rgb(102, 0, 102);" class=3D"styled-by-prettify">Iter</span><span=
 style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt;</span=
><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">cons=
texpr</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-pretti=
fy">auto</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pret=
tify"> make_const_reverse_iterator</span><span style=3D"color: rgb(102, 102=
, 0);" class=3D"styled-by-prettify">(</span><span style=3D"color: rgb(102, =
0, 102);" class=3D"styled-by-prettify">Iter</span><span style=3D"color: rgb=
(0, 0, 0);" class=3D"styled-by-prettify"> it</span><span style=3D"color: rg=
b(102, 102, 0);" class=3D"styled-by-prettify">)</span><span style=3D"color:=
 rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color: =
rgb(102, 102, 0);" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color=
: rgb(0, 0, 136);" class=3D"styled-by-prettify">return</span><span style=3D=
"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> const_reverse_iterator=
</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify=
">&lt;</span><span style=3D"color: rgb(102, 0, 102);" class=3D"styled-by-pr=
ettify">Iter</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled=
-by-prettify">&gt;(</span><span style=3D"color: rgb(0, 0, 0);" class=3D"sty=
led-by-prettify">it</span><span style=3D"color: rgb(102, 102, 0);" class=3D=
"styled-by-prettify">);</span><span style=3D"color: rgb(0, 0, 0);" class=3D=
"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0);" class=
=3D"styled-by-prettify">}</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: rgb(136, 0, 0)=
;" class=3D"styled-by-prettify">//SFINAE: return c.cbegin();</span><span st=
yle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: rgb(136, 0, 0);" class=3D"styled-by-prettify">//or: return =
make_const_iterator(c.begin());</span><span style=3D"color: rgb(0, 0, 0);" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 136=
);" class=3D"styled-by-prettify">template</span><span style=3D"color: rgb(0=
, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(10=
2, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: =
rgb(0, 0, 136);" class=3D"styled-by-prettify">typename</span><span style=3D=
"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> C</span><span style=3D=
"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt;</span><span st=
yle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">auto</span><s=
pan style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> std</span>=
<span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">cbegi=
n</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-pretti=
fy">const</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pre=
ttify"> C</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by=
-prettify">&amp;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled=
-by-prettify"> c</span><span style=3D"color: rgb(102, 102, 0);" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: rgb(0, 0, 0);" class=3D"st=
yled-by-prettify"><br><br></span><span style=3D"color: rgb(136, 0, 0);" cla=
ss=3D"styled-by-prettify">//SFINAE: return c.cend()</span><span style=3D"co=
lor: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: rgb(136, 0, 0);" class=3D"styled-by-prettify">//or: return make_cons=
t_iterator(c.end());</span><span style=3D"color: rgb(0, 0, 0);" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 136);" class=
=3D"styled-by-prettify">template</span><span style=3D"color: rgb(0, 0, 0);"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0=
);" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: rgb(0, 0,=
 136);" class=3D"styled-by-prettify">typename</span><span style=3D"color: r=
gb(0, 0, 0);" class=3D"styled-by-prettify"> C</span><span style=3D"color: r=
gb(102, 102, 0);" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: rgb(0, 0, 136);" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> std</span><span sty=
le=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">cend</span><sp=
an style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">const</=
span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> C</=
span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">=
&amp;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettif=
y"> c</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pre=
ttify">);</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pre=
ttify"><br><br></span><span style=3D"color: rgb(136, 0, 0);" class=3D"style=
d-by-prettify">//SFINAE: return c.</span><span style=3D"color: rgb(136, 0, =
0);" class=3D"styled-by-prettify">rbegin() </span></div><div class=3D"subpr=
ettyprint"><span style=3D"color: rgb(136, 0, 0);" class=3D"styled-by-pretti=
fy">//or: return make_reverse_iterator(c.end());</span><span style=3D"color=
: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=3D"col=
or: rgb(0, 0, 136);" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=
=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span=
 style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">typename</sp=
an><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> C</sp=
an><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&g=
t;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-pretti=
fy">auto</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pret=
tify"> std</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-b=
y-prettify">rbegin</span><span style=3D"color: rgb(102, 102, 0);" class=3D"=
styled-by-prettify">(</span><span style=3D"color: rgb(0, 0, 136);" class=3D=
"styled-by-prettify">const</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"> C</span><span style=3D"color: rgb(102, 102, 0);" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: rgb(0, 0, 0);=
" class=3D"styled-by-prettify"> c</span><span style=3D"color: rgb(102, 102,=
 0);" class=3D"styled-by-prettify">);</span><span style=3D"color: rgb(0, 0,=
 0);" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: rgb=
(136, 0, 0);" class=3D"styled-by-prettify">//SFINAE: return=C2=A0c.rend()<b=
r>//or:=C2=A0return make_reverse_iterator(c.begin());</span><span style=3D"=
color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">template</span><sp=
an style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">typen=
ame</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"=
> C</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prett=
ify">&gt;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by=
-prettify">auto</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-=
by-prettify"> std</span><span style=3D"color: rgb(102, 102, 0);" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: rgb(0, 0, 0);" class=3D"s=
tyled-by-prettify">rend</span><span style=3D"color: rgb(102, 102, 0);" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: rgb(0, 0, 136);" cla=
ss=3D"styled-by-prettify">const</span><span style=3D"color: rgb(0, 0, 0);" =
class=3D"styled-by-prettify"> C</span><span style=3D"color: rgb(102, 102, 0=
);" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: rgb(0, 0=
, 0);" class=3D"styled-by-prettify"> c</span><span style=3D"color: rgb(102,=
 102, 0);" class=3D"styled-by-prettify">);</span><span style=3D"color: rgb(=
0, 0, 0);" class=3D"styled-by-prettify"><br><br></span><span style=3D"color=
: rgb(136, 0, 0);" class=3D"styled-by-prettify">//SFINAE: return=C2=A0c.crb=
egin();</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: rgb(136, 0, 0);" class=3D"styled-by-p=
rettify">//or: return make_const_iterator(c.rbegin());</span><span style=3D=
"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: rgb(136, 0, 0);" class=3D"styled-by-prettify">//or: return make_=
const_reverse_iterator(c.end());</span><span style=3D"color: rgb(0, 0, 0);"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 13=
6);" class=3D"styled-by-prettify">template</span><span style=3D"color: rgb(=
0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(1=
02, 102, 0);" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 rgb(0, 0, 136);" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> C</span><span style=
=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt;</span><span=
 style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">auto</span=
><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">::=
</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">cr=
begin</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-pr=
ettify">const</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by=
-prettify"> C</span><span style=3D"color: rgb(102, 102, 0);" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: rgb(0, 0, 0);" class=3D"st=
yled-by-prettify"> c</span><span style=3D"color: rgb(102, 102, 0);" class=
=3D"styled-by-prettify">);</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"><br><br>//SFINAE:=C2=A0return c.crend();<br>//or: r=
eturn make_const_iterator(c.rend());<br>//or: return make_const_reverse_ite=
rator(c.end());</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: rgb(0, 0, 136);" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0);" cl=
ass=3D"styled-by-prettify">&lt;</span><span style=3D"color: rgb(0, 0, 136);=
" class=3D"styled-by-prettify">typename</span><span style=3D"color: rgb(0, =
0, 0);" class=3D"styled-by-prettify"> C</span><span style=3D"color: rgb(102=
, 102, 0);" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: r=
gb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
 rgb(0, 0, 136);" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: rgb(0, 0, 0);" class=3D"styled-by-prettify"> std</span><span style=3D"=
color: rgb(102, 102, 0);" class=3D"styled-by-prettify">::</span><span style=
=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">crend</span><span st=
yle=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">const</span>=
<span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> C</span>=
<span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">&amp;=
</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> c=
</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify=
">);</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify=
"><br></span></div></code></div><div><br>Now we no longer need to write the=
se things as members of containers unless there is some reason you really n=
eed to customize how a const_iterator or reverse_iterator works.</div><div>=
=C2=A0</div><div>As a followup range proposal, asconst() and reversed() ran=
ge adapters can be defined pretty trivially using these and then we get for=
each loop support.</div><div>=C2=A0</div><div>=C2=A0</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_686_44108770.1436464170044--
------=_Part_685_1661850830.1436464170042--

.


Author: Nicola Gigante <nicola.gigante@gmail.com>
Date: Thu, 9 Jul 2015 20:35:27 +0200
Raw View
> Il giorno 09/lug/2015, alle ore 19:49, Matthew Fioravante <fmatthew5876@g=
mail.com> ha scritto:
>=20
> For an STL compatible container C, we usually have to define these:
> =20
> C::const_iterator
> C::reverse_iterator
> C::const_reverse_iterator
> C::cbegin()
> C::cend()
> C::rbegin()
> C::rend()
> C::crbegin()
> C::crend()
> =20
> In 99% of (100%?) the cases, this is just 9 lines of useless boilerplate.=
 Not only is it time consuming, not productive, annoying, class definition =
polluting, and pointless, it also complicates things for beginners who want=
 to learn how to write a "correct" container class. These member functions =
are not very helpful in modern C++ anyway because they can't be used direct=
ly in foreach loops.
> =20
> Instead I would propose something like the following types and free funct=
ions:
> =20

I like the idea, but old code would expect member functions anyway, and
you can=E2=80=99t break it.

How about a base class template that defines the common functions=20
using a CRTP?

class container : public iterable<container>=20
{
public:
   using iterator =3D =E2=80=A6;

   iterator begin();
   iterator end();
   iterator begin() const;
   iterator end() const;  =20
};

Looks good?

Greetings,
Nicola

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

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 9 Jul 2015 11:59:00 -0700 (PDT)
Raw View
------=_Part_1272_604334853.1436468341093
Content-Type: multipart/alternative;
 boundary="----=_Part_1273_1067514097.1436468341093"

------=_Part_1273_1067514097.1436468341093
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


On Thursday, July 9, 2015 at 2:35:33 PM UTC-4, Nicola Gigante wrote:
>
>
> > Il giorno 09/lug/2015, alle ore 19:49, Matthew Fioravante <
> fmatth...@gmail.com <javascript:>> ha scritto:=20
> >=20
> > For an STL compatible container C, we usually have to define these:=20
> >  =20
> > C::const_iterator=20
> > C::reverse_iterator=20
> > C::const_reverse_iterator=20
> > C::cbegin()=20
> > C::cend()=20
> > C::rbegin()=20
> > C::rend()=20
> > C::crbegin()=20
> > C::crend()=20
> >  =20
> > In 99% of (100%?) the cases, this is just 9 lines of useless=20
> boilerplate. Not only is it time consuming, not productive, annoying, cla=
ss=20
> definition polluting, and pointless, it also complicates things for=20
> beginners who want to learn how to write a "correct" container class. The=
se=20
> member functions are not very helpful in modern C++ anyway because they=
=20
> can't be used directly in foreach loops.=20
> >  =20
> > Instead I would propose something like the following types and free=20
> functions:=20
> >  =20
>
> I like the idea, but old code would expect member functions anyway, and=
=20
> you can=E2=80=99t break it.=20
>
=20
For that reason, the members of the current set of STL containers probably=
=20
can never be removed. Maybe they can be deprecated to encourage people to=
=20
update their algorithms to the new standard.

New algorithms can use the non-member functions and new containers can omit=
=20
defining the members. The only issue is when you want to use a new style=20
container class with an older style algorithms library that still depends=
=20
on the members.
=20
As for the member iterator typedefs, I'm not sure they are necessary at all=
=20
going forward since we now have auto and decltype().
=20

>
> How about a base class template that defines the common functions=20
> using a CRTP?=20
>
> class container : public iterable<container>=20
> {=20
> public:=20
>    using iterator =3D =E2=80=A6;=20
>
>    iterator begin();=20
>    iterator end();=20
>    iterator begin() const;=20
>    iterator end() const;  =20
> };=20
>
> Looks good?=20
>
=20
Not sure I picture exactly how this is intended to be used. Its used to=20
implement non-member cbegin() and friends?=20

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

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

<br>On Thursday, July 9, 2015 at 2:35:33 PM UTC-4, Nicola Gigante wrote:<bl=
ockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left=
-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: soli=
d;" class=3D"gmail_quote">
<br>&gt; Il giorno 09/lug/2015, alle ore 19:49, Matthew Fioravante &lt;<a o=
nmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"th=
is.href=3D&#39;javascript:&#39;;return true;" href=3D"javascript:" rel=3D"n=
ofollow" target=3D"_blank">fmatth...@gmail.com</a>&gt; ha scritto:
<br>&gt;=20
<br>&gt; For an STL compatible container C, we usually have to define these=
:
<br>&gt; =C2=A0
<br>&gt; C::const_iterator
<br>&gt; C::reverse_iterator
<br>&gt; C::const_reverse_iterator
<br>&gt; C::cbegin()
<br>&gt; C::cend()
<br>&gt; C::rbegin()
<br>&gt; C::rend()
<br>&gt; C::crbegin()
<br>&gt; C::crend()
<br>&gt; =C2=A0
<br>&gt; In 99% of (100%?) the cases, this is just 9 lines of useless boile=
rplate. Not only is it time consuming, not productive, annoying, class defi=
nition polluting, and pointless, it also complicates things for beginners w=
ho want to learn how to write a &quot;correct&quot; container class. These =
member functions are not very helpful in modern C++ anyway because they can=
&#39;t be used directly in foreach loops.
<br>&gt; =C2=A0
<br>&gt; Instead I would propose something like the following types and fre=
e functions:
<br>&gt; =C2=A0
<br>
<br>I like the idea, but old code would expect member functions anyway, and
<br>you can=E2=80=99t break it.
<br></blockquote><div>=C2=A0</div><div>For that reason, the members of the =
current set of STL containers probably can never be removed. Maybe they can=
 be deprecated to encourage people to update their algorithms to the new st=
andard.</div><div><br>New algorithms can use the non-member functions and n=
ew containers can omit defining the members. The only issue is when you wan=
t to use a new style container class with an older style algorithms library=
 that still depends on the members.</div><div>=C2=A0</div><div>As for the m=
ember iterator typedefs, I&#39;m not sure they are necessary at all going f=
orward since we now have auto and decltype().</div><div>=C2=A0</div><blockq=
uote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-col=
or: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" =
class=3D"gmail_quote">
<br>How about a base class template that defines the common functions=20
<br>using a CRTP?
<br>
<br>class container : public iterable&lt;container&gt;=20
<br>{
<br>public:
<br>=C2=A0 =C2=A0using iterator =3D =E2=80=A6;
<br>
<br>=C2=A0 =C2=A0iterator begin();
<br>=C2=A0 =C2=A0iterator end();
<br>=C2=A0 =C2=A0iterator begin() const;
<br>=C2=A0 =C2=A0iterator end() const; =C2=A0=20
<br>};
<br>
<br>Looks good?
<br></blockquote><div>=C2=A0</div><div>Not sure I picture exactly how this =
is intended to be used. Its used to implement non-member cbegin() and frien=
ds?=C2=A0</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_1273_1067514097.1436468341093--
------=_Part_1272_604334853.1436468341093--

.


Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 10 Jul 2015 16:18:52 -0300
Raw View
On Thu, Jul 9, 2015 at 2:49 PM, Matthew Fioravante
<fmatthew5876@gmail.com> wrote:
> For an STL compatible container C, we usually have to define these:
>
> C::const_iterator
> C::reverse_iterator
> C::const_reverse_iterator
> C::cbegin()
> C::cend()
> C::rbegin()
> C::rend()
> C::crbegin()
> C::crend()
>
> In 99% of (100%?) the cases, this is just 9 lines of useless boilerplate.
> Not only is it time consuming, not productive, annoying, class definition
> polluting, and pointless, it also complicates things for beginners who wa=
nt
> to learn how to write a "correct" container class. These member functions
> are not very helpful in modern C++ anyway because they can't be used
> directly in foreach loops.
>
> Instead I would propose something like the following types and free
> functions:
>
> //An iterator adapter type that dereferences to const
> decltype(iterator::operator*())
> template <typename Iter>
> class const_iterator<Iter>;
>
> template <typename Iter>
> constexpr auto make_const_iterator(Iter it) { return
> const_iterator<Iter>(it); }
>
> template <typename Iter>
> constexpr auto make_reverse_iterator(Iter it) { return
> reverse_iterator<Iter>(it); }
>
> template <typename Iter>
> using const_reverse_iterator =3D const_iterator<reverse_iterator<Iter>>;
>
> template <typename Iter>
> constexpr auto make_const_reverse_iterator(Iter it) { return
> const_reverse_iterator<Iter>(it); }
>
> //SFINAE: return c.cbegin();
> //or: return make_const_iterator(c.begin());
> template <typename C>
> auto std::cbegin(const C& c);
>
> //SFINAE: return c.cend()
> //or: return make_const_iterator(c.end());
> template <typename C>
> auto std::cend(const C& c);
>
> //SFINAE: return c.rbegin()
> //or: return make_reverse_iterator(c.end());
> template <typename C>
> auto std::rbegin(const C& c);
>
> //SFINAE: return c.rend()
> //or: return make_reverse_iterator(c.begin());
> template <typename C>
> auto std::rend(const C& c);
>
> //SFINAE: return c.crbegin();
> //or: return make_const_iterator(c.rbegin());
> //or: return make_const_reverse_iterator(c.end());
> template <typename C>
> auto std::crbegin(const C& c);
>
> //SFINAE: return c.crend();
> //or: return make_const_iterator(c.rend());
> //or: return make_const_reverse_iterator(c.end());
> template <typename C>
> auto std::crend(const C& c);
>
> Now we no longer need to write these things as members of containers unle=
ss
> there is some reason you really need to customize how a const_iterator or
> reverse_iterator works.
>
> As a followup range proposal, asconst() and reversed() range adapters can=
 be
> defined pretty trivially using these and then we get foreach loop support=
..

Sorry if I'm looking your proposal too quickly, but doesn't unified
call syntax address this?
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4165.pdf

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



--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?

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

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Sun, 12 Jul 2015 19:02:53 -0700 (PDT)
Raw View
------=_Part_611_951370937.1436752973627
Content-Type: multipart/alternative;
 boundary="----=_Part_612_312127976.1436752973627"

------=_Part_612_312127976.1436752973627
Content-Type: text/plain; charset=UTF-8

On Friday, July 10, 2015 at 3:18:54 PM UTC-4, dgutson wrote:

> Sorry if I'm looking your proposal too quickly, but doesn't unified
> call syntax address this?
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4165.pdf
>
>
It might help, but alone its not sufficient.

We still need a default implementation of std::rbegin()/std::rend() using
std::reverse_iterator so that class authors can cease writing
reverse_iterator boilerplate over and over again for each container type.

A default implementation of 'rbegin()' provided by the STL would need to
live in std::. Since user defined types will not live in std::, ADL doesn't
work and therefore uniform call syntax cannot find std::rebgin() unless the
programmer has written using namespace std; (not always desirable) or
written their own rbegin() and rend() for their type in the type's
namespace (useless boillerplate) which just calls std::rbegin.

Requiring using namespace std; for any standard library use cases should be
avoided. For example, with std::swap(), you cannot do a constexpr swap
directly in an expression in a header file because you'll pollute the
namespace. All calls to swap() have to be safely wrapped to avoid namespace
pollution. Swapping 2 objects is about as fundamental concept as you can
get and yet executing a swap operation in C++ requires 2 expressions and
very easy to get wrong.



--

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

<div dir=3D"ltr"><div>On Friday, July 10, 2015 at 3:18:54 PM UTC-4, dgutson=
 wrote:</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Sorry if I&#39;m =
looking your proposal too quickly, but doesn&#39;t unified
<br>call syntax address this?
<br><a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n416=
5.pdf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;h=
ttp://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2F=
wg21%2Fdocs%2Fpapers%2F2014%2Fn4165.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCN=
FnBxoG3pbC-udE1SiOc6U7JdMjPg&#39;;return true;" onclick=3D"this.href=3D&#39=
;http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%=
2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4165.pdf\46sa\75D\46sntz\0751\46usg\75AFQj=
CNFnBxoG3pbC-udE1SiOc6U7JdMjPg&#39;;return true;">http://www.open-std.org/j=
tc1/sc22/wg21/docs/papers/2014/n4165.pdf</a>
<br><br></blockquote><div><br></div><div>It might help, but alone its not s=
ufficient.=C2=A0</div><div><br></div><div>We still need a default implement=
ation of std::rbegin()/std::rend() using std::reverse_iterator so that clas=
s authors can cease writing reverse_iterator boilerplate over and over agai=
n for each container type.=C2=A0</div><div><br></div><div>A default impleme=
ntation of &#39;rbegin()&#39; provided by the STL would need to live in std=
::. Since user defined types will not live in std::, ADL doesn&#39;t work a=
nd therefore uniform call syntax cannot find std::rebgin() unless the progr=
ammer has written using namespace std; (not always desirable) or written th=
eir own rbegin() and rend() for their type in the type&#39;s namespace (use=
less boillerplate) which just calls std::rbegin.=C2=A0</div><div><br></div>=
<div>Requiring using namespace std; for any standard library use cases shou=
ld be avoided. For example, with std::swap(), you cannot do a constexpr swa=
p directly in an expression in a header file because you&#39;ll pollute the=
 namespace. All calls to swap() have to be safely wrapped to avoid namespac=
e pollution. Swapping 2 objects is about as fundamental concept as you can =
get and yet executing a swap operation in C++ requires 2 expressions and ve=
ry easy to get wrong.</div><div><br></div><div><br></div><div><br></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">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_612_312127976.1436752973627--
------=_Part_611_951370937.1436752973627--

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Sun, 12 Jul 2015 19:13:19 -0700 (PDT)
Raw View
------=_Part_1394_972797800.1436753599467
Content-Type: multipart/alternative;
 boundary="----=_Part_1395_1019750421.1436753599468"

------=_Part_1395_1019750421.1436753599468
Content-Type: text/plain; charset=UTF-8



On Sunday, July 12, 2015 at 10:02:53 PM UTC-4, Matthew Fioravante wrote:
>
> On Friday, July 10, 2015 at 3:18:54 PM UTC-4, dgutson wrote:
>
>> Sorry if I'm looking your proposal too quickly, but doesn't unified
>> call syntax address this?
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4165.pdf
>>
>>
> It might help, but alone its not sufficient.
>
> We still need a default implementation of std::rbegin()/std::rend() using
> std::reverse_iterator so that class authors can cease writing
> reverse_iterator boilerplate over and over again for each container type.
>
> A default implementation of 'rbegin()' provided by the STL would need to
> live in std::. Since user defined types will not live in std::, ADL doesn't
> work and therefore uniform call syntax cannot find std::rebgin() unless the
> programmer has written using namespace std; (not always desirable) or
> written their own rbegin() and rend() for their type in the type's
> namespace (useless boillerplate) which just calls std::rbegin.
>
> Requiring using namespace std; for any standard library use cases should
> be avoided. For example, with std::swap(), you cannot do a constexpr swap
> directly in an expression in a header file because you'll pollute the
> namespace. All calls to swap() have to be safely wrapped to avoid namespace
> pollution. Swapping 2 objects is about as fundamental concept as you can
> get and yet executing a swap operation in C++ requires 2 expressions and
> very easy to get wrong.
>
>
>
>
Basically what I would propose to do is to have the generic idiom to for
the programmer to always call std::rbegin(), std::begin(), std::cbegin(),
std::swap(), etc.. explicitly and those can lookup using ADL, call member
function if exists, or optionally try to do a default action otherwise if
such a default action exists. This documents that these standard library
"attributes" (for lack of a better name) belong to the standard because
they are called with std::. Uniform call syntax doesn't really come into
the picture for this scenario because we are always directly calling
std::xyz().

Uniform call syntax by itself does not provide a solution for "do the
default action otherwise" required by swap() and others.

--

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

<br><br>On Sunday, July 12, 2015 at 10:02:53 PM UTC-4, Matthew Fioravante 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"ltr"><div>On =
Friday, July 10, 2015 at 3:18:54 PM UTC-4, dgutson wrote:</div><blockquote =
class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #=
ccc solid;padding-left:1ex">Sorry if I&#39;m looking your proposal too quic=
kly, but doesn&#39;t unified
<br>call syntax address this?
<br><a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n416=
5.pdf" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;h=
ttp://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2F=
wg21%2Fdocs%2Fpapers%2F2014%2Fn4165.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCN=
FnBxoG3pbC-udE1SiOc6U7JdMjPg&#39;;return true;" onclick=3D"this.href=3D&#39=
;http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%=
2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4165.pdf\46sa\75D\46sntz\0751\46usg\75AFQj=
CNFnBxoG3pbC-udE1SiOc6U7JdMjPg&#39;;return true;">http://www.open-std.org/j=
tc1/sc22/wg21/docs/papers/2014/n4165.pdf</a>
<br><br></blockquote><div><br></div><div>It might help, but alone its not s=
ufficient.=C2=A0</div><div><br></div><div>We still need a default implement=
ation of std::rbegin()/std::rend() using std::reverse_iterator so that clas=
s authors can cease writing reverse_iterator boilerplate over and over agai=
n for each container type.=C2=A0</div><div><br></div><div>A default impleme=
ntation of &#39;rbegin()&#39; provided by the STL would need to live in std=
::. Since user defined types will not live in std::, ADL doesn&#39;t work a=
nd therefore uniform call syntax cannot find std::rebgin() unless the progr=
ammer has written using namespace std; (not always desirable) or written th=
eir own rbegin() and rend() for their type in the type&#39;s namespace (use=
less boillerplate) which just calls std::rbegin.=C2=A0</div><div><br></div>=
<div>Requiring using namespace std; for any standard library use cases shou=
ld be avoided. For example, with std::swap(), you cannot do a constexpr swa=
p directly in an expression in a header file because you&#39;ll pollute the=
 namespace. All calls to swap() have to be safely wrapped to avoid namespac=
e pollution. Swapping 2 objects is about as fundamental concept as you can =
get and yet executing a swap operation in C++ requires 2 expressions and ve=
ry easy to get wrong.</div><div><br></div><div><br></div><div><br></div></d=
iv></blockquote><div><br></div><div>Basically what I would propose to do is=
 to have the generic idiom to for the programmer to always call std::rbegin=
(), std::begin(), std::cbegin(), std::swap(), etc.. explicitly and those ca=
n lookup using ADL, call member function if exists, or optionally try to do=
 a default action otherwise if such a default action exists. This documents=
 that these standard library &quot;attributes&quot; (for lack of a better n=
ame) belong to the standard because they are called with std::. Uniform cal=
l syntax doesn&#39;t really come into the picture for this scenario because=
 we are always directly calling std::xyz().</div><div><br></div><div>Unifor=
m call syntax by itself does not provide a solution for &quot;do the defaul=
t action otherwise&quot; required by swap() and others.</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_1395_1019750421.1436753599468--
------=_Part_1394_972797800.1436753599467--

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 15 Jul 2015 11:35:57 -0700 (PDT)
Raw View
------=_Part_62_1844126195.1436985357840
Content-Type: multipart/alternative;
 boundary="----=_Part_63_574363607.1436985357841"

------=_Part_63_574363607.1436985357841
Content-Type: text/plain; charset=UTF-8

Here is yet another glaring problem with requiring "using namespace std;"
for interfaces like swap() and begin(). It doesn't directly work with
decltype() because you cannot add using statements within a decltype()
expression.

It would be helpful to retrieve the type of a given container type T's
iterator using an expression like decltype(declval<T>().begin()) instead of
depending on the typedef T::iterator. This would mean that container
authors no longer need to provide this typedef boilerplate and with the
version of the ranges proposal I read last, begin() and end() might return
different types anyway in which case T::iterator would no longer be
helpful.


//doesn't work for C array or types that define only non-member begin (With
uniform call syntax, still doesn't work for C arrays.
template <typename T> using begin_t = decltype(declval<T>().begin());

//doesn't work for C array or types that define only member begin (with
uniform call syntax, still doesn't work for C arrays).
template <typename T> using begin_t = decltype(begin(declval<T>()));

//does not compile! But if it did and returned the type of begin(c), would
do what we want for all cases
template <typename T> using begin_t = decltype(using namespace std; begin(
declval<T>()));

//Pollutes the outer namespace with using namespace std
using namespace std;
template <typename T> using begin_t = decltype(begin(declval<T>()));

//Ugly workaround
namespace detail {
using namespace std;
template <typename T> using begin_t = begin(declval<T>());
}
using begin_t = detail::begin_t;


If instead we would always just call std::begin(), which itself would do
member dispatch, ADL non-member lookup, or default action for built in
types like C arrays. The lookup complexity is encapsulated within
std::begin() and all concepts can just be defined in a simple and
consistent way like below:

using begin_t = decltype(std::begin(std::declval<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-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_63_574363607.1436985357841
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Here is yet another glaring problem with requiring &quot;u=
sing namespace std;&quot; for interfaces like swap() and begin(). It doesn&=
#39;t directly work with decltype() because you cannot add using statements=
 within a decltype() expression.<br><br>It would be helpful to retrieve the=
 type of a given container type T&#39;s iterator using an expression like d=
ecltype(declval&lt;T&gt;().begin()) instead of depending on the typedef T::=
iterator. This would mean that container authors no longer need to provide =
this typedef boilerplate and with the version of the ranges proposal I read=
 last, begin() and end() might return different types anyway in which case =
T::iterator would no longer be helpful. <br><br><div class=3D"prettyprint" =
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, =
187); border-style: solid; border-width: 1px; word-wrap: break-word;"><code=
 class=3D"prettyprint"><div class=3D"subprettyprint"><br><code class=3D"pre=
ttyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">//doesn=
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;t wor=
k for C array or types that define only non-member begin (With uniform call=
 syntax, still doesn&#39;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">t work </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">for</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> C arrays</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span></code><span style=3D"color: #008;" class=3D"styled-by-prettify"><cod=
e class=3D"prettyprint"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template &lt;typename T&gt; using begin_t =3D </span></code>decltype=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">declval&lt;T&gt;()<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">())</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">;<br></span><br><code class=3D"p=
rettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">//doe=
sn</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;t w=
ork for C array or types that define only member begin (with uniform call s=
yntax, still doesn&#39;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">t work </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">for</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> C arrays</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">).</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span></code><span style=3D"color: #008;" class=3D"styled-by-prettify">templ=
ate &lt;typename T&gt; using begin_t =3D decltype</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">declval&lt;T&gt;()</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">;<br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>//does not compile! But if it did and returned the type of begin(c), w=
ould do what we want for all cases<br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify"><code class=3D"prettyprint"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">template &lt;typename T&gt; using be=
gin_t =3D </span></code>decltype</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>namespace</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">begin</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">declval&lt;T&gt;()</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">));</span><span style=3D"col=
or: #080;" class=3D"styled-by-prettify"><br><br>//Pollutes the outer namesp=
ace with using namespace std<br>using namespace std;<br></span><span style=
=3D"color: #080;" class=3D"styled-by-prettify"><code class=3D"prettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">template &lt;type=
name T&gt; using begin_t =3D </span></code>decltype(begin(declval&lt;T&gt;(=
))); <br><br>//Ugly workaround<br>namespace detail {<br>using namespace std=
;<br>template &lt;typename T&gt; using begin_t =3D begin(declval&lt;T&gt;()=
);<br>}<br>using begin_t =3D detail::begin_t;<br><br></span></div></code></=
div><br>If instead we would always just call std::begin(), which itself wou=
ld do member dispatch, ADL non-member lookup, or default action for built i=
n types like C arrays. The lookup complexity is encapsulated within std::be=
gin() and all concepts can just be defined in a simple and consistent way l=
ike below:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">using begin_t =3D decltype(std::begin(std::declval&lt;T&gt;()));</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify"></span></div></=
code></div><br><br><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_63_574363607.1436985357841--
------=_Part_62_1844126195.1436985357840--

.


Author: Myriachan <myriachan@gmail.com>
Date: Wed, 15 Jul 2015 17:47:03 -0700 (PDT)
Raw View
------=_Part_309_2109833749.1437007623989
Content-Type: multipart/alternative;
 boundary="----=_Part_310_1820708615.1437007623990"

------=_Part_310_1820708615.1437007623990
Content-Type: text/plain; charset=UTF-8

On Wednesday, July 15, 2015 at 11:35:57 AM UTC-7, Matthew Fioravante wrote:
>
> Here is yet another glaring problem with requiring "using namespace std;"
> for interfaces like swap() and begin(). It doesn't directly work with
> decltype() because you cannot add using statements within a decltype()
> expression.
>
> It would be helpful to retrieve the type of a given container type T's
> iterator using an expression like decltype(declval<T>().begin()) instead of
> depending on the typedef T::iterator. This would mean that container
> authors no longer need to provide this typedef boilerplate and with the
> version of the ranges proposal I read last, begin() and end() might return
> different types anyway in which case T::iterator would no longer be
> helpful.
>
>
I think that it's been proposed before, but I think that array types should
have .begin(), .end(), .cbegin(), .cend() member functions.

int x[6];
int *a = x.begin();  // same as x
int *b = x.end();  // same as &x[6]
int *c = x.cbegin();  // ill-formed: lost qualifier
const int *d = x.cbegin();  // same as static_cast<const int *>(x)
auto e = x.begin();  // implementation-defined type (to allow debug
iterators for arrays)
static_assert(std::is_same<decltype(e), int *>::value);  // unspecified
whether well-formed
  // (an implementation can simply make the iterator type be a raw pointer,
but doesn't have to)

int (&y)[6] = ...;
int *f = y.begin();  // references to arrays work the same way
int *g = y.end();  // references to arrays work the same way

int (*z)[] = ...;
int *h = z->begin();  // pointers to arrays use -> member access syntax
const int *i = z->cend();  // ill-formed: end and cend don't exist on
arrays of unknown bound

typedef int T[6];  // typedef required for grammar reasons: "int
[6]::begin" just doesn't work.
decltype(std::declval<int[6]>().end()) (T::*m)() = &T::end;
int *j = (x.*m)();  // same as &x[6]

typedef int U[];
decltype(std::declval<int[]>().begin()) (U::*n)() = &U::begin;
int *k = (x.*n)();  // no idea whether this should be legal



Melissa

--

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

<div dir=3D"ltr">On Wednesday, July 15, 2015 at 11:35:57 AM UTC-7, Matthew =
Fioravante wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">Here is yet another glaring problem with requiring &quot;using namespac=
e std;&quot; for interfaces like swap() and begin(). It doesn&#39;t directl=
y work with decltype() because you cannot add using statements within a dec=
ltype() expression.<br><br>It would be helpful to retrieve the type of a gi=
ven container type T&#39;s iterator using an expression like decltype(declv=
al&lt;T&gt;().begin()) instead of depending on the typedef T::iterator. Thi=
s would mean that container authors no longer need to provide this typedef =
boilerplate and with the version of the ranges proposal I read last, begin(=
) and end() might return different types anyway in which case T::iterator w=
ould no longer be helpful. <br><br></div></blockquote><div><br>I think that=
 it&#39;s been proposed before, but I think that array types should have <s=
pan style=3D"font-family: courier new,monospace;">.begin()</span>, <span st=
yle=3D"font-family: courier new,monospace;">.end()</span>, <span style=3D"f=
ont-family: courier new,monospace;">.cbegin()</span>, <span style=3D"font-f=
amily: courier new,monospace;">.cend()</span> member functions.<br><br><div=
 class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #=
066;" class=3D"styled-by-prettify">6</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">];</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">a </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// same as x</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">b </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">end</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// same as &amp;x[6]</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cbegin</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// ill-formed: lost qualifier</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">cbegin</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;" c=
lass=3D"styled-by-prettify">// same as static_cast&lt;const int *&gt;(x)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> e </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">// implementation-defined type (to allow debug iterators for arrays)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">static_assert</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=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">is_same</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">decltype</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">e</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=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"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// unspecified whether well-formed</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// (an implementati=
on can simply make the iterator type be a raw pointer, but doesn&#39;t have=
 to)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">y</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">)[</span><span style=3D"color: #066;"=
 class=3D"styled-by-prettify">6</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">...;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">f </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #008;" class=3D"styled-by-prettify">begin</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">// references to array=
s work the same way</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">g </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> y</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">end</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// references to arrays work the same way</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(*</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">z</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)[]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">...;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">h </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> z</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// pointers to arrays use -&gt;=
 member access syntax</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">i </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> z</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">cend</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
ill-formed: end and cend don&#39;t exist on arrays of unknown bound</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">6</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">];</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ typedef required for grammar reasons: &quot;int [6]::begin&quot; just doe=
sn&#39;t work.</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">de=
cltype</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">declval</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">6</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">]&gt;().</span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">end</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">())</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
(T::*m)() </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">end</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">j </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">x</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">.*</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">m</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)();</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// same as &amp;x[6]</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">typedef</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> U</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">[];</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><code class=3D"=
prettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">decl=
type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><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">declval</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]&gt;().</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">())</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> (U::*n)() </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">U::begin=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"></span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>int *k =3D (x.*n)();=C2=
=A0 // no idea whether this should be legal<br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify"></span></code></div></code></div><br><=
br><br>Melissa<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_310_1820708615.1437007623990--
------=_Part_309_2109833749.1437007623989--

.