I have a little issue with removing the constness of using Templated function.
#include <iostream>
using namespace std;
template< typename T>
void fct(T& param)
{
const_cast<T>(param) = 40;
}
int _tmain(int argc, _TCHAR* argv[])
{
int x = 30;
const int cx = x;
const int& rx = x;
fct(cx);
return 0;
}
when I run this I get :
error C2440: 'const_cast' : cannot convert from 'int' to 'int'
How could I use const_cast
into my function.