Topic: template<auto>


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Fri, 16 Jan 2015 16:25:35 -0800 (PST)
Raw View
------=_Part_1573_1888826396.1421454335735
Content-Type: multipart/alternative;
 boundary="----=_Part_1574_1401967618.1421454335735"

------=_Part_1574_1401967618.1421454335735
Content-Type: text/plain; charset=UTF-8

We cannot use type deduction for non-type template parameters. Auto would
be useful for removing type dependencies.
Here is one use case for having auto type deduction in template parameters.

template <auto& counter> struct Foo {}

int global_counter = 0;
Foo<global_counter> f;

In this example, we could later change the global_counter to size_t and all
of the things using it would automatically pick up the change.

--

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

<div dir=3D"ltr">We cannot use type deduction for non-type template paramet=
ers. Auto would be useful for removing type dependencies.<div>Here is one u=
se case for having auto type deduction in template parameters.<div><br></di=
v><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">template</span><font color=3D"#666600"><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> counter</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Foo</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></font>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> global_counter </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><font color=3D"#666600"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Foo</span><span style=3D"color: #0=
80;" class=3D"styled-by-prettify">&lt;global_counter&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> f</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span></font></div></code></div><b=
r>In this example, we could later change the global_counter to size_t and a=
ll of the things using it would automatically pick up the change.</div></di=
v></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1574_1401967618.1421454335735--
------=_Part_1573_1888826396.1421454335735--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Fri, 16 Jan 2015 17:10:20 -0800
Raw View
See the thread "auto in template parameter lists".

On Fri, Jan 16, 2015 at 4:25 PM, Matthew Fioravante
<fmatthew5876@gmail.com> wrote:
> We cannot use type deduction for non-type template parameters. Auto would be
> useful for removing type dependencies.
> Here is one use case for having auto type deduction in template parameters.
>
> template <auto& counter> struct Foo {}
>
> int global_counter = 0;
> Foo<global_counter> f;
>
> In this example, we could later change the global_counter to size_t and all
> of the things using it would automatically pick up the change.
>
> --
>
> ---
> 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/.

.