LCOV - code coverage report
Current view: directory - cygdrive/c/program files/microsoft visual studio 9.0/vc/include - utility (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 11 11 100.0 %
Date: 2014-09-25 Functions: 0 0 -

       1                 : // utility standard header

       2                 : #pragma once
       3                 : #ifndef _UTILITY_
       4                 : #define _UTILITY_
       5                 : #ifndef RC_INVOKED
       6                 : #include <iosfwd>
       7                 : 
       8                 : #ifdef _MSC_VER
       9                 :  #pragma pack(push,_CRT_PACKING)
      10                 :  #pragma warning(push,3)
      11                 : #endif  /* _MSC_VER */
      12                 : 
      13                 : _STD_BEGIN
      14                 :                 // TEMPLATE FUNCTION swap (from <algorithm>)
      15                 : template<class _Ty> inline
      16                 :         void swap(_Ty& _Left, _Ty& _Right)
      17               1 :         {       // exchange values stored at _Left and _Right

      18               1 :         if (&_Left != &_Right)

      19                 :                 {       // different, worth swapping
      20               1 :                 _Ty _Tmp = _Left;

      21                 : 
      22               1 :                 _Left = _Right;

      23               1 :                 _Right = _Tmp;

      24                 :                 }
      25               1 :         }

      26                 : 
      27                 :                 // TEMPLATE FUNCTION _Swap_adl
      28                 : template<class _Ty> inline
      29                 :         void _Swap_adl(_Ty& _Left, _Ty& _Right)
      30               5 :         {       // exchange values stored at _Left and _Right, using ADL

      31               5 :         swap(_Left, _Right);

      32               5 :         }

      33                 : 
      34                 :                 // TEMPLATE STRUCT pair
      35                 : template<class _Ty1,
      36                 :         class _Ty2>
      37                 :         struct pair
      38                 :         {       // store a pair of values
      39                 :         typedef pair<_Ty1, _Ty2> _Myt;
      40                 :         typedef _Ty1 first_type;
      41                 :         typedef _Ty2 second_type;
      42                 : 
      43                 :         pair()
      44                 :                 : first(_Ty1()), second(_Ty2())
      45                 :                 {       // construct from defaults
      46                 :                 }
      47                 : 
      48                 :         pair(const _Ty1& _Val1, const _Ty2& _Val2)
      49                 :                 : first(_Val1), second(_Val2)
      50               3 :                 {       // construct from specified values

      51               3 :                 }

      52                 : 
      53                 :         template<class _Other1,
      54                 :                 class _Other2>
      55                 :                 pair(const pair<_Other1, _Other2>& _Right)
      56                 :                 : first(_Right.first), second(_Right.second)
      57                 :                 {       // construct from compatible pair
      58                 :                 }
      59                 : 
      60                 :         void swap(_Myt& _Right)
      61                 :                 {       // exchange contents with _Right
      62                 :                 if (this != &_Right)
      63                 :                         {       // different, worth swapping
      64                 :                         _STD _Swap_adl(first, _Right.first);
      65                 :                         _STD _Swap_adl(second, _Right.second);
      66                 :                         }
      67                 :                 }
      68                 : 
      69                 :         _Ty1 first;     // the first stored value
      70                 :         _Ty2 second;    // the second stored value
      71                 :         };
      72                 : 
      73                 :                 // pair TEMPLATE FUNCTIONS
      74                 : template<class _Ty1,
      75                 :         class _Ty2> inline
      76                 :         void swap(pair<_Ty1, _Ty2>& _Left, pair<_Ty1, _Ty2>& _Right)
      77                 :         {       // swap _Left and _Right pairs
      78                 :         _Left.swap(_Right);
      79                 :         }
      80                 : 
      81                 : template<class _Ty1,
      82                 :         class _Ty2> inline
      83                 :         bool operator==(const pair<_Ty1, _Ty2>& _Left,
      84                 :                 const pair<_Ty1, _Ty2>& _Right)
      85                 :         {       // test for pair equality
      86                 :         return (_Left.first == _Right.first && _Left.second == _Right.second);
      87                 :         }
      88                 : 
      89                 : template<class _Ty1,
      90                 :         class _Ty2> inline
      91                 :         bool operator!=(const pair<_Ty1, _Ty2>& _Left,
      92                 :                 const pair<_Ty1, _Ty2>& _Right)
      93                 :         {       // test for pair inequality
      94                 :         return (!(_Left == _Right));
      95                 :         }
      96                 : 
      97                 : template<class _Ty1,
      98                 :         class _Ty2> inline
      99                 :         bool operator<(const pair<_Ty1, _Ty2>& _Left,
     100                 :                 const pair<_Ty1, _Ty2>& _Right)
     101                 :         {       // test if _Left < _Right for pairs
     102                 :         return (_Left.first < _Right.first ||
     103                 :                 !(_Right.first < _Left.first) && _Left.second < _Right.second);
     104                 :         }
     105                 : 
     106                 : template<class _Ty1,
     107                 :         class _Ty2> inline
     108                 :         bool operator>(const pair<_Ty1, _Ty2>& _Left,
     109                 :                 const pair<_Ty1, _Ty2>& _Right)
     110                 :         {       // test if _Left > _Right for pairs
     111                 :         return (_Right < _Left);
     112                 :         }
     113                 : 
     114                 : template<class _Ty1,
     115                 :         class _Ty2> inline
     116                 :         bool operator<=(const pair<_Ty1, _Ty2>& _Left,
     117                 :                 const pair<_Ty1, _Ty2>& _Right)
     118                 :         {       // test if _Left <= _Right for pairs
     119                 :         return (!(_Right < _Left));
     120                 :         }
     121                 : 
     122                 : template<class _Ty1,
     123                 :         class _Ty2> inline
     124                 :         bool operator>=(const pair<_Ty1, _Ty2>& _Left,
     125                 :                 const pair<_Ty1, _Ty2>& _Right)
     126                 :         {       // test if _Left >= _Right for pairs
     127                 :         return (!(_Left < _Right));
     128                 :         }
     129                 : 
     130                 : template<class _Ty1,
     131                 :         class _Ty2> inline
     132                 :         pair<_Ty1, _Ty2> make_pair(_Ty1 _Val1, _Ty2 _Val2)
     133                 :         {       // return pair composed from arguments
     134                 :         return (pair<_Ty1, _Ty2>(_Val1, _Val2));
     135                 :         }
     136                 : 
     137                 :                 // TEMPLATE OPERATORS
     138                 :         namespace rel_ops
     139                 :                 {       // nested namespace to hide relational operators from std
     140                 : template<class _Ty> inline
     141                 :         bool  operator!=(const _Ty& _Left, const _Ty& _Right)
     142                 :         {       // test for inequality, in terms of equality
     143                 :         return (!(_Left == _Right));
     144                 :         }
     145                 : 
     146                 : template<class _Ty> inline
     147                 :         bool operator>(const _Ty& _Left, const _Ty& _Right)
     148                 :         {       // test if _Left > _Right, in terms of operator<
     149                 :         return (_Right < _Left);
     150                 :         }
     151                 : 
     152                 : template<class _Ty> inline
     153                 :         bool operator<=(const _Ty& _Left, const _Ty& _Right)
     154                 :         {       // test if _Left <= _Right, in terms of operator<
     155                 :         return (!(_Right < _Left));
     156                 :         }
     157                 : 
     158                 : template<class _Ty> inline
     159                 :         bool operator>=(const _Ty& _Left, const _Ty& _Right)
     160                 :         {       // test if _Left >= _Right, in terms of operator<
     161                 :         return (!(_Left < _Right));
     162                 :         }
     163                 :                 }
     164                 : _STD_END
     165                 : 
     166                 :  #if _HAS_TR1
     167                 : _STD_BEGIN
     168                 :         namespace tr1 { // TR1 additions
     169                 : 
     170                 :         // TUPLE INTERFACE TO std::tr1::pair
     171                 : template<class _Tuple>
     172                 :         struct tuple_size;
     173                 : template<int _Idx,
     174                 :         class _Tuple>
     175                 :         struct tuple_element;
     176                 : template<class _Ty1,
     177                 :         class _Ty2>
     178                 :         struct tuple_size<std::pair<_Ty1, _Ty2> >
     179                 :         {       // struct to determine number of elements in pair
     180                 :         static const int value = 2;
     181                 :         };
     182                 : 
     183                 : template<int _Idx,
     184                 :         class _Ty>
     185                 :         struct _Pair_data;
     186                 : template<class _Ty1,
     187                 :         class _Ty2>
     188                 :         struct _Pair_data<0, std::pair<_Ty1, _Ty2> >
     189                 :         {       // struct to pick out argument type and value at index 0
     190                 :         typedef _Ty1& _Type;
     191                 :         typedef const _Ty1& _CType;
     192                 : 
     193                 :         static _Type _Val(std::pair<_Ty1, _Ty2>& _Pr)
     194                 :                 {       // return value
     195                 :                 return (_Pr.first);
     196                 :                 }
     197                 : 
     198                 :         static _CType _Val(const std::pair<_Ty1, _Ty2>& _Pr)
     199                 :                 {       // return value
     200                 :                 return (_Pr.first);
     201                 :                 }
     202                 :         };
     203                 : 
     204                 : template<class _Ty1,
     205                 :         class _Ty2>
     206                 :         struct _Pair_data<1, std::pair<_Ty1, _Ty2> >
     207                 :         {       // struct to pick out argument type and value at index 1
     208                 :         typedef _Ty2& _Type;
     209                 :         typedef const _Ty2& _CType;
     210                 : 
     211                 :         static _Type _Val(std::pair<_Ty1, _Ty2>& _Pr)
     212                 :                 {       // return value
     213                 :                 return (_Pr.second);
     214                 :                 }
     215                 : 
     216                 :         static _CType _Val(const std::pair<_Ty1, _Ty2>& _Pr)
     217                 :                 {       // return value
     218                 :                 return (_Pr.second);
     219                 :                 }
     220                 :         };
     221                 : 
     222                 : template<class _Ty1,
     223                 :         class _Ty2>
     224                 :         struct tuple_element<0, std::pair<_Ty1, _Ty2> >
     225                 :         {       // struct to determine type of element 0 in pair
     226                 :         typedef _Ty1 type;
     227                 :         };
     228                 : 
     229                 : template<class _Ty1,
     230                 :         class _Ty2>
     231                 :         struct tuple_element<1, std::pair<_Ty1, _Ty2> >
     232                 :         {       // struct to determine type of element 1 in pair
     233                 :         typedef _Ty2 type;
     234                 :         };
     235                 : 
     236                 : template<int _Idx,
     237                 :         class _Ty1,
     238                 :         class _Ty2>
     239                 :         typename _Pair_data<_Idx, std::pair<_Ty1, _Ty2> >::_Type
     240                 :                 get(std::pair<_Ty1, _Ty2>& _Pr)
     241                 :         {       // return element at _Idx in pair _Pr
     242                 :         return (_Pair_data<_Idx, std::pair<_Ty1, _Ty2> >::_Val(_Pr));
     243                 :         }
     244                 : 
     245                 : template<int _Idx,
     246                 :         class _Ty1,
     247                 :         class _Ty2>
     248                 :         typename _Pair_data<_Idx, std::pair<_Ty1, _Ty2> >::_CType
     249                 :                 get(const std::pair<_Ty1, _Ty2>& _Pr)
     250                 :         {       // return element at _Idx in pair _Pr
     251                 :         return (_Pair_data<_Idx, std::pair<_Ty1, _Ty2> >::_Val(_Pr));
     252                 :         }
     253                 : 
     254                 :         }       // namespace tr1
     255                 : _STD_END
     256                 :  #endif /* _HAS_TR1 */
     257                 : 
     258                 : #ifdef _MSC_VER
     259                 :  #pragma warning(pop)
     260                 :  #pragma pack(pop)
     261                 : #endif  /* _MSC_VER */
     262                 : 
     263                 : #endif /* RC_INVOKED */
     264                 : #endif /* _UTILITY_ */
     265                 : 
     266                 : 
     267                 : /*
     268                 :  * This file is derived from software bearing the following
     269                 :  * restrictions:
     270                 :  *
     271                 :  * Copyright (c) 1994
     272                 :  * Hewlett-Packard Company
     273                 :  *
     274                 :  * Permission to use, copy, modify, distribute and sell this
     275                 :  * software and its documentation for any purpose is hereby
     276                 :  * granted without fee, provided that the above copyright notice
     277                 :  * appear in all copies and that both that copyright notice and
     278                 :  * this permission notice appear in supporting documentation.
     279                 :  * Hewlett-Packard Company makes no representations about the
     280                 :  * suitability of this software for any purpose. It is provided
     281                 :  * "as is" without express or implied warranty.
     282                 :  */
     283                 : 
     284                 : /*
     285                 :  * Copyright (c) 1992-2008 by P.J. Plauger.  ALL RIGHTS RESERVED.
     286                 :  * Consult your license regarding permissions and restrictions.
     287                 :  V5.05:0009 */
     288                 : 
     289                 : 

Generated by: LCOV version 1.7