what's the purpose of typename assignment inside templates

前端 未结 6 936
后悔当初
后悔当初 2021-01-02 08:07

I have come across this piece of code (I\'m trying to include all details in case I\'m missing something):

template< typename TYPE = TYPE_with_an_arbitrar         


        
6条回答
  •  猫巷女王i
    2021-01-02 08:20

    1. The "assignments" inside the template parameter list are default parameters, just as in function parameter lists. That means in your example, Foo<> is the same as Foo, and Foo is the same as Foo.
    2. It will not be used in your examples. You don't use Foo at all, and the parameters of baz and bar will always be deduced by the compiler from the given arguments.

提交回复
热议问题