Topic: Fixed size parameter packs
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Thu, 18 Jul 2013 12:48:06 -0700 (PDT)
Raw View
------=_Part_1956_12028503.1374176886074
Content-Type: text/plain; charset=ISO-8859-1
Hello,
I think it'd be quite handy to have a syntax to say that a function takes N
parameters of type T, without having to write T N times.
For example: void foo(int...[5]); instead of void foo(int,int,int,int,int);
This is not just for convenience; it also adds interesting new
possibilities when used in a template, such as:
template<size_t N> void foo(int...[N] v);
Inside the body of 'foo', 'v' can then be used like a parameter pack.
Some examples:
// Here we make a constructor that takes exactly N integers:
// (Such that my_vector<3>{1,2,3} is valid, and my_vector<3>{1,2} is not.)
template<size_t N>
struct my_vector {
// ...
my_vector(int...[N] v) : values{v...} {}
};
// This declares a function that takes a variable number of parameters,
// all of which must be integers:
template<size_t N> int sum(int...[N] v);
// This declares a function that takes a variable number of parameters,
// all of which must be of the same type:
template<typename T, size_t N> T max(T...[N] v);
// This declares a function that takes exactly 5 parameters of any type:
template<typename...[5] T> T blah(T... v);
// A bigger example:
template<size_t N>
struct square_matrix {
static_assert(N>1, "Noonono.");
square_matrix(int...[N*N] v); // fills the entire matrix
square_matrix(int...[N] v); // fills only the diagonal
square_matrix(int v = 0); // fills the entire diagonal with the same
number
};
// Last example:
template<size_t N>
struct foo {
template<typename...[N] T> void bar(T... v);
// foo<5>::bar takes exactly 5 parameters of any type.
};
Feedback is greatly appreciated.
Thanks.
-Maurice-
--
---
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_1956_12028503.1374176886074
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello,<br><br>I think it'd be quite handy to have a syntax to say that a fu=
nction takes N parameters of type T, without having to write T N times.<br>=
For example: <span style=3D"font-family: courier new,monospace;">void foo(i=
nt...[5]);</span> instead of <span style=3D"font-family: courier new,monosp=
ace;">void foo(int,int,int,int,int);</span><br><br>This is not just for con=
venience; it also adds interesting new possibilities when used in a templat=
e, such as:<br><br><div style=3D"margin-left: 40px;"> <span style=3D"f=
ont-family: courier new,monospace;">template<size_t N> void foo(int..=
..[N] v);</span><br></div><br>Inside the body of 'foo', 'v' can then be used=
like a parameter pack.<br><br><br>Some examples:<br><br><br><span style=3D=
"font-family: courier new,monospace;">// Here we make a constructor that ta=
kes exactly N integers:<br>// (Such that my_vector<3>{1,2,3} is valid=
, and </span><span style=3D"font-family: courier new,monospace;"><span styl=
e=3D"font-family: courier new,monospace;">my_vector</span><3>{1,2} is=
not.)<br>template<size_t N><br>struct </span><span style=3D"font-fam=
ily: courier new,monospace;"><span style=3D"font-family: courier new,monosp=
ace;">my_vector</span> {<br> // ...<br> =
</span><span style=3D"font-family: courier new,monospace;"><span style=3D"=
font-family: courier new,monospace;">my_vector</span>(int...[N] v) : values=
{v...} {}<br>};<br><br><br>// This declares a function that takes a variabl=
e number of </span><span style=3D"font-family: courier new,monospace;"><spa=
n style=3D"font-family: courier new,monospace;"><span style=3D"font-family:=
courier new,monospace;">parameters</span></span>,<br>// all of which must =
be integers:<br>template<size_t N> int sum(int...[N] v);<br><br><br>/=
/ This declares a function that takes a variable number of </span><span sty=
le=3D"font-family: courier new,monospace;"><span style=3D"font-family: cour=
ier new,monospace;"><span style=3D"font-family: courier new,monospace;">par=
ameters</span></span>,<br>// all of which must be of the same type:<br>temp=
late<typename T, size_t N> T max(T...[N] v);<br><br></span><br><span =
style=3D"font-family: courier new,monospace;"><span style=3D"font-family: c=
ourier new,monospace;">// This declares a function that takes exactly 5 par=
ameters of any type:<br>template<typename...[5] T> T blah(T... v);</s=
pan><br><br><br>// A bigger example:<br>template<size_t N><br>struct =
square_matrix {<br> static_assert(N>1, "Noonono.");<br=
> <br> square_matrix(int...[N*N] v); //=
fills the entire matrix<br> square_matrix(int...[N] v); =
// fills only the diagonal<br> square_matrix(int v =3D 0)=
; // fills the entire diagonal with the same number<br>};<br><br><br>// Las=
t example:<br>template<size_t N><br>struct foo {<br>  =
; template<typename...[N] T> void bar(T... v);<br> =
// foo<5>::bar takes exactly 5 parameters of any type.<br>};</span><b=
r><br><br><font face=3D"arial,sans-serif">Feedback is greatly appreciated.<=
br><br>Thanks.<br><br>-Maurice-<br></font>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_1956_12028503.1374176886074--
.
Author: inkwizytoryankes@gmail.com
Date: Thu, 18 Jul 2013 13:08:01 -0700 (PDT)
Raw View
------=_Part_11_22948101.1374178081907
Content-Type: text/plain; charset=ISO-8859-1
with concept lite you could do something like that:
template<typename... T>
concept bool Limit() { return sizeof...(T) == 5; }
template<typename... T> require Limit<T...>()
void func(T... a);
--
---
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_11_22948101.1374178081907
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>with concept lite you could do something like that:<br><div class=3D"pr=
ettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-w=
ord;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">...</span><span 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"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">concept</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">Limit</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">()</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"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">...(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">temp=
late</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">...</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"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">require</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">Limit</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">T</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"styled-by-prettify">void</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> func</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span></div></code></div><br><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_11_22948101.1374178081907--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 18 Jul 2013 23:21:58 +0300
Raw View
--047d7bdc939646ac7604e1cef65e
Content-Type: text/plain; charset=ISO-8859-1
On 18 July 2013 22:48, Maurice Bos <m-ou.se@m-ou.se> wrote:
> Hello,
>
> I think it'd be quite handy to have a syntax to say that a function takes
> N parameters of type T, without having to write T N times.
> For example: void foo(int...[5]); instead of void
> foo(int,int,int,int,int);
>
No worries:
template <class... T>
typename enable_if<sizeof...(T) == 5>::type f(T... x) {}
int main()
{
f(1,2,3,4,5); // ok
f(1,2); // ill-formed
}
--
---
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/.
--047d7bdc939646ac7604e1cef65e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 18 July 2013 22:48, Maurice Bos <span dir=3D"ltr"><<a href=3D=
"mailto:m-ou.se@m-ou.se" target=3D"_blank">m-ou.se@m-ou.se</a>></span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br><br>I think it&=
#39;d be quite handy to have a syntax to say that a function takes N parame=
ters of type T, without having to write T N times.<br>
For example: <span style=3D"font-family:courier new,monospace">void foo(int=
....[5]);</span> instead of <span style=3D"font-family:courier new,monospace=
">void foo(int,int,int,int,int);</span><br></blockquote><div><br></div><div=
>
No worries:<br><br>template <class... T> <br>typename enable_if<si=
zeof...(T) =3D=3D 5>::type f(T... x) {} <br><br>int main() <br>{<br>=A0=
=A0=A0 f(1,2,3,4,5); // ok<br></div><div>=A0=A0=A0 f(1,2); // ill-formed<br=
>}<br><br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--047d7bdc939646ac7604e1cef65e--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 18 Jul 2013 23:24:30 +0300
Raw View
--047d7bdc9396631ff104e1ceff25
Content-Type: text/plain; charset=ISO-8859-1
On 18 July 2013 23:21, Ville Voutilainen <ville.voutilainen@gmail.com>wrote:
>
>
>
> On 18 July 2013 22:48, Maurice Bos <m-ou.se@m-ou.se> wrote:
>
>> Hello,
>>
>> I think it'd be quite handy to have a syntax to say that a function takes
>> N parameters of type T, without having to write T N times.
>> For example: void foo(int...[5]); instead of void
>> foo(int,int,int,int,int);
>>
>
> No worries:
>
> template <class... T>
> typename enable_if<sizeof...(T) == 5>::type f(T... x) {}
>
> int main()
> {
> f(1,2,3,4,5); // ok
> f(1,2); // ill-formed
> }
>
>
>
Hmm, this needs an additional check that every type in the pack is the
same. We can do that already, too,
so I think all the tools are in place. Whether that results in a palatable
syntax is another question. :)
--
---
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/.
--047d7bdc9396631ff104e1ceff25
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 18 July 2013 23:21, Ville Voutilainen <span dir=3D"ltr"><<a h=
ref=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.voutilai=
nen@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div class=3D"gmail_ext=
ra"><br><br><div class=3D"gmail_quote"><div class=3D"im">On 18 July 2013 22=
:48, Maurice Bos <span dir=3D"ltr"><<a href=3D"mailto:m-ou.se@m-ou.se" t=
arget=3D"_blank">m-ou.se@m-ou.se</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br><br>I think it&=
#39;d be quite handy to have a syntax to say that a function takes N parame=
ters of type T, without having to write T N times.<br>
For example: <span style=3D"font-family:courier new,monospace">void foo(int=
....[5]);</span> instead of <span style=3D"font-family:courier new,monospace=
">void foo(int,int,int,int,int);</span><br></blockquote><div><br></div></di=
v>
<div>
No worries:<br><br>template <class... T> <br>typename enable_if<si=
zeof...(T) =3D=3D 5>::type f(T... x) {} <br><br>int main() <br>{<br>=A0=
=A0=A0 f(1,2,3,4,5); // ok<br></div><div>=A0=A0=A0 f(1,2); // ill-formed<br=
>}<br><br></div>
</div><br></div></div>
</blockquote></div><br></div><div class=3D"gmail_extra">Hmm, this needs an =
additional check that every type in the pack is the same. We can do that al=
ready, too,<br>so I think all the tools are in place. Whether that results =
in a palatable syntax is another question. :)<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--047d7bdc9396631ff104e1ceff25--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Thu, 18 Jul 2013 13:33:52 -0700 (PDT)
Raw View
------=_Part_36_29267662.1374179632577
Content-Type: text/plain; charset=ISO-8859-1
Hey,
Indeed, making sure a pack is of the right length is indeed not really a
challenge using what's already available in C++11.
However, it gets a lot trickier in the cases of all the other examples I
gave, such as making a 'template<size_t N> struct my_vector;' such that
my_vector<3> behaves exactly like it has a my_vector(int,int,int)
constructor.
Using enable_if and a template<typename...T> constructor, that wouldn't
only require checking the size of the pack, but also whether the types in
the pack are all implicitly convertible to int. Having a way to simply
define a constructor my_vector(int,int/*,....*/,int) with the number of
parameters depending on a template parameter of the class template would be
a very pretty solution here.
-Maurice-
--
---
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_36_29267662.1374179632577
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hey,<br><br>Indeed, making sure a pack is of the right length is indeed not=
really a challenge using what's already available in C++11.<br><br>However=
, it gets a lot trickier in the cases of all the other examples I gave, suc=
h as making a 'template<size_t N> struct my_vector;' such that my_vec=
tor<3> behaves exactly like it has a my_vector(int,int,int) construct=
or.<br><br>Using enable_if and a template<typename...T> constructor, =
that wouldn't only require checking the size of the pack, but also whether =
the types in the pack are all implicitly convertible to int. Having a way t=
o simply define a constructor my_vector(int,int/*,....*/,int) with the numb=
er of parameters depending on a template parameter of the class template wo=
uld be a very pretty solution here.<br><br>-Maurice-<br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_36_29267662.1374179632577--
.
Author: cornedbee@google.com
Date: Fri, 19 Jul 2013 02:48:31 -0700 (PDT)
Raw View
------=_Part_257_18108061.1374227311072
Content-Type: text/plain; charset=ISO-8859-1
On Thursday, July 18, 2013 10:33:52 PM UTC+2, Maurice Bos wrote:
>
> Using enable_if and a template<typename...T> constructor, that wouldn't
> only require checking the size of the pack, but also whether the types in
> the pack are all implicitly convertible to int. Having a way to simply
> define a constructor my_vector(int,int/*,....*/,int) with the number of
> parameters depending on a template parameter of the class template would be
> a very pretty solution here.
>
>
my_vector(std::array<int, N> args) ?
All you need now are additional braces when initializing.
--
---
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_257_18108061.1374227311072
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><br>On Thursday, July 18, 2013 10:33:52 PM UTC+2, Maurice Bos wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;">Using enable_if and a template<=
;typename...T> constructor, that wouldn't only require checking the size=
of the pack, but also whether the types in the pack are all implicitly con=
vertible to int. Having a way to simply define a constructor my_vector(int,=
int/*,....*/,<wbr>int) with the number of parameters depending on a templat=
e parameter of the class template would be a very pretty solution here.<br>=
<br></blockquote><div><br></div><div>my_vector(std::array<int, N> arg=
s) ?</div><div><br></div><div>All you need now are additional braces when i=
nitializing. <br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_257_18108061.1374227311072--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 19 Jul 2013 11:56:05 +0200
Raw View
--001a11c3a9680149e004e1da578c
Content-Type: text/plain; charset=ISO-8859-1
Apart from it not being a nice solution because it doesn't allow
my_vector<3>{1,2,3}, there is another problem: Using std::array<int, N>
allows my_vector<3>{{1,2}};
2013/7/19 <cornedbee@google.com>
>
>
> On Thursday, July 18, 2013 10:33:52 PM UTC+2, Maurice Bos wrote:
>>
>> Using enable_if and a template<typename...T> constructor, that wouldn't
>> only require checking the size of the pack, but also whether the types in
>> the pack are all implicitly convertible to int. Having a way to simply
>> define a constructor my_vector(int,int/*,....*/,**int) with the number
>> of parameters depending on a template parameter of the class template would
>> be a very pretty solution here.
>>
>>
> my_vector(std::array<int, N> args) ?
>
> All you need now are additional braces when initializing.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a11c3a9680149e004e1da578c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<span style=3D"font-family:arial,helvetica,sans-serif"><font>Apart from it =
not being a nice solution because it doesn't allow my_vector<3>{1=
,2,3}, there is another problem: Using std::array<int, N> allows my_v=
ector<3>{{1,2}};<br>
</font></span><br><div class=3D"gmail_quote">2013/7/19 <span dir=3D"ltr">&=
lt;<a href=3D"mailto:cornedbee@google.com" target=3D"_blank">cornedbee@goog=
le.com</a>></span><br><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br><br>On Thursday, July 18, 2013 10:33:52 PM UTC+2, Maurice Bos wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex">Using enable_if and a template<=
;typename...T> constructor, that wouldn't only require checking the =
size of the pack, but also whether the types in the pack are all implicitly=
convertible to int. Having a way to simply define a constructor my_vector(=
int,int/*,....*/,<u></u>int) with the number of parameters depending on a t=
emplate parameter of the class template would be a very pretty solution her=
e.<br>
<br></blockquote><div><br></div></div><div>my_vector(std::array<int, N&g=
t; args) ?</div><div><br></div><div>All you need now are additional braces =
when initializing.=A0<br></div><div><div>
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
=A0<br>
=A0<br>
</div></div></blockquote></div><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c3a9680149e004e1da578c--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 19 Jul 2013 12:18:10 +0200
Raw View
--089e0158b554ffb89b04e1daa530
Content-Type: text/plain; charset=ISO-8859-1
Maybe I can describe the problem better like this:
It's very easy to make a function (template) that
[1] takes two ints:
void foo(int, int);
[2] takes two parameters of any type:
template<typename A, typename B>
void foo(A, B);
[3] - - -
- - -
[4] takes any number of parameters of any type:
template<typename... T>
void foo(T...);
Clearly, [3] is missing. (Taking any number of ints, that is.) Although
something could already be done by combining [4] with enough enable_if
black magic, I think this is a serious gap in the above list. (Imagine not
having [1], and having to do that with [2] combined with enable_if.)
The 'fixed size parameter packs' idea I proposed would fill this gap as
follows:
[3] takes any number of ints:
template<size_t N>
void foo(int...[N]);
And, at the same time, it also provides cleaner solutions for other
situations in which enable_if now has to be used in complicated ways
together with a variadic template, such as the examples I gave in the first
e-mail in this conversation.
-Maurice-
2013/7/19 Maurice Bos <m-ou.se@m-ou.se>
> Apart from it not being a nice solution because it doesn't allow
> my_vector<3>{1,2,3}, there is another problem: Using std::array<int, N>
> allows my_vector<3>{{1,2}};
>
> 2013/7/19 <cornedbee@google.com>
>
>
>>
>> On Thursday, July 18, 2013 10:33:52 PM UTC+2, Maurice Bos wrote:
>>>
>>> Using enable_if and a template<typename...T> constructor, that wouldn't
>>> only require checking the size of the pack, but also whether the types in
>>> the pack are all implicitly convertible to int. Having a way to simply
>>> define a constructor my_vector(int,int/*,....*/,**int) with the number
>>> of parameters depending on a template parameter of the class template would
>>> be a very pretty solution here.
>>>
>>>
>> my_vector(std::array<int, N> args) ?
>>
>> All you need now are additional braces when initializing.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>>
>>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--089e0158b554ffb89b04e1daa530
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Maybe I can describe the problem better like this:<br><br>It's very eas=
y to make a function (template) that<br>=A0 [1] takes two ints:<br><span st=
yle=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 void foo(int, int=
);</span><br>
=A0 [2] takes two parameters of any type:<br><span style=3D"font-family:cou=
rier new,monospace">=A0=A0=A0=A0=A0 template<typename A, typename B><=
br>=A0=A0=A0=A0=A0 void foo(A, B);</span><br>=A0 [3] - - -<br><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 - - -</span><br>
=A0 [4] takes any number of parameters of any type:<br><span style=3D"font-=
family:courier new,monospace">=A0=A0=A0=A0=A0 template<typename... T>=
<br>=A0=A0=A0=A0=A0 void foo(T...);</span><br><br>Clearly, [3] is missing. =
(Taking any number of ints, that is.) Although something could already be d=
one by combining [4] with enough enable_if black magic, I think this is a s=
erious gap in the above list.=A0 (Imagine not having [1], and having to do =
that with [2] combined with enable_if.)<br>
<br>The 'fixed size parameter packs' idea I proposed would fill thi=
s gap as follows:<br>=A0 [3] takes any number of ints:<br><span style=3D"fo=
nt-family:courier new,monospace">=A0=A0=A0=A0=A0 template<size_t N><b=
r>=A0=A0=A0=A0=A0 void foo(int...[N]);</span><br>
<br>And, at the same time, it also provides cleaner solutions for other sit=
uations in which enable_if now has to be used in complicated ways together =
with a variadic template, such as the examples I gave in the first e-mail i=
n this conversation.<br>
<br>-Maurice-<br><br><br><div class=3D"gmail_quote">2013/7/19 Maurice Bos <=
span dir=3D"ltr"><<a href=3D"mailto:m-ou.se@m-ou.se" target=3D"_blank">m=
-ou.se@m-ou.se</a>></span><br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span style=3D"font-family:arial,helvetica,sans-serif"><font>Apart from it =
not being a nice solution because it doesn't allow my_vector<3>{1=
,2,3}, there is another problem: Using std::array<int, N> allows my_v=
ector<3>{{1,2}};<br>
</font></span><br><div class=3D"gmail_quote">2013/7/19 <span dir=3D"ltr">&=
lt;<a href=3D"mailto:cornedbee@google.com" target=3D"_blank">cornedbee@goog=
le.com</a>></span><div><div class=3D"h5"><br><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex">
<div><br><br>On Thursday, July 18, 2013 10:33:52 PM UTC+2, Maurice Bos wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex">Using enable_if and a template<=
;typename...T> constructor, that wouldn't only require checking the =
size of the pack, but also whether the types in the pack are all implicitly=
convertible to int. Having a way to simply define a constructor my_vector(=
int,int/*,....*/,<u></u>int) with the number of parameters depending on a t=
emplate parameter of the class template would be a very pretty solution her=
e.<br>
<br></blockquote><div><br></div></div><div>my_vector(std::array<int, N&g=
t; args) ?</div><div><br></div><div>All you need now are additional braces =
when initializing.=A0<br></div><div><div>
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
=A0<br>
=A0<br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--089e0158b554ffb89b04e1daa530--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 19 Jul 2013 15:06:21 +0300
Raw View
--047d7beb9bf4aa2dde04e1dc2704
Content-Type: text/plain; charset=ISO-8859-1
On 19 July 2013 13:18, Maurice Bos <m-ou.se@m-ou.se> wrote:
> Maybe I can describe the problem better like this:
>
> It's very easy to make a function (template) that
> [1] takes two ints:
> void foo(int, int);
> [2] takes two parameters of any type:
> template<typename A, typename B>
> void foo(A, B);
> [3] - - -
> - - -
> [4] takes any number of parameters of any type:
> template<typename... T>
> void foo(T...);
>
> Clearly, [3] is missing. (Taking any number of ints, that is.) Although
> something could already be done by combining [4] with
Except that you can do that with an initializer_list<int>.
What I find funny is that static_assert of an initializer_list size doesn't
seem to work.
gcc says the initializer_list is not a constant expression, so it refuses
to compute
its size in a static assert. So that approach doesn't yield the solution to
a "list
of ints with size limitation".
--
---
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/.
--047d7beb9bf4aa2dde04e1dc2704
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 19 July 2013 13:18, Maurice Bos <span dir=3D"ltr"><<a href=3D=
"mailto:m-ou.se@m-ou.se" target=3D"_blank">m-ou.se@m-ou.se</a>></span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Maybe I can describe the problem better like=
this:<br><br>It's very easy to make a function (template) that<br>=A0 =
[1] takes two ints:<br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 void foo(=
int, int);</span><br>
=A0 [2] takes two parameters of any type:<br><span style=3D"font-family:cou=
rier new,monospace">=A0=A0=A0=A0=A0 template<typename A, typename B><=
br>=A0=A0=A0=A0=A0 void foo(A, B);</span><br>=A0 [3] - - -<br><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 - - -</span><br>
=A0 [4] takes any number of parameters of any type:<br><span style=3D"font-=
family:courier new,monospace">=A0=A0=A0=A0=A0 template<typename... T>=
<br>=A0=A0=A0=A0=A0 void foo(T...);</span><br><br>Clearly, [3] is missing. =
(Taking any number of ints, that is.) Although something could already be d=
one by combining [4] with </blockquote>
<div><br></div><div>Except that you can do that with an initializer_list<=
;int>.<br><br></div><div>What I find funny is that static_assert of an i=
nitializer_list size doesn't seem to work.<br></div><div>gcc says the i=
nitializer_list is not a constant expression, so it refuses to compute<br>
its size in a static assert. So that approach doesn't yield the solutio=
n to a "list<br>of ints with size limitation".<br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--047d7beb9bf4aa2dde04e1dc2704--
.
Author: Martinho Fernandes <martinho.fernandes@gmail.com>
Date: Fri, 19 Jul 2013 14:12:35 +0200
Raw View
On Fri, Jul 19, 2013 at 2:06 PM, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
>
> Except that you can do that with an initializer_list<int>.
>
> What I find funny is that static_assert of an initializer_list size doesn=
't
> seem to work.
> gcc says the initializer_list is not a constant expression, so it refuses=
to
> compute
> its size in a static assert. So that approach doesn't yield the solution =
to
> a "list
> of ints with size limitation".
>
Function arguments are never constant expressions.
Mit freundlichen Gr=FC=DFen,
Martinho
--=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: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 19 Jul 2013 14:19:25 +0200
Raw View
--001a11336974a03bfd04e1dc575f
Content-Type: text/plain; charset=ISO-8859-1
> It's very easy to make a function (template) that
>> [1] takes two ints:
>> void foo(int, int);
>> [2] takes two parameters of any type:
>> template<typename A, typename B>
>> void foo(A, B);
>> [3] - - -
>> - - -
>> [4] takes any number of parameters of any type:
>> template<typename... T>
>> void foo(T...);
>>
>> Clearly, [3] is missing. (Taking any number of ints, that is.) Although
>> something could already be done by combining [4] with
>
>
> Except that you can do that with an initializer_list<int>.
>
>
That's like saying you can do [1] with void foo(std::pair<int, int>). It
can do similar things, but it's not quite the same.
--
---
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/.
--001a11336974a03bfd04e1dc575f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D"im"=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex">
It's very easy to make a function (template) that<br>=A0 [1] takes two =
ints:<br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 void foo(=
int, int);</span><br>
=A0 [2] takes two parameters of any type:<br><span style=3D"font-family:cou=
rier new,monospace">=A0=A0=A0=A0=A0 template<typename A, typename B><=
br>=A0=A0=A0=A0=A0 void foo(A, B);</span><br>=A0 [3] - - -<br><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 - - -</span><br>
=A0 [4] takes any number of parameters of any type:<br><span style=3D"font-=
family:courier new,monospace">=A0=A0=A0=A0=A0 template<typename... T>=
<br>=A0=A0=A0=A0=A0 void foo(T...);</span><br><br>Clearly, [3] is missing. =
(Taking any number of ints, that is.) Although something could already be d=
one by combining [4] with </blockquote>
<div><br></div></div><div>Except that you can do that with an initializer_l=
ist<int>.</div></div><br></div></div></blockquote></div><br>That'=
s like saying you can do [1] with void foo(std::pair<int, int>). It c=
an do similar things, but it's not quite the same.<br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11336974a03bfd04e1dc575f--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 19 Jul 2013 14:30:22 +0200
Raw View
--089e0160b7bed0b45b04e1dc7e70
Content-Type: text/plain; charset=ISO-8859-1
More importantly, with a std::initializer_list<int> you can't make
something like:
template<size_t N> std::array<int, N> make_int_array(int...[N] v) { return
{{v...}}; }
(Because the return type can't depend on the length of the
initializer_list.)
2013/7/19 Maurice Bos <m-ou.se@m-ou.se>
>
> It's very easy to make a function (template) that
>>> [1] takes two ints:
>>> void foo(int, int);
>>> [2] takes two parameters of any type:
>>> template<typename A, typename B>
>>> void foo(A, B);
>>> [3] - - -
>>> - - -
>>> [4] takes any number of parameters of any type:
>>> template<typename... T>
>>> void foo(T...);
>>>
>>> Clearly, [3] is missing. (Taking any number of ints, that is.) Although
>>> something could already be done by combining [4] with
>>
>>
>> Except that you can do that with an initializer_list<int>.
>>
>>
> That's like saying you can do [1] with void foo(std::pair<int, int>). It
> can do similar things, but it's not quite the same.
>
--
---
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/.
--089e0160b7bed0b45b04e1dc7e70
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
More importantly, with a std::initializer_list<int> you can't mak=
e something like:<br><br>template<size_t N> std::array<int, N> =
make_int_array(int...[N] v) { return {{v...}}; }<br><br>(Because the return=
type can't depend on the length of the initializer_list.)<br>
<br><br><div class=3D"gmail_quote">2013/7/19 Maurice Bos <span dir=3D"ltr">=
<<a href=3D"mailto:m-ou.se@m-ou.se" target=3D"_blank">m-ou.se@m-ou.se</a=
>></span><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex">
<div class=3D"im"><br><div class=3D"gmail_quote"><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"=
><div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex">
It's very easy to make a function (template) that<br>=A0 [1] takes two =
ints:<br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 void foo(=
int, int);</span><br>
=A0 [2] takes two parameters of any type:<br><span style=3D"font-family:cou=
rier new,monospace">=A0=A0=A0=A0=A0 template<typename A, typename B><=
br>=A0=A0=A0=A0=A0 void foo(A, B);</span><br>=A0 [3] - - -<br><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 - - -</span><br>
=A0 [4] takes any number of parameters of any type:<br><span style=3D"font-=
family:courier new,monospace">=A0=A0=A0=A0=A0 template<typename... T>=
<br>=A0=A0=A0=A0=A0 void foo(T...);</span><br><br>Clearly, [3] is missing. =
(Taking any number of ints, that is.) Although something could already be d=
one by combining [4] with </blockquote>
<div><br></div></div><div>Except that you can do that with an initializer_l=
ist<int>.</div></div><br></div></div></blockquote></div><br></div>Tha=
t's like saying you can do [1] with void foo(std::pair<int, int>)=
.. It can do similar things, but it's not quite the same.<br>
</blockquote></div><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--089e0160b7bed0b45b04e1dc7e70--
.
Author: Alex B <devalexb@gmail.com>
Date: Thu, 25 Jul 2013 10:55:44 -0700 (PDT)
Raw View
------=_Part_3064_12731200.1374774944862
Content-Type: text/plain; charset=ISO-8859-1
I really like the idea. Even if there are a few workarounds, it really
makes things easier and clearer. The examples you gave speak for
themselves; they are very easy to read.
The feature is easy enough to be understood and used by most average users
(which is not the case with actual solutions relying on enable_if/SFINAE
trickery). So is it worth the trouble of adding it to the standard? Totally.
Were you going to write a detailed proposal?
--
---
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_3064_12731200.1374774944862
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I really like the idea. Even if there are a few workarounds, it really make=
s things easier and clearer. The examples you gave speak for themselves; th=
ey are very easy to read.<div><br></div><div>The feature is easy enough to =
be understood and used by most average users (which is not the case with ac=
tual solutions relying on enable_if/SFINAE trickery). So is it worth the tr=
ouble of adding it to the standard? Totally.</div><div><br></div><div>Were =
you going to write a detailed proposal?</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_3064_12731200.1374774944862--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Thu, 25 Jul 2013 21:32:35 +0200
Raw View
--14dae93d9300c48ea004e25b1755
Content-Type: text/plain; charset=ISO-8859-1
Hey,
Good to hear you like the idea.
If there are enough people interested in the idea then I definitely want to
write it down properly in the form of a proposal. However, if there's
little interest, it might not be worth the effort. (Also, I have never
written a proposal before, so it'll probably require some more effort to
get everything right.)
-Maurice-
2013/7/25 Alex B <devalexb@gmail.com>
> I really like the idea. Even if there are a few workarounds, it really
> makes things easier and clearer. The examples you gave speak for
> themselves; they are very easy to read.
>
> The feature is easy enough to be understood and used by most average users
> (which is not the case with actual solutions relying on enable_if/SFINAE
> trickery). So is it worth the trouble of adding it to the standard? Totally.
>
> Were you going to write a detailed proposal?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
>
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--14dae93d9300c48ea004e25b1755
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hey,<br><br>Good to hear you like the idea.<br><br>If there are enough peop=
le interested in the idea then I definitely want to write it down properly =
in the form of a proposal. However, if there's little interest, it migh=
t not be worth the effort. (Also, I have never written a proposal before, s=
o it'll probably require some more effort to get everything right.)<br>
<br>-Maurice-<br><br><div class=3D"gmail_quote">2013/7/25 Alex B <span dir=
=3D"ltr"><<a href=3D"mailto:devalexb@gmail.com" target=3D"_blank">devale=
xb@gmail.com</a>></span><br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I really like the idea. Even if there are a few workarounds, it really make=
s things easier and clearer. The examples you gave speak for themselves; th=
ey are very easy to read.<div><br></div><div>The feature is easy enough to =
be understood and used by most average users (which is not the case with ac=
tual solutions relying on enable_if/SFINAE trickery). So is it worth the tr=
ouble of adding it to the standard? Totally.</div>
<div><br></div><div>Were you going to write a detailed proposal?</div><div =
class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
=A0<br>
=A0<br>
</div></div></blockquote></div><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--14dae93d9300c48ea004e25b1755--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 26 Jul 2013 00:02:40 +0300
Raw View
--f46d04479fb7c2bed304e25c58ed
Content-Type: text/plain; charset=ISO-8859-1
On 25 July 2013 22:32, Maurice Bos <m-ou.se@m-ou.se> wrote:
> Hey,
>
> Good to hear you like the idea.
>
> If there are enough people interested in the idea then I definitely want
> to write it down properly in the form of a proposal. However, if there's
> little interest, it might not be worth the effort. (Also, I have never
> written a proposal before, so it'll probably require some more effort to
> get everything right.)
>
>
>
Take an existing proposal and use that as an example.
This proposal, however the syntax ends up being, is certainly interesting.
It's even more interesting if
it can solve, possibly in conjunction with concepts, cases like
template <class T, class U, class V, class... Rest> void f(T, U, V,
Rest...);
in which Rest should actually be a repetition of T,U,V as many times as the
caller provided such a triplet.
The original proposal supports cases like N-ints-whatever-N-is, but I
sometimes notice when writing
new case-like selection structures with variadic templates that it would be
very very useful to have
a way to express "the argument is a repeating pack of this triplet". For
some such cases, a tuple
will work, but there are situations where it's very sub-optimal to use a
tuple.
--
---
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/.
--f46d04479fb7c2bed304e25c58ed
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 25 July 2013 22:32, Maurice Bos <span dir=3D"ltr"><<a href=3D=
"mailto:m-ou.se@m-ou.se" target=3D"_blank">m-ou.se@m-ou.se</a>></span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Hey,<br><br>Good to hear you like the idea.<=
br><br>If there are enough people interested in the idea then I definitely =
want to write it down properly in the form of a proposal. However, if there=
's little interest, it might not be worth the effort. (Also, I have nev=
er written a proposal before, so it'll probably require some more effor=
t to get everything right.)<span class=3D"HOEnZb"><font color=3D"#888888"><=
br>
<br><br></font></span></blockquote><div><br></div><div>Take an existing pro=
posal and use that as an example.<br><br></div><div>This proposal, however =
the syntax ends up being, is certainly interesting. It's even more inte=
resting if<br>
it can solve, possibly in conjunction with concepts, cases like<br><br>temp=
late <class T, class U, class V, class... Rest> void f(T, U, V, Rest.=
...);<br><br></div><div>in which Rest should actually be a repetition of T,U=
,V as many times as the caller provided such a triplet.<br>
</div><div>The original proposal supports cases like N-ints-whatever-N-is, =
but I sometimes notice when writing<br>new case-like selection structures w=
ith variadic templates that it would be very very useful to have<br></div>
<div>a way to express "the argument is a repeating pack of this triple=
t". For some such cases, a tuple<br></div><div>will work, but there ar=
e situations where it's very sub-optimal to use a tuple.<br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--f46d04479fb7c2bed304e25c58ed--
.
Author: Alex B <devalexb@gmail.com>
Date: Thu, 25 Jul 2013 23:00:14 -0400
Raw View
--089e0153844a7bceca04e26157a4
Content-Type: text/plain; charset=ISO-8859-1
I doesn't solve your use case exactly, but you could do this:
template <class T, class U, class V, int N>
void f(T...[N] t, U...[N] u, V...[N] v);
The order of the function parameters is not the same but it might be an
acceptable alternative.
To obtain exactly what you are looking for would require something
additional, like being able to chain packs:
template <class...[3] T, int N>
void f(T... ...[N] t); // First ... is for repeating 3 times, second ...
is for repeating the sequence of 3 any N number of times
But this last approach would not work well with concepts; all 3 T (that is
T, U and V in the original example) would required to be the same concept.
Or being able to group types in some way:
template <class T, class U, class V, int N>
void f(<T t, U u, V v>...[N]);
That would work well with concepts but here we are talking about a whole
new language feature...
--
---
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/.
--089e0153844a7bceca04e26157a4
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I doesn't solve your use case exactly, but you could d=
o this:<div><br></div><div><font face=3D"courier new, monospace">=A0 templa=
te <class T, class U, class V, int N></font></div><div><font face=3D"=
courier new, monospace">=A0 void f(T...[N] t, U...[N] u, V...[N] v);</font>=
<br>
</div><div><br></div><div>The order of the function parameters is not the s=
ame but it might be an acceptable alternative.</div><div><br></div><div>To =
obtain exactly what you are looking for would require something additional,=
like being able to chain packs:</div>
<div><br></div><div><span style=3D"font-family:'courier new',monosp=
ace">=A0</span><span style=3D"font-family:'courier new',monospace">=
=A0</span><font face=3D"courier new, monospace">template <class...[3] T,=
int N></font></div>
<div><font face=3D"courier new, monospace">=A0 void f(T... ...[N] t); // Fi=
rst ... is for repeating 3 times, second ... is for repeating the sequence =
of 3 any N number of times</font><br></div><div><br></div><div>But this las=
t approach would not work well with concepts; all 3 T (that is T, U and V i=
n the original example) would required to be the same concept.</div>
<div><br></div><div>Or being able to group types in some way:</div><div><br=
></div><div><span style=3D"font-family:'courier new',monospace">=A0=
</span><span style=3D"font-family:'courier new',monospace">=A0</spa=
n><font face=3D"courier new, monospace">template <</font><span style=3D"=
font-family:'courier new',monospace">class T, class U, class V,=A0<=
/span><span style=3D"font-family:'courier new',monospace">int N>=
</span></div>
<div><font face=3D"courier new, monospace">=A0 void f(<T t, U u, V v>=
....[N]);</font></div><div><br></div><div>That would work well with concepts=
but here we are talking about a whole new language feature...</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--089e0153844a7bceca04e26157a4--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 26 Jul 2013 11:29:45 +0200
Raw View
--089e0160b7beb01cd504e266c98d
Content-Type: text/plain; charset=ISO-8859-1
2013/7/26 Alex B <devalexb@gmail.com>
>
> To obtain exactly what you are looking for would require something
> additional, like being able to chain packs:
>
> template <class...[3] T, int N>
> void f(T... ...[N] t); // First ... is for repeating 3 times, second ...
> is for repeating the sequence of 3 any N number of times
>
> But this last approach would not work well with concepts; all 3 T (that is
> T, U and V in the original example) would required to be the same concept.
>
I like this idea.
Why would this not work well with concepts? You can quite simply get the
three elements of the T pack separately, something like:
template<typename T,typename,typename> using first = T;
template<typename,typename T,typename> using second = T;
template<typename...[3] T, unsigned int N>
require something<first<T>>() && something_else<second<T>>()
void f(T... ...[N] t);
(Or of course something more generic like pack_element<0, T...>.)
Inside f, t could be a pack such that inside f(1,2,3,4,5,6), t... gives
'1,2,3,4,5,6'. However, I think it'd make more sense, and is a lot more
flexible, if it would be a pack of packs, such that t... gives three packs
of N types, such that t... ... gives '1,2,3,4,5,6'. Although two ellipsis
right after each other look a bit weird, it allows something like:
template<typename T, typename... U>
T && first_value(T && t, U && ...) { return std::forward<T>(t); }
first_value(t...)... // In f(1,0,0,2,0,0,3,0,0,4,0,0), this will be: 1,2,3,4
I came across quite some situations in which this would be very handy.
However, this only solves the problem for the pattern f(T,U,V,T,U,V,...),
but not for f(int,char,int,char,...). Four options I can think of now to
allow that are:
1. The last option Alex showed:
template <class T, class U, class V, int N>
void f(<T t, U u, V v>...[N]);
This would allow:
template<size_t N>
void f(<int a, char b>...[N]);
2. A way to make your own packs, combined with pack chaining. Something
like:
using... MyPack = <int, char>; // Not this exact syntax, but you get the
point.
template<size_t N>
void f(MyPack... ...[N] x);
3. Option 2, but with a way to create packs 'inline' (without having to
give them a name), which makes it look llike option 1:
template<size_t N>
void f(<int, char>... ...[N] t); // Not this exact syntax, but you get the
point.
4. Option 2, but writing the expansion of 'MyPack...' written out
explicitly (if that'd be possible):
template<size_t N>
void f((int, char) ...[N] x);
// Note: Allowing this would probably also mean allowing this:
void f((int, char) x); // Such that 'x' is a pack of two.
--
---
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/.
--089e0160b7beb01cd504e266c98d
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><br><div class=3D"gmail_quote">2013/7/26 Alex B <span dir=3D"ltr"><<=
a href=3D"mailto:devalexb@gmail.com" target=3D"_blank">devalexb@gmail.com</=
a>></span><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><br><div>To obtain exactly what you are looking for would =
require something additional, like being able to chain packs:</div>
<div><br></div><div><span style=3D"font-family:'courier new',monosp=
ace">=A0</span><span style=3D"font-family:'courier new',monospace">=
=A0</span><font face=3D"courier new, monospace">template <class...[3] T,=
int N></font></div>
<div><font face=3D"courier new, monospace">=A0 void f(T... ...[N] t); // Fi=
rst ... is for repeating 3 times, second ... is for repeating the sequence =
of 3 any N number of times</font><br></div><div><br></div><div>But this las=
t approach would not work well with concepts; all 3 T (that is T, U and V i=
n the original example) would required to be the same concept.</div>
</div></blockquote><div><br>I like this idea.<br><br>Why would this not wor=
k well with concepts? You can quite simply get the three elements of the T =
pack separately, something like:<br><br><font face=3D"courier new,monospace=
">template<typename T,typename,typename> using first =3D T;</font><br=
>
<font face=3D"courier new,monospace"><font face=3D"courier new,monospace">t=
emplate<typename,typename T,typename> using second =3D T;<br><br></fo=
nt>template<typename...[3] T, unsigned int N><br>require something<=
;first<T>>() && something_else<second<T>>()<br=
>
void f(T... ...[N] t);<br></font><br>(Or of course something more generic l=
ike pack_element<0, T...>.)<br><br>Inside f, t could be a pack such t=
hat inside f(1,2,3,4,5,6), t... gives '1,2,3,4,5,6'. However, I thi=
nk it'd make more sense, and is a lot more flexible, if it would be a p=
ack of packs, such that t... gives three packs of N types, such that t... .=
... gives '1,2,3,4,5,6'. Although two ellipsis right after each othe=
r look a bit weird, it allows something like:<br>
<br><span style=3D"font-family:courier new,monospace">template<typename =
T, typename... U><br>T && first_value(T && t, U &&am=
p; ...) { return std::forward<T>(t); }<br><br>first_value(t...)... //=
In f(1,0,0,2,0,0,3,0,0,4,0,0), this will be: 1,2,3,4</span><br>
<br>I came across quite some situations in which this would be very handy.<=
br><br>However, this only solves the problem for the pattern f(T,U,V,T,U,V,=
....), but not for f(int,char,int,char,...). Four options I can think of now=
to allow that are:<br>
<br>1. The last option Alex showed:<br><br><span style=3D"font-family:'=
courier new',monospace"></span><font face=3D"courier new, monospace">te=
mplate <</font><span style=3D"font-family:'courier new',monospac=
e">class T, class U, class V,=A0</span><span style=3D"font-family:'cour=
ier new',monospace">int N></span><br>
<font face=3D"courier new, monospace"> void f(<T t, U u, V v>...[N]);=
</font><br><br>This would allow:<br><br><span style=3D"font-family:courier =
new,monospace">template<size_t N><br>void f(<int a, char b>...[=
N]);</span><br>
<br>2. A way to make your own packs, combined with pack chaining. Something=
like:<br><br><span style=3D"font-family:courier new,monospace">using... My=
Pack =3D <int, char>; // Not this exact syntax, but you get the point=
..<br>
<br>template<size_t N><br>void f(MyPack... ...[N] x);</span><br><br>3=
.. Option 2, but with a way to create packs 'inline' (without having=
to give them a name), which makes it look llike option 1:<br><span style=
=3D"font-family:courier new,monospace"><br>
template<size_t N><br>void f(<int, char>... ...[N] t);</span><s=
pan style=3D"font-family:courier new,monospace"> // Not this exact syntax, =
but you get the point.<br><br><span style=3D"font-family:arial,helvetica,sa=
ns-serif">4. Option 2, but writing the expansion of 'MyPack...' wri=
tten out explicitly (if that'd be possible):</span><br>
<br>template<size_t N><br>void f((int, char) ...[N] x);<br><br>// Not=
e: Allowing this would probably also mean allowing this:</span><span style=
=3D"font-family:courier new,monospace"><br>void f((int, char) x); // Such t=
hat 'x' is a pack of two.</span><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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--089e0160b7beb01cd504e266c98d--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 26 Jul 2013 11:55:53 +0200
Raw View
--001a11c3663e2a051c04e2672758
Content-Type: text/plain; charset=ISO-8859-1
>
> 4. Option 2, but writing the expansion of 'MyPack...' written out
> explicitly (if that'd be possible):
>
> template<size_t N>
> void f((int, char) ...[N] x);
>
> // Note: Allowing this would probably also mean allowing this:
> void f((int, char) x); // Such that 'x' is a pack of two.
>
I just realized that this would give me a rather clean way to implement a
function I made last week. Here's what's the function is supposed to do,
and how it'd look like using chained parameter packs with option 4:
https://gist.github.com/m-ou-se/6087660
(With C++11, It takes (relatively) quite a lot of code to implement
something like this.)
--
---
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/.
--001a11c3663e2a051c04e2672758
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=3D=
"gmail_quote"><div><span style=3D"font-family:courier new,monospace"><br><s=
pan style=3D"font-family:arial,helvetica,sans-serif">4. Option 2, but writi=
ng the expansion of 'MyPack...' written out explicitly (if that'=
;d be possible):</span><br>
<br>template<size_t N><br>void f((int, char) ...[N] x);<br><br>// Not=
e: Allowing this would probably also mean allowing this:</span><span style=
=3D"font-family:courier new,monospace"><br>void f((int, char) x); // Such t=
hat 'x' is a pack of two.</span><br>
</div></div>
</blockquote></div><br><br>I just realized that this would give me a rather=
clean way to implement a function I made last week. Here's what's =
the function is supposed to do, and how it'd look like using chained pa=
rameter packs with option 4: <a href=3D"https://gist.github.com/m-ou-se/608=
7660">https://gist.github.com/m-ou-se/6087660</a><br>
(With C++11, It takes (relatively) quite a lot of code to implement somethi=
ng like this.)<br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c3663e2a051c04e2672758--
.
Author: Alex B <devalexb@gmail.com>
Date: Fri, 26 Jul 2013 09:26:46 -0400
Raw View
--001a11c37b0a2610fc04e26a18b8
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
>
> Why would this not work well with concepts? You can quite simply get the
> three elements of the T pack separately, something like:
Ah, indeed :)
> 4. Option 2, but writing the expansion of 'MyPack...' written out
>> explicitly (if that'd be possible):
>> =E0
>> template<size_t N>
>> void f((int, char) ...[N] x);
>>
>> // Note: Allowing this would probably also mean allowing this:
>> void f((int, char) x); // Such that 'x' is a pack of two.
>>
>
>
With option 4, how do you access the int elements in x?
I like the idea of being able to make "pack aliases" (option 2). It could
also be combined with option 3 (defining "inline packs").
In addition to solving Ville's problem, it allows simplifying a lot of use
cases as well. For example, that would allow something like this:
template <class T, T... I>
struct integer_sequence
{
using... pack =3D <I...>;
// .....
}
template <class T>
struct _tuple_elements_pack_impl;
template <class... T>
struct _tuple_elements_pack_impl<tuple<T...>>
{
using... pack =3D <T...>;
};
// also specialize for cv qualified tuple
// also specialize for std::pair and std::array
template <class T>
using tuple_elements_pack =3D <_tuple_elements_pack_impl<T>::pack...>;
template <class T>
using tuple_indices_pack =3D <make_index_sequence<tuple_size<T>>::pack...>;
How does it helps? Just imagine a function f taking a tuple of integers (of
any types) as a parameter and it needs to forward its elements to a
function g. It now becomes really simple:
template <Tuple T>
requires Integer<tuple_elements_pack<remove_reference_t<T>>>()...
auto f(T&& t)
{
return
g(get<tuple_indices_pack<remove_reference_t<T>>>(forward<T>(t)...);
}
// (assume a Tuple concept verifying if std::tuple, std::pair or std::array=
)
With current C++14 (+ concepts), to perform this rather (conceptually)
simple task, there is a lot more code involved.
--=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/.
--001a11c37b0a2610fc04e26a18b8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex">Why would this not work well with concept=
s? You can quite simply get the three elements of the T pack separately, so=
mething like:</blockquote>
<br><div class=3D"gmail_extra"><div class=3D"gmail_quote">Ah, indeed :)</di=
v><div class=3D"gmail_quote"><br><div>=A0</div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-c=
olor:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=3D"im"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-col=
or:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=3D=
"gmail_quote">
<div><span style=3D"font-family:'courier new',monospace"><span styl=
e=3D"font-family:arial,helvetica,sans-serif">4. Option 2, but writing the e=
xpansion of 'MyPack...' written out explicitly (if that'd be po=
ssible):</span><br>
=E0<br>template<size_t N><br>void f((int, char) ...[N] x);<br><br>// =
Note: Allowing this would probably also mean allowing this:</span><span sty=
le=3D"font-family:'courier new',monospace"><br>void f((int, char) x=
); // Such that 'x' is a pack of two.</span><br>
</div></div>
</blockquote></div><br></div></blockquote><div><br></div><div>With option 4=
, how do you access the int elements in x?</div><div><br></div><div>I like =
the idea of being able to make "pack aliases" (option 2). It coul=
d also be combined with option 3 (defining "inline packs").</div>
<div><br></div><div>In addition to solving Ville's problem, it allows s=
implifying a lot of use cases as well. For example, that would allow someth=
ing like this:</div><div><br></div><div><font face=3D"courier new, monospac=
e">template <class T, T... I></font></div>
<div><font face=3D"courier new, monospace">struct integer_sequence</font></=
div><div><font face=3D"courier new, monospace">{</font></div><div><font fac=
e=3D"courier new, monospace">=A0 =A0 using... pack =3D <I...>;</font>=
</div><div>
<font face=3D"courier new, monospace">=A0 =A0 // .....</font></div><div><fo=
nt face=3D"courier new, monospace">}</font></div><div><font face=3D"courier=
new, monospace"><br></font></div><div><font face=3D"courier new, monospace=
">template <class T></font></div>
<div><font face=3D"courier new, monospace">struct _tuple_elements_pack_impl=
;</font></div><div><font face=3D"courier new, monospace"><br></font></div><=
div><div><font face=3D"courier new, monospace">template <class... T><=
/font></div>
<div><font face=3D"courier new, monospace">struct _tuple_elements_pack_impl=
<tuple<T...>></font></div></div><div><font face=3D"courier new,=
monospace">{</font></div><div><font face=3D"courier new, monospace">=A0 =
=A0 using... pack =3D <T...>;</font></div>
<div><font face=3D"courier new, monospace">};</font></div><div><font face=
=3D"courier new, monospace"><br></font></div><div><font face=3D"courier new=
, monospace">// also specialize for cv qualified tuple</font></div><div><fo=
nt face=3D"courier new, monospace">// also specialize for std::pair and std=
::array</font></div>
<div><font face=3D"courier new, monospace"><br></font></div><div><font face=
=3D"courier new, monospace">template <class T></font></div><div><font=
face=3D"courier new, monospace">using tuple_elements_pack =3D <_tuple_e=
lements_pack_impl<T>::pack...>;</font></div>
<div><font face=3D"courier new, monospace"><br></font></div><div><font face=
=3D"courier new, monospace">template <class T></font></div><div><font=
face=3D"courier new, monospace">using tuple_indices_pack =3D <make_inde=
x_sequence<tuple_size<T>>::pack...>;</font></div>
<div><br></div><div><br></div><div>How does it helps? Just imagine a functi=
on f taking a tuple of integers (of any types) as a parameter and it needs =
to forward its elements to a function g. It now becomes really simple:</div=
>
<div><br></div><div><font face=3D"courier new, monospace">template <Tupl=
e T></font></div><div><font face=3D"courier new, monospace">=A0 =A0 requ=
ires Integer<tuple_elements_pack<remove_reference_t<T>>>(=
)...</font></div>
<div><font face=3D"courier new, monospace">auto f(T&& t)</font></di=
v><div><font face=3D"courier new, monospace">{</font></div><div><font face=
=3D"courier new, monospace">=A0 =A0 return g(get<tuple_indices_pack<r=
emove_reference_t<T>>>(forward<T>(t)...);</font></div>
<div><font face=3D"courier new, monospace">}</font></div><div><font face=3D=
"courier new, monospace"><br></font></div><div><span style=3D"font-family:&=
#39;courier new',monospace">// (assume a Tuple concept verifying if std=
::tuple, std::pair or std::array)</span><font face=3D"courier new, monospac=
e"><br>
</font></div><div><br></div><div><br></div><div>With current C++14 (+ conce=
pts), to perform this rather (conceptually) simple task, there is a lot mor=
e code involved.</div></div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c37b0a2610fc04e26a18b8--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Fri, 26 Jul 2013 15:40:30 +0200
Raw View
--001a11c37cac7d429e04e26a4a22
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
>
>
>> 4. Option 2, but writing the expansion of 'MyPack...' written out
>>> explicitly (if that'd be possible):
>>> =E0
>>> template<size_t N>
>>> void f((int, char) ...[N] x);
>>>
>>> // Note: Allowing this would probably also mean allowing this:
>>> void f((int, char) x); // Such that 'x' is a pack of two.
>>>
>>
>>
> With option 4, how do you access the int elements in x?
>
Just like with the other options:
With f((int, char) x), x would be a pack of two, such that x... gives
"a,b", with a and b the integer and char, respectively.
With template<size_t N> void f((int, char) ...[N] x), x would be a pack of
packs, such that first_value(x...)... gives you the ints. (x... would give
you: some_pack_of_ints, some_pack_of_chars).
>
> I like the idea of being able to make "pack aliases" (option 2). It could
> also be combined with option 3 (defining "inline packs").
>
> In addition to solving Ville's problem, it allows simplifying a lot of us=
e
> cases as well. For example, that would allow something like this:
>
> --
>
Yeah, a way to pass packs around more easily could allow for a lot of
simplifications. However, that would be a separate proposal on its own.
(Even though 'fixed size parameter packs' would certainly benefit from it.)
(I'd love to be able to write this:
template<typename Head, typename...> using head =3D Head;
template<typename, typename... Tail> using... tail =3D Tail; )
--=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/.
--001a11c37cac7d429e04e26a4a22
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div class=
=3D"im"><br><div>
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-styl=
e:solid;padding-left:1ex">
<div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,20=
4,204);border-left-style:solid;padding-left:1ex"><div class=3D"gmail_quote"=
>
<div><span style=3D"font-family:'courier new',monospace"><span styl=
e=3D"font-family:arial,helvetica,sans-serif">4. Option 2, but writing the e=
xpansion of 'MyPack...' written out explicitly (if that'd be po=
ssible):</span><br>
=E0<br>template<size_t N><br>void f((int, char) ...[N] x);<br><br>// =
Note: Allowing this would probably also mean allowing this:</span><span sty=
le=3D"font-family:'courier new',monospace"><br>void f((int, char) x=
); // Such that 'x' is a pack of two.</span><br>
</div></div>
</blockquote></div><br></div></blockquote><div><br></div></div><div>With op=
tion 4, how do you access the int elements in x?</div></div></div></div></b=
lockquote><div><br>Just like with the other options:<br>With <span style=3D=
"font-family:courier new,monospace">f((int, char) x)</span>, x would be a p=
ack of two, such that x... gives "a,b", with a and b the integer =
and char, respectively.<br>
<span style=3D"font-family:'courier new',monospace"><br><span style=
=3D"font-family:arial,helvetica,sans-serif">With </span>template<size_t =
N> void f((int, char) ...[N] x)<span style=3D"font-family:arial,helvetic=
a,sans-serif">, x would be a pack of packs, such that first_value(x...)... =
gives you the ints. (x... would give you: some_pack_of_ints, some_pack_of_c=
hars)</span>.<br>
</span>=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div cl=
ass=3D"gmail_extra"><div class=3D"h5"><div><br></div><div>I like the idea o=
f being able to make "pack aliases" (option 2). It could also be =
combined with option 3 (defining "inline packs").</div>
<div><br></div><div>In addition to solving Ville's problem, it allows s=
implifying a lot of use cases as well. For example, that would allow someth=
ing like this:</div><div><br></div>--</div></div></div></blockquote><div>
<br>Yeah, a way to pass packs around more easily could allow for a lot of s=
implifications. However, that would be a separate proposal on its own. (Eve=
n though 'fixed size parameter packs' would certainly benefit from =
it.)<br>
<br>(I'd love to be able to write this:<br>=A0=A0=A0 template<typena=
me Head, typename...> using head =3D Head;<br>=A0=A0=A0 template<type=
name, typename... Tail> using... tail =3D Tail; )<br></div></div><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c37cac7d429e04e26a4a22--
.
Author: Alex B <devalexb@gmail.com>
Date: Fri, 26 Jul 2013 10:04:32 -0400
Raw View
--001a11c37b0a3999ca04e26a9f6a
Content-Type: text/plain; charset=ISO-8859-1
>
> Just like with the other options:
> With f((int, char) x), x would be a pack of two, such that x... gives
> "a,b", with a and b the integer and char, respectively.
>
> With template<size_t N> void f((int, char) ...[N] x), x would be a pack
> of packs, such that first_value(x...)... gives you the ints. (x... would
> give you: some_pack_of_ints, some_pack_of_chars).
>
>
I see. Thanks for the explanation.
>
> Yeah, a way to pass packs around more easily could allow for a lot of
> simplifications. However, that would be a separate proposal on its own.
> (Even though 'fixed size parameter packs' would certainly benefit from it.)
>
>
In fact there could be 3 distinct proposals:
1- Fixed size parameter packs (everything in your original post)
2- Pack aliases
3- Chaining packs, or "packs of packs" (this one would build on features of
the two previous proposals)
(I'd love to be able to write this:
> template<typename Head, typename...> using head = Head;
> template<typename, typename... Tail> using... tail = Tail; )
>
Note that the head alias is already possible, but it is a bit useless until
we can define the tail one.
--
---
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/.
--001a11c37b0a3999ca04e26a9f6a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div class=3D"gmail_quote">Just like with the ot=
her options:<br>
<div>With <span style=3D"font-family:courier new,monospace">f((int, char) x=
)</span>, x would be a pack of two, such that x... gives "a,b", w=
ith a and b the integer and char, respectively.<br>
<span style=3D"font-family:'courier new',monospace"><br><span style=
=3D"font-family:arial,helvetica,sans-serif">With </span>template<size_t =
N> void f((int, char) ...[N] x)<span style=3D"font-family:arial,helvetic=
a,sans-serif">, x would be a pack of packs, such that first_value(x...)... =
gives you the ints. (x... would give you: some_pack_of_ints, some_pack_of_c=
hars)</span>.<br>
</span>=A0</div></div></blockquote><div><br></div><div>I see. Thanks for th=
e explanation.</div><div>=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div cla=
ss=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra">=
<div class=3D"im"></div></div></div></blockquote><div>
<br>Yeah, a way to pass packs around more easily could allow for a lot of s=
implifications. However, that would be a separate proposal on its own. (Eve=
n though 'fixed size parameter packs' would certainly benefit from =
it.)<br>
<br></div></div></blockquote><div><br></div><div>In fact there could be 3 d=
istinct proposals:</div><div>1- Fixed size parameter packs (everything in y=
our original post)</div><div>2- Pack aliases</div><div>3- Chaining packs, o=
r "packs of packs" (this one would build on features of the two p=
revious proposals)</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div class=3D"gmail_quote"><d=
iv>(I'd love to be able to write this:<br>=A0=A0=A0 template<typenam=
e Head, typename...> using head =3D Head;<br>
=A0=A0=A0 template<typename, typename... Tail> using... tail =3D Tail=
; )</div></div></blockquote><div><br></div><div>Note that the head alias is=
already possible, but it is a bit useless until we can define the tail one=
..</div>
</div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c37b0a3999ca04e26a9f6a--
.
Author: Alex B <devalexb@gmail.com>
Date: Mon, 29 Jul 2013 11:03:29 -0400
Raw View
--001a11c37b0a8e1bdc04e2a7cbf2
Content-Type: text/plain; charset=ISO-8859-1
As a side note, I just found a new use case that would be allowed by your
proposal in your original post: it would allow a single definition of a
function currently overloaded to support an optional parameter.
Example of a single definition for std::accumulate (for which there are
currently 2 versions to support an optional custom callable object):
template <Input_iterator I, class T, size_t N, Binary_operation Op =
plus<T>>
requires N <= 1
T accumulate(I first, I last, T init, Op...[N] op)
{
Op _op{move(op)...};
for (; first != last; ++first)
init = _op(init, *first);
return init;
}
There could even be a concept for this kind of optional parameter:
template <size_t N>
concept bool Optional_arg_count()
{
return N <= 1;
}
template <Input_iterator I, class T, Optional_arg_count N, Binary_operation
Op = plus<T>>
T accumulate(I first, I last, T init, Op...[N] op)
{
//...
}
On Fri, Jul 26, 2013 at 10:04 AM, Alex B <devalexb@gmail.com> wrote:
> Just like with the other options:
>> With f((int, char) x), x would be a pack of two, such that x... gives
>> "a,b", with a and b the integer and char, respectively.
>>
>> With template<size_t N> void f((int, char) ...[N] x), x would be a pack
>> of packs, such that first_value(x...)... gives you the ints. (x... would
>> give you: some_pack_of_ints, some_pack_of_chars).
>>
>>
>
> I see. Thanks for the explanation.
>
>
>>
>> Yeah, a way to pass packs around more easily could allow for a lot of
>> simplifications. However, that would be a separate proposal on its own.
>> (Even though 'fixed size parameter packs' would certainly benefit from it.)
>>
>>
> In fact there could be 3 distinct proposals:
> 1- Fixed size parameter packs (everything in your original post)
> 2- Pack aliases
> 3- Chaining packs, or "packs of packs" (this one would build on features
> of the two previous proposals)
>
> (I'd love to be able to write this:
>> template<typename Head, typename...> using head = Head;
>> template<typename, typename... Tail> using... tail = Tail; )
>>
>
> Note that the head alias is already possible, but it is a bit useless
> until we can define the tail one.
>
--
---
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/.
--001a11c37b0a8e1bdc04e2a7cbf2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>As a side note, I just found a new use case that woul=
d be allowed by your proposal in your original post: it would allow a singl=
e definition of a function currently overloaded to support an optional para=
meter.<br>
</div><div><br></div><div>Example of a single definition for std::accumulat=
e (for which there are currently 2 versions to support an optional custom c=
allable object):</div><div><br></div><div><div><font face=3D"courier new, m=
onospace">template <Input_iterator I, class T, size_t N, Binary_operatio=
n Op =3D plus<T>></font></div>
<div><font face=3D"courier new, monospace">=A0 =A0 requires N <=3D 1</fo=
nt></div><div><font face=3D"courier new, monospace">T accumulate(I first, I=
last, T init, Op...[N] op)</font></div><div><font face=3D"courier new, mon=
ospace">{</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0 Op _op{move(op)...};</fo=
nt></div><div><font face=3D"courier new, monospace">=A0 =A0 for (; first !=
=3D last; ++first)</font></div><div><font face=3D"courier new, monospace">=
=A0 =A0 =A0 =A0 init =3D _op(init, *first);</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0 return init;</font></div=
><div><font face=3D"courier new, monospace">}</font></div></div><div><font =
face=3D"courier new, monospace"><br></font></div><div><font face=3D"courier=
new, monospace"><br>
</font></div>There could even be a concept for this kind of optional parame=
ter:<div><font face=3D"courier new, monospace"><br></font></div><div><font =
face=3D"courier new, monospace">template <size_t N></font></div><div>
<font face=3D"courier new, monospace">concept bool Optional_arg_count()</fo=
nt></div><div><font face=3D"courier new, monospace">{</font></div><div><fon=
t face=3D"courier new, monospace">=A0 =A0 return N <=3D 1;</font></div><=
div><font face=3D"courier new, monospace">}</font></div>
<div><font face=3D"courier new, monospace"><br></font></div><div><div><font=
face=3D"courier new, monospace">template <Input_iterator I, class T,=A0=
</font><span style=3D"font-family:'courier new',monospace">Optional=
_arg_count</span><font face=3D"courier new, monospace">=A0N, Binary_operati=
on Op =3D plus<T>></font></div>
<div><font face=3D"courier new, monospace">T accumulate(I first, I last, T =
init, Op...[N] op)</font></div></div><div><font face=3D"courier new, monosp=
ace">{</font></div><div><font face=3D"courier new, monospace">=A0 =A0 //...=
</font></div>
<div><font face=3D"courier new, monospace">}</font></div></div><div class=
=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Fri, Jul 26, 2013 at=
10:04 AM, Alex B <span dir=3D"ltr"><<a href=3D"mailto:devalexb@gmail.co=
m" target=3D"_blank">devalexb@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra">=
<div class=3D"gmail_quote"><div class=3D"im"><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
>
<div class=3D"gmail_quote">Just like with the other options:<br>
<div>With <span style=3D"font-family:courier new,monospace">f((int, char) x=
)</span>, x would be a pack of two, such that x... gives "a,b", w=
ith a and b the integer and char, respectively.<br>
<span style=3D"font-family:'courier new',monospace"><br><span style=
=3D"font-family:arial,helvetica,sans-serif">With </span>template<size_t =
N> void f((int, char) ...[N] x)<span style=3D"font-family:arial,helvetic=
a,sans-serif">, x would be a pack of packs, such that first_value(x...)... =
gives you the ints. (x... would give you: some_pack_of_ints, some_pack_of_c=
hars)</span>.<br>
</span>=A0</div></div></blockquote><div><br></div></div><div>I see. Thanks =
for the explanation.</div><div class=3D"im"><div>=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
<div class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra">=
<div></div></div></div></blockquote><div>
<br>Yeah, a way to pass packs around more easily could allow for a lot of s=
implifications. However, that would be a separate proposal on its own. (Eve=
n though 'fixed size parameter packs' would certainly benefit from =
it.)<br>
<br></div></div></blockquote><div><br></div></div><div>In fact there could =
be 3 distinct proposals:</div><div>1- Fixed size parameter packs (everythin=
g in your original post)</div><div>2- Pack aliases</div><div>3- Chaining pa=
cks, or "packs of packs" (this one would build on features of the=
two previous proposals)</div>
<div class=3D"im">
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div class=3D"gmail_quote"><d=
iv>(I'd love to be able to write this:<br>=A0=A0=A0 template<typenam=
e Head, typename...> using head =3D Head;<br>
=A0=A0=A0 template<typename, typename... Tail> using... tail =3D Tail=
; )</div></div></blockquote><div><br></div></div><div>Note that the head al=
ias is already possible, but it is a bit useless until we can define the ta=
il one.</div>
</div></div></div>
</blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c37b0a8e1bdc04e2a7cbf2--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 29 Jul 2013 18:14:33 +0300
Raw View
--047d7bdc9396219d7104e2a7f35e
Content-Type: text/plain; charset=ISO-8859-1
On 29 July 2013 18:03, Alex B <devalexb@gmail.com> wrote:
> As a side note, I just found a new use case that would be allowed by your
> proposal in your original post: it would allow a single definition of a
> function currently overloaded to support an optional parameter.
>
> Example of a single definition for std::accumulate (for which there are
> currently 2 versions to support an optional custom callable object):
>
> template <Input_iterator I, class T, size_t N, Binary_operation Op =
> plus<T>>
> requires N <= 1
> T accumulate(I first, I last, T init, Op...[N] op)
> {
> Op _op{move(op)...};
> for (; first != last; ++first)
> init = _op(init, *first);
> return init;
> }
>
>
>
>
Interesting, but if Op is a pack, you can't just take the first type in the
pack as in
Op _op{move(op)...};, so this needs another language change.
Also, if the pack happens to be empty, there is no first type to deal with.
I assume that piece of code is meant to either direct-initialize an object
from another,
or value-initialize it if the incoming pack is empty, but then we end up
not knowing
what we're initializing, unless it's not deduced.
I'm slightly confused what the exact semantics here would be.
--
---
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/.
--047d7bdc9396219d7104e2a7f35e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 29 July 2013 18:03, Alex B <span dir=3D"ltr"><<a href=3D"mail=
to:devalexb@gmail.com" target=3D"_blank">devalexb@gmail.com</a>></span> =
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>As a side note, I just=
found a new use case that would be allowed by your proposal in your origin=
al post: it would allow a single definition of a function currently overloa=
ded to support an optional parameter.<br>
</div><div><br></div><div>Example of a single definition for std::accumulat=
e (for which there are currently 2 versions to support an optional custom c=
allable object):</div><div><br></div><div><div><font face=3D"courier new, m=
onospace">template <Input_iterator I, class T, size_t N, Binary_operatio=
n Op =3D plus<T>></font></div>
<div><font face=3D"courier new, monospace">=A0 =A0 requires N <=3D 1</fo=
nt></div><div><font face=3D"courier new, monospace">T accumulate(I first, I=
last, T init, Op...[N] op)</font></div><div><font face=3D"courier new, mon=
ospace">{</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0 Op _op{move(op)...};</fo=
nt></div><div><font face=3D"courier new, monospace">=A0 =A0 for (; first !=
=3D last; ++first)</font></div><div><font face=3D"courier new, monospace">=
=A0 =A0 =A0 =A0 init =3D _op(init, *first);</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0 return init;</font></div=
><div><font face=3D"courier new, monospace">}</font></div></div><div><font =
face=3D"courier new, monospace"><br></font></div><div><font face=3D"courier=
new, monospace"><br>
<br></font></div></div></blockquote><div><br></div><div>Interesting, but if=
Op is a pack, you can't just take the first type in the pack as in<br>=
</div><div>Op _op{move(op)...};, so this needs another language change.<br>
</div><div>Also, if the pack happens to be empty, there is no first type to=
deal with. <br></div></div>I assume that piece of code is meant to either =
direct-initialize an object from another,<br>or value-initialize it if the =
incoming pack is empty, but then we end up not knowing<br>
what we're initializing, unless it's not deduced.<br><br></div><div=
class=3D"gmail_extra">I'm slightly confused what the exact semantics h=
ere would be.<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--047d7bdc9396219d7104e2a7f35e--
.
Author: Alex B <devalexb@gmail.com>
Date: Mon, 29 Jul 2013 11:35:11 -0400
Raw View
--089e01228e5aebf9bf04e2a83c47
Content-Type: text/plain; charset=ISO-8859-1
>
>
> Interesting, but if Op is a pack, you can't just take the first type in
> the pack as in
> Op _op{move(op)...};, so this needs another language change.
>
Op is a pack of size N, which is required to be 0 or 1. So the pack could
only be empty or contains a single element.
If the pack is empty (no optional parameter specified), we get this (with
Op defaulted to plus<T>):
plus<T> _op{}; // default constructor
If the pack contains a single element (optional parameter of type Op used),
we get this:
Op _op{move(op1)}; // move constructor
That covers all the cases; the pack could not contain more elements because
of the requires clause. In both case it is just regular pack expansion so
there is no need for a specific language feature to take the first type in
the pack.
> Also, if the pack happens to be empty, there is no first type to deal
> with.
> I assume that piece of code is meant to either direct-initialize an object
> from another, or value-initialize it if the incoming pack is empty but then
> we end up not knowing
>
what we're initializing, unless it's not deduced. I'm slightly confused
> what the exact semantics here would be.
>
Please tell me if my answer still isn't clarifying.
--
---
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/.
--089e01228e5aebf9bf04e2a83c47
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddi=
ng-left:1ex">
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
class=3D"im"><div><br></div></div><div>Interesting, but if Op is a pack, y=
ou can't just take the first type in the pack as in<br></div><div>Op _o=
p{move(op)...};, so this needs another language change.<br>
</div></div></div></div></blockquote><div><br></div><div>Op is a pack of si=
ze N, which is required to be 0 or 1. So the pack could only be empty or co=
ntains a single element.</div><div><br></div><div>If the pack is empty (no =
optional parameter specified), we get this (with Op defaulted to plus<T&=
gt;):</div>
<div><font face=3D"courier new, monospace">=A0 =A0 plus<T> _op{}; // =
default constructor</font></div><div><br></div><div>If the pack contains a =
single element (optional parameter of type Op used), we get this:</div><div=
><font face=3D"courier new, monospace">=A0 =A0 Op _op{move(op1)}; // move c=
onstructor</font></div>
<div><br></div><div>That covers all the cases; the pack could not contain m=
ore elements because of the requires clause. In both case it is just regula=
r pack expansion so there is no need for a specific language feature to tak=
e the first type in the pack.</div>
<div>=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-=
left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_ext=
ra"><div class=3D"gmail_quote">
<div>
</div><div>Also, if the pack happens to be empty, there is no first type to=
deal with. <br></div></div>I assume that piece of code is meant to either =
direct-initialize an object from another, or value-initialize it if the inc=
oming pack is empty but then we end up not knowing</div>
</div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border=
-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_ex=
tra">
what we're initializing, unless it's not deduced. I'm slightly =
confused what the exact semantics here would be.</div></div></blockquote><d=
iv><br></div><div>Please tell me if my answer still isn't clarifying.</=
div>
</div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--089e01228e5aebf9bf04e2a83c47--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 29 Jul 2013 18:39:40 +0300
Raw View
--047d7bdc9396fd58ac04e2a84c1b
Content-Type: text/plain; charset=ISO-8859-1
On 29 July 2013 18:35, Alex B <devalexb@gmail.com> wrote:
>
>> Interesting, but if Op is a pack, you can't just take the first type in
>> the pack as in
>> Op _op{move(op)...};, so this needs another language change.
>>
>
> Op is a pack of size N, which is required to be 0 or 1. So the pack could
> only be empty or contains a single element.
>
> If the pack is empty (no optional parameter specified), we get this (with
> Op defaulted to plus<T>):
> plus<T> _op{}; // default constructor
>
> If the pack contains a single element (optional parameter of type Op
> used), we get this:
> Op _op{move(op1)}; // move constructor
>
> That covers all the cases; the pack could not contain more elements
> because of the requires clause. In both case it is just regular pack
> expansion so there is no need for a specific language feature to take the
> first type in the pack.
>
Ok, thanks, this makes it clear what's sought after.
The snag with this is that if there's a regular pack that is empty, you
can't say
Op op_;
at all. With a 'bounded' pack where the type is defaulted, you can. That
seems certainly a bit inconsistent
wrt what the syntax means in what context.
--
---
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/.
--047d7bdc9396fd58ac04e2a84c1b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 29 July 2013 18:35, Alex B <span dir=3D"ltr"><<a href=3D"mail=
to:devalexb@gmail.com" target=3D"_blank">devalexb@gmail.com</a>></span> =
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra">=
<div class=3D"gmail_quote"><div class=3D"im"><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-col=
or:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
><div><br></div></div><div>Interesting, but if Op is a pack, you can't =
just take the first type in the pack as in<br></div><div>Op _op{move(op)...=
};, so this needs another language change.<br>
</div></div></div></div></blockquote><div><br></div></div><div>Op is a pack=
of size N, which is required to be 0 or 1. So the pack could only be empty=
or contains a single element.</div><div><br></div><div>If the pack is empt=
y (no optional parameter specified), we get this (with Op defaulted to plus=
<T>):</div>
<div><font face=3D"courier new, monospace">=A0 =A0 plus<T> _op{}; // =
default constructor</font></div><div><br></div><div>If the pack contains a =
single element (optional parameter of type Op used), we get this:</div><div=
>
<font face=3D"courier new, monospace">=A0 =A0 Op _op{move(op1)}; // move co=
nstructor</font></div>
<div><br></div><div>That covers all the cases; the pack could not contain m=
ore elements because of the requires clause. In both case it is just regula=
r pack expansion so there is no need for a specific language feature to tak=
e the first type in the pack.</div>
</div></div></div></blockquote><div><br></div><div>Ok, thanks, this makes i=
t clear what's sought after.<br><br></div><div>The snag with this is th=
at if there's a regular pack that is empty, you can't say<br></div>
<div>Op op_;<br></div><div>at all. With a 'bounded' pack where the =
type is defaulted, you can. That seems certainly a bit inconsistent<br></di=
v><div>wrt what the syntax means in what context.<br><br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--047d7bdc9396fd58ac04e2a84c1b--
.
Author: Maurice Bos <m-ou.se@m-ou.se>
Date: Mon, 29 Jul 2013 17:53:02 +0200
Raw View
--001a11c365a6f2bc8904e2a87d5a
Content-Type: text/plain; charset=ISO-8859-1
> The snag with this is that if there's a regular pack that is empty, you
> can't say
> Op op_;
> at all. With a 'bounded' pack where the type is defaulted, you can. That
> seems certainly a bit inconsistent
> wrt what the syntax means in what context.
>
Note that in 'T...[N] x', T is not a pack, only x is a pack. T is just a
typename:
template<typename T> void x(T...[N] x); // N parameters of the same type,
T. (T is a typename, x is a pack (of size N))
template<typename...[N] T> void x(T... x); // N parameters of any type. (T
is a pack (of size N), x is a pack too (of size N))
--
---
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/.
--001a11c365a6f2bc8904e2a87d5a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div>The snag wit=
h this is that if there's a regular pack that is empty, you can't s=
ay<br>
</div>
<div>Op op_;<br></div><div>at all. With a 'bounded' pack where the =
type is defaulted, you can. That seems certainly a bit inconsistent<br></di=
v><div>wrt what the syntax means in what context.<br></div></div></div>
</div></blockquote><div><br>Note that in 'T...[N] x', T is not a pa=
ck, only x is a pack. T is just a typename:<br><br>template<typename T&g=
t; void x(T...[N] x); // N parameters of the same type, T. (T is a typename=
, x is a pack (of size N))<br>
template<typename...[N] T> void x(T... x); // N parameters of any typ=
e. (T is a pack (of size N), x is a pack too (of size N))<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c365a6f2bc8904e2a87d5a--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 29 Jul 2013 19:01:49 +0300
Raw View
--001a11c339e82e68da04e2a89c72
Content-Type: text/plain; charset=ISO-8859-1
On 29 July 2013 18:53, Maurice Bos <m-ou.se@m-ou.se> wrote:
>
> The snag with this is that if there's a regular pack that is empty, you
>> can't say
>> Op op_;
>> at all. With a 'bounded' pack where the type is defaulted, you can. That
>> seems certainly a bit inconsistent
>> wrt what the syntax means in what context.
>>
>
> Note that in 'T...[N] x', T is not a pack, only x is a pack. T is just a
> typename:
>
> template<typename T> void x(T...[N] x); // N parameters of the same type,
> T. (T is a typename, x is a pack (of size N))
> template<typename...[N] T> void x(T... x); // N parameters of any type. (T
> is a pack (of size N), x is a pack too (of size N))
>
>
>
>
Yeah. Multiple meanings for T... can be confusing, I guess. These are just
off-sleeve observations, I wish
I had a superb syntax to propose, but currently I don't. I'll have some
beer, maybe it'll appear out of thin
air. Maybe it won'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/.
--001a11c339e82e68da04e2a89c72
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 29 July 2013 18:53, Maurice Bos <span dir=3D"ltr"><<a href=3D=
"mailto:m-ou.se@m-ou.se" target=3D"_blank">m-ou.se@m-ou.se</a>></span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><br><div class=3D"gmail_quote"><div class=3D=
"im"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div=
>The snag with this is that if there's a regular pack that is empty, yo=
u can't say<br>
</div>
<div>Op op_;<br></div><div>at all. With a 'bounded' pack where the =
type is defaulted, you can. That seems certainly a bit inconsistent<br></di=
v><div>wrt what the syntax means in what context.<br></div></div></div>
</div></blockquote></div><div><br>Note that in 'T...[N] x', T is no=
t a pack, only x is a pack. T is just a typename:<br><br>template<typena=
me T> void x(T...[N] x); // N parameters of the same type, T. (T is a ty=
pename, x is a pack (of size N))<br>
template<typename...[N] T> void x(T... x); // N parameters of any typ=
e. (T is a pack (of size N), x is a pack too (of size N))<br></div></div><d=
iv class=3D"HOEnZb"><div class=3D"h5">
<p></p>
<br><br></div></div></blockquote><div><br></div><div>Yeah. Multiple meaning=
s for T... can be confusing, I guess. These are just off-sleeve observation=
s, I wish<br></div><div>I had a superb syntax to propose, but currently I d=
on't. I'll have some beer, maybe it'll appear out of thin<br>
air. Maybe it won't. :) <br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c339e82e68da04e2a89c72--
.
Author: Xeo <hivemaster@hotmail.de>
Date: Mon, 29 Jul 2013 09:09:38 -0700 (PDT)
Raw View
------=_Part_1715_7134745.1375114178839
Content-Type: text/plain; charset=ISO-8859-1
On Monday, July 29, 2013 5:03:29 PM UTC+2, Alex B wrote:
>
> Example of a single definition for std::accumulate (for which there are
> currently 2 versions to support an optional custom callable object):
>
> template <Input_iterator I, class T, size_t N, Binary_operation Op =
> plus<T>>
> requires N <= 1
> T accumulate(I first, I last, T init, Op...[N] op)
>
Uhm...
template<class InIt, class T, class BinOp = plus<>>
T accumulate(InIt first, InIt last, T init, BinOp op = BinOp{})
^ valid C++11 code.
{
> Op _op{move(op)...};
> for (; first != last; ++first)
> init = _op(init, *first);
> return init;
> }
>
>
> There could even be a concept for this kind of optional parameter:
>
> template <size_t N>
> concept bool Optional_arg_count()
> {
> return N <= 1;
> }
>
> template <Input_iterator I, class T, Optional_arg_count N,
> Binary_operation Op = plus<T>>
> T accumulate(I first, I last, T init, Op...[N] op)
> {
> //...
> }
>
>
> On Fri, Jul 26, 2013 at 10:04 AM, Alex B <deva...@gmail.com <javascript:>>wrote:
>
>> Just like with the other options:
>>> With f((int, char) x), x would be a pack of two, such that x... gives
>>> "a,b", with a and b the integer and char, respectively.
>>>
>>> With template<size_t N> void f((int, char) ...[N] x), x would be a pack
>>> of packs, such that first_value(x...)... gives you the ints. (x... would
>>> give you: some_pack_of_ints, some_pack_of_chars).
>>>
>>>
>>
>> I see. Thanks for the explanation.
>>
>>
>>>
>>> Yeah, a way to pass packs around more easily could allow for a lot of
>>> simplifications. However, that would be a separate proposal on its own.
>>> (Even though 'fixed size parameter packs' would certainly benefit from it.)
>>>
>>>
>> In fact there could be 3 distinct proposals:
>> 1- Fixed size parameter packs (everything in your original post)
>> 2- Pack aliases
>> 3- Chaining packs, or "packs of packs" (this one would build on features
>> of the two previous proposals)
>>
>> (I'd love to be able to write this:
>>> template<typename Head, typename...> using head = Head;
>>> template<typename, typename... Tail> using... tail = Tail; )
>>>
>>
>> Note that the head alias is already possible, but it is a bit useless
>> until we can define the tail one.
>>
>
>
--
---
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_1715_7134745.1375114178839
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Monday, July 29, 2013 5:03:29 PM UTC+2, Alex B wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Example of a single def=
inition for std::accumulate (for which there are currently 2 versions to su=
pport an optional custom callable object):</div><div><br></div><div><div><f=
ont face=3D"courier new, monospace">template <Input_iterator I, class T,=
size_t N, Binary_operation Op =3D plus<T>></font></div>
<div><font face=3D"courier new, monospace"> requires N <=3D=
1</font></div><div><font face=3D"courier new, monospace">T accumulate(I fi=
rst, I last, T init, Op...[N] op)</font></div></div></div></blockquote><div=
><br>Uhm...<br><br><div class=3D"prettyprint" style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
lass</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">InIt</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">BinOp</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> plus</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><>></span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>T accumulate</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">InIt</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> first</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">InIt</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
last</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> T init</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #606;" class=3D"styled-by-prettify">BinOp</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> op </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">BinOp</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{})</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span></div></code></div><br>^ valid C++11 code.<br><br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div><font face=
=3D"courier new, monospace">{</font></div>
<div><font face=3D"courier new, monospace"> Op _op{move(op)...=
};</font></div><div><font face=3D"courier new, monospace"> for=
(; first !=3D last; ++first)</font></div><div><font face=3D"courier new, m=
onospace"> init =3D _op(init, *first);</font></d=
iv>
<div><font face=3D"courier new, monospace"> return init;</font=
></div><div><font face=3D"courier new, monospace">}</font></div></div><div>=
<font face=3D"courier new, monospace"><br></font></div><div><font face=3D"c=
ourier new, monospace"><br>
</font></div>There could even be a concept for this kind of optional parame=
ter:<div><font face=3D"courier new, monospace"><br></font></div><div><font =
face=3D"courier new, monospace">template <size_t N></font></div><div>
<font face=3D"courier new, monospace">concept bool Optional_arg_count()</fo=
nt></div><div><font face=3D"courier new, monospace">{</font></div><div><fon=
t face=3D"courier new, monospace"> return N <=3D 1;</font><=
/div><div><font face=3D"courier new, monospace">}</font></div>
<div><font face=3D"courier new, monospace"><br></font></div><div><div><font=
face=3D"courier new, monospace">template <Input_iterator I, class T,&nb=
sp;</font><span style=3D"font-family:'courier new',monospace">Optional_arg_=
count</span><font face=3D"courier new, monospace"> N, Binary_operation=
Op =3D plus<T>></font></div>
<div><font face=3D"courier new, monospace">T accumulate(I first, I last, T =
init, Op...[N] op)</font></div></div><div><font face=3D"courier new, monosp=
ace">{</font></div><div><font face=3D"courier new, monospace"> =
//...</font></div>
<div><font face=3D"courier new, monospace">}</font></div></div><div><br><br=
><div class=3D"gmail_quote">On Fri, Jul 26, 2013 at 10:04 AM, Alex B <span =
dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-ma=
ilto=3D"AMz-sS0hSS4J">deva...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_qu=
ote"><div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
er-left:1px #ccc solid;padding-left:1ex">
<div class=3D"gmail_quote">Just like with the other options:<br>
<div>With <span style=3D"font-family:courier new,monospace">f((int, char) x=
)</span>, x would be a pack of two, such that x... gives "a,b", with a and =
b the integer and char, respectively.<br>
<span style=3D"font-family:'courier new',monospace"><br><span style=3D"font=
-family:arial,helvetica,sans-serif">With </span>template<size_t N> vo=
id f((int, char) ...[N] x)<span style=3D"font-family:arial,helvetica,sans-s=
erif">, x would be a pack of packs, such that first_value(x...)... gives yo=
u the ints. (x... would give you: some_pack_of_ints, some_pack_of_chars)</s=
pan>.<br>
</span> </div></div></blockquote><div><br></div></div><div>I see. Than=
ks for the explanation.</div><div><div> </div><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">
<div class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div></div></div></div=
></blockquote><div>
<br>Yeah, a way to pass packs around more easily could allow for a lot of s=
implifications. However, that would be a separate proposal on its own. (Eve=
n though 'fixed size parameter packs' would certainly benefit from it.)<br>
<br></div></div></blockquote><div><br></div></div><div>In fact there could =
be 3 distinct proposals:</div><div>1- Fixed size parameter packs (everythin=
g in your original post)</div><div>2- Pack aliases</div><div>3- Chaining pa=
cks, or "packs of packs" (this one would build on features of the two previ=
ous proposals)</div>
<div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div class=3D"gmail_quote"><d=
iv>(I'd love to be able to write this:<br> template<ty=
pename Head, typename...> using head =3D Head;<br>
template<typename, typename... Tail> using... tail=
=3D Tail; )</div></div></blockquote><div><br></div></div><div>Note that th=
e head alias is already possible, but it is a bit useless until we can defi=
ne the tail one.</div>
</div></div></div>
</blockquote></div><br></div>
</blockquote>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_1715_7134745.1375114178839--
.
Author: Alex B <devalexb@gmail.com>
Date: Mon, 29 Jul 2013 14:09:31 -0400
Raw View
--001a11c2650edb856f04e2aa64fd
Content-Type: text/plain; charset=ISO-8859-1
> Yeah. Multiple meanings for T... can be confusing, I guess.
>
In fact, it is by introducing T...[N] that we get two different meanings;
one for T... and one for T...[N].
But T... alone (without [N]) should only have the same meaning as before.
> These are just off-sleeve observations, I wish
> I had a superb syntax to propose, but currently I don't. I'll have some
> beer, maybe it'll appear out of thin
> air. Maybe it won't. :)
>
I'm sure it will :)
--
---
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/.
--001a11c2650edb856f04e2aa64fd
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra">=
<div class=3D"gmail_quote">
<div>Yeah. Multiple meanings for T... can be confusing, I guess.</div></div=
></div></div></blockquote><div><br></div><div>In fact, it is by introducing=
T...[N] that we get two different meanings; one for T... and one for T...[=
N].</div>
<div><br></div><div>But T... alone (without [N]) should only have the same =
meaning as before.</div><div>=A0</div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr">
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><div>These are just o=
ff-sleeve observations, I wish<br></div><div>I had a superb syntax to propo=
se, but currently I don't. I'll have some beer, maybe it'll app=
ear out of thin<br>
air. Maybe it won't. :) <br></div></div></div></div></blockquote></div>=
<br></div><div class=3D"gmail_extra">I'm sure it will :)</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c2650edb856f04e2aa64fd--
.
Author: Alex B <devalexb@gmail.com>
Date: Mon, 29 Jul 2013 14:17:42 -0400
Raw View
--001a11c34da028f24504e2aa82b3
Content-Type: text/plain; charset=ISO-8859-1
> Uhm...
>
> template<class InIt, class T, class BinOp = plus<>>
> T accumulate(InIt first, InIt last, T init, BinOp op = BinOp{})
>
> ^ valid C++11 code.
>
>
Indeed; this is not the best example. Considering std::plus is empty, there
shouldn't be any performance hit when using your version. Still, why is it
defined as two overloads in the standard?
There are other places where the purpose of having overloads instead of a
default argument is more obvious however. Consider vector::resize; the
overload allows to call the default constructor in-place instead of first
having to default construct and then move/construct.
That could be:
template <Optional_arg_count N>
void resize(size_type count, const value_type&...[N] value);
Instead of:
void resize(size_type count);
void resize(size_type count, const value_type& value);
Let me add that I'm not proposing to change anything regarding those
functions in the standard library. My point is only to show what would be
possible to do with what is proposed in the original post.
--
---
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/.
--001a11c34da028f24504e2aa82b3
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex">
<div>Uhm...<br><br><div style=3D"background-color:rgb(250,250,250);border:1=
px solid rgb(187,187,187);word-wrap:break-word">
<code><div><span style=3D"color:rgb(0,0,136)">template</span><span style=3D=
"color:rgb(102,102,0)"><</span><span style=3D"color:rgb(0,0,136)">class<=
/span><span> </span><span style=3D"color:rgb(102,0,102)">InIt</span><span s=
tyle=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"color:rg=
b(0,0,136)">class</span><span> T</span><span style=3D"color:rgb(102,102,0)"=
>,</span><span> </span><span style=3D"color:rgb(0,0,136)">class</span><span=
> </span><span style=3D"color:rgb(102,0,102)">BinOp</span><span> </span><sp=
an style=3D"color:rgb(102,102,0)">=3D</span><span> plus</span><span style=
=3D"color:rgb(102,102,0)"><>></span><span><br>
T accumulate</span><span style=3D"color:rgb(102,102,0)">(</span><span style=
=3D"color:rgb(102,0,102)">InIt</span><span> first</span><span style=3D"colo=
r:rgb(102,102,0)">,</span><span> </span><span style=3D"color:rgb(102,0,102)=
">InIt</span><span> </span><span style=3D"color:rgb(0,0,136)">last</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> T init</span><span style=
=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"color:rgb(10=
2,0,102)">BinOp</span><span> op </span><span style=3D"color:rgb(102,102,0)"=
>=3D</span><span> </span><span style=3D"color:rgb(102,0,102)">BinOp</span><=
span style=3D"color:rgb(102,102,0)">{})</span><span><br>
</span></div></code></div><br>^ valid C++11 code.<br><br></div></blockquote=
><div><br></div><div>Indeed; this is not the best example. Considering std:=
:plus is empty, there shouldn't be any performance hit when using your =
version. Still, why is it defined as two overloads in the standard?</div>
<div><br></div><div>There are other places where the purpose of having over=
loads instead of a default argument is more obvious however. Consider vecto=
r::resize; the overload allows to call the default constructor in-place ins=
tead of first having to default construct and then move/construct.</div>
<div><br></div><div>That could be:</div><div><div><font face=3D"courier new=
, monospace">template <Optional_arg_count N></font></div><div><font f=
ace=3D"courier new, monospace">void resize(size_type count, const value_typ=
e&...[N] value);</font></div>
<div><br></div><div>Instead of:</div><div><font face=3D"courier new, monosp=
ace">void resize(size_type count);</font></div><div><font face=3D"courier n=
ew, monospace">void resize(size_type count, const value_type& value);</=
font></div>
</div><div><br></div><div>Let me add that I'm not proposing to change a=
nything regarding those functions in the standard library. My point is only=
to show what would be possible to do with what is proposed in the original=
post.</div>
</div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
--001a11c34da028f24504e2aa82b3--
.
Author: Xeo <hivemaster@hotmail.de>
Date: Mon, 29 Jul 2013 11:43:30 -0700 (PDT)
Raw View
------=_Part_238_31787232.1375123410009
Content-Type: text/plain; charset=ISO-8859-1
On Monday, July 29, 2013 8:17:42 PM UTC+2, Alex B wrote:
> Still, why is it defined as two overloads in the standard?
>
Because it has been defined that way back in C++98, so no changing it now,
I guess.
> There are other places where the purpose of having overloads instead of a
> default argument is more obvious however. Consider vector::resize; the
> overload allows to call the default constructor in-place instead of first
> having to default construct and then move/construct.
>
> That could be:
> template <Optional_arg_count N>
> void resize(size_type count, const value_type&...[N] value);
>
> Instead of:
> void resize(size_type count);
> void resize(size_type count, const value_type& value);
>
> Let me add that I'm not proposing to change anything regarding those
> functions in the standard library. My point is only to show what would be
> possible to do with what is proposed in the original post.
>
As you said, there's a very good reason why the single overload from C++98
was split in two in C++11.
--
---
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_238_31787232.1375123410009
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Monday, July 29, 2013 8:17:42 PM UTC+2, Alex B wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quo=
te"><div>Still, why is it defined as two overloads in the standard?</div></=
div></div></div></blockquote><div><br>Because it has been defined that way =
back in C++98, so no changing it now, I guess.<br> </div><blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_q=
uote"><div>There are other places where the purpose of having overloads ins=
tead of a default argument is more obvious however. Consider vector::resize=
; the overload allows to call the default constructor in-place instead of f=
irst having to default construct and then move/construct.</div>
<div><br></div><div>That could be:</div><div><div><font face=3D"courier new=
, monospace">template <Optional_arg_count N></font></div><div><font f=
ace=3D"courier new, monospace">void resize(size_type count, const value_typ=
e&...[N] value);</font></div>
<div><br></div><div>Instead of:</div><div><font face=3D"courier new, monosp=
ace">void resize(size_type count);</font></div><div><font face=3D"courier n=
ew, monospace">void resize(size_type count, const value_type& value);</=
font></div>
</div><div><br></div><div>Let me add that I'm not proposing to change anyth=
ing regarding those functions in the standard library. My point is only to =
show what would be possible to do with what is proposed in the original pos=
t.</div></div></div></div></blockquote><div><br>As you said, there's a very=
good reason why the single overload from C++98 was split in two in C++11. =
<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
<br />
<br />
------=_Part_238_31787232.1375123410009--
.