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

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Nov 5 16:07:08 EDT 2010


I dont' recall where the discussion of utilizing some parts of boost in ITK went. But this is the type of think I was thinking which may be a candidate for integration:

http://www.boost.org/doc/libs/1_43_0/doc/html/boost_tr1.html


On Nov 5, 2010, at 4:01 PM, kent williams wrote:

> G++ 4 and later has the std::tr1 type_traits, and you can include it with #include <tr1/type_traits> I believe.  There’s nothing I’ve seen in that header that would require anything except partial template specialization.  We can’t just glom that into ITK though, as it is licensed with some version of GPL.
> 
> Most — if not all — modern compilers have some version of type_traits though it seems like there’s not much consistency in implementation — how you get access to them, what namespace the members are in.  I don’t know if there’s a really good way to handle this, frankly.
> 
> 
> On 11/5/10 2:19 PM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:
> 
>> 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 <http://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/b3c6e8de/attachment.htm>


More information about the Insight-developers mailing list