[LC++]can't seem to use reference

Mark Phillips mark at austrics.com.au
Wed Feb 20 12:48:09 UTC 2002


Carlo Wood wrote:
> 
> Err, that should be
> 
> largeStructTy const* lsp = &largeStructList[0];
> for (largeStructTy const* next_lsp = &largeStructList[1];
>      next_lsp < &largeStructList[N];
>      lsp = next_lsp, ++next_lsp)
>      ^^^^^^^^^^^^^^
> Adding another instruction.
> 

Or actually, I could do:

for (largeStructTy const* lsPr=&largeStructList[0]; 
    lsPr<&largeStructList[N];) {
  largeStructTy const& ls(*lsPr);
  ++lsPr;
  largeStructTy const& nextLs(*lsPr);
  // do stuff involving the reading of ls and nextLs
  // ...
}

How would the compiler deal with this?  nextLs and lsPr could
be the same register, but would the compiler do this?

Cheers,

Mark.



More information about the tuxCPProgramming mailing list