diff --git a/AbstractFactory.h b/AbstractFactory.h index b44be82..7e33124 100644 --- a/AbstractFactory.h +++ b/AbstractFactory.h @@ -14,6 +14,8 @@ # include "Reference/AbstractFactory.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/AbstractFactory.h" +# elif (_MSC_VER >= 1301) +# include "Reference/AbstractFactory.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/AbstractFactory.h" # elif (_MSC_VER >= 1200) diff --git a/AssocVector.h b/AssocVector.h index 4b16211..a72c6a3 100644 --- a/AssocVector.h +++ b/AssocVector.h @@ -14,6 +14,8 @@ # include "Reference/AssocVector.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/AssocVector.h" +# elif (_MSC_VER >= 1301) +# include "Reference/AssocVector.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/AssocVector.h" # elif (_MSC_VER >= 1200) diff --git a/Borland/Factory.h b/Borland/Factory.h index d13d2e3..c8af103 100644 --- a/Borland/Factory.h +++ b/Borland/Factory.h @@ -18,7 +18,7 @@ #ifndef FACTORY_INC_ #define FACTORY_INC_ -#include "Loki_TypeInfo.h" +#include "LokiTypeInfo.h" #include "AssocVector.h" #include diff --git a/Borland/TypeInfo.h b/Borland/LokiTypeInfo.h similarity index 88% rename from Borland/TypeInfo.h rename to Borland/LokiTypeInfo.h index 50fdce0..aa1e03e 100644 --- a/Borland/TypeInfo.h +++ b/Borland/LokiTypeInfo.h @@ -1,26 +1,4 @@ -head 1.1; -access; -symbols; -locks; strict; -comment @ * @; - - -1.1 -date 2002.07.16.22.42.05; author tslettebo; state Exp; -branches; -next ; - - -desc -@@ - - -1.1 -log -@Initial commit -@ -text -@//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // The Loki Library // Copyright (c) 2001 by Andrei Alexandrescu // This code accompanies the book: @@ -35,10 +13,10 @@ text // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// -// Last update: June 20, 2001 +// Last update: August 9, 2002 -#ifndef TYPEINFO_INC_ -#define TYPEINFO_INC_ +#ifndef LOKITYPEINFO_INC_ +#define LOKITYPEINFO_INC_ #include #include @@ -54,6 +32,7 @@ namespace Loki class TypeInfo { public: + // Constructors TypeInfo(); // needed for containers TypeInfo(const std::type_info&); // non-explicit @@ -123,8 +102,7 @@ namespace Loki //////////////////////////////////////////////////////////////////////////////// // Change log: // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! -// July 16, 2002: Ported by Terje Slettebų to BCC 5.6 +// July 16, 2002: Ported by Terje Slettebų and Pavel Vozenilek to BCC 5.6 //////////////////////////////////////////////////////////////////////////////// -#endif // TYPEINFO_INC_ -@ +#endif // LOKITYPEINFO_INC_ diff --git a/Borland/MultiMethods.h b/Borland/MultiMethods.h index ca069da..c97424e 100644 --- a/Borland/MultiMethods.h +++ b/Borland/MultiMethods.h @@ -19,7 +19,7 @@ #define MULTIMETHODS_INC_ #include "Typelist.h" -#include "Loki_TypeInfo.h" //### BCB +#include "LokiTypeInfo.h" //### BCB #include "Functor.h" #include "AssocVector.h" #include // *** diff --git a/Borland/SmallObj.cpp b/Borland/SmallObj.cpp index 8ce55e3..22ba29e 100644 --- a/Borland/SmallObj.cpp +++ b/Borland/SmallObj.cpp @@ -280,6 +280,9 @@ FixedAllocator::Chunk* FixedAllocator::VicinityFind(void* p) Chunk* loBound = &chunks_.front(); Chunk* hiBound = &chunks_.back() + 1; + // Special case: deallocChunk_ is the last in the array + if (hi == hiBound) hi = 0; + for (;;) { if (lo) diff --git a/Borland/TypeManip.h b/Borland/TypeManip.h index 8861101..32f5034 100644 --- a/Borland/TypeManip.h +++ b/Borland/TypeManip.h @@ -67,6 +67,27 @@ namespace Loki typedef U Result; }; +//////////////////////////////////////////////////////////////////////////////// +// class template IsSameType +// Return true iff two given types are the same +// Invocation: SameType::value +// where: +// T and U are types +// Result evaluates to true iff U == T (types equal) +//////////////////////////////////////////////////////////////////////////////// + + template + struct IsSameType + { + enum { value = false }; + }; + + template + struct IsSameType + { + enum { value = true }; + }; + //////////////////////////////////////////////////////////////////////////////// // Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big) //////////////////////////////////////////////////////////////////////////////// diff --git a/Borland/Typelist.h b/Borland/Typelist.h index d7e76fe..01fea52 100644 --- a/Borland/Typelist.h +++ b/Borland/Typelist.h @@ -368,6 +368,47 @@ namespace Loki namespace TL { //////////////////////////////////////////////////////////////////////////////// +// class template MakeTypelist +// Takes a number of arguments equal to its numeric suffix +// The arguments are type names. +// MakeTypelist::Result +// returns a typelist that is of T1, T2, ... +//////////////////////////////////////////////////////////////////////////////// + + template + < + typename T1 = NullType, typename T2 = NullType, typename T3 = NullType, + typename T4 = NullType, typename T5 = NullType, typename T6 = NullType, + typename T7 = NullType, typename T8 = NullType, typename T9 = NullType, + typename T10 = NullType, typename T11 = NullType, typename T12 = NullType, + typename T13 = NullType, typename T14 = NullType, typename T15 = NullType, + typename T16 = NullType, typename T17 = NullType, typename T18 = NullType + > + struct MakeTypelist + { + private: + typedef typename MakeTypelist + < + T2 , T3 , T4 , + T5 , T6 , T7 , + T8 , T9 , T10, + T11, T12, T13, + T14, T15, T16, + T17, T18 + > + ::Result TailResult; + + public: + typedef Typelist Result; + }; + + template<> + struct MakeTypelist<> + { + typedef NullType Result; + }; + +//////////////////////////////////////////////////////////////////////////////// // class template Length // Computes the length of a typelist // Invocation (TList is a typelist): diff --git a/DataGenerators.h b/DataGenerators.h index 1ef07f2..62dd970 100644 --- a/DataGenerators.h +++ b/DataGenerators.h @@ -14,6 +14,8 @@ # include "Reference/DataGenerators.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/DataGenerators.h" +# elif (_MSC_VER >= 1301) +# include "Reference/DataGenerators.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/DataGenerators.h" # elif (_MSC_VER >= 1200) diff --git a/EmptyType.h b/EmptyType.h index 780befa..a9a70c4 100644 --- a/EmptyType.h +++ b/EmptyType.h @@ -14,6 +14,8 @@ # include "Reference/EmptyType.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/EmptyType.h" +# elif (_MSC_VER >= 1301) +# include "Reference/EmptyType.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/EmptyType.h" # elif (_MSC_VER >= 1200) diff --git a/Factory.h b/Factory.h index d46ec0c..3a5905a 100644 --- a/Factory.h +++ b/Factory.h @@ -14,6 +14,8 @@ # include "Reference/Factory.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/Factory.h" +# elif (_MSC_VER >= 1301) +# include "Reference/Factory.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/Factory.h" # elif (_MSC_VER >= 1200) diff --git a/Functor.h b/Functor.h index e0796d4..0bab576 100644 --- a/Functor.h +++ b/Functor.h @@ -14,6 +14,8 @@ # include "Reference/Functor.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/Functor.h" +# elif (_MSC_VER >= 1301) +# include "Reference/Functor.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/Functor.h" # elif (_MSC_VER >= 1200) diff --git a/HierarchyGenerators.h b/HierarchyGenerators.h index 24ee545..1be9c03 100644 --- a/HierarchyGenerators.h +++ b/HierarchyGenerators.h @@ -14,6 +14,8 @@ # include "Reference/HierarchyGenerators.h" # elif (__BORLANDC__ >= 0x560) # include "Borland/HierarchyGenerators.h" +# elif (_MSC_VER >= 1301) +# include "Reference/HierarchyGenerators.h" # elif (_MSC_VER >= 1300) # include "MSVC/1300/HierarchyGenerators.h" # elif (_MSC_VER >= 1200) diff --git a/TypeInfo.h b/LokiTypeInfo.h similarity index 54% rename from TypeInfo.h rename to LokiTypeInfo.h index e2cd8e8..a13faf2 100644 --- a/TypeInfo.h +++ b/LokiTypeInfo.h @@ -6,19 +6,21 @@ //////////////////////////////// #ifdef LOKI_USE_REFERENCE -# include "Reference/TypeInfo.h" +# include "Reference/LokiTypeInfo.h" #else # if (__INTEL_COMPILER) -# include "Reference/TypeInfo.h" +# include "Reference/LokiTypeInfo.h" # elif (__MWERKS__) -# include "Reference/TypeInfo.h" +# include "Reference/LokiTypeInfo.h" # elif (__BORLANDC__ >= 0x560) -# include "Borland/TypeInfo.h" +# include "Borland/LokiTypeInfo.h" +# elif (_MSC_VER >= 1301) +# include "Borland/LokiTypeInfo.h" # elif (_MSC_VER >= 1300) -# include "MSVC/1300/TypeInfo.h" +# include "MSVC/1300/LokiTypeInfo.h" # elif (_MSC_VER >= 1200) -# include "MSVC/1200/TypeInfo.h" +# include "MSVC/1200/LokiTypeInfo.h" # else -# include "Reference/TypeInfo.h" +# include "Reference/LokiTypeInfo.h" # endif #endif diff --git a/MSVC/1200/Factory.h b/MSVC/1200/Factory.h index 8894866..29d6bbf 100644 --- a/MSVC/1200/Factory.h +++ b/MSVC/1200/Factory.h @@ -21,7 +21,7 @@ #ifndef FACTORY_INC_ #define FACTORY_INC_ -#include "TypeInfo.h" +#include "LokiTypeInfo.h" #include "AssocVector.h" #include diff --git a/Reference/TypeInfo.h b/MSVC/1200/LokiTypeInfo.h similarity index 94% rename from Reference/TypeInfo.h rename to MSVC/1200/LokiTypeInfo.h index f9ed1a5..d8ec1ed 100644 --- a/Reference/TypeInfo.h +++ b/MSVC/1200/LokiTypeInfo.h @@ -15,8 +15,8 @@ // Last update: June 20, 2001 -#ifndef TYPEINFO_INC_ -#define TYPEINFO_INC_ +#ifndef LOKITYPEINFO_INC_ +#define LOKITYPEINFO_INC_ #include #include @@ -62,7 +62,7 @@ namespace Loki inline bool TypeInfo::before(const TypeInfo& rhs) const { assert(pInfo_); - return pInfo_->before(*rhs.pInfo_); + return pInfo_->before(*rhs.pInfo_) != 0; } inline const std::type_info& TypeInfo::Get() const @@ -80,7 +80,7 @@ namespace Loki // Comparison operators inline bool operator==(const TypeInfo& lhs, const TypeInfo& rhs) - { return lhs.Get() == rhs.Get(); } + { return (lhs.Get() == rhs.Get()) != 0; } inline bool operator<(const TypeInfo& lhs, const TypeInfo& rhs) { return lhs.before(rhs); } @@ -103,4 +103,4 @@ namespace Loki // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! //////////////////////////////////////////////////////////////////////////////// -#endif // TYPEINFO_INC_ +#endif // LOKITYPEINFO_INC_ diff --git a/MSVC/1200/MultiMethods.h b/MSVC/1200/MultiMethods.h index 1303c2d..0655603 100644 --- a/MSVC/1200/MultiMethods.h +++ b/MSVC/1200/MultiMethods.h @@ -42,7 +42,7 @@ #define MULTIMETHODS_INC_ #include "Typelist.h" -#include "TypeInfo.h" +#include "LokiTypeInfo.h" #include "Functor.h" #include "AssocVector.h" diff --git a/MSVC/1300/Factory.h b/MSVC/1300/Factory.h index af61639..62bb4dc 100644 --- a/MSVC/1300/Factory.h +++ b/MSVC/1300/Factory.h @@ -18,7 +18,7 @@ #ifndef FACTORY_INC_ #define FACTORY_INC_ -#include "TypeInfo.h" +#include "LokiTypeInfo.h" #include "AssocVector.h" #include diff --git a/MSVC/1300/HierarchyGenerators.h b/MSVC/1300/HierarchyGenerators.h index 4bf690f..16e882c 100644 --- a/MSVC/1300/HierarchyGenerators.h +++ b/MSVC/1300/HierarchyGenerators.h @@ -240,7 +240,7 @@ namespace Loki typedef typename Select < - SameType >::value, + IsSameType >::value, ElementType, UnitType > @@ -285,7 +285,7 @@ namespace Loki typedef typename Select < - SameType >::value, + IsSameType >::value, ElementType, UnitType > diff --git a/MSVC/1300/TypeInfo.h b/MSVC/1300/LokiTypeInfo.h similarity index 97% rename from MSVC/1300/TypeInfo.h rename to MSVC/1300/LokiTypeInfo.h index ee6701c..98c66be 100644 --- a/MSVC/1300/TypeInfo.h +++ b/MSVC/1300/LokiTypeInfo.h @@ -15,8 +15,8 @@ // Last update: May 19, 2002 -#ifndef TYPEINFO_INC_ -#define TYPEINFO_INC_ +#ifndef LOKITYPEINFO_INC_ +#define LOKITYPEINFO_INC_ #include #include @@ -104,4 +104,4 @@ namespace Loki // May 10, 2002: ported by Rani Sharoni to VC7 (RTM - 9466) //////////////////////////////////////////////////////////////////////////////// -#endif // TYPEINFO_INC_ +#endif // LOKITYPEINFO_INC_ diff --git a/MSVC/1300/MultiMethods.h b/MSVC/1300/MultiMethods.h index 14421bd..21c6bd8 100644 --- a/MSVC/1300/MultiMethods.h +++ b/MSVC/1300/MultiMethods.h @@ -19,7 +19,7 @@ #define MULTIMETHODS_INC_ #include "Typelist.h" -#include "TypeInfo.h" +#include "LokiTypeInfo.h" #include "Functor.h" #include "AssocVector.h" diff --git a/MSVC/1300/Singleton.h b/MSVC/1300/Singleton.h index 1a232ed..c9c1118 100644 --- a/MSVC/1300/Singleton.h +++ b/MSVC/1300/Singleton.h @@ -335,14 +335,10 @@ namespace Loki class SingletonHolderStaticData { friend ClientType; // illegal (11.4/2) but works with VC - static ThreadingModelType s_ThreadingModelData; static PtrInstanceType s_pInstance; static bool s_destroyed; }; - template - M SingletonHolderStaticData::s_ThreadingModelData; - template P SingletonHolderStaticData::s_pInstance; @@ -382,9 +378,7 @@ namespace Loki // Helpers static void MakeInstance() { - typename ThreadingModel::Lock guard( - MySingletonHolderStaticData::s_ThreadingModelData); - + typename ThreadingModel::Lock guard; (void)guard; if (!pInstance_()) diff --git a/MSVC/1300/SmallObj.cpp b/MSVC/1300/SmallObj.cpp index e7a8585..527445f 100644 --- a/MSVC/1300/SmallObj.cpp +++ b/MSVC/1300/SmallObj.cpp @@ -273,6 +273,9 @@ FixedAllocator::Chunk* FixedAllocator::VicinityFind(void* p) Chunk* loBound = &chunks_.front(); Chunk* hiBound = &chunks_.back() + 1; + // Special case: deallocChunk_ is the last in the array + if (hi == hiBound) hi = 0; + for (;;) { if (lo) diff --git a/MSVC/1300/SmallObj.h b/MSVC/1300/SmallObj.h index 4c5a2f0..ebab465 100644 --- a/MSVC/1300/SmallObj.h +++ b/MSVC/1300/SmallObj.h @@ -127,20 +127,6 @@ namespace Loki // allocations/deallocations //////////////////////////////////////////////////////////////////////////////// - template - < - class ClientType, - class ThreadingModelType - > - class SmallObjectStaticData - { - friend ClientType; // illegal (11.4/2) but works with VC - static ThreadingModelType s_ThreadingModelData; - }; - - template - M SmallObjectStaticData::s_ThreadingModelData; - template < template class ThreadingModel = DEFAULT_THREADING, @@ -153,13 +139,6 @@ namespace Loki typedef ThreadingModel< SmallObject > MyThreadingModel; - typedef SmallObjectStaticData - < - SmallObject, - MyThreadingModel - > - MySmallObjectStaticData; - struct MySmallObjAllocator : public SmallObjAllocator { MySmallObjAllocator() @@ -175,8 +154,7 @@ namespace Loki static void* operator new(std::size_t size) { #if (MAX_SMALL_OBJECT_SIZE != 0) && (DEFAULT_CHUNK_SIZE != 0) - typename MyThreadingModel::Lock lock( - MySmallObjectStaticData::s_ThreadingModelData); + typename MyThreadingModel::Lock lock; (void)lock; // get rid of warning return SingletonHolder::RefCountedMT //////////////////////////////////////////////////////////////////////////////// + template