Topic: Are T& and T the same from template point of view?
Author: boukanov@sentef1.fi.uib.no (Igor Boukanov)
Date: 1996/04/09 Raw View
Consider the following code example:
#include<iostream.h>
template<class T> void incr(T t) { ++t; }
typedef int& rint;
void main() {
int i = 0;
incr(rint(i)); // Atemption to use 'template void incr<rint>(rint)'
cout << i << '\n';
}
I compiled it by g++ 2.7.2 and the program printed 0. Is this right from
the standard point of view and call 'incr((int&)i)' should always use
'template void incr<int>(int)' instead of 'template void incr<int&>(int&)' ?
--
Regards, Igor Boukanov.
igor.boukanov@fi.uib.no
http://www.fi.uib.no/~boukanov/
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]