Article View: gnu.g++.bug
Article #1384templates and const
From: Frederick Herrmann
Date: Mon, 11 Jan 1993 19:08
Date: Mon, 11 Jan 1993 19:08
37 lines
1215 bytes
1215 bytes
I'm having trouble with type unification for templates with const
args. We are running g++ 2.3.3 under SunOS 4.1.3 and Ultrix 4.2
The FAQ says there are still some problems with templates. Is this a
real bug or am I doing something wrong?
Thanks,
- Fritz
fritz@mtl.mit.edu
#include <iostream.h>
// This code produces type unification errors when
// CONST is defined to be const, but works fine when
// compiled with -DNOCONST
#ifdef NOCONST
# define CONST /*blank*/
#else
# define CONST const
#endif
template<class C> void cpy( C* to, CONST C* from)
{
while ( *to++ = *from++);
}
int main( int argc, char** argv)
{
char tobuf[9];
CONST char frombuf[] = "Testing.";
cpy( tobuf, frombuf);
cout << tobuf << '\n';
}
Technical Details
Message-ID:
<1993Jan11.190809.4504@athena.mit.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!mtl.mit.edu!fritzShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!mtl.mit.edu!fritz From: fritz@mtl.mit.edu (Frederick Herrmann) Subject: templates and const Message-ID: <1993Jan11.190809.4504@athena.mit.edu> Sender: gnulists@ai.mit.edu Organization: MIT Microsystems Technology Laboratories Distribution: gnu Date: Mon, 11 Jan 1993 19:08:09 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 38