How do template aliases affect template parameter deduction?

前端 未结 3 1280
情歌与酒
情歌与酒 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:19

    Imagine this:

    template  struct Foo { typedef   T type; }
    template <> struct Foo     { typedef int type; }
    
    template  using mytype = typename Foo::type;
    
    template  void f(mytype);
    

    Now if I want int n; f(n);, how could I decide whether I want T = int or T = char? The whole problem, which is unaffected by template aliases, is that you cannot deduce backwards to all the things that could possibly define something.

提交回复
热议问题