🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3965

Re: static members as members of a metaclass h

#3965
From: Fergus Henderson
Date: Tue, 09 Apr 1996 13:20
32 lines
2254 bytes
jgealow@mtl.mit.edu (Jeffrey C. Gealow) writes:

>In article <4jckdc$ad6@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM 
>(Steve Clamage) writes:
>
>   I believe a reasonable solution to the problem of initialization of 
>   non-local static data is not to use non-local static data!
>
>   Instead of a static data object or static class data member, use a 
>   function with a local static object.
>
>But this adds the overhead of the function call mechanism to every use 
>of the object.

A good compiler will inline the function, especially if you define
it as `inline' and put the function definition in the header file.
(If it is a non-member function, you need to declare it as `extern
inline' to ensure that you get one copy of the static object.)
Some compilers don't inline functions containing local static objects,
but it is certainly possible to do so; if you have such a compiler, you
should ask your compiler vendor to improve their compiler's inlining.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <4kd143$op9@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <4jc5lt$doh@arl-news-svc-2.compuserve.com> <4jckdc$ad6@engnews1.Eng.Sun.COM> <kywx3q1nox.fsf@gator.mit.edu>

Show Full Headers
Complete Article Headers
From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Message-ID: <4kd143$op9@mulga.cs.mu.OZ.AU>
X-Original-Date: 9 Apr 1996 06:46:27 GMT
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 09 Apr 96 13:20:29 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: static members as members of a metaclass h
Organization: Comp Sci, University of Melbourne
References: <4jc5lt$doh@arl-news-svc-2.compuserve.com>  <4jckdc$ad6@engnews1.Eng.Sun.COM> <kywx3q1nox.fsf@gator.mit.edu>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMWpkLeEDnX0m9pzZAQFR+gF/ea5RP8HK9j6j6TRfNolCA8LhTY1hHX7+
 ZUxJd7m9/3h/eBjzbmGDNrA9gXFTP39Y
 =0Pyi