[Insight-users] Borland 6 Build error

Luis Ibanez luis.ibanez@kitware.com
Sat, 23 Nov 2002 15:18:35 -0500


Hi John,

Well, I guess this is good news.

A secondary question: Does it run ?
does the result of the factorial = 120 ?

---

Let's move one step forward to get closer
to what ImageRegion::Slice() is doing.

Could you please try the following code ?

I already tested in Borland 5.5 and gcc
and compiles fine. It runs ok in gcc but
producs incorrect results on borland.

You may want to try it with the two combinations
of defining and undefining the ENUMWORKS symbol.

=========================================

#include <iostream>

#define ENUMWORKS
//#undef ENUMWORKS

template<int N>
class ImageRegion {
public:

     typedef ImageRegion<N> Self;
#ifndef ENUMWORKS
     static const unsigned int  Dimension = N;
     static const unsigned int  SliceDimension = N-1;
     typedef ImageRegion< N-1 > SliceRegion;
#else
     enum { Dimension = N };
     enum { SliceDimension = N-1 };
     typedef ImageRegion< SliceDimension > SliceRegion;
#endif
     SliceRegion Slice() { return SliceRegion(); }
     ImageRegion() { std::cout << "Region " << N << std::endl; }
};

main()
{
   typedef ImageRegion<5> RegionType;
   RegionType region;
   RegionType::SliceRegion sliceRegion;
   sliceRegion = region.Slice();
   return 0;
}

===========================================

Please let us know what you find,

Thanks


Luis

===================================


John Biddiscombe wrote:

> Luis, Interesting stuff, I'm sorry to say that this...
> 
> 
>>#include <iostream>
>>
>>template<int N>
>>class Factorial {
>>public:
>>     enum { value = N * Factorial<N-1>::value };
>>     Factorial()
>>     {
>>       std::cout << "Factorial of " << N << " = " << value << endl;
>>     }
>>};
>>
>>class Factorial<1> {
>>public:
>>     enum { value = 1 };
>>};
>>
>>
>>main()
>>{
>>   Factorial<5> f;
>>   return 0;
>>}
>>
> 
> Compiled fine. I say "Sorry" becasue if it didn't then we'd be closer to the
> problem. NB. The enum was left in unchanged. It also compiled fine when I
> put the static const unsigned in version in.
> 
> I'll play some more...
> 
> JB
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>