Re: RFC, problem with g++4
* Goswin von Brederlow:
> The proper use of this construct seems to be:
>
> template <typename T>
> struct Foo {
> static const unsigned N = T::N;
> char bar[N];
> };
>
> struct Bla {
> static const unsigned N;
> };
>
> const unsigned Bla::N = 10;
>
> int main() {
> Foo<Bla> foo;
> }
This program is ill-formed.
Bla::N is not an integral constant expression (5.19/1) and thus does
not make Foo::N an integral constant expression, either (9.4.2/4).
I will file a couple of bug reports. Some of these things might
actually undocumented G++ extensions.
> Correct me if I'm wrong but doesn't that
>
> 1.) Only move the const declaration from the template into the
> template parameter?
>
> 2.) Cause the template to have static member N in every file that uses
> the template and for every type?
>
> 3.) Cause Bla to have a static member N in every file that uses
> the template and for every type?
I don't understand these questions.
If the definition of Bla::N appears in multiple translation units, the
one definition rule is violated and the program is ill-formed.
Reply to: