[LC++]Return values vs reference parameters
lloyd at acm.jhu.edu
Sat Jul 28 02:01:05 UTC 2001
> There is a huge price of computational inefficiencies in order to get
> syntactically nice code.
That is the whole price of abstractions, after all.
> Surely this is not the C++ way? Are there ways and means to get around
> these problems?
You may want to look at Blitz++. It's a (supposedly, I'm not much of a
pure numerics person) very fast C++ numerics library, which uses something
called template meta-programming. I don't know much about template
meta-programming either, but I guess it uses templates (and inlining) to
move things from run time to compile time (I know the technique requries
loads of memory at compile time). For example, with this technique,
a = b*c + d;
can be reduced to a single function call. So you could either use Blitz or
something simliar (I know there is at least one other big C++ numerics
library), or use these techniques in your own code to reduce the overhead.
> I've heard of "return value optimization", but this seems to only
> partially solve these issues, and currently seems not to be well
Have you tried gcc3? Or, if this is important, try KAI C++ (commercial,
about $400 for a single user Linux/x86 license - there are 30 day demos
too). It does stuff like this well, and it's really fast. Really really
More information about the tuxCPProgramming