The topic ‘USE NON-CONSTANT LITERALS TO PASS CONSTANT REFERENCES, PART 1’ is interesting. But don’t forget that when you are writing your own library that you can make it so that your callers don’t have do that. Here is an example:-
#include
template
class cS
{
public:
T fOutX(T&);
T fOutX(const T& iaX);
};
void main()
{
int iX = 125;
cS
csY.fOutX(31);
csY.fOutX(iX);
}
template
T cS
{
std::cout << iaX << std::endl;
return iaX;
}
template
T cS
{
T iX = iaX;
return fOutX(iX);
}
If you see what I mean.