Title
Is a typedef redeclaration allowed with a template type that might be the same?
Status
nad
Section
9.2.4 [dcl.typedef]
Submitter
Steve Adamczyk

Created on 2003-06-18.00:00:00 last changed 248 months ago

Messages

Date: 2003-10-15.00:00:00

Notes from the October 2003 meeting:

We believe that all these cases should be allowed, and that errors should be required only when an instance of the template is generated. The current standard wording does not seem to disallow such cases, so no change is required.

Date: 2003-06-18.00:00:00

Is the following valid?

  template <class T> void f(T) {
    typedef int x;
    typedef T x;
  }
  int main() {
    f(1);
  }

There is an instantiation where the function is valid. Is an implementation allowed to issue an error on the template declaration because the types on the typedef are not the same (9.2.4 [dcl.typedef])?

How about

  typedef T x;
  typedef T2 x;
?

It can be argued that these cases should be allowed because they aren't necessarily wrong, but it can also be argued that there's no reason to write things like the first case above, and if such a case appears it's more likely to be a mistake than some kind of intentional test that int and T are the same type.

History
Date User Action Args
2003-11-15 00:00:00adminsetmessages: + msg948
2003-11-15 00:00:00adminsetstatus: open -> nad
2003-06-18 00:00:00admincreate