os/ossrv/lowlevellibsandfws/genericusabilitylib/inc/isbaseof.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 #ifndef ISBASEOF_H
    18 #define ISBASEOF_H
    19 
    20 
    21 // Provisional implementation of a construct that allows to determine
    22 // at compile time whether a class type is derived from another class
    23 // type
    24 
    25 // To be redefined using std::tr1:is_base_of when a TR1 implementation
    26 // becomes available for use with Symbian OS.
    27 
    28 
    29 // Implementation construct - do not use
    30 template<typename B, typename D>
    31 class TIsBaseOf
    32 	{
    33   private:
    34 	typedef TUint8 TIsDerived;
    35 
    36 	class TIsNotDerived
    37 		{
    38 		TUint8 iPadding[2];
    39 		};
    40 
    41 
    42 	static TIsDerived ReturnType(B*);
    43 	static TIsNotDerived ReturnType(...);
    44 
    45   public:
    46 
    47 	enum
    48 	{
    49 		EValue = sizeof(ReturnType(static_cast<D*>(0))) == sizeof(TIsDerived) ? 1 : 0
    50 	};
    51 	};
    52 
    53 
    54 #define IS_BASE_OF(BaseType, DerivedType) TIsBaseOf<BaseType, DerivedType>::EValue
    55 
    56 
    57 #endif //! ISBASEOF_H
    58