From dd92e75cdaeebb770b5d4211aaca8fc14bf1df88 Mon Sep 17 00:00:00 2001 From: vsonnier Date: Thu, 28 Feb 2019 22:05:27 +0100 Subject: [PATCH] Try to workaround explicit specialization in class scope error for GCC and friends --- src/util/DataTree.h | 54 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/util/DataTree.h b/src/util/DataTree.h index 1c2d136..9aecfc0 100755 --- a/src/util/DataTree.h +++ b/src/util/DataTree.h @@ -125,69 +125,71 @@ private: //keep the vector of types in a spearate vector of DataElementBuffer. DataElementBufferVector data_val_vector; + //specializations to extract type: (need to be declared/done OUTSIDE of class scope else "Error: explicit specialization is not allowed in the current scope") + //this is apparently fixed in C++17... + // so we need to workaround it with a partial specialization using a fake Dummy parameter. + //if the exact right determineScalarDataType specialization was not used, throw exception at runtime. - template + template DataElementTypeEnum determineScalarDataType(const U& type_in) { throw DataTypeMismatchException("determineScalarDataType(U) usage with unsupported type !"); } - //specializations to extract type: - template<> - DataElementTypeEnum determineScalarDataType(const char& type_in) { return DATA_CHAR; } + template< typename Dummy = int > + DataElementTypeEnum determineScalarDataType(const char& type_in) { return DATA_CHAR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const unsigned char& type_in) { return DATA_UCHAR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const int& type_in) { return DATA_INT; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const unsigned int& type_in) { return DATA_UINT; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const long& type_in) { return DATA_LONG; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const unsigned long& type_in) { return DATA_ULONG; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const long long& type_in) { return DATA_LONGLONG; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const float& type_in) { return DATA_FLOAT; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineScalarDataType(const double& type_in) { return DATA_DOUBLE; } - + //vector versions: //if the exact right determineVectorDataType specialization was not used, throw exception at runtime. - template + template DataElementTypeEnum determineVectorDataType(const vector& type_in) { throw DataTypeMismatchException("determineVectorDataType(V) usage with unsupported type !"); } - //specializations to extract type: - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_CHAR_VECTOR; } - template<> - DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_UCHAR_VECTOR; } + template< typename Dummy = int > + DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_UCHAR_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_INT_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_UINT_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_LONG_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_ULONG_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_LONGLONG_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_FLOAT_VECTOR; } - template<> + template< typename Dummy = int > DataElementTypeEnum determineVectorDataType(const vector& type_in) { return DATA_DOUBLE_VECTOR; } public: @@ -506,7 +508,7 @@ public: std::string toString(); }; - +/// class DataNode { private: