home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:16424 gnu.g++.help:1445
- Newsgroups: comp.lang.c++,gnu.g++.help
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!cs.mu.OZ.AU!lenard
- From: lenard@mullian.ee.mu.OZ.AU (rohan james lenard)
- Subject: Template question with g++/gcc
- Message-ID: <lenard.722005741@munagin>
- Summary: Need advise on a template question with g++/gcc
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- Date: Tue, 17 Nov 1992 13:09:01 GMT
- Lines: 50
-
- I have a question regarding template and g++/gcc.
- According to the ARM something like this should be valid -
-
- > template<class T,char *V> class foo
- > {
- > foo(char *filename = V) {} ;
- > }
- ...
- > foo<int,"Hello"> a;
-
- However g++/gcc (2.2.2) complains pretty mightily about it.
- I have tried something like this -
-
- > class A
- > {
- > const char *str = "Hello";
- > operator char * () const { return str; }
- > }
- > template<class T,class V> class foo
- > {
- > foo(char *filename = (char *)V) {} ;
- > }
- >
- > foo<int,A> a;
-
- and it can be made to work, but it is not as elegant.
-
- Does anyone have a work around so that I can use something like the first
- example ? (NOTE: I may not have my code syntactically correct, as I am trying
- to remember it from a few days ago at a friends work, but I assume you get the
- idea)
-
- Any help would be appreciated.
-
- As an aside (sp?), the examples in the ARM for this sort of template class
- both work - did GNU only use these or what :-) ?
-
-
- Thanks in advance,
- Regards,
- Rohan
- --------------------------------------------------------------------------
- lenard@munagin.ee.mu.OZ.AU O O
- lenard@mundil.cs.mu.OZ.AU |
- lenard@ecr.mu.OZ.AU \_/
- --
- Rohan Lenard
- lenard@munagin.ee.mu.OZ.AU
- lenard@mundil.cs.mu.OZ.AU
- lenard@ecr.mu.OZ.AU
-