Re: C++ Speed Vs. Java
Mathias Gaunard wrote:
James Kanze wrote:
void f( double a[], double b[] ) ;
Either a an b are the same array, or they don't overlap in any
way. And that's very important information for an optimizer.
(I've given a simple example in another posting.)
void f(std::vector<double>& a, std::vector<double>& b);
basically gaves the same guarantees.
You know that, and I know it, but does the compiler know?
While std::vector is not a construct of the language, it is part of the
standard library, so the compiler could know about it.
It could. It's even possible that the compiler analyse the
code enough to deduct that the internal pointers of std::vector
all originate as the return value of an operator new, and that
they are guaranteed not to overlap for that reason (and operator
new, of course, is part of the basic language).
In practice, however, where are we? (It's an interesting
observation, however---logically, it means that for some
programs, at least, using std::vector should, or at least could,
result in faster code than using C style arrays.)
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]