non-type

Non type template parameters of reference

What is the use of 'non type template' parameters which are of 'reference' type? Why are such parameters also treated as 'rvalues'? template<int &n> void f(){ &n; // error } int main(){ int x = 0; f<x>(); } ...

template+floating point non type

Section 4.3 of C++ Templates states 'Not being able to use floating-point literals (and simple constant floating-point expressions) as template arguments has historical reasons.' Similarly, $14.1/7 states - "A non-type template-parameter shall not be declared to have floating point, class, or void type. [ Example...

got "cannot appear in a constant-expression" when using template

Hi , template < int > class CAT {}; int main() { int i=10; CAT<(const int)i> cat; return 0; //here I got error: ‘i’ cannot appear in a constant-expression } even int i=10; const int j=i; CAT<j> cat; //this still can not work but I have convert i to const int ,why compiler...