220 4301 <CAGqM8fbD7_jfwi_rViz32XE9CVcZd4bSe4GiE37hOk5Exu-XFA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Lawrence Crowl <crowl@googlers.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A cleaner way to define nested class/structure
Date: Tue, 7 May 2013 11:52:49 -0700
Lines: 139
Approved: news@gmane.org
Message-ID: <CAGqM8fbD7_jfwi_rViz32XE9CVcZd4bSe4GiE37hOk5Exu-XFA@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>
	<CAE1+XsbjYX127-K_UcPZVfjHoFFweEkzZXvx7VmC1hjGxvw41A@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: ger.gmane.org 1367952777 26320 80.91.229.3 (7 May 2013 18:52:57 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 7 May 2013 18:52:57 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCY3D77DYUDBBA43UWGAKGQE25EVNXI@isocpp.org Tue May 07 20:52:58 2013
Return-path: <std-proposals+bncBCY3D77DYUDBBA43UWGAKGQE25EVNXI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ve0-f197.google.com ([209.85.128.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCY3D77DYUDBBA43UWGAKGQE25EVNXI@isocpp.org>)
	id 1UZn0O-0007zC-Lq
	for gclcip-std-proposals@m.gmane.org; Tue, 07 May 2013 20:52:52 +0200
Original-Received: by mail-ve0-f197.google.com with SMTP id jz10sf1236336veb.4
        for <gclcip-std-proposals@m.gmane.org>; Tue, 07 May 2013 11:52:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlers.com; s=googlers;
        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=eXURiLgUXFoX6vv/NHo/gEVrBN/nG6e40ytq28EokFM=;
        b=IkeOO1L+GQ1u3TEQRYXGhDIOdEHH/uRqL7Py1RBqt9fHquXFsCGvdLZM+Ygt3fBOVH
         93ZfkGzbTDSacF0eBxmWBYjbN4EcnFQ1vmAsyvHMfFXLnxaLQoXZhJcQdFb+dCJUteur
         LKNwjtg6XAcXDhsAidc6mhA9Wcdg6OmzF3b30=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.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-gm-message-state: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=eXURiLgUXFoX6vv/NHo/gEVrBN/nG6e40ytq28EokFM=;
        b=kVNP3LxmdYp1JJaLjphH0/h3nwSk2zDWJrS9a1PFGwH7ICDDDqJosDJkeTSLuub6ng
         icnObyTDZc2GEvXbI5E3PfS1QuAtUltkpQ4H+53UHjZe7pGOKx4PFLJXGYbOZ2+mKnnd
         DgOgEvJlUhSfW9KhW3710jlpcpNLYeoww9l+xpFu5n7mWM/fRVRp0XBQQdFHvd/M5p/E
         TOfA92MIdEEkEB2F1gsNcRSNrxy351NDINtlnijQfdDVA1LWlnOxlofA4toXq6MjIwFT
         M2LZ0vjd7KMNoHEMNKUYYgLTfw0eDMQ 
X-Received: by 10.236.140.99 with SMTP id d63mr2120703yhj.6.1367952771733;
        Tue, 07 May 2013 11:52:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.14.9 with SMTP id l9ls523183qec.97.gmail; Tue, 07 May 2013
 11:52:50 -0700 (PDT)
X-Received: by 10.49.71.165 with SMTP id w5mr2693944qeu.36.1367952770686;
        Tue, 07 May 2013 11:52:50 -0700 (PDT)
Original-Received: from mail-qa0-x22b.google.com (mail-qa0-x22b.google.com [2607:f8b0:400d:c00::22b])
        by mx.google.com with ESMTPS id w8si18924014qag.88.2013.05.07.11.52.49
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 07 May 2013 11:52:49 -0700 (PDT)
Received-SPF: pass (google.com: domain of crowl@google.com designates 2607:f8b0:400d:c00::22b as permitted sender) client-ip=2607:f8b0:400d:c00::22b;
Original-Received: by mail-qa0-f43.google.com with SMTP id bs12so2309636qab.9
        for <std-proposals@isocpp.org>; Tue, 07 May 2013 11:52:49 -0700 (PDT)
X-Received: by 10.49.85.131 with SMTP id h3mr2704733qez.42.1367952769437; Tue,
 07 May 2013 11:52:49 -0700 (PDT)
Original-Received: by 10.229.197.13 with HTTP; Tue, 7 May 2013 11:52:49 -0700 (PDT)
In-Reply-To: <CAE1+XsbjYX127-K_UcPZVfjHoFFweEkzZXvx7VmC1hjGxvw41A@mail.gmail.com>
X-Gm-Message-State: ALoCoQlCDUKjBQpDRcv8Mpk40G9lBdUV+22R8XDgEwvU9gBPkqzK28yDG+fo9YC9IpaG1dQlG70N3bySk2PD7cFtRfxwnlRlRUkwI6AIOhf8utbCfs1JkN8jc2mQm5x4nNLKLCtgH53GeQCjZcl0TGzlciTKfinNzZxmIFgiFeqhFtOVtGD6xhstMdyB+mfXOeqS2Ozn3DVa
X-Original-Sender: crowl@googlers.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of crowl@google.com designates 2607:f8b0:400d:c00::22b as permitted
 sender) smtp.mail=crowl@google.com;       dkim=pass header.i=@googlers.com;
       dmarc=pass (p=NONE dis=none) d=googlers.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:4301
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4301>

On 5/1/13, Hariharan Subramanian <tohari@gmail.com> wrote:
> 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.

That is a good improvement.

>
> 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.
>
>
>


-- 
Lawrence Crowl

-- 

--- 
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.



.
