5

I have a question specifically about clang's behavior when we declare a variable template within a class scope. What the Standard stated about this is (N4296::14/1 [temp]):

A variable template at class scope is a static data member template.

I thought that any variable template (static and non-static) is going to be declared as just static data member template. But actually, clang prevent declaring non-static data member template ever.

template <class U>
struct A
{
    template <class T, const T& t>
    int a; //non-static data member template
};

int main(){}

DEMO

My question is how the rule actually should be treated. Does it mean a compiler should declare any data member template as a static data template member implicitly?

Piotr Skotnicki
  • 46,953
  • 7
  • 118
  • 160
  • I don't understand the meaning of your last question, specifically the "implicitely ". Do you mean to ask if the rule says that the compiler should consider implicitely (ie without explicit instructions) declarations of variable templates to be `static`? – didierc Feb 15 '15 at 11:09
  • 1
    http://stackoverflow.com/questions/21474111/variable-template-at-class-scope/21482264?noredirect=1#comment32627331_21482264 – T.C. Feb 15 '15 at 11:43
  • @T.C. Interesting, if the comitee decided to make the static keyword neccesary required why didn't they add a note about that explicitly? –  Feb 15 '15 at 16:23
  • Guess they haven't gotten to it yet. Given the number of open issues on variable templates, I'm not surprised. – T.C. Feb 15 '15 at 16:25

0 Answers0