I don't have a copy of the standard available, so I'm not going to add an answer, but I'm very sure that it allows struct and class to be interchanged. Visual Studio won't emit a warning and this will compile if you disable extensions and lower the warning level. Likewise, gcc with all the flags (wall, ansi, pedantic, etc) won't complain. It may cause issues with linkage, though I'm not sure if this applies to 2010.
–
Collin DauphineeFeb 20 '12 at 23:51

2 Answers
2

First off, here is the answer to 2. taken from 14.5.1 [temp.class] paragraph 4:

In a redeclaration, partial specialization, explicit specialization or explicit instantiation of a class template, the class-key shall agree in kind with the original class template declaration.

However, struct and class are referring to the same class-key according to 7.1.6.3 [dcl.type.elab] paragraph 3 last sentence:

The class-key or enum keyword present in the elaborated-type-specifier shall agree in kind with the declaration to which the name in the elaborated-type-specifier refers. [...] Thus, in any elaborated-type-specifier, the enum keyword shall be used to refer to an enumeration, the union class-key shall be used to refer to a union, and either the class or struct class-key shall be used to refer to a class declared using the class or struct class-key.

Trying g++, clang, and EDG all agree that it is possible to specialize a template declared as struct as a class. However, clang warns about having changed from struct to class or vice versa. Based on this, the standard library is free to choose whatever keyword it sees fit for the definition. Obviously, if the compiler rejects the code as a result something is seriously broken but I'd think it is the compiler rather than the library which is at error in this case.

Good answer. I added the first part of the paragraph to the second quote, which explains a bit more what the "shall agree in kind" from the first quote means, which I didn't realize immediately.
–
Christian RauFeb 21 '12 at 2:07

For 2: Don't worry, it shouldn't result in any weird behavior. Just be careful with the scopes of functions that you define. As for the warning, it is actually pretty general (i.e. not especially made for templates), so I wouldn't care about it much.

Edit: See also the answer to this question, which basically says that it doesn't make any difference in the standard, but some compilers may behave strangely.