LTP GCOV extension - code coverage report
Current view: directory - usr/include/c++/4.3/ext - type_traits.h
Test: lcov.info
Date: 2008-08-14 Instrumented lines: 4
Code covered: 50.0 % Executed lines: 2

       1                 : // -*- C++ -*-
       2                 : 
       3                 : // Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
       4                 : //
       5                 : // This file is part of the GNU ISO C++ Library.  This library is free
       6                 : // software; you can redistribute it and/or modify it under the terms
       7                 : // of the GNU General Public License as published by the Free Software
       8                 : // Foundation; either version 2, or (at your option) any later
       9                 : // version.
      10                 : 
      11                 : // This library is distributed in the hope that it will be useful, but
      12                 : // WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14                 : // General Public License for more details.
      15                 : 
      16                 : // You should have received a copy of the GNU General Public License along
      17                 : // with this library; see the file COPYING.  If not, write to the Free
      18                 : // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
      19                 : // USA.
      20                 : 
      21                 : // As a special exception, you may use this file as part of a free
      22                 : // software library without restriction.  Specifically, if other files
      23                 : // instantiate templates or use macros or inline functions from this
      24                 : // file, or you compile this file and link it with other files to
      25                 : // produce an executable, this file does not by itself cause the
      26                 : // resulting executable to be covered by the GNU General Public
      27                 : // License.  This exception does not however invalidate any other
      28                 : // reasons why the executable file might be covered by the GNU General
      29                 : // Public License.
      30                 : 
      31                 : /** @file ext/type_traits.h
      32                 :  *  This file is a GNU extension to the Standard C++ Library.
      33                 :  */
      34                 : 
      35                 : #ifndef _EXT_TYPE_TRAITS
      36                 : #define _EXT_TYPE_TRAITS 1
      37                 : 
      38                 : #pragma GCC system_header
      39                 : 
      40                 : #include <bits/c++config.h>
      41                 : #include <bits/cpp_type_traits.h>
      42                 : 
      43                 : _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
      44                 : 
      45                 :   // Define a nested type if some predicate holds.
      46                 :   template<bool, typename>
      47                 :     struct __enable_if 
      48                 :     { };
      49                 : 
      50                 :   template<typename _Tp>
      51                 :     struct __enable_if<true, _Tp>
      52                 :     { typedef _Tp __type; };
      53                 : 
      54                 : 
      55                 :   // Conditional expression for types. If true, first, if false, second.
      56                 :   template<bool _Cond, typename _Iftrue, typename _Iffalse>
      57                 :     struct __conditional_type
      58                 :     { typedef _Iftrue __type; };
      59                 : 
      60                 :   template<typename _Iftrue, typename _Iffalse>
      61                 :     struct __conditional_type<false, _Iftrue, _Iffalse>
      62                 :     { typedef _Iffalse __type; };
      63                 : 
      64                 : 
      65                 :   // Given an integral builtin type, return the corresponding unsigned type.
      66                 :   template<typename _Tp>
      67                 :     struct __add_unsigned
      68                 :     { 
      69                 :     private:
      70                 :       typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
      71                 :       
      72                 :     public:
      73                 :       typedef typename __if_type::__type __type; 
      74                 :     };
      75                 : 
      76                 :   template<>
      77                 :     struct __add_unsigned<char>
      78                 :     { typedef unsigned char __type; };
      79                 : 
      80                 :   template<>
      81                 :     struct __add_unsigned<signed char>
      82                 :     { typedef unsigned char __type; };
      83                 : 
      84                 :   template<>
      85                 :     struct __add_unsigned<short>
      86                 :     { typedef unsigned short __type; };
      87                 : 
      88                 :   template<>
      89                 :     struct __add_unsigned<int>
      90                 :     { typedef unsigned int __type; };
      91                 : 
      92                 :   template<>
      93                 :     struct __add_unsigned<long>
      94                 :     { typedef unsigned long __type; };
      95                 : 
      96                 :   template<>
      97                 :     struct __add_unsigned<long long>
      98                 :     { typedef unsigned long long __type; };
      99                 : 
     100                 :   // Declare but don't define.
     101                 :   template<>
     102                 :     struct __add_unsigned<bool>;
     103                 : 
     104                 :   template<>
     105                 :     struct __add_unsigned<wchar_t>;
     106                 : 
     107                 : 
     108                 :   // Given an integral builtin type, return the corresponding signed type.
     109                 :   template<typename _Tp>
     110                 :     struct __remove_unsigned
     111                 :     { 
     112                 :     private:
     113                 :       typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type;
     114                 :       
     115                 :     public:
     116                 :       typedef typename __if_type::__type __type; 
     117                 :     };
     118                 : 
     119                 :   template<>
     120                 :     struct __remove_unsigned<char>
     121                 :     { typedef signed char __type; };
     122                 : 
     123                 :   template<>
     124                 :     struct __remove_unsigned<unsigned char>
     125                 :     { typedef signed char __type; };
     126                 : 
     127                 :   template<>
     128                 :     struct __remove_unsigned<unsigned short>
     129                 :     { typedef short __type; };
     130                 : 
     131                 :   template<>
     132                 :     struct __remove_unsigned<unsigned int>
     133                 :     { typedef int __type; };
     134                 : 
     135                 :   template<>
     136                 :     struct __remove_unsigned<unsigned long>
     137                 :     { typedef long __type; };
     138                 : 
     139                 :   template<>
     140                 :     struct __remove_unsigned<unsigned long long>
     141                 :     { typedef long long __type; };
     142                 : 
     143                 :   // Declare but don't define.
     144                 :   template<>
     145                 :     struct __remove_unsigned<bool>;
     146                 : 
     147                 :   template<>
     148                 :     struct __remove_unsigned<wchar_t>;
     149                 : 
     150                 : 
     151                 :   // For use in string and vstring.
     152                 :   template<typename _Type>
     153                 :     inline bool
     154               0 :     __is_null_pointer(_Type* __ptr)
     155               0 :     { return __ptr == 0; }
     156                 : 
     157                 :   template<typename _Type>
     158                 :     inline bool
     159            1287 :     __is_null_pointer(_Type)
     160            1287 :     { return false; }
     161                 : 
     162                 : 
     163                 :   // For complex and cmath
     164                 :   template<typename _Tp, bool = std::__is_integer<_Tp>::__value>
     165                 :     struct __promote
     166                 :     { typedef double __type; };
     167                 : 
     168                 :   template<typename _Tp>
     169                 :     struct __promote<_Tp, false>
     170                 :     { typedef _Tp __type; };
     171                 : 
     172                 :   template<typename _Tp, typename _Up>
     173                 :     struct __promote_2
     174                 :     {
     175                 :     private:
     176                 :       typedef typename __promote<_Tp>::__type __type1;
     177                 :       typedef typename __promote<_Up>::__type __type2;
     178                 : 
     179                 :     public:
     180                 :       typedef __typeof__(__type1() + __type2()) __type;
     181                 :     };
     182                 : 
     183                 :   template<typename _Tp, typename _Up, typename _Vp>
     184                 :     struct __promote_3
     185                 :     {
     186                 :     private:
     187                 :       typedef typename __promote<_Tp>::__type __type1;
     188                 :       typedef typename __promote<_Up>::__type __type2;
     189                 :       typedef typename __promote<_Vp>::__type __type3;
     190                 : 
     191                 :     public:
     192                 :       typedef __typeof__(__type1() + __type2() + __type3()) __type;
     193                 :     };
     194                 : 
     195                 :   template<typename _Tp, typename _Up, typename _Vp, typename _Wp>
     196                 :     struct __promote_4
     197                 :     {
     198                 :     private:
     199                 :       typedef typename __promote<_Tp>::__type __type1;
     200                 :       typedef typename __promote<_Up>::__type __type2;
     201                 :       typedef typename __promote<_Vp>::__type __type3;
     202                 :       typedef typename __promote<_Wp>::__type __type4;
     203                 : 
     204                 :     public:
     205                 :       typedef __typeof__(__type1() + __type2() + __type3() + __type4()) __type;
     206                 :     };
     207                 : 
     208                 : _GLIBCXX_END_NAMESPACE
     209                 : 
     210                 : #endif 

Generated by: LTP GCOV extension version 1.6