diff --git a/src/cxxTemplates/resourceLib.h b/src/cxxTemplates/resourceLib.h index 0fd30a9e5..f8ad1c4e3 100644 --- a/src/cxxTemplates/resourceLib.h +++ b/src/cxxTemplates/resourceLib.h @@ -220,7 +220,11 @@ private: // efficently. Hash indexes are produced more efficiently // when (MAX_ID_WIDTH - MIN_INDEX_WIDTH) is minimized. // -template +#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) ) +template +#else +template +#endif class intId { public: intId (const T &idIn); @@ -243,7 +247,11 @@ protected: // // NOTE: ITEM must public inherit from chronIntIdRes // +#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) ) +typedef intId chronIntId; +#else typedef intId chronIntId; +#endif template class chronIntIdResTable : public resTable { public: diff --git a/src/cxxTemplates/test/resourceLibTest.cc b/src/cxxTemplates/test/resourceLibTest.cc index e6655b420..8b9cc3151 100644 --- a/src/cxxTemplates/test/resourceLibTest.cc +++ b/src/cxxTemplates/test/resourceLibTest.cc @@ -11,10 +11,16 @@ void empty(); -class albert : public intId, public tsSLNode { +#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) ) +typedef intId testIntId; +#else +typedef intId testIntId; +#endif + +class albert : public testIntId, public tsSLNode { public: - albert (resTable< albert, intId > &atIn, unsigned idIn) : - intId(idIn), at(atIn) + albert (resTable< albert, testIntId > &atIn, unsigned idIn) : + testIntId(idIn), at(atIn) { assert (at.add (*this)==0); } @@ -27,13 +33,13 @@ public: delete this; } private: - resTable< albert, intId > &at; + resTable< albert, testIntId > &at; }; -class fred : public intId, public tsSLNode { +class fred : public testIntId, public tsSLNode { public: fred (const char *pNameIn, unsigned idIn) : - intId(idIn), pName(pNameIn) {} + testIntId(idIn), pName(pNameIn) {} void show (unsigned) { printf("fred %s\n", pName); @@ -78,7 +84,7 @@ void jane::testTraverse() // This explicitly instantiates the template class's member // functions into "templInst.o" // - template class resTable >; + template class resTable; template class resTable; #endif @@ -88,7 +94,7 @@ int main() clock_t start, finish; double duration; const unsigned LOOPS = 50000; - resTable > intTbl (8); + resTable intTbl (8); resTable strTbl (8); fred fred0("fred0",0); fred fred1("fred1",0x1000a432); @@ -104,16 +110,16 @@ int main() jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); fred *pFred; jane *pJane; - intId intId0 (0); - intId intId1 (0x1000a432); - intId intId2 (0x0000a432); - intId intId3 (1); - intId intId4 (2); - intId intId5 (3); - intId intId6 (4); - intId intId7 (5); - intId intId8 (6); - intId intId9 (7); + testIntId intId0 (0); + testIntId intId1 (0x1000a432); + testIntId intId2 (0x0000a432); + testIntId intId3 (1); + testIntId intId4 (2); + testIntId intId5 (3); + testIntId intId6 (4); + testIntId intId7 (5); + testIntId intId8 (6); + testIntId intId9 (7); stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); @@ -235,7 +241,7 @@ int main() // hash distribution test // static const unsigned tableSize = 0x1000; - resTable< albert, intId > alTbl (tableSize); + resTable< albert, testIntId > alTbl (tableSize); for (i=0; i > alTblIter (alTbl); + resTableIter< albert, testIntId > alTblIter (alTbl); albert *pa; i=0; while ( (pa = alTblIter.next()) ) { diff --git a/src/libCom/cxxTemplates/resourceLib.h b/src/libCom/cxxTemplates/resourceLib.h index 0fd30a9e5..f8ad1c4e3 100644 --- a/src/libCom/cxxTemplates/resourceLib.h +++ b/src/libCom/cxxTemplates/resourceLib.h @@ -220,7 +220,11 @@ private: // efficently. Hash indexes are produced more efficiently // when (MAX_ID_WIDTH - MIN_INDEX_WIDTH) is minimized. // -template +#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) ) +template +#else +template +#endif class intId { public: intId (const T &idIn); @@ -243,7 +247,11 @@ protected: // // NOTE: ITEM must public inherit from chronIntIdRes // +#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) ) +typedef intId chronIntId; +#else typedef intId chronIntId; +#endif template class chronIntIdResTable : public resTable { public: diff --git a/src/libCom/cxxTemplates/test/resourceLibTest.cc b/src/libCom/cxxTemplates/test/resourceLibTest.cc index e6655b420..8b9cc3151 100644 --- a/src/libCom/cxxTemplates/test/resourceLibTest.cc +++ b/src/libCom/cxxTemplates/test/resourceLibTest.cc @@ -11,10 +11,16 @@ void empty(); -class albert : public intId, public tsSLNode { +#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) ) +typedef intId testIntId; +#else +typedef intId testIntId; +#endif + +class albert : public testIntId, public tsSLNode { public: - albert (resTable< albert, intId > &atIn, unsigned idIn) : - intId(idIn), at(atIn) + albert (resTable< albert, testIntId > &atIn, unsigned idIn) : + testIntId(idIn), at(atIn) { assert (at.add (*this)==0); } @@ -27,13 +33,13 @@ public: delete this; } private: - resTable< albert, intId > &at; + resTable< albert, testIntId > &at; }; -class fred : public intId, public tsSLNode { +class fred : public testIntId, public tsSLNode { public: fred (const char *pNameIn, unsigned idIn) : - intId(idIn), pName(pNameIn) {} + testIntId(idIn), pName(pNameIn) {} void show (unsigned) { printf("fred %s\n", pName); @@ -78,7 +84,7 @@ void jane::testTraverse() // This explicitly instantiates the template class's member // functions into "templInst.o" // - template class resTable >; + template class resTable; template class resTable; #endif @@ -88,7 +94,7 @@ int main() clock_t start, finish; double duration; const unsigned LOOPS = 50000; - resTable > intTbl (8); + resTable intTbl (8); resTable strTbl (8); fred fred0("fred0",0); fred fred1("fred1",0x1000a432); @@ -104,16 +110,16 @@ int main() jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); fred *pFred; jane *pJane; - intId intId0 (0); - intId intId1 (0x1000a432); - intId intId2 (0x0000a432); - intId intId3 (1); - intId intId4 (2); - intId intId5 (3); - intId intId6 (4); - intId intId7 (5); - intId intId8 (6); - intId intId9 (7); + testIntId intId0 (0); + testIntId intId1 (0x1000a432); + testIntId intId2 (0x0000a432); + testIntId intId3 (1); + testIntId intId4 (2); + testIntId intId5 (3); + testIntId intId6 (4); + testIntId intId7 (5); + testIntId intId8 (6); + testIntId intId9 (7); stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); @@ -235,7 +241,7 @@ int main() // hash distribution test // static const unsigned tableSize = 0x1000; - resTable< albert, intId > alTbl (tableSize); + resTable< albert, testIntId > alTbl (tableSize); for (i=0; i > alTblIter (alTbl); + resTableIter< albert, testIntId > alTblIter (alTbl); albert *pa; i=0; while ( (pa = alTblIter.next()) ) {