Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6705

Re: Does friendship extend to inner classes?

From Kai-Uwe Bux <jkherciueh@gmx.net>
Newsgroups comp.lang.c++
Subject Re: Does friendship extend to inner classes?
Followup-To comp.lang.c++
Date 2011-06-13 18:46 +0200
Organization University of Bielefeld
Message-ID <it5f3n$911$1@hoshi.visyn.net> (permalink)
References <4df25dc2$0$2869$7b1e8fa0@news.nbl.fi> <it39ra$m54$1@hoshi.visyn.net> <4df60094$0$2839$7b1e8fa0@news.nbl.fi>

Followups directed to: comp.lang.c++

Show all headers | View raw


Juha Nieminen wrote:

> Kai-Uwe Bux <jkherciueh@gmx.net> wrote:
>> As one can see from the example, C++ is changing in this regard. That
>> could explain your observation that compilers disagree on this one.
> 
>   I suppose this means that, technically speaking, gcc (and apparently
> newer versions of Visual Studio) are breaking the standard when they are
> compiling in C++98/03 compatibility mode (ie. with no C++1x extensions
> enabled)?
[...]

I am not sure whether the situation is all that clear cut.

You snipped the quotes from the standard and the draft. Let me re-quote the 
normative parts:

Standard [11.4/2]:

  Declaring a class to be a friend implies that the names of private and 
  protected members from the class granting friendship can be accessed in   
  declarations of members of the befriended class. [Note: ... ]

Draft n3291 [11.3/2]:

  Declaring a class to be a friend implies that the names of private and 
  protected members from the class granting friendship can be accessed in 
  the base-specifiers and member declarations of the befriended class.
  [ Example: ... ]

As you can see, the normative relevant wording has _not_ changed with 
respect to visibility of names in nested classes. Aparently, the committee 
is of the opinion that the non-normative note in the C++03 standard was 
errorneous. Hence, one can argue, g++ and newer versions of Visual Studio 
are correct in _not_ rejecting your code even in strict c++03 mode; it was a 
bug in the standard and not in the compilers.


Best,

Kai-Uwe Bux

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Does friendship extend to inner classes? Juha Nieminen <nospam@thanks.invalid> - 2011-06-10 18:09 +0000
  Re: Does friendship extend to inner classes? Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-10 13:04 -0700
    Re: Does friendship extend to inner classes? Juha Nieminen <nospam@thanks.invalid> - 2011-06-11 04:45 +0000
      Re: Does friendship extend to inner classes? Geoff <geoff@invalid.invalid> - 2011-06-12 10:53 -0700
  Re: Does friendship extend to inner classes? Ruben Safir <mrbrklyn@panix.com> - 2011-06-11 20:41 +0000
    Re: Does friendship extend to inner classes? Juha Nieminen <nospam@thanks.invalid> - 2011-06-12 14:10 +0000
    Re: Does friendship extend to inner classes? Werner <werasm@gmail.com> - 2011-06-13 03:51 -0700
  Re: Does friendship extend to inner classes? Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-12 23:01 +0200
    Re: Does friendship extend to inner classes? "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-12 23:31 +0200
    Re: Does friendship extend to inner classes? Juha Nieminen <nospam@thanks.invalid> - 2011-06-13 12:20 +0000
      Re: Does friendship extend to inner classes? Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-13 18:46 +0200

csiph-web