[Insight-developers] Explicit Instantiation Proposal

Miller, James V (GE, Research) millerjv at crd.ge.com
Wed Apr 26 09:30:02 EDT 2006


Brad,

Thanks for putting together this page.  I was hanging with it until we got
to the handling of multiple template arguments.  My concern is whether developers
are going to be able to write the macros like

#define ITK_TEMPLATE_Vector(_, EXPORT, T, D) namespace itk { \ 
    (2(class EXPORT Vector< T,D >)) \
    (1(EXPORT std::ostream& operator<<(std::ostream&, \
                                       const Vector< T,D >&))) \
    (1(EXPORT std::istream& operator>>(std::istream&, \
                                       Vector< T,D >&))) \ 
    }


When we get to this level of complexity are we better off simply writing out
the template instantition?  Granted, it would be awfully repetitive (having to put 
in similar lines for each instantiation) but more tractable for a developer.

I am all for macros for simplifying the export/import mayhem. So the question is
whether this 

// Bottom of itkFoo.h 
namespace itk { 
#if (...compiler supports extern instantiation...) 
   extern template class ITKCommon_EXPORT Foo<int>; 
#elif (...compiler supports do_not_instantiate...) 
# pragma do_not_instantiate class ITKCommon_EXPORT Foo<int> 
#endif 
}

could be simplified to something like

TEMPLATE_EXPORT(ITKCommon) Foo<int>;

so the Foo<int> or Vector<double, 3> is not passed into the macro.

Jim




-----Original Message-----
From: insight-developers-bounces+millerjv=crd.ge.com at itk.org
[mailto:insight-developers-bounces+millerjv=crd.ge.com at itk.org]On Behalf
Of Brad King
Sent: Tuesday, April 25, 2006 6:43 PM
To: Insight Developers
Cc: Julien Jomier; Zachary Pincus
Subject: [Insight-developers] Explicit Instantiation Proposal


Hello, all:

I've added a proposal entry on the ITK Wiki describing the explicit 
instantiation design.  See the page for details:

   http://www.itk.org/Wiki/Proposals:Explicit_Instantiation

So far I've completed the basic motivation and implementation of the 
macro-based instantiation syntax.  I'll finish the "Writing 
Instantiation Macros" and "Organizing Source Files" sections at the 
bottom later this week.

Also, I'd like help from Julien, Benoit, Gaetan, and Zachary to complete 
the "Generating Instantiations" section.  Likely this will overlap alot 
with wrapper generation, and I'd like to take knowledge from the WrapITK 
project.  Some of the discussion will have to wait until I've completed 
the section on Organizing Source Files because many of the files 
mentioned in that section will need to be generated.  If you look at the 
Code/Common/Templates directory in current ITK CVS you will see examples 
of these files.  Take a look also in Code/Common/*.h for places that 
include files from the Templates subdirectory.

Please take a look and post feedback.

Thanks,
-Brad
_______________________________________________
Insight-developers mailing list
Insight-developers at itk.org
http://www.itk.org/mailman/listinfo/insight-developers


More information about the Insight-developers mailing list