I’ve come across some C++ code that has the following:
typedef Request Request;
Is this just a no-op or does this typedef actual have an effect, and if so, what effect does it have?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can read all rules relative to typedef specifier for C++2003 ANSI ISO IEC 14882 2003 in section 7.1.3. In 7.1.3, 2) it have been said the identity typedef is allowed if the name already refers to some type.
This is legal:
And that it is not:
The standard has a specific example relating to this. C++2003, §7.1.3/2:
In 7.1.3, 3) it have been said that use typedef to redefine type to alias to another type is prohibited