RE: template typedef

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

I have some examples of this type and many more can be found in the
publicly available source for the ITK toolkit, which makes extensive use
of such templates and compiles under gcc, at least I have not had any
trouble compiling and using it in every gcc I have tried, once I
understood how to use template classes. Here is a bit of code to help
you judge wheter the syntax is what you expect. I did not write the
toolkit and you can look at many many more examples in the projects'
source code repository on sourceforge, there are examples of seemignly
arbitrary complexity in the toolkit. 

For example in itkMedianImageFilter.txx:

...headers etc....
namespace itk
{
template <class TInputImage, class TOutputImage>
MedianImageFilter<TInputImage, TOutputImage>
::MedianImageFilter()
{
  m_Radius.Fill(1);
}

template <class TInputImage, class TOutputImage>
void
MedianImageFilter<TInputImage, TOutputImage>
::GenerateInputRequestedRegion() throw (InvalidRequestedRegionError)
{
  // call the superclass' implementation of this method
  Superclass::GenerateInputRequestedRegion(); 
... And so on ... 


Then in the code that uses the template, for example to create a
two-dimensional and a three-dimensional median filter using the
toolkit's other templates for images and so on:


  typedef tomo_t PixelType;
  typedef itk::Image< PixelType, 2 > ScalarImageSlice;
  typedef itk::Image< PixelType, 3 > ScalarImageType;
  typedef itk::MedianImageFilter<ScalarImageSlice,ScalarImageSlice>
SliceMedian;
  typedef itk::MedianImageFilter<ScalarImageType,ScalarImageType>
VolMedian;



-----Original Message-----
 Vincent Torri Sent: 16 December 2005 10:39

hey,

does gcc 3.4 (or 4.*) support template typedef, like that:

template<class T>
typedef std::map<std::string, T> Registry;

? (or any other syntax)

thank you

Vincent Torri


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux