Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2010, 5:04:12 PM (14 years ago)
Author:
rgrieder
Message:

Moved Loki library files to separate loki folder in externals.
Also added TypeManip.h (now used in Convert.h) and static_check.h.

Location:
code/trunk/src/external/loki
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/loki/TypeTraits.h

    r7263 r7266  
    33// Copyright (c) 2001 by Andrei Alexandrescu
    44// This code accompanies the book:
    5 // Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design 
     5// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
    66//     Patterns Applied". Copyright (c) 2001. Addison-Wesley.
    7 // Permission to use, copy, modify, distribute and sell this software for any 
    8 //     purpose is hereby granted without fee, provided that the above copyright 
    9 //     notice appear in all copies and that both that copyright notice and this 
     7// Permission to use, copy, modify, distribute and sell this software for any
     8//     purpose is hereby granted without fee, provided that the above copyright
     9//     notice appear in all copies and that both that copyright notice and this
    1010//     permission notice appear in supporting documentation.
    11 // The author or Addison-Wesley Longman make no representations about the 
    12 //     suitability of this software for any purpose. It is provided "as is" 
     11// The author or Addison-Wesley Longman make no representations about the
     12//     suitability of this software for any purpose. It is provided "as is"
    1313//     without express or implied warranty.
    1414//
    15 // Changes by Orxonox (Reto)
     15// Changes by Orxonox (Reto Grieder)
    1616//     Removed all stdInt, etc. type traits and function pointer traits
    1717//     and added UnqualifiedReferredType.
     
    2020#define LOKI_TYPETRAITS_INC_
    2121
    22 // $Id: TypeTraits.h 835 2007-08-02 19:39:02Z syntheticpp $
    23 
     22// $Id: TypeTraits.h 1069 2010-04-19 03:09:59Z rich_sposato $
     23
     24
     25#include <loki/NullType.h>
    2426
    2527#if (defined _MSC_VER) && (_MSC_VER < 1400)
     
    2931
    3032#ifdef _MSC_VER
    31 #pragma warning( push ) 
     33#pragma warning( push )
    3234#pragma warning( disable : 4180 ) //qualifier applied to function type has no meaning; ignored
    3335#endif
     
    3638{
    3739////////////////////////////////////////////////////////////////////////////////
    38 // class NullType
    39 // Used as a placeholder for "no type here"
    40 // Useful as an end marker in typelists
    41 ////////////////////////////////////////////////////////////////////////////////
    42 
    43     class NullType {};
    44 
    45 ////////////////////////////////////////////////////////////////////////////////
    4640// class template IsCustomUnsignedInt
    4741// Offers a means to integrate nonstandard built-in unsigned integral types
    48 // (such as unsigned __int64 or unsigned long long int) with the TypeTraits 
     42// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
    4943//     class template defined below.
    5044// Invocation: IsCustomUnsignedInt<T> where T is any type
     
    5953    {
    6054        enum { value = 0 };
    61     };       
     55    };
    6256
    6357////////////////////////////////////////////////////////////////////////////////
    6458// class template IsCustomSignedInt
    6559// Offers a means to integrate nonstandard built-in unsigned integral types
    66 // (such as unsigned __int64 or unsigned long long int) with the TypeTraits 
     60// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
    6761//     class template defined below.
    6862// Invocation: IsCustomSignedInt<T> where T is any type
     
    7771    {
    7872        enum { value = 0 };
    79     };       
     73    };
    8074
    8175////////////////////////////////////////////////////////////////////////////////
     
    9488    {
    9589        enum { value = 0 };
    96     };       
     90    };
    9791
    9892////////////////////////////////////////////////////////////////////////////////
     
    142136        };
    143137    }// namespace Private
    144        
     138
    145139////////////////////////////////////////////////////////////////////////////////
    146140// class template TypeTraits
     
    150144//
    151145// - isPointer       : returns true if T is a pointer type
    152 // - PointeeType     : returns the type to which T points if T is a pointer 
     146// - PointeeType     : returns the type to which T points if T is a pointer
    153147//                     type, NullType otherwise
    154148// - isReference     : returns true if T is a reference type
    155 // - ReferredType    : returns the type to which T refers if T is a reference 
     149// - ReferredType    : returns the type to which T refers if T is a reference
    156150//                     type, NullType otherwise
    157 // - ParameterType   : returns the optimal type to be used as a parameter for 
     151// - ParameterType   : returns the optimal type to be used as a parameter for
    158152//                     functions that take Ts
    159153// - isConst         : returns true if T is a const-qualified type
     
    161155// - isVolatile      : returns true if T is a volatile-qualified type
    162156// - NonVolatileType : Type with removed 'volatile' qualifier from T, if any
    163 // - UnqualifiedType : Type with removed 'const' and 'volatile' qualifiers from 
     157// - UnqualifiedType : Type with removed 'const' and 'volatile' qualifiers from
    164158//                     T, if any
    165 // - ParameterType   : returns the optimal type to be used as a parameter 
     159// - ParameterType   : returns the optimal type to be used as a parameter
    166160//                       for functions that take 'const T's
    167161//
     
    172166    {
    173167    private:
    174    
     168
    175169        template <class U> struct ReferenceTraits
    176170        {
     
    178172            typedef U ReferredType;
    179173        };
    180        
     174
    181175        template <class U> struct ReferenceTraits<U&>
    182176        {
     
    184178            typedef U ReferredType;
    185179        };
    186                
     180
    187181        template <class U> struct PointerTraits
    188182        {
     
    190184            typedef NullType PointeeType;
    191185        };
    192        
     186
    193187        template <class U> struct PointerTraits<U*>
    194188        {
     
    196190            typedef U PointeeType;
    197191        };
    198        
     192
    199193        template <class U> struct PointerTraits<U*&>
    200194        {
     
    202196            typedef U PointeeType;
    203197        };
    204          
     198
    205199        template <class U> struct PToMTraits
    206200        {
    207201            enum { result = false };
    208202        };
    209        
     203
    210204        template <class U, class V> struct PToMTraits<U V::*>
    211205        {
    212206            enum { result = true };
    213207        };
    214        
     208
    215209        template <class U, class V> struct PToMTraits<U V::*&>
    216210        {
    217211            enum { result = true };
    218212        };
    219        
     213
    220214        template <class U> struct UnConst
    221215        {
     
    223217            enum { isConst = 0 };
    224218        };
    225        
     219
    226220        template <class U> struct UnConst<const U>
    227221        {
     
    235229            enum { isConst = 1 };
    236230        };
    237  
     231
    238232        template <class U> struct UnVolatile
    239233        {
     
    241235            enum { isVolatile = 0 };
    242236        };
    243        
     237
    244238        template <class U> struct UnVolatile<volatile U>
    245239        {
     
    253247            enum { isVolatile = 1 };
    254248        };
    255        
     249
    256250    public:
    257         typedef typename UnConst<T>::Result 
     251        typedef typename UnConst<T>::Result
    258252            NonConstType;
    259         typedef typename UnVolatile<T>::Result 
     253        typedef typename UnVolatile<T>::Result
    260254            NonVolatileType;
    261         typedef typename UnVolatile<typename UnConst<T>::Result>::Result 
     255        typedef typename UnVolatile<typename UnConst<T>::Result>::Result
    262256            UnqualifiedType;
    263         typedef typename PointerTraits<UnqualifiedType>::PointeeType 
     257        typedef typename PointerTraits<UnqualifiedType>::PointeeType
    264258            PointeeType;
    265         typedef typename ReferenceTraits<T>::ReferredType 
     259        typedef typename ReferenceTraits<T>::ReferredType
    266260            ReferredType;
    267261        typedef typename ReferenceTraits<typename UnVolatile<typename UnConst<T>::Result>::Result>::ReferredType
     
    273267        enum { isPointer        = PointerTraits<
    274268                                        typename ReferenceTraits<UnqualifiedType>::ReferredType >::result};
    275                
     269
    276270    };
    277271}
Note: See TracChangeset for help on using the changeset viewer.