How do template aliases affect template parameter deduction?

前端 未结 3 1271
情歌与酒
情歌与酒 2020-12-20 13:41

In C++03, template parameter deduction does not occur in some contexts. For example:

template  struct B {};

template 
st         


        
3条回答
  •  感情败类
    2020-12-20 14:18

    I think the relevant quote in the C++ standard is 14.5.7 [temp.alias] paragraph 2:

    When a template-id refers to the specialization of an alias template, it is equivalent to the associated type obtained by substitution of its template-arguments for the template-parameters in the type-id of the alias template. [ Note: An alias template name is never deduced. — end note ]

    There is an example following the quote which effectively spells out that it is pointless to use an alias template in a function template and hoping to deduce the template argument. This apparently applies even for situation which don't involve nested types.

提交回复
热议问题