[Insight-developers] Convenience functions for Index, Offset,
Point, Vector, etc.
Luis Ibanez
luis.ibanez@kitware.com
Wed, 12 Mar 2003 18:19:04 -0500
It sounds like a good idea,
I agree in that filling the indices is
cumbersome and distracting.
It is nice that what you propose is not
invasive in the class.
Luis
------------------
Brad King wrote:
> Jim,
>
>
>>MakeIndex is not terribly efficient since it must construct the Index,
>>set the components, and return the index but it does make the notation
>>"shorter".
>
>
> This should be pretty fast:
>
> inline Index<2> MakeIndex(Index<2>::IndexValueType i0,
> Index<2>::IndexValueType i1)
> {
> Index<2> i = {{i0,i1}};
> return i;
> }
>
> Most modern compilers have a "Named Return Value Optimization" (NVRO) that
> will optimize the entire call away. The optimization was introduced to
> help reduce the penalty of the common postfix-increment operator problem:
>
> foo foo::operator++(int) { foo tmp(*this); ++*this; return tmp; }
>
> -Brad
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>