[Insight-developers] Image as an OrientedImage Progress

Bill Lorensen bill.lorensen at gmail.com
Fri Oct 10 23:22:02 EDT 2008


Steve,

Unfortunately, this program will not compile with the Borland
compiler. It generates an internal compiler error. I'll try a couple
of VS compilers next.

Bill

On Fri, Oct 10, 2008 at 4:01 AM, Steve M. Robbins <steve at sumost.ca> wrote:
> On Mon, Sep 22, 2008 at 12:50:08PM -0400, Rupert Brooks wrote:
>
>> What could work, could be something like
>> template<class TPixel, unsigned int VImageDimension = 2, unsigned int
>> VSpaceDimension=VImageDimension>
>> class itk::Image< TPixel, VImageDimension, VSpaceDimension >
>>
>> Sadly, i dont think the default argument for a template parameter can
>> be another template parameter, although i didnt try this.
>
> I just tried and it works on my system (Linux/GCC 4).  In fact, this is
> part of the C++ standard working draft [1, section 14.2, page 279]:
>
>  13 The scope of a template-parameter extends from its point of
>     declaration until the end of its template. In particular, a
>     template-parameter can be used in the declaration of subsequent
>     template-parameters and their default arguments.
>
>     [ Example:
>
>       template < class T , T * p , class U = T > class X { /* ... */ };
>
>
> Here's a simple test program to demonstrate.
>
> #include <iostream>
>
> template <class TPixel,
>          unsigned int VImageDimension=2,
>          unsigned int VSpaceDimension=VImageDimension>
> class Image
> {
> public:
>    unsigned int getImageDimension() const { return VImageDimension; }
>    unsigned int getSpaceDimension() const { return VSpaceDimension; }
>    void printSelf()
>    {
>        std::cout << "Image dimension: " << getImageDimension()
>                  << ", space dimension: " << getSpaceDimension()
>                  << "\n";
>    }
>
> };
>
> int main( int ac, char* av[] )
> {
>    Image<short> image1;
>    image1.printSelf();
>
>    Image<short,9> image2;
>    image2.printSelf();
>
>    Image<short,7,2> image3;
>    image3.printSelf();
>
>    return 0;
> }
>
>
> As a test, I have started adding VSpaceDimension to Image, ImageBase,
> ImageHelper, ImageRegion, etc.  It ends up touching a lot of classes,
> so I'm not done yet.  What do you all think of this approach?
>
> -Steve
>
>
> [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iD8DBQFI7wvg0i2bPSHbMcURAtxrAJsEpa/GBYUAD8n/lp6NSnOjfRE1DwCglZHo
> 417B1x9Pmojv5E0zdphYutw=
> =aDom
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>
>


More information about the Insight-developers mailing list