C++ Quiz170 of 173
Difficulty:
⬅️ Prev: 350Quiz ID: 352Next: 354 ➡️

According to the C++23 standard, what is the output of this program?

#include <iostream>
#include <vector>

typedef std::vector<int> TVint;

int main() {
    TVint t(1);
    std::cout << (typeid(t) == typeid(std::vector<int>));
}
Hint

A typedef-name is a synonym for another type.

Reveal answer

1

Explanation

The typedef specifier provides a way for declaring a type alias. However, it does not introduce a new type-id. §[dcl.typedef]¶1 in the standard:

A name declared with the typedef specifier becomes a typedef-name. A typedef-name names the type associated with the identifier (§[dcl.decl]) or simple-template-id (§[temp.pre]); a typedef-name is thus a synonym for another type. A typedef-name does not introduce a new type the way a class declaration (§[class.name]) or enum declaration (§[dcl.enum]) does.

⬅️ Prev: 350Quiz ID: 352Next: 354 ➡️