как функция дедукции тип шаблона работает, когда тип параметра является константой именующее ссылка против неконстантной ссылки именующее в c 11


template<typename T>void fun(T& param) // param is a reference{   T abc;   abc=1;//cannot change abc value because T is deduced as const int//It gives compilation error because T is deduced as const int       }template<typename T>void fun1(const T& param) // param is a reference{   T abc;   abc=1;//can change abc value because T is deduced as int//why T is deduced int here}int main(){int x = 2; // x is an intconst int cx = x; // cx is a const intconst int& rx = x; // rx is a reference to x as a const intfun(x); // T is int, param's type is int&fun(cx); // T is const int, param's type is const int&fun(rx); // T is const int,param's type is const int&fun1(x); // T is int, param's type is int&fun1(cx); // T is int, param's type is const int&fun1(rx); // T is int,param's type is const int&return 0;}
updated
  • Why const int is not deduced for T in case of fun1 template function(when function template parameter type is const lvalue reference) even const int cx and const int& rx is passed while instantiation but const int(T) type is deduced for fun(function template)?
  • Does T type deduction is depend on function template param(parameter) type.