[Insight-developers] Templates and preprocessor macros

Benoit Scherrer benoitscherrer at gmail.com
Wed Jul 13 09:01:19 EDT 2011


Ok thanks!
I will look at that

B

On Tue, Jul 12, 2011 at 9:48 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>wrote:

> With C++0x there is the static_assert:
>
> http://en.wikipedia.org/wiki/C%2B%2B0x#Static_assertions
>
> Which is by far the easiest was to check what you are looking for, as it is
> just :
>
> static_assert( VImageDimension == 3 );
>
> *poof* compile time assertion. However, this is not supported by all
> compilers that ITK needs to support so we can't do that for the main code.
> But if it's just your own project you could use it.
>
> I would be  in favor for adding a itkStaticAssert as a macro to ITKv4. But
> I am also a meta-programing wacko, so I may be alone. We could use the C++0x
> implementation if available or fall back to something else, or just do
> nothing.
>
> Brad
>
> On Jul 11, 2011, at 1:28 PM, Williams, Norman K wrote:
>
> > The only way to solve this is with template metaprogramming.  This makes
> > for some extra work getting the syntax right, but you can write the code
> > so that it only uses a filter on 3D.
> >
> >
> > On the other hand, as one of the people who worked on OrientImageFilter
> > back in the day, I don't think anyone should be using OrientImageFilter
> > and it should be deprecated, because it destroys information. It only
> does
> > the right thing if all of the direction cosines are aligned with one of
> > the world coordinate axes.
> >
> >
> >
> > On 7/11/11 11:10 AM, "Benoit Scherrer" <benoitscherrer at gmail.com> wrote:
> >
> >> Hi,
> >>
> >> Is there a way to use the C++ preprocessor macros that test the value of
> >> a template parameter?
> >> For example i want to do a generic image filter ( using itk::Image<type,
> >> VImageDimension> ) that
> >> will use itk::OrientImageFilter only for VImageDimension==3
> >>
> >> However, it seems that the preprocessor tool does not 'expand' the
> >> templates and
> >> just don't know when VImageDimension==3 or not.
> >>
> >> Is there any trick to do that, or is it a lost cause ?
> >>
> >> Thanks a lot!
> >>
> >> Benoit
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Kitware offers ITK Training Courses, for more information visit:
> >> http://kitware.com/products/protraining.html
> >>
> >> Please keep messages on-topic and check the ITK FAQ at:
> >> http://www.itk.org/Wiki/ITK_FAQ
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.itk.org/mailman/listinfo/insight-developers
> >
> >
> >
> > ________________________________
> > Notice: This UI Health Care e-mail (including attachments) is covered by
> the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is
> confidential and may be legally privileged.  If you are not the intended
> recipient, you are hereby notified that any retention, dissemination,
> distribution, or copying of this communication is strictly prohibited.
>  Please reply to the sender that you have received the message in error,
> then delete it.  Thank you.
> > ________________________________
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://kitware.com/products/protraining.html
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110713/3a2292bc/attachment.htm>


More information about the Insight-developers mailing list