Topic: Templated namespaces


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 26 Jan 2015 02:59:43 -0800 (PST)
Raw View
------=_Part_82_1108890195.1422269983573
Content-Type: multipart/alternative;
 boundary="----=_Part_83_1254418699.1422269983573"

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

Suppose you wanted a number of functions, classes or constants, all=20
templated on one parameter, what about putting them in a namespace and=20
raising the parameter a level?
=20
template <typename T>
namespace foo {
  // various declarations, etc.
}

Consider, for example, the standard header <limits>.  There, due to the=20
lack of a templated namespace, the hack of using a templated class has been=
=20
used (not that I=E2=80=99m suggesting we change the, due to a change in ABI=
).
=20
Doug.

--=20

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

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

<div dir=3D"ltr"><div>Suppose you wanted a number of functions, classes or =
constants, all templated on one parameter, what about putting them in a nam=
espace and raising the parameter a level?</div><div>&nbsp;</div><div style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);" class=3D"prettyprint"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: rgb(0, 0, 136);" cl=
ass=3D"styled-by-prettify">template</span><span style=3D"color: rgb(0, 0, 0=
);" class=3D"styled-by-prettify"> </span><span style=3D"color: rgb(102, 102=
, 0);" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: rgb(0,=
 0, 136);" class=3D"styled-by-prettify">typename</span><span style=3D"color=
: rgb(0, 0, 0);" class=3D"styled-by-prettify"> T</span><span style=3D"color=
: rgb(102, 102, 0);" class=3D"styled-by-prettify">&gt;</span><span style=3D=
"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">namespace</span><s=
pan style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> foo </span=
><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br>&=
nbsp; </span><span style=3D"color: rgb(136, 0, 0);" class=3D"styled-by-pret=
tify">// various declarations, etc.</span><span style=3D"color: rgb(0, 0, 0=
);" class=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(102, =
102, 0);" class=3D"styled-by-prettify">}</span><span style=3D"color: rgb(0,=
 0, 0);" class=3D"styled-by-prettify"><br></span></div></code></div><br><di=
v>Consider, for example, the standard header &lt;limits&gt;.&nbsp; There, d=
ue to the lack of a templated namespace, the hack of using a templated clas=
s has been used (not that I=E2=80=99m suggesting we change the, due to a ch=
ange in ABI).</div><div>&nbsp;</div><div>Doug.</div></div>

<p></p>

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

------=_Part_83_1254418699.1422269983573--
------=_Part_82_1108890195.1422269983573--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Mon, 26 Jan 2015 14:51:51 -0800 (PST)
Raw View
------=_Part_1184_859036356.1422312711152
Content-Type: multipart/alternative;
 boundary="----=_Part_1185_291476511.1422312711152"

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

On Monday, January 26, 2015 at 2:59:43 AM UTC-8, Douglas Boffey wrote:
>
> Suppose you wanted a number of functions, classes or constants, all=20
> templated on one parameter, what about putting them in a namespace and=20
> raising the parameter a level?
> =20
> template <typename T>
> namespace foo {
>   // various declarations, etc.
> }
>
>
C++ already supports that feature, although it's spelled "class", not=20
"namespace".
If you think the existing feature doesn't suffice, why not provide some=20
examples of "old syntax" versus "new syntax" to show how the new syntax=20
would be better?

=E2=80=93Arthur

--=20

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

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

<div dir=3D"ltr">On Monday, January 26, 2015 at 2:59:43 AM UTC-8, Douglas B=
offey wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><=
div>Suppose you wanted a number of functions, classes or constants, all tem=
plated on one parameter, what about putting them in a namespace and raising=
 the parameter a level?</div><div>&nbsp;</div><div style=3D"border:1px soli=
d rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)">=
<code><div><span style=3D"color:rgb(0,0,136)">template</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">&lt;</span>=
<span style=3D"color:rgb(0,0,136)">typename</span><span style=3D"color:rgb(=
0,0,0)"> T</span><span style=3D"color:rgb(102,102,0)">&gt;</span><span styl=
e=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">namesp=
ace</span><span style=3D"color:rgb(0,0,0)"> foo </span><span style=3D"color=
:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; </span=
><span style=3D"color:rgb(136,0,0)">// various declarations, etc.</span><sp=
an style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0=
)">}</span><span style=3D"color:rgb(0,0,0)"><br></span></div></code></div><=
br></div></blockquote><div><br></div><div>C++ already supports that feature=
, although it's spelled "class", not "namespace".</div><div>If you think th=
e existing feature doesn't suffice, why not provide some examples of "old s=
yntax" versus "new syntax" to show how the new syntax would be better?</div=
><div><br></div><div>=E2=80=93Arthur</div></div>

<p></p>

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

------=_Part_1185_291476511.1422312711152--
------=_Part_1184_859036356.1422312711152--

.


Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Mon, 26 Jan 2015 14:53:55 -0800 (PST)
Raw View
------=_Part_1044_673389689.1422312835365
Content-Type: multipart/alternative;
 boundary="----=_Part_1045_421683333.1422312835365"

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

Works today by making them static functions of a struct, e.g.

template <typename T>
struct foo {
  static void bar(T param) { /*...*/ }
};

Other than just looking cleaner, what advantage would the namespace version=
=20
have?

On Monday, January 26, 2015 at 2:59:43 AM UTC-8, Douglas Boffey wrote:
>
> Suppose you wanted a number of functions, classes or constants, all=20
> templated on one parameter, what about putting them in a namespace and=20
> raising the parameter a level?
> =20
> template <typename T>
> namespace foo {
>   // various declarations, etc.
> }
>
> Consider, for example, the standard header <limits>.  There, due to the=
=20
> lack of a templated namespace, the hack of using a templated class has be=
en=20
> used (not that I=E2=80=99m suggesting we change the, due to a change in A=
BI).
> =20
> Doug.
>

--=20

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

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

<div dir=3D"ltr">Works today by making them static functions of a struct, e=
..g.<div><br></div><div>template &lt;typename T&gt;</div><div>struct foo {</=
div><div>&nbsp; static void bar(T param) { /*...*/ }</div><div>};</div><div=
><br></div><div>Other than just looking cleaner, what advantage would the n=
amespace version have?<br><br>On Monday, January 26, 2015 at 2:59:43 AM UTC=
-8, Douglas Boffey wrote:<blockquote 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>Suppose you wanted a number of functions, classes or const=
ants, all templated on one parameter, what about putting them in a namespac=
e and raising the parameter a level?</div><div>&nbsp;</div><div style=3D"bo=
rder:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(2=
50,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">template</span><=
span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)=
">&lt;</span><span style=3D"color:rgb(0,0,136)">typename</span><span style=
=3D"color:rgb(0,0,0)"> T</span><span style=3D"color:rgb(102,102,0)">&gt;</s=
pan><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,=
0,136)">namespace</span><span style=3D"color:rgb(0,0,0)"> foo </span><span =
style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br=
>&nbsp; </span><span style=3D"color:rgb(136,0,0)">// various declarations, =
etc.</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color=
:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span></div>=
</code></div><br><div>Consider, for example, the standard header &lt;limits=
&gt;.&nbsp; There, due to the lack of a templated namespace, the hack of us=
ing a templated class has been used (not that I=E2=80=99m suggesting we cha=
nge the, due to a change in ABI).</div><div>&nbsp;</div><div>Doug.</div></d=
iv></blockquote></div></div>

<p></p>

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

------=_Part_1045_421683333.1422312835365--
------=_Part_1044_673389689.1422312835365--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 27 Jan 2015 10:03:19 +0800
Raw View
--Apple-Mail=_BC1A7F0B-7173-41DF-BEAD-BBCAD0851A17
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9301=E2=80=9326, at 6:59 PM, Douglas Boffey <douglas.boffey=
@gmail.com> wrote:
>=20
> Consider, for example, the standard header <limits>.

If <limits> were to be redone today, it would be made out of variable templ=
ates instead of class templates.

It=E2=80=99s true that it=E2=80=99s a bit arbitrary that classes are used a=
s metafunctions. They have baggage such as constructors and layout, and bog=
us restrictions such as all members being grouped in a single member-specif=
ication block. Namespaces would provide a cleaner mapping from template par=
ameters to a =E2=80=9Cbag of declarations.=E2=80=9D Metaprogramming could b=
e cleaner overall using namespaces.

Higher-order metafunctions are a rare and finicky beast. There is no way to=
 pass a namespace as a template argument, and we could draw a line in the s=
and that there should never be. Metafunctions defined as namespaces would e=
ssentially declare themselves incompatible with any template template param=
eter, and vice versa, metafunctions defined as classes would implicitly sug=
gest membership in a Concept that is compatible with some higher-order func=
tion. As long as programmers are aware of the difference, it would help exp=
ressiveness and discourage cases where template complexity gets out of cont=
rol or template parameter lists become too solidified.

Template instantiation involves a lot of implementation details, though, so=
 it would be nice to see how templated namespaces really works, and take th=
em for a test drive. The suggestion comes up fairly often here, but what ca=
n we really say?

--=20

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

--Apple-Mail=_BC1A7F0B-7173-41DF-BEAD-BBCAD0851A17
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9301=
=E2=80=9326, at 6:59 PM, Douglas Boffey &lt;<a href=3D"mailto:douglas.boffe=
y@gmail.com" class=3D"">douglas.boffey@gmail.com</a>&gt; wrote:</div><br cl=
ass=3D"Apple-interchange-newline"><div class=3D""><span style=3D"font-famil=
y: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; fo=
nt-weight: normal; letter-spacing: normal; line-height: normal; orphans: au=
to; text-align: start; text-indent: 0px; text-transform: none; white-space:=
 normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; f=
loat: none; display: inline !important;" class=3D"">Consider, for example, =
the standard header &lt;limits&gt;.</span></div></blockquote></div><br clas=
s=3D""><div class=3D"">If <font face=3D"Courier" class=3D"">&lt;limits&gt;<=
/font> were to be redone today, it would be made out of variable templates =
instead of class templates.</div><div class=3D""><br class=3D""></div><div =
class=3D"">It=E2=80=99s true that it=E2=80=99s a bit arbitrary that classes=
 are used as metafunctions. They have baggage such as constructors and layo=
ut, and bogus restrictions such as all members being grouped in a single <i=
 class=3D"">member-specification</i> block. Namespaces would provide a clea=
ner mapping from template parameters to a =E2=80=9Cbag of declarations.=E2=
=80=9D Metaprogramming could be cleaner overall using namespaces.</div><div=
 class=3D""><br class=3D""></div><div class=3D"">Higher-order metafunctions=
 are a rare and finicky beast. There is no way to pass a namespace as a tem=
plate argument, and we could draw a line in the sand that there should neve=
r be. Metafunctions defined as namespaces would essentially declare themsel=
ves incompatible with any template template parameter, and vice versa, meta=
functions defined as classes would implicitly suggest membership in a Conce=
pt that is compatible with some higher-order function. As long as programme=
rs are aware of the difference, it would help expressiveness and discourage=
 cases where template complexity gets out of control or template parameter =
lists become too solidified.</div><div class=3D""><br class=3D""></div><div=
 class=3D"">Template instantiation involves a lot of implementation details=
, though, so it would be nice to see how templated namespaces really works,=
 and take them for a test drive. The suggestion comes up fairly often here,=
 but what can we really say?</div></body></html>

<p></p>

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

--Apple-Mail=_BC1A7F0B-7173-41DF-BEAD-BBCAD0851A17--

.


Author: Tom Honermann <thonermann@coverity.com>
Date: Mon, 26 Jan 2015 22:17:21 -0500
Raw View
On 01/26/2015 05:59 AM, Douglas Boffey wrote:
> Suppose you wanted a number of functions, classes or constants, all
> templated on one parameter, what about putting them in a namespace and
> raising the parameter a level?
> |
> template<typename T>
> namespace foo {
>   // various declarations, etc.
> }

How would this extern "C" declaration within the namespace be handled?
   template<typename T>
   namespace foo {
     extern "C" func() {}
   }

Perhaps as ill-formed code?  This scenario doesn't arise with the class
based approach since extern "C" declarations aren't allowed in class
scope.  Presumably, any member declaration within the namespace that
wouldn't be valid if prefixed by a template parameter list would be
considered ill-formed?

Similarly, what about a class or function template?
   template<typename T>
   namespace foo {
     template<typename U>
     struct S {};
   }

Also ill-formed code?  As if the user had written this ill-formed code?
   namespace foo {
     template<typename T>
     template<typename U>
     struct S {};
   }

Or, perhaps the template parameter lists would be implicitly combined
like this?
   namespace foo {
     template<typename T, typename U>
     struct S {};
   }

Tom.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Tue, 27 Jan 2015 02:02:58 -0600
Raw View
On 1/26/2015 4:53 PM, Sean Middleditch wrote:
> Works today by making them static functions of a struct, e.g.
>
> template <typename T>
> struct foo {
>    static void bar(T param) { /*...*/ }
> };
>
> Other than just looking cleaner, what advantage would the namespace
> version have?

The most obvious advantage would be using directives.

- Jim

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jean-Marc Bourguet <jm.bourguet@gmail.com>
Date: Tue, 27 Jan 2015 01:05:25 -0800 (PST)
Raw View
------=_Part_2883_882178585.1422349525187
Content-Type: multipart/alternative;
 boundary="----=_Part_2884_548379207.1422349525187"

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

Le lundi 26 janvier 2015 23:53:55 UTC+1, Sean Middleditch a =C3=A9crit :
>
>
> Other than just looking cleaner, what advantage would the namespace=20
> version have?
>
>
Be open instead of closed (that's something which makes me still use=20
classes instead of namespaces in some cases, but it goes in the two=20
directions)

Yours

--=20
Jean-Marc

--=20

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

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

<div dir=3D"ltr">Le lundi 26 janvier 2015 23:53:55 UTC+1, Sean Middleditch =
a =C3=A9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><div><br></div><div>Other than just looking cleaner, what advantage w=
ould the namespace version have?<br><br></div></div></blockquote><div><br><=
/div><div>Be open instead of closed (that's something which makes me still =
use classes instead of namespaces in some cases, but it goes in the two dir=
ections)</div><div><br></div><div>Yours</div><div><br></div><div>--&nbsp;</=
div><div>Jean-Marc</div></div>

<p></p>

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

------=_Part_2884_548379207.1422349525187--
------=_Part_2883_882178585.1422349525187--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 27 Jan 2015 11:55:33 +0100
Raw View
--089e011615f20f972d050da0188e
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

This has already been proposed and discussed informally last year.

The correct term would be a "namespace template".

All that needs to happen is for someone to submit a formal proposal and
specification for such an entity, show up at a committee meeting and
present it.

On Mon, Jan 26, 2015 at 11:59 AM, Douglas Boffey <douglas.boffey@gmail.com>
wrote:

> Suppose you wanted a number of functions, classes or constants, all
> templated on one parameter, what about putting them in a namespace and
> raising the parameter a level?
>
> template <typename T>
> namespace foo {
>   // various declarations, etc.
> }
>
> Consider, for example, the standard header <limits>.  There, due to the
> lack of a templated namespace, the hack of using a templated class has be=
en
> used (not that I=E2=80=99m suggesting we change the, due to a change in A=
BI).
>
> Doug.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--=20

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

--089e011615f20f972d050da0188e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This has already been proposed and discussed informally la=
st year.<div><br></div><div>The correct term would be a &quot;namespace tem=
plate&quot;.</div><div><br></div><div>All that needs to happen is for someo=
ne to submit a formal proposal and specification for such an entity, show u=
p at a committee meeting and present it.</div></div><div class=3D"gmail_ext=
ra"><br><div class=3D"gmail_quote">On Mon, Jan 26, 2015 at 11:59 AM, Dougla=
s Boffey <span dir=3D"ltr">&lt;<a href=3D"mailto:douglas.boffey@gmail.com" =
target=3D"_blank">douglas.boffey@gmail.com</a>&gt;</span> wrote:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr"><div>Suppose you wanted a number o=
f functions, classes or constants, all templated on one parameter, what abo=
ut putting them in a namespace and raising the parameter a level?</div><div=
>=C2=A0</div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:brea=
k-word;background-color:rgb(250,250,250)"><code><div><span style=3D"color:r=
gb(0,0,136)">template</span><span style=3D"color:rgb(0,0,0)"> </span><span =
style=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,136)=
">typename</span><span style=3D"color:rgb(0,0,0)"> T</span><span style=3D"c=
olor:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"><br></span=
><span style=3D"color:rgb(0,0,136)">namespace</span><span style=3D"color:rg=
b(0,0,0)"> foo </span><span style=3D"color:rgb(102,102,0)">{</span><span st=
yle=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0=
)">// various declarations, etc.</span><span style=3D"color:rgb(0,0,0)"><br=
></span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:r=
gb(0,0,0)"><br></span></div></code></div><br><div>Consider, for example, th=
e standard header &lt;limits&gt;.=C2=A0 There, due to the lack of a templat=
ed namespace, the hack of using a templated class has been used (not that I=
=E2=80=99m suggesting we change the, due to a change in ABI).</div><div>=C2=
=A0</div><div>Doug.</div></div><span class=3D"HOEnZb"><font color=3D"#88888=
8">

<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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 />

--089e011615f20f972d050da0188e--

.


Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 30 Jan 2015 13:43:56 -0300
Raw View
On Tue, Jan 27, 2015 at 7:55 AM, Andrew Tomazos <andrewtomazos@gmail.com> w=
rote:
> This has already been proposed and discussed informally last year.

https://groups.google.com/a/isocpp.org/d/msg/std-proposals/8IDbb1L5_UA/TVdj=
ru4mFCEJ

>
> The correct term would be a "namespace template".
>
> All that needs to happen is for someone to submit a formal proposal and
> specification for such an entity, show up at a committee meeting and pres=
ent
> it.
>
> On Mon, Jan 26, 2015 at 11:59 AM, Douglas Boffey <douglas.boffey@gmail.co=
m>
> wrote:
>>
>> Suppose you wanted a number of functions, classes or constants, all
>> templated on one parameter, what about putting them in a namespace and
>> raising the parameter a level?
>>
>> template <typename T>
>> namespace foo {
>>   // various declarations, etc.
>> }
>>
>> Consider, for example, the standard header <limits>.  There, due to the
>> lack of a templated namespace, the hack of using a templated class has b=
een
>> used (not that I=E2=80=99m suggesting we change the, due to a change in =
ABI).
>>
>> Doug.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/.



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

--=20

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

.


Author: jake.arkinstall@gmail.com
Date: Mon, 27 Nov 2017 10:02:29 -0800 (PST)
Raw View
------=_Part_25696_390723064.1511805749434
Content-Type: multipart/alternative;
 boundary="----=_Part_25697_131056927.1511805749435"

------=_Part_25697_131056927.1511805749435
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Proposal

I am proposing that we equip namespaces with template functionality, in the=
=20
same way that classes and functions can be templated.
For example:

template<typename T, typename S, size_t X, size_t Y>namespace Example{
    typedef std::array<T, X> T_array;
    typedef std::array<S, Y> S_array;
    class A{    protected:
        T_array t_values;
        S_array s_values;    public:
        A(T_array t_values, S_array s_values)
        :
            t_values(t_values),
            s_values(s_values)
        {}
    };
       =20
    class B{    protected:
        std::vector<std::shared_ptr<A>> some_As;    public:
        void add_A(T_array t_values, S_array s_values){
            some_As.push_back(std::make_shared<A>(t_values, s_values));
        }
        Example<T, S, X+1, Y+1>::B promote() const{
            // ... do something
        }
    };}


Motivation

When a library comprises classes which have a high degree of interaction=20
with one another, the class templates start to become the same set.

For example, consider the example above. In order to achieve the same=20
result in the current standard, we would have something like:

namespace Example{
    template<typename T, size_t X>
    using array_t =3D std::array<T, X>;
   =20
    template<typename T, typename S, size_t X, size_t Y>
    class A{    protected:
        array_t<T,X> t_values;
        array_t<S,Y> s_values;    public:
        A(array_t<T,X> t_values, array_t<S,Y> s_values)
        :
            t_values(t_values),
            s_values(s_values)
        {}
    };
       =20
    template<typename T, typename S, size_t X, size_t Y>
    class B{    protected:
        std::vector<std::shared_ptr<A<T,S,X,Y>>> some_As;    public:
        void add_A(array_t<T,X> t_values, array_t<S,Y> s_values){
            some_As.push_back(std::make_shared<A<T,S,X,Y>>(t_values, s_valu=
es));
        }
        B<T, S, X+1, Y+1> promote() const{
            // ... do something
        }
    };}


In this case, we must define the template parameters at each stage - before=
=20
class definitions and in variable declarations. We cannot make typedefs=20
specialised to the current template parameter set until we are within the=
=20
scope of the class/function, which means that they are redefined multiple=
=20
times or explicitly templated at each variable declaration. This becomes an=
=20
especially noticeable problem when we venture away from situations where=20
purely generic template parameter names (e.g. 'typename T'), and into the=
=20
realm where template names carry meaning to the developer (e.g. 'typename=
=20
LeftType, typename RightType, size_t RowCount, size_t ColumnCount') - if=20
you imagine putting those into the second example, it will appear quite=20
messy (although I admit that 'messy' is subjective).

Another situation where this may be useful is in generic libraries where=20
there exist a large number of functions with a single typedef template=20
parameter. I often see projects on GitHub, for example, which have=20
'template<typename T>' repeated dozens of times in the same file, and the T=
=20
is passed around between functions, and so on. In these cases, applying the=
=20
template to the namespace itself would increase the signal-to-noise ratio=
=20
in the code.

Further Thoughts


   - In some cases, a namespace may contain class/functions templated with=
=20
   a parameter set X, but some may be more generic and only need a subset Y=
 of=20
   parameters (Y =E2=8A=82 X). In this case, an optimal compiler would spot=
 when a=20
   class/function doesn't need recompilation under a new set X because the=
=20
   subset Y has been seen before. This isn't mandatory, but is advisable in=
=20
   order to negate increases to the compiled program size.
  =20
   - Another option is to allow templated blocks, rather than namespaces:
  =20
   template<typename T, typename S, size_t X, size_t Y>{
       typedef something<T,X> shortcut;
       class A;
       class B;
       void blah();}
  =20
  =20
   -=20
  =20
   Other suggestions I have seen include:
  =20
  =20

   1. Passing structs that 'bag' the parameter set, and unpacking types=20
      manually (e.g. s::T). However, SFINAE makes this unbearable - the dev=
eloper=20
      would need to check for existence of parameters within the struct, an=
d=20
      that's on top of the usual SFINAE-ing.
      2. Using a non-namespace container, such as a struct. This works, but=
=20
      this is semantically questionable - in an ideal standard, a struct sh=
ould=20
      do the job of a struct, and a namespace that of a namespace IMO.
  =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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/fa30c4bd-78f9-435c-965c-af4812779032%40isocpp.or=
g.

------=_Part_25697_131056927.1511805749435
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><font size=3D"4">Proposal</font><div><font size=3D"4"><br>=
</font></div><div><font size=3D"2">I am proposing that we equip namespaces =
with template functionality, in the same way that classes and functions can=
 be templated.<br>For example:</font></div><div><font size=3D"2"><br></font=
></div><div><pre style=3D"color: rgb(0, 0, 0); background-image: initial; b=
ackground-position: initial; background-size: initial; background-repeat: i=
nitial; background-attachment: initial; background-origin: initial; backgro=
und-clip: initial;"><pre style=3D"background-image: initial; background-pos=
ition: initial; background-size: initial; background-repeat: initial; backg=
round-attachment: initial; background-origin: initial; background-clip: ini=
tial;"><span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</=
span><span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"col=
or: rgb(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"col=
or: rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(128, 0, 0); font=
-weight: bold;">typename</span> S<span style=3D"color: rgb(128, 128, 48);">=
,</span> <span style=3D"color: rgb(96, 48, 0);">size_t</span> X<span style=
=3D"color: rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0=
);">size_t</span> Y<span style=3D"color: rgb(128, 0, 128);">&gt;</span>
<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">namespace</span> =
Example<span style=3D"color: rgb(128, 0, 128);">{</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">typedef</span=
> std<span style=3D"color: rgb(128, 0, 128);">::</span>array<span style=3D"=
color: rgb(128, 0, 128);">&lt;</span>T<span style=3D"color: rgb(128, 128, 4=
8);">,</span> X<span style=3D"color: rgb(128, 0, 128);">&gt;</span> T_array=
<span style=3D"color: rgb(128, 0, 128);">;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">typedef</span=
> std<span style=3D"color: rgb(128, 0, 128);">::</span>array<span style=3D"=
color: rgb(128, 0, 128);">&lt;</span>S<span style=3D"color: rgb(128, 128, 4=
8);">,</span> Y<span style=3D"color: rgb(128, 0, 128);">&gt;</span> S_array=
<span style=3D"color: rgb(128, 0, 128);">;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> =
A<span style=3D"color: rgb(128, 0, 128);">{</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">protected</span><sp=
an style=3D"color: rgb(227, 74, 220);">:</span>
        T_array t_values<span style=3D"color: rgb(128, 0, 128);">;</span>
        S_array s_values<span style=3D"color: rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">public</span><span =
style=3D"color: rgb(227, 74, 220);">:</span>
        A<span style=3D"color: rgb(128, 128, 48);">(</span>T_array t_values=
<span style=3D"color: rgb(128, 128, 48);">,</span> S_array s_values<span st=
yle=3D"color: rgb(128, 128, 48);">)</span>
        <span style=3D"color: rgb(128, 0, 128);">:</span>
            t_values<span style=3D"color: rgb(128, 128, 48);">(</span>t_val=
ues<span style=3D"color: rgb(128, 128, 48);">)</span><span style=3D"color: =
rgb(128, 128, 48);">,</span>
            s_values<span style=3D"color: rgb(128, 128, 48);">(</span>s_val=
ues<span style=3D"color: rgb(128, 128, 48);">)</span>
        <span style=3D"color: rgb(128, 0, 128);">{</span><span style=3D"col=
or: rgb(128, 0, 128);">}</span>
    <span style=3D"color: rgb(128, 0, 128);">}</span><span style=3D"color: =
rgb(128, 0, 128);">;</span>
       =20
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> =
B<span style=3D"color: rgb(128, 0, 128);">{</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">protected</span><sp=
an style=3D"color: rgb(227, 74, 220);">:</span>
        <span style=3D"color: rgb(102, 102, 22);">std</span><span style=3D"=
color: rgb(128, 0, 128);">::</span><span style=3D"color: rgb(96, 48, 0);">v=
ector</span><span style=3D"color: rgb(128, 128, 48);">&lt;</span><span styl=
e=3D"color: rgb(102, 102, 22);">std</span><span style=3D"color: rgb(128, 0,=
 128);">::</span><span style=3D"color: rgb(96, 48, 0);">shared_ptr</span><s=
pan style=3D"color: rgb(128, 128, 48);">&lt;</span>A<span style=3D"color: r=
gb(128, 128, 48);">&gt;</span><span style=3D"color: rgb(128, 128, 48);">&gt=
;</span> some_As<span style=3D"color: rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">public</span><span =
style=3D"color: rgb(227, 74, 220);">:</span>
        <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">void</spa=
n> add_A<span style=3D"color: rgb(128, 128, 48);">(</span>T_array t_values<=
span style=3D"color: rgb(128, 128, 48);">,</span> S_array s_values<span sty=
le=3D"color: rgb(128, 128, 48);">)</span><span style=3D"color: rgb(128, 0, =
128);">{</span>
            some_As<span style=3D"color: rgb(128, 128, 48);">.</span>push_b=
ack<span style=3D"color: rgb(128, 128, 48);">(</span><span style=3D"color: =
rgb(102, 102, 22);">std</span><span style=3D"color: rgb(128, 0, 128);">::</=
span>make_shared<span style=3D"color: rgb(128, 0, 128);">&lt;</span>A<span =
style=3D"color: rgb(128, 0, 128);">&gt;</span><span style=3D"color: rgb(128=
, 128, 48);">(</span>t_values<span style=3D"color: rgb(128, 128, 48);">,</s=
pan> s_values<span style=3D"color: rgb(128, 128, 48);">)</span><span style=
=3D"color: rgb(128, 128, 48);">)</span><span style=3D"color: rgb(128, 0, 12=
8);">;</span>
        <span style=3D"color: rgb(128, 0, 128);">}</span>
        Example<span style=3D"color: rgb(128, 128, 48);">&lt;</span>T<span =
style=3D"color: rgb(128, 128, 48);">,</span> S<span style=3D"color: rgb(128=
, 128, 48);">,</span> X<span style=3D"color: rgb(128, 128, 48);">+</span><s=
pan style=3D"color: rgb(0, 140, 0);">1</span><span style=3D"color: rgb(128,=
 128, 48);">,</span> Y<span style=3D"color: rgb(128, 128, 48);">+</span><sp=
an style=3D"color: rgb(0, 140, 0);">1</span><span style=3D"color: rgb(128, =
128, 48);">&gt;</span><span style=3D"color: rgb(128, 0, 128);">::</span>B p=
romote<span style=3D"color: rgb(128, 128, 48);">(</span><span style=3D"colo=
r: rgb(128, 128, 48);">)</span> <span style=3D"color: rgb(128, 0, 0); font-=
weight: bold;">const</span><span style=3D"color: rgb(128, 0, 128);">{</span=
>
            <span style=3D"color: rgb(105, 105, 105);">// ... do something<=
/span>
        <span style=3D"color: rgb(128, 0, 128);">}</span>
    <span style=3D"color: rgb(128, 0, 128);">}</span><span style=3D"color: =
rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(128, 0, 128);">}</span></pre><pre style=3D"backgr=
ound-image: initial; background-position: initial; background-size: initial=
; background-repeat: initial; background-attachment: initial; background-or=
igin: initial; background-clip: initial;"><span style=3D"color: rgb(128, 0,=
 128);"><br></span></pre></pre></div><div><font size=3D"4">Motivation</font=
></div><div><font size=3D"4"><br></font></div><div><font size=3D"2">When a =
library comprises classes which have a high degree of interaction with one =
another, the class templates start to become the same set.<br><br>For examp=
le, consider the example above. In order to achieve the same result in the =
current standard, we would have something like:</font></div><div><font size=
=3D"2"><br></font></div><div><pre style=3D"color: rgb(0, 0, 0); background-=
image: initial; background-position: initial; background-size: initial; bac=
kground-repeat: initial; background-attachment: initial; background-origin:=
 initial; background-clip: initial;"><pre style=3D"background-image: initia=
l; background-position: initial; background-size: initial; background-repea=
t: initial; background-attachment: initial; background-origin: initial; bac=
kground-clip: initial;"><span style=3D"color: rgb(128, 0, 0); font-weight: =
bold;">namespace</span> Example<span style=3D"color: rgb(128, 0, 128);">{</=
span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</spa=
n><span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color:=
 rgb(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color:=
 rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0);">size_t=
</span> X<span style=3D"color: rgb(128, 0, 128);">&gt;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">using</span> =
array_t <span style=3D"color: rgb(128, 128, 48);">=3D</span> <span style=3D=
"color: rgb(102, 102, 22);">std</span><span style=3D"color: rgb(128, 0, 128=
);">::</span><span style=3D"color: rgb(96, 48, 0);">array</span><span style=
=3D"color: rgb(128, 0, 128);">&lt;</span>T<span style=3D"color: rgb(128, 12=
8, 48);">,</span> X<span style=3D"color: rgb(128, 0, 128);">&gt;</span><spa=
n style=3D"color: rgb(128, 0, 128);">;</span>
   =20
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</spa=
n><span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color:=
 rgb(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color:=
 rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(128, 0, 0); font-we=
ight: bold;">typename</span> S<span style=3D"color: rgb(128, 128, 48);">,</=
span> <span style=3D"color: rgb(96, 48, 0);">size_t</span> X<span style=3D"=
color: rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0);">=
size_t</span> Y<span style=3D"color: rgb(128, 0, 128);">&gt;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> =
A<span style=3D"color: rgb(128, 0, 128);">{</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">protected</span><sp=
an style=3D"color: rgb(227, 74, 220);">:</span>
        array_t<span style=3D"color: rgb(128, 0, 128);">&lt;</span>T<span s=
tyle=3D"color: rgb(128, 128, 48);">,</span>X<span style=3D"color: rgb(128, =
0, 128);">&gt;</span> t_values<span style=3D"color: rgb(128, 0, 128);">;</s=
pan>
        array_t<span style=3D"color: rgb(128, 0, 128);">&lt;</span>S<span s=
tyle=3D"color: rgb(128, 128, 48);">,</span>Y<span style=3D"color: rgb(128, =
0, 128);">&gt;</span> s_values<span style=3D"color: rgb(128, 0, 128);">;</s=
pan>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">public</span><span =
style=3D"color: rgb(227, 74, 220);">:</span>
        A<span style=3D"color: rgb(128, 128, 48);">(</span>array_t<span sty=
le=3D"color: rgb(128, 0, 128);">&lt;</span>T<span style=3D"color: rgb(128, =
128, 48);">,</span>X<span style=3D"color: rgb(128, 0, 128);">&gt;</span> t_=
values<span style=3D"color: rgb(128, 128, 48);">,</span> array_t<span style=
=3D"color: rgb(128, 0, 128);">&lt;</span>S<span style=3D"color: rgb(128, 12=
8, 48);">,</span>Y<span style=3D"color: rgb(128, 0, 128);">&gt;</span> s_va=
lues<span style=3D"color: rgb(128, 128, 48);">)</span>
        <span style=3D"color: rgb(128, 0, 128);">:</span>
            t_values<span style=3D"color: rgb(128, 128, 48);">(</span>t_val=
ues<span style=3D"color: rgb(128, 128, 48);">)</span><span style=3D"color: =
rgb(128, 128, 48);">,</span>
            s_values<span style=3D"color: rgb(128, 128, 48);">(</span>s_val=
ues<span style=3D"color: rgb(128, 128, 48);">)</span>
        <span style=3D"color: rgb(128, 0, 128);">{</span><span style=3D"col=
or: rgb(128, 0, 128);">}</span>
    <span style=3D"color: rgb(128, 0, 128);">}</span><span style=3D"color: =
rgb(128, 0, 128);">;</span>
       =20
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</spa=
n><span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color:=
 rgb(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color:=
 rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(128, 0, 0); font-we=
ight: bold;">typename</span> S<span style=3D"color: rgb(128, 128, 48);">,</=
span> <span style=3D"color: rgb(96, 48, 0);">size_t</span> X<span style=3D"=
color: rgb(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0);">=
size_t</span> Y<span style=3D"color: rgb(128, 0, 128);">&gt;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> =
B<span style=3D"color: rgb(128, 0, 128);">{</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">protected</span><sp=
an style=3D"color: rgb(227, 74, 220);">:</span>
        <span style=3D"color: rgb(102, 102, 22);">std</span><span style=3D"=
color: rgb(128, 0, 128);">::</span><span style=3D"color: rgb(96, 48, 0);">v=
ector</span><span style=3D"color: rgb(128, 128, 48);">&lt;</span><span styl=
e=3D"color: rgb(102, 102, 22);">std</span><span style=3D"color: rgb(128, 0,=
 128);">::</span><span style=3D"color: rgb(96, 48, 0);">shared_ptr</span><s=
pan style=3D"color: rgb(128, 128, 48);">&lt;</span>A<span style=3D"color: r=
gb(128, 128, 48);">&lt;</span>T<span style=3D"color: rgb(128, 128, 48);">,<=
/span>S<span style=3D"color: rgb(128, 128, 48);">,</span>X<span style=3D"co=
lor: rgb(128, 128, 48);">,</span>Y<span style=3D"color: rgb(128, 128, 48);"=
>&gt;</span><span style=3D"color: rgb(128, 128, 48);">&gt;</span><span styl=
e=3D"color: rgb(128, 128, 48);">&gt;</span> some_As<span style=3D"color: rg=
b(128, 0, 128);">;</span>
<span style=3D"color: rgb(227, 74, 220);">=C2=A0=C2=A0=C2=A0=C2=A0</span><s=
pan style=3D"color: rgb(128, 0, 0); font-weight: bold;">public</span><span =
style=3D"color: rgb(227, 74, 220);">:</span>
        <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">void</spa=
n> add_A<span style=3D"color: rgb(128, 128, 48);">(</span>array_t<span styl=
e=3D"color: rgb(128, 0, 128);">&lt;</span>T<span style=3D"color: rgb(128, 1=
28, 48);">,</span>X<span style=3D"color: rgb(128, 0, 128);">&gt;</span> t_v=
alues<span style=3D"color: rgb(128, 128, 48);">,</span> array_t<span style=
=3D"color: rgb(128, 0, 128);">&lt;</span>S<span style=3D"color: rgb(128, 12=
8, 48);">,</span>Y<span style=3D"color: rgb(128, 0, 128);">&gt;</span> s_va=
lues<span style=3D"color: rgb(128, 128, 48);">)</span><span style=3D"color:=
 rgb(128, 0, 128);">{</span>
            some_As<span style=3D"color: rgb(128, 128, 48);">.</span>push_b=
ack<span style=3D"color: rgb(128, 128, 48);">(</span><span style=3D"color: =
rgb(102, 102, 22);">std</span><span style=3D"color: rgb(128, 0, 128);">::</=
span>make_shared<span style=3D"color: rgb(128, 128, 48);">&lt;</span>A<span=
 style=3D"color: rgb(128, 128, 48);">&lt;</span>T<span style=3D"color: rgb(=
128, 128, 48);">,</span>S<span style=3D"color: rgb(128, 128, 48);">,</span>=
X<span style=3D"color: rgb(128, 128, 48);">,</span>Y<span style=3D"color: r=
gb(128, 128, 48);">&gt;</span><span style=3D"color: rgb(128, 128, 48);">&gt=
;</span><span style=3D"color: rgb(128, 128, 48);">(</span>t_values<span sty=
le=3D"color: rgb(128, 128, 48);">,</span> s_values<span style=3D"color: rgb=
(128, 128, 48);">)</span><span style=3D"color: rgb(128, 128, 48);">)</span>=
<span style=3D"color: rgb(128, 0, 128);">;</span>
        <span style=3D"color: rgb(128, 0, 128);">}</span>
        B<span style=3D"color: rgb(128, 128, 48);">&lt;</span>T<span style=
=3D"color: rgb(128, 128, 48);">,</span> S<span style=3D"color: rgb(128, 128=
, 48);">,</span> X<span style=3D"color: rgb(128, 128, 48);">+</span><span s=
tyle=3D"color: rgb(0, 140, 0);">1</span><span style=3D"color: rgb(128, 128,=
 48);">,</span> Y<span style=3D"color: rgb(128, 128, 48);">+</span><span st=
yle=3D"color: rgb(0, 140, 0);">1</span><span style=3D"color: rgb(128, 128, =
48);">&gt;</span> promote<span style=3D"color: rgb(128, 128, 48);">(</span>=
<span style=3D"color: rgb(128, 128, 48);">)</span> <span style=3D"color: rg=
b(128, 0, 0); font-weight: bold;">const</span><span style=3D"color: rgb(128=
, 0, 128);">{</span>
            <span style=3D"color: rgb(105, 105, 105);">// ... do something<=
/span>
        <span style=3D"color: rgb(128, 0, 128);">}</span>
    <span style=3D"color: rgb(128, 0, 128);">}</span><span style=3D"color: =
rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(128, 0, 128);">}

</span></pre></pre></div><div><font size=3D"2">In this case, we must define=
 the template parameters at each stage - before class definitions and in va=
riable declarations. We cannot make typedefs specialised to the current tem=
plate parameter set until we are within the scope of the class/function, wh=
ich means that they are redefined multiple times or explicitly templated at=
 each variable declaration. This becomes an especially noticeable problem w=
hen we venture away from situations where purely generic template parameter=
 names (e.g. &#39;typename T&#39;), and into the realm where template names=
 carry meaning to the developer (e.g. &#39;typename LeftType, typename Righ=
tType, size_t RowCount, size_t ColumnCount&#39;) - if you imagine putting t=
hose into the second example, it will appear quite messy (although I admit =
that &#39;messy&#39; is subjective).</font><br><br><font size=3D"2">Another=
 situation where this may be useful is in generic libraries where there exi=
st a large number of functions with a single typedef template parameter. I =
often see projects on GitHub, for example, which have &#39;template&lt;type=
name T&gt;&#39; repeated dozens of times in the same file, and the T is pas=
sed around between functions, and so on. In these cases, applying the templ=
ate to the namespace itself would increase the signal-to-noise ratio in the=
 code.</font><br><br><font size=3D"4">Further Thoughts</font></div><div><br=
></div><div><ul><li>In some cases, a namespace may contain class/functions =
templated with a parameter set X, but some may be more generic and only nee=
d a subset Y of parameters (Y=C2=A0<span style=3D"font-family: sans-serif; =
font-size: 14px;">=E2=8A=82</span>=C2=A0X). In this case, an optimal compil=
er would spot when a class/function doesn&#39;t need recompilation under a =
new set X because the subset Y has been seen before. This isn&#39;t mandato=
ry, but is advisable in order to negate increases to the compiled program s=
ize.<br><br></li><li>Another option is to allow templated blocks, rather th=
an namespaces:<br><pre style=3D"color: rgb(0, 0, 0); background-image: init=
ial; background-position: initial; background-size: initial; background-rep=
eat: initial; background-attachment: initial; background-origin: initial; b=
ackground-clip: initial;"><span style=3D"color: rgb(128, 0, 0); font-weight=
: bold;">template</span><span style=3D"color: rgb(128, 0, 128);">&lt;</span=
><span style=3D"color: rgb(128, 0, 0); font-weight: bold;">typename</span> =
T<span style=3D"color: rgb(128, 128, 48);">,</span> <span style=3D"color: r=
gb(128, 0, 0); font-weight: bold;">typename</span> S<span style=3D"color: r=
gb(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0);">size_t</=
span> X<span style=3D"color: rgb(128, 128, 48);">,</span> <span style=3D"co=
lor: rgb(96, 48, 0);">size_t</span> Y<span style=3D"color: rgb(128, 0, 128)=
;">&gt;</span>
<span style=3D"color: rgb(128, 0, 128);">{</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">typedef</span=
> something<span style=3D"color: rgb(128, 0, 128);">&lt;</span>T<span style=
=3D"color: rgb(128, 128, 48);">,</span>X<span style=3D"color: rgb(128, 0, 1=
28);">&gt;</span> shortcut<span style=3D"color: rgb(128, 0, 128);">;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> =
A<span style=3D"color: rgb(128, 0, 128);">;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> =
B<span style=3D"color: rgb(128, 0, 128);">;</span>
    <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">void</span> b=
lah<span style=3D"color: rgb(128, 128, 48);">(</span><span style=3D"color: =
rgb(128, 128, 48);">)</span><span style=3D"color: rgb(128, 0, 128);">;</spa=
n>
<span style=3D"color: rgb(128, 0, 128);">}

</span></pre></li><li><pre style=3D"background-image: initial; background-p=
osition: initial; background-size: initial; background-repeat: initial; bac=
kground-attachment: initial; background-origin: initial; background-clip: i=
nitial;"><font face=3D"arial, sans-serif" style=3D"" color=3D"#000000">Othe=
r suggestions I have seen include:</font></pre></li></ul><ol><ol><li>Passin=
g structs that &#39;bag&#39; the parameter set, and unpacking types manuall=
y (e.g. s::T). However, SFINAE makes this unbearable - the developer would =
need to check for existence of parameters within the struct, and that&#39;s=
 on top of the usual SFINAE-ing.<br></li><li>Using a non-namespace containe=
r, such as a struct. This works, but this is semantically questionable - in=
 an ideal standard, a struct should do the job of a struct, and a namespace=
 that of a namespace IMO.</li></ol></ol></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/fa30c4bd-78f9-435c-965c-af4812779032%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fa30c4bd-78f9-435c-965c-af4812779032=
%40isocpp.org</a>.<br />

------=_Part_25697_131056927.1511805749435--

------=_Part_25696_390723064.1511805749434--

.


Author: Magnus Fromreide <magfr@lysator.liu.se>
Date: Mon, 27 Nov 2017 20:40:50 +0100
Raw View
On Mon, Nov 27, 2017 at 10:02:29AM -0800, jake.arkinstall@gmail.com wrote:
> Proposal
>
> I am proposing that we equip namespaces with template functionality, in the
> same way that classes and functions can be templated.

Have you read the discussion from the last time around?

https://groups.google.com/a/isocpp.org/forum/?fromgroups#!searchin/std-proposals/Templetized$20namespaces/std-proposals/8IDbb1L5_UA/TVdjru4mFCEJ

/MF

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/20171127194050.GA10682%40fukushima.lysator.liu.se.

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Mon, 27 Nov 2017 12:28:10 -0800 (PST)
Raw View
------=_Part_16281_884584145.1511814490742
Content-Type: text/plain; charset="UTF-8"

Thanks for the response. I could not find a similar post, but I think the choice of naming was problematic.

I have now looked over the discussion, though I actually have some major disagreements with the conclusion. I will address them in full in a later reply.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f51f5070-bd0a-471c-8a2c-f6dd29df0ea4%40isocpp.org.

------=_Part_16281_884584145.1511814490742--

.


Author: jake.arkinstall@cambridgequantum.com
Date: Mon, 27 Nov 2017 17:55:59 -0800 (PST)
Raw View
------=_Part_26412_1241295932.1511834159609
Content-Type: multipart/alternative;
 boundary="----=_Part_26413_1433417922.1511834159610"

------=_Part_26413_1433417922.1511834159610
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



> I have now looked over the discussion, though I actually have some major=
=20
> disagreements with the conclusion. I will address them in full in a later=
=20
> reply.
>

And now I shall do just that.

In fact, after reading through again, I can see that there wasn't really a=
=20
conclusion, per se. It went out not with a bang, but with a whimper - which=
=20
gives me hope.


   - *"Namespaces don't have a unique definition and are only affecting=20
   naming."*
   That is not a necessary property of namespaces - just the unfortunate=20
   situation that we are currently in. Namespaces could be used with more=
=20
   power if we allow them to be used to describe classes united with the sa=
me=20
   template structures.
   - *"Namespaces differ from classes in that they can be split within and=
=20
   amongst translation units"*
   I don't quite see this as a problem, but as a consideration. If=20
   namespaces are to be templated, they should only be considered the "same=
"=20
   namespace if those template parameters match. If the set of parameters i=
s=20
   different, they aren't considered equivalent (but I see no reason for it=
 to=20
   be an error). Current approach:
  =20
   namespace A {
    template<typename T>
    class B {};}namespace A {
    template<typename S>
    class C : B<S> {};}namespace A {
    template<typename T, size_t X>
    class D : B<T,X>{}; // Uh-oh - too many template arguments
  =20
   }
   New approach, using templates:
  =20
   template<typename T>namespace A {
    class B {};}
   template<typename T>namespace A {
    class C : B {};}
   template<typename T, size_t X>namespace A {
    class D : B{}; // A<T,X>::B undeclared}
  =20
  =20
   -=20
*"Namespaces can contain the following declarations, whereas classes=20
   cannot" *
   explicit-instantiation
   explicit-specialization
   linkage-speci=EF=AC=81cation
   namespace-de=EF=AC=81nition
   attribute-declaration
   asm-de=EF=AC=81nition
   namespace-alias-de=EF=AC=81nition
   using-directive
   opaque-enum-declaration
  =20
   This is something I'm going to need to go through with a fine-tooth=20
   comb. I may need assistance with this. *However, *should any such=20
   declaration seem incompatible with the idea of templated namespaces, it=
=20
   could be disabled for templated namespaces without disrupting the=20
   functionality of non-templated namespaces. This may be the case with *as=
m-definition=20
   - *not something I have used, I must admit, but I can see how having=20
   many copies of an asm-definition might be unfortunate. On the other hand=
,=20
   if only functions, objects, and sub-namespaces inside a templated namesp=
ace=20
   are provided with templating, whilst other declarations are only declare=
d=20
   *once.*
  =20
  =20

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/2653ed1f-714b-47e9-94a2-e5aa0d6ca713%40isocpp.or=
g.

------=_Part_26413_1433417922.1511834159610
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>I have=
 now looked over the discussion, though I actually have some major disagree=
ments with the conclusion. I will address them in full in a later reply.</p=
></blockquote><div><br>And now I shall do just that.<br><br>In fact, after =
reading through again, I can see that there wasn&#39;t really a conclusion,=
 per se. It went out not with a bang, but with a whimper - which gives me h=
ope.<br><br></div><div><ul><li><b>&quot;Namespaces don&#39;t have a unique =
definition and are only affecting naming.&quot;</b><br>That is not a necess=
ary property of namespaces - just the unfortunate situation that we are cur=
rently in. Namespaces could be used with more power if we allow them to be =
used to describe classes united with the same template structures.</li><li>=
<b>&quot;Namespaces differ from classes in that they can be split within an=
d amongst translation units&quot;</b><br>I don&#39;t quite see this as a pr=
oblem, but as a consideration. If namespaces are to be templated, they shou=
ld only be considered the &quot;same&quot; namespace if those template para=
meters match. If the set of parameters is different, they aren&#39;t consid=
ered equivalent (but I see no reason for it to be an error). Current approa=
ch:<br><pre style=3D"color: rgb(0, 0, 0); background-image: initial; backgr=
ound-position: initial; background-size: initial; background-repeat: initia=
l; background-attachment: initial; background-origin: initial; background-c=
lip: initial;"><span style=3D"color: rgb(128, 0, 0); font-weight: bold;">na=
mespace</span> A <span style=3D"color: rgb(128, 0, 128);">{</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</span><=
span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color: rg=
b(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color: rg=
b(128, 0, 128);">&gt;</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> B <=
span style=3D"color: rgb(128, 0, 128);">{</span><span style=3D"color: rgb(1=
28, 0, 128);">}</span><span style=3D"color: rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(128, 0, 128);">}</span>
<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">namespace</span> =
A <span style=3D"color: rgb(128, 0, 128);">{</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</span><=
span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color: rg=
b(128, 0, 0); font-weight: bold;">typename</span> S<span style=3D"color: rg=
b(128, 0, 128);">&gt;</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> C <=
span style=3D"color: rgb(128, 0, 128);">:</span> B<span style=3D"color: rgb=
(128, 0, 128);">&lt;</span>S<span style=3D"color: rgb(128, 0, 128);">&gt;</=
span> <span style=3D"color: rgb(128, 0, 128);">{</span><span style=3D"color=
: rgb(128, 0, 128);">}</span><span style=3D"color: rgb(128, 0, 128);">;</sp=
an>
<span style=3D"color: rgb(128, 0, 128);">}</span>
<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">namespace</span> =
A <span style=3D"color: rgb(128, 0, 128);">{</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</span><=
span style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color: rg=
b(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color: rg=
b(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0);">size_t</s=
pan> X<span style=3D"color: rgb(128, 0, 128);">&gt;</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> D <=
span style=3D"color: rgb(128, 0, 128);">:</span> B<span style=3D"color: rgb=
(128, 0, 128);">&lt;</span>T<span style=3D"color: rgb(128, 128, 48);">,</sp=
an>X<span style=3D"color: rgb(128, 0, 128);">&gt;</span><span style=3D"colo=
r: rgb(128, 0, 128);">{</span><span style=3D"color: rgb(128, 0, 128);">}</s=
pan><span style=3D"color: rgb(128, 0, 128);">;</span> <span style=3D"color:=
 rgb(105, 105, 105);">// Uh-oh - too many template arguments</span>
</pre><pre style=3D"color: rgb(0, 0, 0); background-image: initial; backgro=
und-position: initial; background-size: initial; background-repeat: initial=
; background-attachment: initial; background-origin: initial; background-cl=
ip: initial;"><span style=3D"color: rgb(128, 0, 128); font-family: Arial, H=
elvetica, sans-serif;">}

</span>New approach, using templates:<br></pre><pre style=3D"background-ima=
ge: initial; background-position: initial; background-size: initial; backgr=
ound-repeat: initial; background-attachment: initial; background-origin: in=
itial; background-clip: initial; color: rgb(0, 0, 0);"><span style=3D"color=
: rgb(128, 0, 0); font-weight: bold;">
</span></pre><pre style=3D"color: rgb(0, 0, 0); background-image: initial; =
background-position: initial; background-size: initial; background-repeat: =
initial; background-attachment: initial; background-origin: initial; backgr=
ound-clip: initial;"><span style=3D"color: rgb(128, 0, 0); font-weight: bol=
d;">template</span><span style=3D"color: rgb(128, 0, 128);">&lt;</span><spa=
n style=3D"color: rgb(128, 0, 0); font-weight: bold;">typename</span> T<spa=
n style=3D"color: rgb(128, 0, 128);">&gt;</span>
<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">namespace</span> =
A <span style=3D"color: rgb(128, 0, 128);">{</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> B <=
span style=3D"color: rgb(128, 0, 128);">{</span><span style=3D"color: rgb(1=
28, 0, 128);">}</span><span style=3D"color: rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(128, 0, 128);">}</span>

<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</span><s=
pan style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color: rgb=
(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color: rgb=
(128, 0, 128);">&gt;</span>
<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">namespace</span> =
A <span style=3D"color: rgb(128, 0, 128);">{</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> C <=
span style=3D"color: rgb(128, 0, 128);">:</span> B <span style=3D"color: rg=
b(128, 0, 128);">{</span><span style=3D"color: rgb(128, 0, 128);">}</span><=
span style=3D"color: rgb(128, 0, 128);">;</span>
<span style=3D"color: rgb(128, 0, 128);">}</span>

<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">template</span><s=
pan style=3D"color: rgb(128, 0, 128);">&lt;</span><span style=3D"color: rgb=
(128, 0, 0); font-weight: bold;">typename</span> T<span style=3D"color: rgb=
(128, 128, 48);">,</span> <span style=3D"color: rgb(96, 48, 0);">size_t</sp=
an> X<span style=3D"color: rgb(128, 0, 128);">&gt;</span>
<span style=3D"color: rgb(128, 0, 0); font-weight: bold;">namespace</span> =
A <span style=3D"color: rgb(128, 0, 128);">{</span>
 <span style=3D"color: rgb(128, 0, 0); font-weight: bold;">class</span> D <=
span style=3D"color: rgb(128, 0, 128);">:</span> B<span style=3D"color: rgb=
(128, 0, 128);">{</span><span style=3D"color: rgb(128, 0, 128);">}</span><s=
pan style=3D"color: rgb(128, 0, 128);">;</span> <span style=3D"color: rgb(1=
05, 105, 105);">// A&lt;T,X&gt;::B undeclared</span>
<span style=3D"color: rgb(128, 0, 128);">}

</span></pre></li><li><b>&quot;Namespaces can contain the following declara=
tions, whereas classes cannot&quot;<br></b><div style=3D"color: rgb(136, 13=
6, 136);">explicit-instantiation<br></div><div style=3D"color: rgb(136, 136=
, 136);">explicit-specialization</div><div style=3D"color: rgb(136, 136, 13=
6);">linkage-speci=EF=AC=81cation</div><div style=3D"color: rgb(136, 136, 1=
36);">namespace-de=EF=AC=81nition</div><div style=3D"color: rgb(136, 136, 1=
36);">attribute-declaration<br></div><div style=3D"color: rgb(136, 136, 136=
);">asm-de=EF=AC=81nition<br></div><div style=3D"color: rgb(136, 136, 136);=
">namespace-alias-de=EF=AC=81nition</div><div style=3D"color: rgb(136, 136,=
 136);">using-directive<br></div><div style=3D"color: rgb(136, 136, 136);">=
opaque-enum-declaration</div><br>This is something I&#39;m going to need to=
 go through with a fine-tooth comb. I may need assistance with this. <i>How=
ever, </i>should any such declaration seem incompatible with the idea of te=
mplated namespaces, it could be disabled for templated namespaces without d=
isrupting the functionality of non-templated namespaces. This may be the ca=
se with <i>asm-definition - </i>not something I have used, I must admit, bu=
t I can see how having many copies of an asm-definition might be unfortunat=
e. On the other hand, if only functions, objects, and sub-namespaces inside=
 a templated namespace are provided with templating, whilst other declarati=
ons are only declared <i>once.</i><br><br></li></ul></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2653ed1f-714b-47e9-94a2-e5aa0d6ca713%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2653ed1f-714b-47e9-94a2-e5aa0d6ca713=
%40isocpp.org</a>.<br />

------=_Part_26413_1433417922.1511834159610--

------=_Part_26412_1241295932.1511834159609--

.