From 7742943678511644631
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,ac06fef48c3c04df
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,ac06fef48c3c04df
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-25 12:21:50 PST
Newsgroups: comp.lang.c++,comp.std.c++
Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!gatech!bloom-beacon.mit.edu!cambridge-news.cygnus.com!news.cygnus.com!news!jason
From: jason@cygnus.com (Jason Merrill)
Subject: Re: friends and local classes
In-Reply-To: Viktor Yurkovsky's message of 25 Jan 1995 15:41:06 GMT
Content-Type: text/plain; charset=US-ASCII
Message-ID: <JASON.95Jan25122150@phydeaux.cygnus.com>
Sender: news@cygnus.com
Nntp-Posting-Host: phydeaux.cygnus.com
Organization: Cygnus Support, Mountain View, CA
References: <FENSTER.95Jan24182929@ground.cs.columbia.edu> <3g5qc6$16p@news.cc.utah.edu>
	<3g5rei$dl8@news.panix.com>
Mime-Version: 1.0
Date: Wed, 25 Jan 1995 20:21:50 GMT
Lines: 37
Xref: nntp.gmd.de comp.lang.c++:88029 comp.std.c++:11257

>>>>> Viktor Yurkovsky <n4mation@panix.com> writes:

> swillden@fcom.cc.utah.edu (Shawn Willden) wrote:

>> Just make a local class with a static function if you need a local function.
>> 
>> void functionWithLocalFunction()
>> {
>> struct Local
>> {
>> int static compare(const void* a, const void* b)
>> {
>> const int *intA = reinterpret_cast<const int*>(a);
>> const int *intB = reinterpret_cast<const int*>(b);
>> if (*intA == *intB)
>> return 0;
>> else if (*intA < *intB)
>> return -1;
>> else
>> return 1;
>> }
>> };
>> 
>> //...
>> qsort(array, sizeof(array)/sizeof(array[0]), sizeof(array),
>> &Local::compare);
>> }
>> 
>> ...

> Hmm.. This creates a rather large inline, doesn't it?

The compiler is under no obligation to inline calls.  And since the
function is used through a pointer, the compiler would have to be mighty
clever to do so.

Jason


