C++函數模板參數推斷

C++引用類型的模板形參推斷出的類型會包含const屬性。模板

class

template<typename Type>
void Fun(Type &arg)
{
    //do something
}引用

 

template<typename Type>
void Fun2(const Type &arg)
{
    //do something
}di

const int i =0;co

Fun(i);    //Type 是 const int 類型void

Fun2(i);    //Type是intleixingconst

相關文章
相關標籤/搜索