[Insight-developers] Borland/VS issues with new checkins

Luis Ibanez luis.ibanez at kitware.com
Sat Aug 8 09:54:05 EDT 2009


Hi Tom,

Yes, that will be my guess as well.

Visual Studio 6.0 (and 7.0), and Borland may require that
we made the return type part of the function arguments,
in order to be able to resolve the templated type of the
function.

It is not pretty or elegant, but it should do the trick....

One alternative signature could be to follow the FORTRAN-like
style of the TransformPhysicalPointToIndex()

                      Function( input arg, output arg )

which,... in retrospective, that's probaly the reason why we put
the output value as an argument by reference instead of passing
it back as the return type.

In summary, we could do:

     Math::Round( const InputType & in, OutputType & output );

It may look unnatural in certain expression though....


   What do you guys think ?


         Luis



---------------------------------
On Wed, Aug 5, 2009 at 3:56 AM, Tom Vercauteren
<tom.vercauteren at gmail.com>wrote:

> Hi Luis,
>
> Thanks for this information. I guess the same rule applies to the
> templated rounding functions we were discussing a few days ago:
> http://www.itk.org/mailman/private/insight-developers/2009-July/013121.html
>
> This means that this code
>
> template <typename TReturn, typename TInput>
> inline TReturn Round(TInput x) { [snip] }
>
> will not compile on VS60, right? But then, is the following
> alternative usable on these compilers?
>
> template <typename TReturn, typename TInput>
> inline TReturn Round(TInput x, TReturn * = 0) { [snip] }
>
> Tom
>
> On Wed, Aug 5, 2009 at 00:10, Luis Ibanez<luis.ibanez at kitware.com> wrote:
> >
> > Bill, Gaetan,
> >
> >
> > Thanks for the help.
> >
> > Looking closer at the VS60 with Sophie, we think we identified that
> >
> >
> > VS60 will only manage to compile templated methods if:
> >
> >
> >       A) The template parameter is part of
> >           the method arguments
> >
> > and
> >
> >      B) The method is implemented in the header
> >           file instead of the txx file.
> >
> >
> > We have modified the TemplatedGenerateData() method accordingly.
> > It now takes as argument an Accessor, that it most cases, doesn't use
> > for anything. This argument only serves the purpose of resolving the
> > instantiation of the templated method.
> >
> > This matches the pattern that we have in:
> >
> >        ImageBase::TransformPhysicalPointToIndex
> >
> > Namely:
> >
> > Templated class
> > Templated method
> > Method takes arguments whose type depend on the method template parameter
> > Method is implemented in the header (not the .txx) file.
> >
> > With this changes, the code compiles on Visual Studio 6.0.
> >
> > Still remains to be seen if the same construct will work on Borland....
> >
> >
> >        Luis
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090808/f3039d89/attachment.htm>


More information about the Insight-developers mailing list