> Many thanks to you both, Lars and André. I'm still pretty ignorant when
> it comes to functors. I wrote a template function to achieve my goals. Is
> your way better, or is it just a matter of style?

You copy the whole vector once more than either Lars's or my solution.
Moreover, access to a vector by iterator is usually faster than by index,
just think about what is happening:

   *it                        ->  well, just one deref

   a[i]  == *(a.begin() + i)  ->  one variable access to get begin (if inlined) 
                                  one addition
                                  one deref
                                  usually one more register used 

Of course, certain architectures can do both in the same time, but you need
quite a bit of luck for that.
           
I admit that functors in the current Standard Lirary are clumsy to use.
If LyX would use them on a regular base I'd suggest to use the 'Lambda
Library' which makes those things much easier to write and more pleasing to
the eye, but for the occasional for-loop this would be overkill.

Andre'

-- 
André Pönitz ........................................ [EMAIL PROTECTED]

Reply via email to