In your template you say that you want to the compiler that you have a function that get an editable reference to type T and return an editable reference to that type, so you can use it as : char c; read( c ); but you can't use it as read( char() ), since char() is not editable(l-value), since you can't use it in left side of equal operator: char() = 3 is invalid. If you don't want to change input you can have something like:
template< class T >
T read( const T& val ) {
// do something with val and return a T
return val;
}
then you can call it as :
read( char() );
read (char)1 );
char c = read( (char)2 );
read( c );
and if you want a default value then it is just as simple as previous example:
template< class T >
T read( const T& val = T() ) {
// do something with val and return a T
return val;
}
and then you are able to call char c = read<char>()