Boost logo

Boost :

From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2006-09-21 14:17:30

On 9/21/06, Theodore Papadopoulo <Theodore.Papadopoulo_at_[hidden]>
> On Thu, 2006-09-21 at 08:54 -0400, Michael Fawcett wrote:
> >
> > You can get around this using something like this:

<snip code>

> > Here's the original discussion from
> >
> >
> > This wasn't written by me, I just remembered it from there and thought
> > it might be interesting to you.
> Interesting ! But I would certainly prefer the straightforward array
> implementation and an enum {X,Y,Z,Z} that allows the notation
> V[X] or V(X) (depending on your preference). The only fear I may have
> with your proposal is that by having complicated accesses, the compiler
> might not be able to do some optimizations.
> Theo.

There was another thread where the participants looked at the generated
assembly (MSVS 7.1) and found that it was the same as indexing into an
array. The really interesting thing was that the first time they forgot the
const keyword and the generated code was sub-optimal. After fixing the
const-correctness issues the VS 7.1 optimizer was able to produce code
identical to array indexing.

No one has posted a detailed analysis of the generated code in more complex
cases though, but for the simple case it appears that at least VS 7.1 can
optimize the code just fine.


Boost list run by bdawes at, gregod at, cpdaniel at, john at