You've answered 0 of 171 questions correctly. (Clear)

WARNING: This question has been retracted, and should not be part of new quizzes. You're on this page because you're taking an old quiz which includes this question, or have followed an old link.

Reason for retraction:

The standard is unclear about this, and does not reflect CWG's intentions. See CppQuiz issue 114 for a discussion.

To get past this question, enter 21 for the output.

Question #117 Difficulty: 3

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

    #include <iostream>

template <template <typename> class>
struct X {
  X() { std::cout << "1"; }
};

template <typename>
struct Y {};

template <typename T>
using Z = Y<T>;

template <>
struct X<Y> {
  X() { std::cout << "2"; }
};

int main() {
  X<Y> x1;
  X<Z> x2;
}

Hint:

Is a template alias a new family of types?

Answer:

Problems? View a hint or try another question.

I give up, show me the answer (make 3 more attempts first).

Mode : Training

You are currently in training mode, answering random questions. Why not Start a new quiz? Then you can boast about your score, and invite your friends.

Contribute

Create your own!

Android app

Get Sergey Vasilchenko's CppQuiz Android app.

C++ Brain Teasers

Get the book, support the site! C++ Brain Teasers cover