🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Static const data member initializers

#3708
From: Wil Evers
Date: Mon, 18 Mar 1996 16:41
38 lines
1996 bytes
The DWP, section 9.5.2. [class.static.data], clause 4, says:

`If a static data member is of const integral or const enumeration type,
its declaration in the class definition can specify a constant-initializer
which shall be an integral constant expression (5.19). In that case, the
member can appear in integral constant expressions within its scope. The
member shall still be defined in a namespace scope and definition of the
member in namespace scope shall not contain an initializer.'

Does anyone know the rationale behind requiring a definition of a static
const data member that has been declared with an initializer? I mean, if I
write:

        // header file

        class X { static const int bufSize = 42; };

then why should I be required to write

        // some translation unit

        const int X::bufSize;

It seems to me that interpreting bufSize's declaration-with-initializer in
the class definition as a definition in class scope with internal linkage
(analogous to an inline member function) would make more sense.

Thanks in advance,

- Wil

Wil Evers, <wil@ittpub.nl>
---
[ 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: <0099F84782C14100.3D6072A5@ittpub.nl>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back

Show Full Headers
Complete Article Headers
From: "Wil Evers" <wil@ittpub.nl>
Message-ID: <0099F84782C14100.3D6072A5@ittpub.nl>
X-Original-Date: Mon, 18 Mar 96 11:35:45 WET
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 18 Mar 96 16:41:21 GMT
Approved: fjh@cs.mu.oz.au
Organization: -
Newsgroups: comp.std.c++
Subject: Static const data member initializers
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMU2SROEDnX0m9pzZAQEuTAF/WeEylqrIY6g40JukFcDnQJ9oRlLBMmBl
 XAxgv8Nr1O4IxB39iH+R0ufubQSxXuAK
 =yi94