Article View: gnu.g++.bug
Article #863templates not recognizing const functions
From: Victor Miller
Date: Fri, 21 Aug 1992 19:09
Date: Fri, 21 Aug 1992 19:09
42 lines
1310 bytes
1310 bytes
I have the program below (gbug.C) which gives the following results:
g++ -c -DCONST= gbug.C
But
g++ -c -DCONST=const gbug.C
gbug.C: In function `int main (int, char **)':
gbug.C:16: template for method `foo' doesn't match any in class `T2<int>'
// Is this a bug?
template<class T1>
class T2 {
int l;
T1 *x;
int foo(const int) CONST;
public:
T2(const int y=1): l(y) {
x = new T1[l];
};
~T2() {};
void bar(const int y,const T1& t) {
x[foo(y)] = t;
}
};
template<class T1>
int T2<T1>::foo(const int n) CONST {
return n+1;
}
int main(int argc,char * argv[]) {
typedef T2<int> T3;
T3 z;
return 0;
}
--
Victor S. Miller
Bitnet: VICTOR at WATSON
Internet: victor@watson.ibm.com
IBM, TJ Watson Research Center
"Great artists steal; lesser artists borrow" Igor Stravinsky
Technical Details
Message-ID:
<VICTOR.92Aug21150925@terse4.watson.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!watson.ibm.com!victorShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!watson.ibm.com!victor From: victor@watson.ibm.com (Victor Miller) Subject: templates not recognizing const functions Message-ID: <VICTOR.92Aug21150925@terse4.watson.ibm.com> Sender: gnulists@ai.mit.edu Reply-To: victor@watson.ibm.com Organization: IBM, T.J. Watson Research Center Distribution: gnu Date: Fri, 21 Aug 1992 19:09:25 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 43