This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: template typedef


 

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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]