Thread View: comp.std.c++
1 messages
1 total messages
Started by Igor Boukanov
Tue, 09 Apr 1996 17:21
Are T& and T the same from template point of view?
Author: 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 ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads