Is it legal C++ to pass the address of a static const int with no definition to a template?

后端 未结 4 420
刺人心
刺人心 2021-01-15 11:53

I\'m having trouble deciding whether not this code should compile or if just both compilers I tried have a bug (GCC 4.2 and Sun Studio 12). In general, if you have a static

4条回答
  •  生来不讨喜
    2021-01-15 11:57

    Interesting, it compiled fine for me on VS 2008. I kind of assumed that the error came from the typedef because at compile time when it tries to compile 'B' with &x as the template type it doesn't then know where the address of x will be. Still... it compiles and gives a reasonable output.

提交回复
热议问题