Hi, I think there is a small typo in the answer to question №124. At the end of second paragraph, it is written:
... so the default arguments of C (i.e. T = B) are applied and C<B>::f() is called inside g().
I think you meant X<B>::f() instead of C<B>::f(), as C is the argument and X is the actual struct containg f(). I propose the following revision of the second paragraph for better accuracy:
In this code snippet, the template template-parameter is C, and the scope of C is the function template g(). Therefore, the default template argument for C (which is T = B) is applied. This means that when g<X>() is called, it is equivalent to calling g<X<B>>(), which in turn calls X<B>::f(). As X<B>::f() is specialized to print 2, the output of the program is 2.
Hi, I think there is a small typo in the answer to question №124. At the end of second paragraph, it is written: ... so the default arguments of C (i.e. T = B) are applied and
C<B>::f()
is called inside g().I think you meant
X<B>::f()
instead ofC<B>::f()
, asC
is the argument andX
is the actual struct containgf()
. I propose the following revision of the second paragraph for better accuracy:In this code snippet, the template template-parameter is
C
, and the scope ofC
is the function templateg()
. Therefore, the default template argument forC
(which isT = B
) is applied. This means that wheng<X>()
is called, it is equivalent to callingg<X<B>>()
, which in turn callsX<B>::f()
. AsX<B>::f()
is specialized to print 2, the output of the program is 2.