Re: C++ static integer class constants...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* John Ratliff:

> On comp.lang.c++, Victor Bazarov says my example program is well-formed
> standard C++ according to the ISO C++ standard.
>
> "Since their address is never taken, the 'foo::A' and 'foo::B' are, in
> fact, compile-time constant expressions that do not require storage.
> The objects, therefore, don't need to be defined outside of the class
> definition.

This analysis argues from the implementation, not from the standard.

The standard requires that you provide a definition if you use the
constant in a place which does not *require* a constant expression.
In other words,

  int foo[Class::static_const_member];

is fine without a definition, but

  int bar = Class::static_const_member;

is not.

It's strange and smells like a mistake in the standard.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux