* Fixed a couple of bugs in TypeManip.h

* Minor changes to TypeTraits.h and NullType.h for easying migration to boost.


git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@8 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
aandrei 2001-11-23 08:06:43 +00:00
parent 1fadda9836
commit ba72e1e935
3 changed files with 30 additions and 16 deletions

View file

@ -13,7 +13,7 @@
// without express or implied warranty. // without express or implied warranty.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Last update: June 20, 2001 // Last update: November 22, 2001
#ifndef NULLTYPE_INC_ #ifndef NULLTYPE_INC_
#define NULLTYPE_INC_ #define NULLTYPE_INC_
@ -27,11 +27,12 @@ namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class NullType {}; class NullType {};
} } // namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Change log: // Change log:
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
// November 22, 2001: minor change to support porting to boost
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#endif // NULLTYPE_INC_ #endif // NULLTYPE_INC_

View file

@ -13,7 +13,7 @@
// without express or implied warranty. // without express or implied warranty.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Last update: June 20, 2001 // Last update: November 22, 2001
#ifndef TYPEMANIP_INC_ #ifndef TYPEMANIP_INC_
#define TYPEMANIP_INC_ #define TYPEMANIP_INC_
@ -122,7 +122,7 @@ namespace Loki
template <class T> template <class T>
struct Conversion<void, T> struct Conversion<void, T>
{ {
enum { exists = 1, exists2Way = 0,sameType = 0 }; enum { exists = 0, exists2Way = 0, sameType = 0 };
}; };
template <class T> template <class T>
@ -137,7 +137,7 @@ namespace Loki
public: public:
enum { exists = 1, exists2Way = 1, sameType = 1 }; enum { exists = 1, exists2Way = 1, sameType = 1 };
}; };
} } // namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// macro SUPERSUBCLASS // macro SUPERSUBCLASS
@ -149,8 +149,8 @@ namespace Loki
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define SUPERSUBCLASS(T, U) \ #define SUPERSUBCLASS(T, U) \
(::Loki::Conversion<const U*, const T*>::exists && \ (::Loki::Conversion<const volatile U*, const volatile T*>::exists && \
!::Loki::Conversion<const T*, const void*>::sameType) !::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// macro SUPERSUBCLASS // macro SUPERSUBCLASS
@ -162,11 +162,16 @@ namespace Loki
#define SUPERSUBCLASS_STRICT(T, U) \ #define SUPERSUBCLASS_STRICT(T, U) \
(SUPERSUBCLASS(T, U) && \ (SUPERSUBCLASS(T, U) && \
!::Loki::Conversion<const T, const U>::sameType) !::Loki::Conversion<const volatile T, const volatile U>::sameType)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Change log: // Change log:
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
// November 22, 2001: minor change to support porting to boost
// November 22, 2001: fixed bug in Conversion<void, T>
// (credit due to Brad Town)
// November 23, 2001: (well it's 12:01 am) fixed bug in SUPERSUBCLASS - added
// the volatile qualifier to be 100% politically correct
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#endif // TYPEMANIP_INC_ #endif // TYPEMANIP_INC_

View file

@ -13,7 +13,7 @@
// without express or implied warranty. // without express or implied warranty.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Last update: June 20, 2001 // Last update: November 22, 2001
#ifndef TYPELIST_INC_ #ifndef TYPELIST_INC_
#define TYPELIST_INC_ #define TYPELIST_INC_
@ -365,6 +365,8 @@ namespace Loki
typedef U Tail; typedef U Tail;
}; };
// Typelist utility algorithms
namespace TL namespace TL
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -679,7 +681,7 @@ namespace Loki
// class template MostDerived // class template MostDerived
// Finds the type in a typelist that is the most derived from a given type // Finds the type in a typelist that is the most derived from a given type
// Invocation (TList is a typelist, T is a type): // Invocation (TList is a typelist, T is a type):
// Replace<TList, T>::Result // MostDerived<TList, T>::Result
// returns the type in TList that's the most derived from T // returns the type in TList that's the most derived from T
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -724,8 +726,9 @@ namespace Loki
private: private:
typedef typename MostDerived<Tail, Head>::Result typedef typename MostDerived<Tail, Head>::Result
TheMostDerived; TheMostDerived;
typedef typename Replace<Tail, typedef typename ReplaceAll<Tail,
TheMostDerived, Head>::Result L; TheMostDerived, Head>::Result Temp;
typedef typename DerivedToFront<Temp>::Result L;
public: public:
typedef Typelist<TheMostDerived, L> Result; typedef Typelist<TheMostDerived, L> Result;
}; };
@ -738,6 +741,11 @@ namespace Loki
// June 09, 2001: Fix bug in parameter list of macros TYPELIST_23 to TYPELIST_27 // June 09, 2001: Fix bug in parameter list of macros TYPELIST_23 to TYPELIST_27
// (credit due to Dave Taylor) // (credit due to Dave Taylor)
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
// November 22, 2001: fixed bug in DerivedToFront
// (credit due to Gianni Luciani who noticed the bug first;
// Adam Wilkshire;
// Friedrik Hedman who fixed the bug but didn't send the fix;
// Kevin Cline who sent the first actual fix)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#endif // TYPELIST_INC_ #endif // TYPELIST_INC_