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