Article View: comp.sys.mac.programmer.codewarrior
Article #1488Re: typeid & template func woes
From: Conrad Weyns
Date: Wed, 12 Feb 2003 16:34
Date: Wed, 12 Feb 2003 16:34
54 lines
2684 bytes
2684 bytes
"Miro Jurisic" <macdev@meeroh.org> skrev i melding news:macdev-B2A383.10035512022003@senator-bedfellow.mit.edu... > In article <b2dg2g$1117$1@news.dataguard.no>, "Conrad Weyns" <weyns@online.no> > wrote: > > > compiler: CW Pro 8.3 Mac & Win. > > issue: how can I get hold of the real type name of T that is part of a > > function signature in the following stripped to the bone but working code: > > > > Output of this running program: > > > > 1A. tA.report() gives: > > function name: _report<long>(long &) > > using __typeof__: long > > sWoes address: 0x00420460 sWoes = 999 > > type of _t: long > > value of _t 123 > > > > 2A. tA.const_report() gives: > > function name: _report<const long>(const long &) > > using __typeof__: long > > sWoes address: 0x00420454 sWoes = 999 > > type of _t: long > > value of _t 123 > > My understanding is that typeof (T) == typeof (const T) == typeof (volatile T) > == etc. Perhaps if you explain exactly what you are trying to do with this > information we can come up with an answer. (Which will involve type traits, I am > sure.) Thanks meeroh, looks like I need to go back to school -again :-( Ehm, I am lying now, I never went to school! But this was the kick in the behind that I needed to get to an alternative solution. I can simply differentiate between the two cases by supplying *two* template functions: template <typename T> void _report(T& _t); template <typename T> void _report(const T& _t); Works for me :-) /conrad. > > meeroh
Technical Details
Message-ID:
<b2dt3k$2g0n$1@news.dataguard.no>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!news.dataguard.no!not-for-mailReferences:
<b2dg2g$1117$1@news.dataguard.no> <macdev-B2A383.10035512022003@senator-bedfellow.mit.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd047,d1f7d1bdb1e475a0 X-Google-Attributes: gidfd047,public X-Google-Thread: f635e,d1f7d1bdb1e475a0 X-Google-Attributes: gidf635e,public X-Google-ArrivalTime: 2003-02-12 08:35:00 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!news.dataguard.no!not-for-mail From: "Conrad Weyns" <weyns@online.no> Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.windows Subject: Re: typeid & template func woes Date: Wed, 12 Feb 2003 17:34:58 +0100 Lines: 56 Message-ID: <b2dt3k$2g0n$1@news.dataguard.no> References: <b2dg2g$1117$1@news.dataguard.no> <macdev-B2A383.10035512022003@senator-bedfellow.mit.edu> NNTP-Posting-Host: 217.8.149.124 X-Trace: news.dataguard.no 1045067700 81943 217.8.149.124 (12 Feb 2003 16:35:00 GMT) X-Complaints-To: news-abuse@dataguard.no NNTP-Posting-Date: Wed, 12 Feb 2003 16:35:00 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000