[Insight-developers] The time has come for itkTypeTraits.h?

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Nov 5 15:19:45 EDT 2010


Kent,

One minor point is the difference between tr1 and C++0x. "std::tr1" is an extension to standard template library which can be implemented with the current C++03. C++0x includes language extensions which many are not supported by compilers.

So theoretically there could be an open source tr1 library someplace. Or at least some part of it. I think we should look at adding this extension as a whole instead of just a part or two.

http://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1

Brad

On Nov 5, 2010, at 3:11 PM, kent williams wrote:

> In trying to replace the use of typeids in ITK with compile-time code based
> on Template Metaprogramming, I've run into this issue: The job would be a
> whole lot easier if we had access to the C++0x type_traits header.
> 
> What would it take to make this a possibility?
> 
> In CMakeLists.txt:
> 
> CHECK_INCLUDE_FILES(type_traits HAVE_TYPE_TRAITS)
> 
> itkTypeTraits.h:
> 
> #ifndef __itkTypeTraits_h
> #define __itkTypeTraits_h
> #include "itkConfigure.h"
> 
> #if defined(HAVE_TYPE_TRAITS)
> #include <type_traits>
> #else
> // implement needed type_traits macros
> namespace std
> {
>  template<typename _Tp, _Tp __v>
>    struct integral_constant
>    {
>      static const _Tp                      value = __v;
>      typedef _Tp                           value_type;
>      typedef integral_constant<_Tp, __v>   type;
>    };
>  typedef integral_constant<bool, true>     true_type;
>  typedef integral_constant<bool, false>    false_type;
> 
> // e.g. the is_same relation
> template<typename, typename>
> struct is_same : public false_type { };
> 
> template<typename _Tp>
> struct is_same<_Tp, _Tp>  : public true_type { };
> 
> }
> #endif
> 
> _______________________________________________
> 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

========================================================
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/20101105/538fec82/attachment.htm>


More information about the Insight-developers mailing list