Article View: comp.std.c++
Article #3973Are T& and T the same from template point of view?
From: Igor Boukanov
Date: Tue, 09 Apr 1996 17:21
Date: Tue, 09 Apr 1996 17:21
24 lines
1552 bytes
1552 bytes
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 ]
Technical Details
Message-ID:
<4ke65f$b2l@ugress.uib.no>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backShow Full Headers
Complete Article Headers
From: boukanov@sentef1.fi.uib.no (Igor Boukanov) Message-ID: <4ke65f$b2l@ugress.uib.no> X-Original-Date: 9 Apr 1996 17:18:39 GMT Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 09 Apr 96 17:21:08 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Are T& and T the same from template point of view? Organization: Fysisk institutt, Universitetet i Bergen Keywords: C++, template X-Newsreader: TIN [version 1.2 PL2] X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMWqci+EDnX0m9pzZAQFAnwF8CAIn75RsOb04yvvFnRmpGpasxz95ZxyN o7Fbpal3n3RyUtDtGDvtwXpkymWtp7xj =Sy5N