From -3796108210590048170
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,15a3eb1ed336ff4e
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-02-14 15:29:01 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: "Philippe A. Bouchard" <philippeb@videotron.ca>
Newsgroups: comp.std.c++
Subject: Re: Proposal: Nested inline (function | functor)
Date: Thu, 14 Feb 2002 23:28:38 GMT
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <xPWa8.3851$bS4.156208@weber.videotron.net>
References: <VpFa8.4998$MR3.267112@wagner.videotron.net> <memo.20020214195820.5663B@brangdon.madasafish.com>
X-Trace: mail2news.demon.co.uk 1013729323 mail2news:11307 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Date: Thu, 14 Feb 2002 17:25:33 EST
Lines: 68
Xref: archiver1.google.com comp.std.c++:9649


"Dave Harris" <brangdon@cix.co.uk> wrote in message
news:memo.20020214195820.5663B@brangdon.madasafish.com...
> Inlining is best left to the compiler. It usually has more patience and
> more knowledge of the target hardware.

Yes, it's true.

> I think the word you are looking for is "external". For templates we need
> some way to request external linkage of nested classes. It has little to
> do with inlining.

My primary concern was to easily access stacked variables with nested
functors instanciated in template functions. Inlining gave an opportunity
for the compiler to modify the generated contents of a function to access
that stacked variable, depending on the depth the nested class was
instanciated in the template function. Having an external functor meant
introducing garbage collectors since the member function had to be
instanciated once only for virtual tables, etc. and the stacked variable was
to be accessed in different depths at the same time (a~ n_instanciation /
depth).

Initially I wanted to easily use <algo> with on-the-fly functors.
for_each(), find_if(), ... are all template functions who need functors:

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
 string a[] =
 {
  "Marc",
  "Shawn",
  "George",
  "Robert"
 };

 find_if
 (
  a,
  a + 4,
  struct
  {
   bool operator()(string const & b) const
   {
    return b == a[2];
   }
  } ()
 );
}



Regards,

Philippe A. Bouchard
Xandros Software Engineer

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



