[vtk-developers] static template functions.

Bill Hoffman bill.hoffman at kitware.com
Mon Feb 25 16:46:28 EST 2002


I thought the reason for the static's was to avoid creating global linkage
functions.  Anyway static local functions are deprecated in the standard,
so this may be the first of many compilers to die on this.

Essentially what happens is that when the template is instantiated, it may be
in a different file created by the compiler meant only to instantiate that
one function or method.  When the template function is compiled in that file
it will not have access to the static functions in the original file.

-Bill


At 04:10 PM 2/25/2002 -0500, Miller, James V (CRD) wrote:
>Interesting.  The only reason we have the statics in there at all is support
>the HP compiler.  I think all our other compilers do not require the static
>be specified.
>
>
>
>-----Original Message-----
>From: Bill Hoffman [mailto:bill.hoffman at kitware.com]
>Sent: Friday, February 22, 2002 3:31 PM
>To: vtk-developers at public.kitware.com
>Subject: [vtk-developers] static template functions.
>
>
>The most recent HP compiler fails to build VTK.
>It does not allow a static template function to call another static template function.
>Strictly speaking static functions are deprecated in the c++ standard, and you are
>supposed to use anonymous namespaces.  However, for VTK, we are supporting compilers
>that will not support namespaces.   So, it would seem the most portable thing
>to do, would be to remove the static and rename the functions to
>classname_function.
>
>
>Here is an example of something that does not work:
>
>template <class IT, class OT>
> static void CopyTuples(IT* input, OT* output, int nComp, int* ptIds )
>{
> ...
>}
>
>template <class IT>
> static void CopyTuples1(IT* input, vtkDataArray* output, int* ptIds)
>{
>  void* v = 0;
>  typedef double VTK_TT; 
>// this CopyTupes can not be found at compile time.
>  CopyTuples(input, (VTK_TT *)v, GetNumberOfComponents(), ptIds);
>}
>
>
>I would suggest that the statics be removed, and the names be changed
>to vtkDataObject_CopyTuples and vtkDataObject_CopyTupes1.
>
>Any other ideas?
>
>-Bill
>
>_______________________________________________
>vtk-developers mailing list
>vtk-developers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/vtk-developers
>_______________________________________________
>vtk-developers mailing list
>vtk-developers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/vtk-developers 




More information about the vtk-developers mailing list