From 2676073372780046340
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,cabfc5c4a464a339
X-Google-Attributes: gidf78e5,public
From: carson@gwis2.circ.gwu.edu (John Carson)
Subject: Re: Statics and in-lines
Date: 1995/04/28
Message-ID: <3nr6tu$99t@cronkite.seas.gwu.edu>#1/1
X-Deja-AN: 101764425
references: <3nb5vm$4au@cronkite.seas.gwu.edu> <D7Iv3E.Fqz@ucc.su.OZ.AU>
organization: The George Washington University, Washington DC
newsgroups: comp.std.c++

John Max Skaller (maxtal@Physics.usyd.edu.au) wrote:
: In article <3nb5vm$4au@cronkite.seas.gwu.edu>,
: John Carson <carson@gwis2.circ.gwu.edu> wrote:
: >I suspect this has been discussed before but I believe it is not valid to 
: >define an in-line function that contains a static.  Am I correct and for 
: >purposes of learning, where would one find the answer in the ARM or draft 
: >standard?

: 	It is valid to have local static variables in any function.

: 	If the function is inline or inclass, then:

: 	1) If the function has internal linkage then each translation
: 	unit has a distinct function and the local statics are distinct

: 	2) If the function has external linkage then there is only
: 	one function in any translation unit and only one static
: 	variable.

: FYI: these rules are not in the ARM. A new rule you should know
: about is that ALL non-local classes effectively have external linkage
: and ALL member functions of such classes also (effectively) have external
: linkage.

: That is, effectively linkage is "inherited" by all
: nested entities. This is NOT true for inheritance by the way,
: in fact the reverse is true: a class derived from a class
: with external linkage can have internal linkage BUT a class
: derived from a class with internal linkage must have internal
: linkage. (This can happen only if the derived class is local
: to a function)

: It isn't clear the WP correctly states these rules yet.

: --
:         JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
: 	Maxtal Pty Ltd,		    
:         81A Glebe Point Rd, GLEBE   Mem: SA IT/9/22,SC22/WG21 
:         NSW 2037, AUSTRALIA	    Phone: 61-2-566-2189
Wow,

I think it is easier to build a dummy class that contains a static and 
then make a friend function for it to accomplish the desired result.

John C.




