delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/13/14:25:22

From: sbnaran AT localhost DOT localdomain (Siemel Naran)
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Casting a class as a function pointer.
Date: 13 Jul 1999 17:58:24 GMT
Organization: University of Illinois at Urbana-Champaign
Lines: 39
Message-ID: <slrn7omvch.c2d.sbnaran@localhost.localdomain>
References: <378A2FFE DOT D9A4F8A0 AT americasm01 DOT nt DOT com> <slrn7ol5nn DOT 7fp DOT sbnaran AT localhost DOT localdomain> <378AB489 DOT 75F19B1E AT unb DOT ca> <slrn7omnrb DOT c2d DOT sbnaran AT localhost DOT localdomain> <378B7784 DOT E718C436 AT americasm01 DOT nt DOT com>
NNTP-Posting-Host: london-9.slip.uiuc.edu
X-Newsreader: slrn (0.9.4.3 UNIX)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Tue, 13 Jul 1999 13:29:40 -0400, Campbell, Rolf [SKY:1U32:EXCH]


>    I'm beginning to think that it isn't possible.  As someone already told me.

Anything that can be done with typedefs can be done without typedefs too.
Exceptions: a typedef can include "extern C" or "extern F" or whatever,
but writing out the typedef in full does not allow you to use these
extern constructs.  Or the big advantage of typedefs in C++, to make
traits that a template function can use, eg
"typename typedef Container::value_type Value;".  So I feel (not think)
that there's got to be a solution to your problem and the one below.


>> Incidentally, how to make an array of function pointers using 'new'
>> and without using 'typedef', and without using containers.  With
>> typedef, we say
>
>    I think this suffers from the same problem, and is impossible.



>    Actually, what I'm going to do is accept any standard cast as an operator:
>operator int (*)() ();
>
>This isn't syntactically correct, but it should never arrise and it means I
>don't have to make another type parser.

Don't accept incorrect code.  This might screw some people up who will use
the construct, and when they move to another parse, they're in trouble.
Better to say that you won't accept this construct because you're not sure
if its legal, and people using your parser will be forced to use another
construct that you know is legal and portable.  And besides, you're
discouraging them from using operator functions, and that's very good.

--
----------------------------------
Siemel B. Naran (sbnaran AT uiuc DOT edu)
----------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019