“template<>” vs “template” without brackets - what's the difference?

后端 未结 2 1645
情话喂你
情话喂你 2020-12-02 15:16

Suppose I\'ve declared:

template  void foo(T& t);

Now, what is the difference between

template <&         


        
2条回答
  •  天涯浪人
    2020-12-02 15:46

    template <> void foo(int& t); declares a specialization of the template, with potentially different body.

    template void foo(int& t); causes an explicit instantiation of the template, but doesn't introduce a specialization. It just forces the instantiation of the template for a specific type.

提交回复
热议问题