Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2004-08-03 06:56:12

Istvan Buki <istvan.buki_at_[hidden]> writes:

> Hello David,
> thanks for your clean and simple answer. I also thought about
> something similar to your answer but I was wondering if there exist
> some way to calculate that index at compile-time.

Yes there is.

> Looking at the
> assembly code generated, it doesn't make a big difference to my
> version where the index values are hard-coded but still... In fact,
> the question I'm really trying to answer is: what is the price to
> pay (in term of performance and space) for using an mpl based
> solution compared to have my array elements initialized by a totally
> hard-coded function? Up to now what I've found is that my executable
> is 10% larger and the code is about 4 times slower (again by looking
> at the assembly code generated).

Have you got all optimizations enabled with full inlining?
What compiler are you using?

> So, if you can think of a more efficient solution I'm still
> interested.

You could use

          mpl::range_c<0, mpl::size<Descriptors>::value>
        , Descriptors

as the sequence in your for_each; then each element would contain a
compile-time index and a descriptor.


Dave Abrahams
Boost Consulting

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at