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

Carlo Wood carlo at alinoe.com
Wed Feb 20 01:47:03 UTC 2002


On Tue, Feb 19, 2002 at 04:04:21AM +0100, Carlo Wood wrote:
> largeStructTy const* lsp = &largeStructList[0];			// Single, one time assembly instruction.
> for (largeStructTy const* next_lsp = &largeStructList[1];	// Single, one time assembly instruction.
>      next_lsp < &largeStructList[N];				// &largeStructList[N] is a constant, compared with a register.
>      ++next_lsp)						// Single assembly instruction.
> {
>   largeStructTy const& ls(*lsp);		// Generates no code, internally lsp and lp are the same register.
>   largeStructTy const& nextLs(*next_lsp);	// Idem, generates no code.
>   // do stuff involving the reading of ls and nextLs
>   // ...
> }

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.

-- 
Carlo Wood <carlo at alinoe.com>



More information about the tuxCPProgramming mailing list