Created on 2019-02-06.00:00:00 last changed 24 months ago
Notes from the July, 2019 meeting
CWG felt that the example should be allowed if the parameter type is a pointer to object type (thus prohibiting void*).
Consider an example like:
template <const char *N> struct A { static const int val; }; template <const char *N> const int A<N>::val = 0; static const char c[2] = ""; int main() { A<c> a; return A<c>::val; }
Formally, this appears to violate the prohibition of using the address of a subobject as a non-type template argument, since the array reference c in the argument decays to a pointer to the first element of the array. However, at least some implementations accept this example, and at least conceptually the template argument designates the complete object. Should an exception be made for the result of array decay?
See also issue 2043.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-11-25 07:42:21 | admin | set | messages: + msg7064 |
2022-11-25 07:42:21 | admin | set | status: open -> drafting |
2019-02-06 00:00:00 | admin | create |