Differences between template specialization and overloading for functions?

前端 未结 5 1691
误落风尘
误落风尘 2020-12-08 08:24

So, I know that there is a difference between these two tidbits of code:

template 
T inc(const T& t)
{
    return t + 1;
}

template &l         


        
5条回答
  •  星月不相逢
    2020-12-08 08:51

    AFAIK there is no functional difference. All I can add is that if you have both a template function specialisation and an ordinary function defined then there is no overload ambiguity as the ordinary function is favoured.

提交回复
热议问题