Commit b55c10e0 authored by Brad King's avatar Brad King
Browse files

Drop VTK_TEMPLATE_SPECIALIZE compatibility macro

VTK no longer supports compilers that do not understand `template <>`
for full template specialization.  Drop our compatibility layer for
this case.
parent 953d37d8
IF(NOT DEFINED VTK_COMPILER_HAS_FULL_SPECIALIZATION)
MESSAGE(STATUS "Checking support for full template specialization syntax")
TRY_COMPILE(VTK_COMPILER_HAS_FULL_SPECIALIZATION
${VTK_BINARY_DIR}/CMakeTmp
${VTK_CMAKE_DIR}/vtkTestFullSpecialization.cxx
OUTPUT_VARIABLE OUTPUT)
IF(VTK_COMPILER_HAS_FULL_SPECIALIZATION)
MESSAGE(STATUS "Checking support for full template specialization syntax -- yes")
SET(VTK_COMPILER_HAS_FULL_SPECIALIZATION 1 CACHE INTERNAL "Support for full template specialization syntax")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Determining if the C++ compiler supports full template specialization syntax "
"passed with the following output:\n"
"${OUTPUT}\n")
ELSE()
MESSAGE(STATUS "Checking support for full template specialization syntax -- no")
SET(VTK_COMPILER_HAS_FULL_SPECIALIZATION 0 CACHE INTERNAL "Support for full template specialization syntax")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
"Determining if the C++ compiler supports full template specialization syntax "
"failed with the following output:\n"
"${OUTPUT}\n")
ENDIF()
ENDIF()
template <class T> struct A {};
template <> struct A<int*>
{
static int f() { return 0; }
};
int main() { return A<int*>::f(); }
......@@ -457,9 +457,6 @@ include(vtkTestTypes)
# Socket tests etc.
#INCLUDE(Parallel/VTKParallelCMakeTests.cmake)
# Check for full template specialization support by compiler.
include(vtkTestFullSpecialization)
# Check for explicit template instantiation support by compiler.
include(vtkTestExplicitInstantiation)
......
......@@ -339,8 +339,6 @@ endmacro()
vtk_prepare_cmakedefine("" CMAKE_WORDS_BIGENDIAN VTK_WORDS_BIGENDIAN)
vtk_prepare_cmakedefine(NOT VTK_EXPLICIT_TEMPLATES
VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
vtk_prepare_cmakedefine(NOT VTK_COMPILER_HAS_FULL_SPECIALIZATION
VTK_NO_FULL_TEMPLATE_SPECIALIZATION)
# Provide version macros through vtkConfigure.h for compatibility.
if(VTK_LEGACY_REMOVE)
......
......@@ -31,11 +31,11 @@ vtkByteSwap::~vtkByteSwap()
//----------------------------------------------------------------------------
// Define swap functions for each type size.
template <size_t s> struct vtkByteSwapper;
VTK_TEMPLATE_SPECIALIZE struct vtkByteSwapper<1>
template<> struct vtkByteSwapper<1>
{
static inline void Swap(char*) {}
};
VTK_TEMPLATE_SPECIALIZE struct vtkByteSwapper<2>
template<> struct vtkByteSwapper<2>
{
static inline void Swap(char* data)
{
......@@ -43,7 +43,7 @@ VTK_TEMPLATE_SPECIALIZE struct vtkByteSwapper<2>
one_byte = data[0]; data[0] = data[1]; data[1] = one_byte;
}
};
VTK_TEMPLATE_SPECIALIZE struct vtkByteSwapper<4>
template<> struct vtkByteSwapper<4>
{
static inline void Swap(char* data)
{
......@@ -52,7 +52,7 @@ VTK_TEMPLATE_SPECIALIZE struct vtkByteSwapper<4>
one_byte = data[1]; data[1] = data[2]; data[2] = one_byte;
}
};
VTK_TEMPLATE_SPECIALIZE struct vtkByteSwapper<8>
template<> struct vtkByteSwapper<8>
{
static inline void Swap(char* data)
{
......
......@@ -100,7 +100,6 @@
/* Compiler features. */
#cmakedefine VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
#cmakedefine VTK_NO_FULL_TEMPLATE_SPECIALIZATION
#cmakedefine VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T
#cmakedefine VTK_HAVE_SO_REUSEADDR
......@@ -160,17 +159,6 @@
# endif
#endif
/* Define a macro to help define template specializations. Skip if
compiling a windows resource file because the resource compiler
warns about truncating the long symbol. */
#if !defined(RC_INVOKED)
# if defined(VTK_NO_FULL_TEMPLATE_SPECIALIZATION)
# define VTK_TEMPLATE_SPECIALIZE
# else
# define VTK_TEMPLATE_SPECIALIZE template <>
# endif
#endif
/* The maximum length of a file name in bytes including the
* terminating null.
*/
......
......@@ -67,14 +67,14 @@ inline void vtkDataArrayRoundIfNecessary(double val, T* retVal)
}
//--------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
inline void vtkDataArrayRoundIfNecessary(double val, double* retVal)
{
*retVal = val;
}
//--------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
inline void vtkDataArrayRoundIfNecessary(double val, float* retVal)
{
*retVal = static_cast<float>(val);
......
......@@ -26,7 +26,7 @@ template <class T> struct vtkTypeTraits;
// Define a macro to simplify trait definitions.
#define VTK_TYPE_TRAITS(type, macro, isSigned, name, print, format) \
VTK_TEMPLATE_SPECIALIZE struct vtkTypeTraits< type > \
template <> struct vtkTypeTraits< type > \
{ \
/* The type itself. */ \
typedef type ValueType; \
......
......@@ -527,7 +527,7 @@ void vtkDataSetAttributesCopyValues(
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkDataSetAttributesCopyValues(
vtkArrayIteratorTemplate<vtkStdString>* destIter, const int* outExt,
vtkIdType outIncs[3],
......
......@@ -131,7 +131,7 @@ void vtkDelimitedTextWriterGetDataString(
}
//-----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkDelimitedTextWriterGetDataString(
vtkArrayIteratorTemplate<vtkStdString>* iter, vtkIdType tupleIndex,
ostream* stream, vtkDelimitedTextWriter* writer, bool* first)
......
......@@ -542,12 +542,12 @@ public:
template <typename T> T To() const;
#if defined(_MSC_VER)
// workaround for Win32-64ids-nmake70
VTK_TEMPLATE_SPECIALIZE bool Is<int>() const;
VTK_TEMPLATE_SPECIALIZE bool Is<float>() const;
VTK_TEMPLATE_SPECIALIZE bool Is<double>() const;
VTK_TEMPLATE_SPECIALIZE int To<int>() const;
VTK_TEMPLATE_SPECIALIZE float To<float>() const;
VTK_TEMPLATE_SPECIALIZE double To<double>() const;
template<> bool Is<int>() const;
template<> bool Is<float>() const;
template<> bool Is<double>() const;
template<> int To<int>() const;
template<> float To<float>() const;
template<> double To<double>() const;
#endif
// workaround for SunOS-CC5.6-dbg
......@@ -675,32 +675,32 @@ public:
}
};
VTK_TEMPLATE_SPECIALIZE inline bool vtkFoamToken::Is<int>() const
template<> inline bool vtkFoamToken::Is<int>() const
{
return this->Type == LABEL;
}
VTK_TEMPLATE_SPECIALIZE inline bool vtkFoamToken::Is<float>() const
template<> inline bool vtkFoamToken::Is<float>() const
{
return this->Type == LABEL || this->Type == SCALAR;
}
VTK_TEMPLATE_SPECIALIZE inline bool vtkFoamToken::Is<double>() const
template<> inline bool vtkFoamToken::Is<double>() const
{
return this->Type == SCALAR;
}
VTK_TEMPLATE_SPECIALIZE inline int vtkFoamToken::To<int>() const
template<> inline int vtkFoamToken::To<int>() const
{
return this->Int;
}
VTK_TEMPLATE_SPECIALIZE inline float vtkFoamToken::To<float>() const
template<> inline float vtkFoamToken::To<float>() const
{
return this->Type == LABEL ? this->Int : this->Double;
}
VTK_TEMPLATE_SPECIALIZE inline double vtkFoamToken::To<double>() const
template<> inline double vtkFoamToken::To<double>() const
{
return this->Type == LABEL ? this->Int : this->Double;
}
......@@ -2009,12 +2009,12 @@ public:
static T ReadValue(vtkFoamIOobject &io);
};
VTK_TEMPLATE_SPECIALIZE inline int vtkFoamReadValue<int>::ReadValue(vtkFoamIOobject& io)
template<> inline int vtkFoamReadValue<int>::ReadValue(vtkFoamIOobject& io)
{
return io.ReadIntValue();
}
VTK_TEMPLATE_SPECIALIZE inline float vtkFoamReadValue<float>::ReadValue(vtkFoamIOobject& io)
template<> inline float vtkFoamReadValue<float>::ReadValue(vtkFoamIOobject& io)
{
return io.ReadFloatValue();
}
......@@ -2510,7 +2510,7 @@ public:
// specialization for reading double precision binary into vtkFloatArray.
// Must precede ReadNonuniformList() below (HP-UXia64-aCC).
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkFoamEntryValue::listTraits<vtkFloatArray, float>::ReadBinaryList(
vtkFoamIOobject& io, const int size)
{
......
......@@ -97,12 +97,12 @@ inline void vtkMPIImageReaderMaskBits(T *data, vtkIdType length,
}
// Override float and double because masking bits for them makes no sense.
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkMPIImageReaderMaskBits(float *, vtkIdType, vtkTypeUInt64)
{
return;
}
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkMPIImageReaderMaskBits(double *, vtkIdType, vtkTypeUInt64)
{
return;
......
......@@ -111,12 +111,12 @@ inline void vtkPNrrdReaderMaskBits(T *data, vtkIdType length,
}
// Override float and double because masking bits for them makes no sense.
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkPNrrdReaderMaskBits(float *, vtkIdType, vtkTypeUInt64)
{
return;
}
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkPNrrdReaderMaskBits(double *, vtkIdType, vtkTypeUInt64)
{
return;
......
......@@ -585,7 +585,7 @@ int vtkXMLDataReaderReadArrayValues(vtkXMLDataElement* da,
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
int vtkXMLDataReaderReadArrayValues(
vtkXMLDataElement* da,
vtkXMLDataParser* xmlparser, vtkIdType arrayIndex,
......
......@@ -399,7 +399,7 @@ void vtkXMLStructuredDataReaderSubExtentCopyValues(
numValues);
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
void vtkXMLStructuredDataReaderSubExtentCopyValues(
vtkArrayIteratorTemplate<vtkStdString>* destIter, vtkIdType destIndex,
vtkArrayIteratorTemplate<vtkStdString>* srcIter, vtkIdType srcIndex,
......
......@@ -1789,7 +1789,7 @@ inline ostream& vtkXMLWriteAsciiValue(ostream& os, const T& value)
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
inline ostream& vtkXMLWriteAsciiValue(ostream& os, const char &c)
{
os << short(c);
......@@ -1797,7 +1797,7 @@ inline ostream& vtkXMLWriteAsciiValue(ostream& os, const char &c)
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
inline ostream& vtkXMLWriteAsciiValue(ostream& os, const unsigned char &c)
{
os << static_cast<unsigned short>(c);
......@@ -1805,7 +1805,7 @@ inline ostream& vtkXMLWriteAsciiValue(ostream& os, const unsigned char &c)
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
inline ostream& vtkXMLWriteAsciiValue(ostream& os, const signed char &c)
{
os << short(c);
......@@ -1813,7 +1813,7 @@ inline ostream& vtkXMLWriteAsciiValue(ostream& os, const signed char &c)
}
//----------------------------------------------------------------------------
VTK_TEMPLATE_SPECIALIZE
template<>
inline ostream& vtkXMLWriteAsciiValue(ostream& os, const vtkStdString& str)
{
vtkStdString::const_iterator iter;
......
......@@ -78,7 +78,7 @@ void MatrixMultArray(const T *A, T *B, vtkIdType length)
}
// Specialize for floats for greater precision.
VTK_TEMPLATE_SPECIALIZE
template<>
void MatrixMultArray(const float *A, float *B, vtkIdType length)
{
double *tmpA = new double[length];
......@@ -123,13 +123,13 @@ inline T myAbs(T x)
return (x < 0) ? -x : x;
}
VTK_TEMPLATE_SPECIALIZE inline int AreEqual(float a, float b)
template<> inline int AreEqual(float a, float b)
{
float tolerance = myAbs(0.01f*a);
return (myAbs(a-b) <= tolerance);
}
VTK_TEMPLATE_SPECIALIZE inline int AreEqual(double a, double b)
template<> inline int AreEqual(double a, double b)
{
double tolerance = myAbs(0.000001f*a);
return (myAbs(a-b) <= tolerance);
......
......@@ -370,7 +370,7 @@ public:
}
};
VTK_TEMPLATE_SPECIALIZE
template<>
class vtkUpload3D< double >
{
public:
......
......@@ -320,7 +320,7 @@ public:
}
};
VTK_TEMPLATE_SPECIALIZE
template<>
class vtkUpload3D< double >
{
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment