The performance of <algorithm>.

Richard B. Kreckel kreckel@ginac.de
Wed Nov 19 22:06:00 GMT 2003


Hi,

Well, I never bought the "An Inline Function is As Fast As a Macro" rumor.
But still, an experiment using std::for_each shows rather disturbing
results.  Given
    struct A { virtual void someaction(); };
can anybody give an easy explanation why
    for_each(av.begin(), av.end(), mem_fun(&A::something));
blows up the size of the compiled code by a factor of two compared to the
straightforward implemenation?  (Even when one hacks for_each to be
inlined?  (BTW, why isn't it inlined?))

Maybe this is a more general question: I recently got the impression that
it does not seem possible to code efficiently using GCC's <functional> and
<algorithm> in contradiction to what all the books seem to claim.  Is that
gonna change some day?

Curious
    -richy.
-- 
Richard B. Kreckel
<Richard.Kreckel@GiNaC.DE>
<http://www.ginac.de/~kreckel/>



More information about the Libstdc++ mailing list