Topic: class namespace


Author: lorenzo.bellotti@gmail.com
Date: Wed, 2 Jul 2014 06:42:06 -0700 (PDT)
Raw View
------=_Part_928_948481.1404308526862
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

=20

Class namespace=20


=20
 take an example of a simple class:


=20
=20
 #include <map>


 class C {

public:

typedef std::map<int,int> mymap;=20

mymap f();

class D;=20

private:

static mymap x;=20

};


 class C::D {

static mymap x;

}


=20
 // bodies=20


 C::mymap C::D::x;


 C::mymap C::f() { /*body*/ }=20


=20
 C::mymap C::x;


=20
 In the development of a bodies it's always necessary to specify the prefix=
=20
for the name of the class scoped outside the classroom


 It's correct but it's tedios,l expecially in the template developer=20


 hence the Columbus eggs, the class namspace.


 The class namespace it's =C3=A8 space for definition of names external of =
class=20
scope


 In the example the defintion of f,X,D it's wold be:


=20
 namespace class C {

mymap f() { // f body }


 mymap x;

namespace class D {

D(mymap&) { /* body */ }=20

mymap x; // D::x

};


 namespace BAD {} // wrong =E2=80=93 into a class namespace is'not possible=
 a=20
namespace definition=20


 namespace class E {} // wrong =E2=80=93 E it's not a subclass of C

}=20


=20
 An example with a template


=20
 templare <class T1,class T2,class T3>=20

class C {

public:

typedef map<int,int> mymap;=20

mymap f(const mymap&);

T1 f(const T2&,const T3&);

class D;=20

private:

static mymap x;=20

};


=20
 In the classic mode the developer it's:


 templare <class T1,class T2,class T3>=20

T1 C<T1,T2,T3>:f(const T2&,const T3&) { /* body */ }=20


 templare <class T1,class T2,class T3>=20

C<T1,T2,T3>::mymap C<T1,T2,T3>::x;


=20
 with a class namespace:


 templare <class T1,class T2,class T3>=20

namespace class C<T1,T2,T3> {

T1 f(const T2&,const T3&) { /* body */ }

mymap x;

}


=20
 And the instance a the specialization in classic mode:


 template <>

int C<int,int,int>::f(const int&,const int&) { /* body of template=20
specialization*/ }


 template=20

C<int,int,int>::mymap C<int,int,int>::x;

=20
 template=20

class C<int,int,int>; // instance the entire class=20


=20
 with the namespace class:


=20
=20
 template <> // template specialzation=20

namespace class C<int,int,int> {

int f(const int&,const int&) { /* body of template specialization*/ }=20

}


=20
 template=20

namespace class C<int,int,int> {

mymap x;

class this; // instance the entire class=20


 }


=20
=20
=20
=20

--=20

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

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

<div dir=3D"ltr">
=09
=09
=09


<p style=3D"margin-bottom: 0cm">Class namespace=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">take an example of a simple class:</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">#include &lt;map&gt;</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">class   C {</p>
<p style=3D"margin-bottom: 0cm"> public:</p>
<p style=3D"margin-bottom: 0cm">  typedef std::map&lt;int,int&gt;
mymap; </p>
<p style=3D"margin-bottom: 0cm">  mymap f();</p>
<p style=3D"margin-bottom: 0cm">  class D;=20
</p>
<p style=3D"margin-bottom: 0cm"> private:</p>
<p style=3D"margin-bottom: 0cm">  static mymap  x; </p>
<p style=3D"margin-bottom: 0cm">};</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">class C::D {</p>
<p style=3D"margin-bottom: 0cm"> static mymap  x;</p>
<p style=3D"margin-bottom: 0cm">}</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">// bodies=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">C::mymap C::D::x;</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">C::mymap  C::f() { /*body*/ }=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">C::mymap C::x;</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">In the development of a bodies it's
always necessary to specify the prefix for the name of the class
scoped outside the classroom</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">It's correct but it's tedios,l
expecially in the template developer=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">hence the  Columbus eggs, the class
namspace.</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">The class namespace it's =C3=A8 space for
definition of names external of class scope</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">In the example the defintion of f,X,D
it's wold be:</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">namespace class C {</p>
<p style=3D"margin-bottom: 0cm"> mymap f() { // f body }</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"> mymap x;</p>
<p style=3D"margin-bottom: 0cm"> namespace class D {</p>
<p style=3D"margin-bottom: 0cm">  D(mymap&amp;) { /* body */ }=20
</p>
<p style=3D"margin-bottom: 0cm">  mymap   x;     // D::x</p>
<p style=3D"margin-bottom: 0cm"> };</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"> namespace BAD {}   // wrong =E2=80=93 into=
 a
class namespace is'not possible a namespace definition=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"> namespace class E {}  // wrong =E2=80=93 E
it's not a subclass of C</p>
<p style=3D"margin-bottom: 0cm">}=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">An example with a template</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">templare &lt;class T1,class T2,class
T3&gt;=20
</p>
<p style=3D"margin-bottom: 0cm">class C {</p>
<p style=3D"margin-bottom: 0cm"> public:</p>
<p style=3D"margin-bottom: 0cm">  typedef map&lt;int,int&gt; mymap; </p>
<p style=3D"margin-bottom: 0cm">  mymap f(const mymap&amp;);</p>
<p style=3D"margin-bottom: 0cm">  T1 f(const T2&amp;,const T3&amp;);</p>
<p style=3D"margin-bottom: 0cm">  class D;=20
</p>
<p style=3D"margin-bottom: 0cm"> private:</p>
<p style=3D"margin-bottom: 0cm">  static mymap  x; </p>
<p style=3D"margin-bottom: 0cm">};</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">In the classic mode the developer it's:</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">templare &lt;class T1,class T2,class
T3&gt;=20
</p>
<p style=3D"margin-bottom: 0cm">T1 C&lt;T1,T2,T3&gt;:f(const T2&amp;,const
T3&amp;) { /* body */ } =20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">templare &lt;class T1,class T2,class
T3&gt;=20
</p>
<p style=3D"margin-bottom: 0cm">C&lt;T1,T2,T3&gt;::mymap=20
C&lt;T1,T2,T3&gt;::x;</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">with a class namespace:</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">templare &lt;class T1,class T2,class
T3&gt;=20
</p>
<p style=3D"margin-bottom: 0cm">namespace class C&lt;T1,T2,T3&gt; {</p>
<p style=3D"margin-bottom: 0cm"> T1 f(const T2&amp;,const T3&amp;) { /*
body */ }</p>
<p style=3D"margin-bottom: 0cm"> mymap  x;</p>
<p style=3D"margin-bottom: 0cm">}</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">And the instance a the specialization
in classic mode:</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">template &lt;&gt;</p>
<p style=3D"margin-bottom: 0cm">int C&lt;int,int,int&gt;::f(const
int&amp;,const int&amp;) { /* body of template specialization*/ }</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">template=20
</p>
<p style=3D"margin-bottom: 0cm">C&lt;int,int,int&gt;::mymap
C&lt;int,int,int&gt;::x;</p>
<p style=3D"margin-bottom: 0cm">=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">template=20
</p>
<p style=3D"margin-bottom: 0cm">class C&lt;int,int,int&gt;;  //
instance the entire class=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">with the namespace class:</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">template &lt;&gt;  // template
specialzation=20
</p>
<p style=3D"margin-bottom: 0cm">namespace class C&lt;int,int,int&gt; {</p>
<p style=3D"margin-bottom: 0cm"> int  f(const int&amp;,const int&amp;)
{ /* body of template specialization*/ } </p>
<p style=3D"margin-bottom: 0cm">}</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">template=20
</p>
<p style=3D"margin-bottom: 0cm">namespace class C&lt;int,int,int&gt; {</p>
<p style=3D"margin-bottom: 0cm"> mymap x;</p>
<p style=3D"margin-bottom: 0cm"> class this;  // instance the entire
class=20
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm">}</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p>
<p style=3D"margin-bottom: 0cm"><br>
</p></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_928_948481.1404308526862--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Wed, 2 Jul 2014 17:48:59 +0200
Raw View
--20cf30363b4ba24faa04fd37d469
Content-Type: text/plain; charset=UTF-8

On Wed, Jul 2, 2014 at 3:42 PM, <lorenzo.bellotti@gmail.com> wrote:

> templare <class T1,class T2,class T3>
>
> namespace class C<T1,T2,T3> {
>
> T1 f(const T2&,const T3&) { /* body */ }
>
> mymap x;
>
> }
>
>
>
I just formally proposed a very-vaguely similar kind of "grouping"
syntactic convenience in N3955 at the last meeting.  It was voted 2 for, 23
against.  I think the same sort of arguments can be made against this (not
that I personally agree with them), in that you are shifting away
information from local definitions up in the translation unit.  This makes
it easier for the writer, but harder for the reader - and for programming
in the large the reader has priority over the reader.

--

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

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On W=
ed, Jul 2, 2014 at 3:42 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:lorenz=
o.bellotti@gmail.com" target=3D"_blank">lorenzo.bellotti@gmail.com</a>&gt;<=
/span> wrote:<br>
<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 dir=3D"ltr">
=09
=09
=09


<p style=3D"margin-bottom:0cm">templare &lt;class T1,class T2,class
T3&gt;<br></p>
<p style=3D"margin-bottom:0cm">namespace class C&lt;T1,T2,T3&gt; {</p>
<p style=3D"margin-bottom:0cm"> T1 f(const T2&amp;,const T3&amp;) { /*
body */ }</p>
<p style=3D"margin-bottom:0cm"> mymap  x;</p>
<p style=3D"margin-bottom:0cm">}</p>
<p style=3D"margin-bottom:0cm"><br></p></div></blockquote><div><br></div><d=
iv>I just formally proposed a very-vaguely similar kind of &quot;grouping&q=
uot; syntactic convenience in N3955 at the last meeting. =C2=A0It was voted=
 2 for, 23 against. =C2=A0I think the same sort of arguments can be made ag=
ainst this (not that I personally agree with them), in that you are shiftin=
g away information from local definitions up in the translation unit. =C2=
=A0This makes it easier for the writer, but harder for the reader - and for=
 programming in the large the reader has priority over the reader.</div>
<div><br></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&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 />

--20cf30363b4ba24faa04fd37d469--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Wed, 2 Jul 2014 17:50:03 +0200
Raw View
--047d7b673b487790d904fd37d84f
Content-Type: text/plain; charset=UTF-8

On Wed, Jul 2, 2014 at 5:48 PM, Andrew Tomazos <andrewtomazos@gmail.com>
wrote:

> On Wed, Jul 2, 2014 at 3:42 PM, <lorenzo.bellotti@gmail.com> wrote:
>
>> templare <class T1,class T2,class T3>
>>
>> namespace class C<T1,T2,T3> {
>>
>> T1 f(const T2&,const T3&) { /* body */ }
>>
>> mymap x;
>>
>> }
>>
>>
>>
> I just formally proposed a very-vaguely similar kind of "grouping"
> syntactic convenience in N3955 at the last meeting.  It was voted 2 for, 23
> against.  I think the same sort of arguments can be made against this (not
> that I personally agree with them), in that you are shifting away
> information from local definitions up in the translation unit.  This makes
> it easier for the writer, but harder for the reader - and for programming
> in the large the reader has priority over the reader.
>
>
Sorry, the last line should of course read "the reader has priority over
the writer".

--

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

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Wed, Jul 2, 2014 at 5:48 PM, Andrew Tomazos <span dir=3D"ltr">&l=
t;<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">andrewtomazo=
s@gmail.com</a>&gt;</span> wrote:<br>
<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 dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">
<div class=3D"">On Wed, Jul 2, 2014 at 3:42 PM,  <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:lorenzo.bellotti@gmail.com" target=3D"_blank">lorenzo.bellott=
i@gmail.com</a>&gt;</span> wrote:<br>
<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 dir=3D"ltr">
=09
=09
=09


<p style=3D"margin-bottom:0cm">templare &lt;class T1,class T2,class
T3&gt;<br></p>
<p style=3D"margin-bottom:0cm">namespace class C&lt;T1,T2,T3&gt; {</p>
<p style=3D"margin-bottom:0cm"> T1 f(const T2&amp;,const T3&amp;) { /*
body */ }</p>
<p style=3D"margin-bottom:0cm"> mymap  x;</p>
<p style=3D"margin-bottom:0cm">}</p>
<p style=3D"margin-bottom:0cm"><br></p></div></blockquote><div><br></div></=
div><div>I just formally proposed a very-vaguely similar kind of &quot;grou=
ping&quot; syntactic convenience in N3955 at the last meeting. =C2=A0It was=
 voted 2 for, 23 against. =C2=A0I think the same sort of arguments can be m=
ade against this (not that I personally agree with them), in that you are s=
hifting away information from local definitions up in the translation unit.=
 =C2=A0This makes it easier for the writer, but harder for the reader - and=
 for programming in the large the reader has priority over the reader.</div=
>

<div><br></div></div></div></div></blockquote><div><br></div><div>Sorry, th=
e last line should of course read &quot;the reader has priority over the wr=
iter&quot;.=C2=A0</div></div><br></div></div>

<p></p>

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

--047d7b673b487790d904fd37d84f--

.