220 4168 <CAE1+XsbjYX127-K_UcPZVfjHoFFweEkzZXvx7VmC1hjGxvw41A@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Hariharan Subramanian <tohari@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A cleaner way to define nested class/structure
Date: Thu, 2 May 2013 11:11:32 +0530
Lines: 244
Approved: news@gmane.org
Message-ID: <CAE1+XsbjYX127-K_UcPZVfjHoFFweEkzZXvx7VmC1hjGxvw41A@mail.gmail.com>
References: <27175469-a158-4bc1-9f30-66e3a647e931@isocpp.org>
	<CAGqM8fbzQuTd+udZRrrUoGLXtgm+RuP8pSYPv=bBDpxMxSNmMA@mail.gmail.com>
	<CAOHCbivK_6fqJFb+Zgx2Y=6_zOuONSceijG0JvB8uwunBc1MDg@mail.gmail.com>
	<CAGqM8faHKXrrf6pp+ZULVLTewZbb52xRz48YToheakku-AqjZQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7b3a7d92d26eb404dbb5afde
X-Trace: ger.gmane.org 1367473295 22755 80.91.229.3 (2 May 2013 05:41:35 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 2 May 2013 05:41:35 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCJZFFHTQQIBBDPZQ6GAKGQEID32WCA@isocpp.org Thu May 02 07:41:34 2013
Return-path: <std-proposals+bncBCJZFFHTQQIBBDPZQ6GAKGQEID32WCA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f69.google.com ([209.85.215.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCJZFFHTQQIBBDPZQ6GAKGQEID32WCA@isocpp.org>)
	id 1UXmGs-0005tQ-9V
	for gclcip-std-proposals@m.gmane.org; Thu, 02 May 2013 07:41:34 +0200
Original-Received: by mail-la0-f69.google.com with SMTP id er20sf342708lab.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 01 May 2013 22:41:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:x-beenthere:x-received:received-spf:mime-version
         :x-received:in-reply-to:references:date:message-id:subject:from:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-google-group-id:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=8t+tA0WAhrgIohnXYxhAzEKLpn9ogF3AsQUDbPatTC4=;
        b=uq0Pfbcs/nb6PWfmdcmf8/ENQcwKW6JDw2NOSFC9jgjOm61OuVRsD55Mz3A+9BBbvC
         bWme6oKI3P658/GSugMg217tB/midvdVwke+MbHA73JWSeg771OVC/mGhoh3fCADkDB4
         cS/8BLzTQU3kn+UuSomm57abWvx86Zd61uhmIC32MngfKMaKDgF/GIc4vEF9TCfBFAuy
         DI+KHoRxbcAddFn2+22kV9KyNeTRXcoH9EZN1dEhfIuTaBbpjrFEpVnldQAe9oDiG0Au
         PapXZRcDb74SDCdUtlaYGpvVSeAVPqKlhS6OOrr6mMZiTZRYFFlmt9J0zr/FsreoHRnD
  
X-Received: by 10.112.73.7 with SMTP id h7mr5657437lbv.0.1367473293935;
        Wed, 01 May 2013 22:41:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.2.65 with SMTP id 1ls98229las.27.gmail; Wed, 01 May 2013
 22:41:32 -0700 (PDT)
X-Received: by 10.152.4.40 with SMTP id h8mr1922817lah.34.1367473292448;
        Wed, 01 May 2013 22:41:32 -0700 (PDT)
Original-Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171])
        by mx.google.com with ESMTPS id qg10si837527lbb.275.2013.05.01.22.41.32
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 01 May 2013 22:41:32 -0700 (PDT)
Received-SPF: pass (google.com: domain of tohari@gmail.com designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171;
Original-Received: by mail-lb0-f171.google.com with SMTP id u10so177718lbi.2
        for <std-proposals@isocpp.org>; Wed, 01 May 2013 22:41:32 -0700 (PDT)
X-Received: by 10.112.145.230 with SMTP id sx6mr2088419lbb.49.1367473292208;
 Wed, 01 May 2013 22:41:32 -0700 (PDT)
Original-Received: by 10.112.33.177 with HTTP; Wed, 1 May 2013 22:41:32 -0700 (PDT)
In-Reply-To: <CAGqM8faHKXrrf6pp+ZULVLTewZbb52xRz48YToheakku-AqjZQ@mail.gmail.com>
X-Original-Sender: tohari@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of tohari@gmail.com designates 209.85.217.171 as permitted sender)
 smtp.mail=tohari@gmail.com;       dkim=pass header.i=@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4168
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4168>

--047d7b3a7d92d26eb404dbb5afde
Content-Type: text/plain; charset=ISO-8859-1

Iteration 2:

class Outer;

class Outer::Inner1 {
      int i;
};

Outer::Inner1 *i1;
//The above should result in compilation error. Because we do not know yet
if Inner1 is private or public
//even though we are just declaring a pointer. It should wait till we
define the Outer class.

class Outer {
public:
    class Inner1;  //non-declaration of this should be a compilation error
    class Inner2;

private:
   Inner1 inner1;   //No issues
   Inner2 *inner2;  //No issues
};

class Outer::Inner2 {
   int j;
};

Outer::Inner1 *i1; //No compilation error because we know that it's public

--------

Because Inner1 is usable outside only after the Outer class is defined
there should be no other change to the language specification.

Regards,
Hariharan S



On Tue, Apr 30, 2013 at 11:19 PM, Lawrence Crowl <crowl@googlers.com> wrote:

> On Apr 29, 2013 Lawrence Crowl <crowl@googlers.com> wrote:
> > Why isn't the following solution sufficient?
> >
> > class Outer {
> >   class Inner1 {
> >     int i1;
> >   };
> >   class Inner2;
> >   Inner1 inner1;
> >   Inner2 *inner2;
> > };
> >
> > class Outer::Inner2 {
> >   int i2;
> > };
>
> On Apr 29, 2013 Hariharan Subramanian <tohari@gmail.com> wrote:
> > It is sufficient but I think it is incomplete. I am able to define
> > a nested class outside as long as I have a pointer/reference
> > variable. This proposal completes it by giving the ability to
> > define the nested class outside even if we have an object. This
> > improves readability. This is as good as (or as bad as) the
> > existing one.
>
> On 4/30/13, Tony V E <tvaneerd@gmail.com> wrote:
> > It isn't very nice when Inner1 is large.
> >
> > Same with inline member functions - you can define them inside the
> > class, but sometimes it is nicer to define them after the class
> > (yet still in the header, still inline).  The only difference with
> > inner classes would be that you would need to define them first.
> >
> > You see similar things in boost libraries that use the
> > boost::detail namespace.  (There are other reasons to put stuff
> > in boost::detail, inner classes is just one.)
>
> Okay, so you two have two reasons, useful generality and readability.
> Now we need a discussion of any potential language ambiguities, the
> costs of implementation, and eventually wording changes to the
> standard.  All of this should be collected into a formal paper for
> a meeting.  The next one is in Chicago this fall, but the committee
> might be extra busy getting C++14 out, so were I you, I would shoot
> for the meeting after that.
>
> --
> Lawrence Crowl
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/l865qYE3Wa8/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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/?hl=en.
>
>
>

-- 

--- 
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/?hl=en.



--047d7b3a7d92d26eb404dbb5afde
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Iteration 2:<div><br></div><div style>class Outer;</div><d=
iv style><br></div><div style>class Outer::Inner1 {</div><div style>=A0 =A0=
 =A0 int i;</div><div style>};</div><div style><br></div><div style>Outer::=
Inner1 *i1;</div>
<div style>//The above should result in compilation error. Because we do no=
t know yet if Inner1 is private or public</div><div style>//even though we =
are just declaring a pointer. It should wait till we define the Outer class=
..</div>
<div style><br></div><div style>class Outer {</div><div style>public:</div>=
<div style>=A0 =A0 class Inner1; =A0//non-declaration of this should be a c=
ompilation error</div><div style>=A0 =A0 class Inner2;</div><div style><br>=
</div>
<div style>private:</div><div style>=A0 =A0Inner1 inner1; =A0 //No issues</=
div><div style>=A0 =A0Inner2 *inner2; =A0//No issues</div><div style>};</di=
v><div style><br></div><div style>class Outer::Inner2 {</div><div style>=A0=
 =A0int j;</div>
<div style>};</div><div style><br></div><div style>Outer::Inner1 *i1; //No =
compilation error because we know that it&#39;s public</div><div style><br>=
</div><div style>--------</div><div style><br></div><div style>Because Inne=
r1 is usable outside only after the Outer class is defined there should be =
no other change to the language specification.</div>
<div style><br></div><div style>Regards,</div><div style>Hariharan S</div><=
div style><br></div></div><div class=3D"gmail_extra"><br><br><div class=3D"=
gmail_quote">On Tue, Apr 30, 2013 at 11:19 PM, Lawrence Crowl <span dir=3D"=
ltr">&lt;<a href=3D"mailto:crowl@googlers.com" target=3D"_blank">crowl@goog=
lers.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im">On Apr 29, 2013 Lawrence C=
rowl &lt;<a href=3D"mailto:crowl@googlers.com">crowl@googlers.com</a>&gt; w=
rote:<br>

&gt; Why isn&#39;t the following solution sufficient?<br>
&gt;<br>
&gt; class Outer {<br>
&gt; =A0 class Inner1 {<br>
&gt; =A0 =A0 int i1;<br>
&gt; =A0 };<br>
&gt; =A0 class Inner2;<br>
&gt; =A0 Inner1 inner1;<br>
&gt; =A0 Inner2 *inner2;<br>
&gt; };<br>
&gt;<br>
&gt; class Outer::Inner2 {<br>
&gt; =A0 int i2;<br>
&gt; };<br>
<br>
</div><div class=3D"im">On Apr 29, 2013 Hariharan Subramanian &lt;<a href=
=3D"mailto:tohari@gmail.com">tohari@gmail.com</a>&gt; wrote:<br>
&gt; It is sufficient but I think it is incomplete. I am able to define<br>
&gt; a nested class outside as long as I have a pointer/reference<br>
&gt; variable. This proposal completes it by giving the ability to<br>
&gt; define the nested class outside even if we have an object. This<br>
&gt; improves readability. This is as good as (or as bad as) the<br>
&gt; existing one.<br>
<br>
</div><div class=3D"im">On 4/30/13, Tony V E &lt;<a href=3D"mailto:tvaneerd=
@gmail.com">tvaneerd@gmail.com</a>&gt; wrote:<br>
&gt; It isn&#39;t very nice when Inner1 is large.<br>
&gt;<br>
&gt; Same with inline member functions - you can define them inside the<br>
&gt; class, but sometimes it is nicer to define them after the class<br>
&gt; (yet still in the header, still inline). =A0The only difference with<b=
r>
&gt; inner classes would be that you would need to define them first.<br>
&gt;<br>
&gt; You see similar things in boost libraries that use the<br>
&gt; boost::detail namespace. =A0(There are other reasons to put stuff<br>
&gt; in boost::detail, inner classes is just one.)<br>
<br>
</div>Okay, so you two have two reasons, useful generality and readability.=
<br>
Now we need a discussion of any potential language ambiguities, the<br>
costs of implementation, and eventually wording changes to the<br>
standard. =A0All of this should be collected into a formal paper for<br>
a meeting. =A0The next one is in Chicago this fall, but the committee<br>
might be extra busy getting C++14 out, so were I you, I would shoot<br>
for the meeting after that.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Lawrence Crowl<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Goog=
le Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/l865qYE3Wa8/unsubscribe?hl=3Den" target=
=3D"_blank">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/l8=
65qYE3Wa8/unsubscribe?hl=3Den</a>.<br>

To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-proposals+unsubscrib=
e@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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
<br>
<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--047d7b3a7d92d26eb404dbb5afde--

.
