[Insight-developers] itk::Array solutions

Brad King brad.king@kitware.com
Thu, 25 Jan 2001 17:47:52 -0500 (EST)


Luis,

> Looking into Blitz++ they use an interesting technique for
> initialization. Basically the class that goes through the list is 
> templated over an int, and as each element is added, it instantiate 
> and returns a class with N+1 as template parameter. It's like making 
> a for loop using the template parameter as counter.

This is very similar to my approach for doing the upper-bound check.  In
mine, the ArrayCommaListCopier class would not be a member of Array, but
be stand-alone, and have the same template parameters as Array, plus the
counter parameter.  There would be a partial specialization to stop the
count by not having an operator,() in when the parameter counter reaches
the array length parameter.  Unfortunately, we cannot do this with the
ArrayCommaListCopier inlined in Array with only the counter parameter,
because the full specialization needed to stop the recursion is not
allowed by C++ unless you fully specify the outer (Array) class's
arguments.

Your version is interesting because instead of stopping recursion, it just
won't match the assignment operator when the list finishes parsing.  I had
been thinking about something similar, but haven't come up with a way
around that ugly initialization yet.  I'll try it a bit more when I get a
chance.

> It will alse be very fast because the list is loaded at compile time.
> There is no runtime loop.
Actually, I think all the classes would be instantiated, but the
constructors and operator,() methods would all be called in a big chain at
compile time.  I don't think compilers are good enough yet to interpret
their functionality, but they probably inline it, so it will still be
pretty fast.

> Maybe having the Get_vnl_vector() method defined only in itkVector()
> and itkPoint() could be sufficient for most applications.
Would you mind adding these, Luis?  I'm trying to get away from this work
to concentrate on GCC_XML and the wrapper generators.

-Brad