[Insight-developers] Templated itk::Math floating point to integer proposal
Bradley Lowekamp
blowekamp at mail.nih.gov
Wed Jul 29 15:09:06 EDT 2009
Hello Tom,
I am going to open my mouth one more time on this issue. Hopefully I
am being helpful :)
On Jul 27, 2009, at 12:53 PM, Tom Vercauteren wrote:
> Hi all,
>
> The only problem with this solution is that we cannot reuse the same
> name because:
>
> 1) replacing
> int itk::Math::Round( double x )
> by
> template <typename TReturn>
> TReturn itk::Math::Round( double x)
> would break backward compatibility
>
> 2) Using a default template argument is not an option since this is
> not allowed by the standard (see e.g.
> http://codeidol.com/cpp/cpp-templates/Future-Directions/Default-Function-Template-Arguments/)
>
I did not know it wasn't standard. At least the article says that for
our case it as would be a useful feature.
Can the template and non-template version co-exist? Isn't this just a
form of function overloading? (my gcc compiler will allow this)
Do we have to replace?
>
> My current approach is to leave the current functions as is and add a
> templated version of them. They are prepended by a capital T, e.g.
> template <typename TReturn>
> TReturn itk::Math::TRound( double x)
I would still think that we should surround the old Round method with
"#ifndef ITK_LEGACY_REMOVE" because this will help to track down all
usages, and make sure we get the right type. It will also prevent the
wrong methods from being used again.
>
> If anyone has a better proposal, I'll be glad to hear.
>
> The following patch
> http://www.itk.org/Bug/file_download.php?file_id=2383&type=bug
> implements that proposal but there are a few things I would like to
> get feedback on:
>
> 1) I chose to put the new code in a new file (Code/Common/itkMath.h)
> and remove the itk::Math code from itkMacro.h. itkMacro.h includes
> tkMath.h for backward compatibility
Sounds good.
>
> 2) I have added a itk::Math::Detail namespace within itk::Math to put
> helper functions that should not be used by end-users but need to be
> in the header file to be potentially inlined
>
> 3) I chose not to directly rely on the functions from vnl_math.h to
> ease the process of writting and modifying these functions
It would be nice if we could add that "Detail" namespaces are excluded
from Backwards compatibility policy.
>
>
> 4) My helper functions rely on vxl_int_64 and vxl_int_32 as a hope to
> get a portable fixed-width integer within ITK
Excellent!
>
>
> Also, I am not sure if it's still time to commit something like that.
> There is no release schedule for 3.16
> http://www.vtk.org/Wiki/ITK_Release_Schedule
> But if we are close to the feature freeze, I'll definitely hold on
> before moving on.
Luis?
>
> Regards,
> Tom
========================================================
Bradley Lowekamp
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090729/9a25d755/attachment.htm>
More information about the Insight-developers
mailing list