Can one use a not const variable with nullptr value as a non-type argument of some template?
For example:
template
int v = 0;
int main() {
auto nil = nullptr;
return v;
}
I see that the program is accepted by both GCC and Clang. But other compilers do not agree.
MSVC:
error C2971: 'v': template parameter 'P': 'nil': a variable with non-static storage duration cannot be used as a non-type argument
EDG:
error: argument of type "std::nullptr_t" is incompatible with template parameter of type "int *"
Even if I write template EDG still dislikes it:
error: expression must have a constant value
Which implementation is correct?