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

       1                 : // functional standard header

       2                 : #pragma once
       3                 : #ifndef _FUNCTIONAL_
       4                 : #define _FUNCTIONAL_
       5                 : #ifndef RC_INVOKED
       6                 : #include <cstdlib>
       7                 : #include <xstring>
       8                 : 
       9                 : #ifdef _MSC_VER
      10                 :  #pragma pack(push,_CRT_PACKING)
      11                 :  #pragma warning(push,3)
      12                 :  #pragma warning(disable: 4100 4180 4244)
      13                 : #endif  /* _MSC_VER */
      14                 : 
      15                 : _STD_BEGIN
      16                 : 
      17                 :                 // TEMPLATE STRUCT unary_function
      18                 : template<class _Arg,
      19                 :         class _Result>
      20                 :         struct unary_function
      21                 :         {       // base class for unary functions
      22                 :         typedef _Arg argument_type;
      23                 :         typedef _Result result_type;
      24                 :         };
      25                 : 
      26                 :                 // TEMPLATE STRUCT binary_function
      27                 : template<class _Arg1,
      28                 :         class _Arg2,
      29                 :         class _Result>
      30                 :         struct binary_function
      31                 :         {       // base class for binary functions
      32                 :         typedef _Arg1 first_argument_type;
      33                 :         typedef _Arg2 second_argument_type;
      34                 :         typedef _Result result_type;
      35                 :         };
      36                 : 
      37                 :                 // TEMPLATE STRUCT plus
      38                 : template<class _Ty>
      39                 :         struct plus
      40                 :                 : public binary_function<_Ty, _Ty, _Ty>
      41                 :         {       // functor for operator+
      42                 :         _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
      43                 :                 {       // apply operator+ to operands
      44                 :                 return (_Left + _Right);
      45                 :                 }
      46                 :         };
      47                 : 
      48                 :                 // TEMPLATE STRUCT minus
      49                 : template<class _Ty>
      50                 :         struct minus
      51                 :                 : public binary_function<_Ty, _Ty, _Ty>
      52                 :         {       // functor for operator-
      53                 :         _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
      54                 :                 {       // apply operator- to operands
      55                 :                 return (_Left - _Right);
      56                 :                 }
      57                 :         };
      58                 : 
      59                 :                 // TEMPLATE STRUCT multiplies
      60                 : template<class _Ty>
      61                 :         struct multiplies
      62                 :                 : public binary_function<_Ty, _Ty, _Ty>
      63                 :         {       // functor for operator*
      64                 :         _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
      65                 :                 {       // apply operator* to operands
      66                 :                 return (_Left * _Right);
      67                 :                 }
      68                 :         };
      69                 : 
      70                 :                 // TEMPLATE STRUCT divides
      71                 : template<class _Ty>
      72                 :         struct divides
      73                 :                 : public binary_function<_Ty, _Ty, _Ty>
      74                 :         {       // functor for operator/
      75                 :         _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
      76                 :                 {       // apply operator/ to operands
      77                 :                 return (_Left / _Right);
      78                 :                 }
      79                 :         };
      80                 : 
      81                 :                 // TEMPLATE STRUCT modulus
      82                 : template<class _Ty>
      83                 :         struct modulus
      84                 :                 : public binary_function<_Ty, _Ty, _Ty>
      85                 :         {       // functor for operator%
      86                 :         _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
      87                 :                 {       // apply operator% to operands
      88                 :                 return (_Left % _Right);
      89                 :                 }
      90                 :         };
      91                 : 
      92                 :                 // TEMPLATE STRUCT negate
      93                 : template<class _Ty>
      94                 :         struct negate
      95                 :                 : public unary_function<_Ty, _Ty>
      96                 :         {       // functor for unary operator-
      97                 :         _Ty operator()(const _Ty& _Left) const
      98                 :                 {       // apply operator- to operand
      99                 :                 return (-_Left);
     100                 :                 }
     101                 :         };
     102                 : 
     103                 :                 // TEMPLATE STRUCT equal_to
     104                 : template<class _Ty>
     105                 :         struct equal_to
     106                 :                 : public binary_function<_Ty, _Ty, bool>
     107                 :         {       // functor for operator==
     108                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     109                 :                 {       // apply operator== to operands
     110                 :                 return (_Left == _Right);
     111                 :                 }
     112                 :         };
     113                 : 
     114                 :                 // TEMPLATE STRUCT not_equal_to
     115                 : template<class _Ty>
     116                 :         struct not_equal_to
     117                 :                 : public binary_function<_Ty, _Ty, bool>
     118                 :         {       // functor for operator!=
     119                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     120                 :                 {       // apply operator!= to operands
     121                 :                 return (_Left != _Right);
     122                 :                 }
     123                 :         };
     124                 : 
     125                 :                 // TEMPLATE STRUCT greater
     126                 : template<class _Ty>
     127                 :         struct greater
     128                 :                 : public binary_function<_Ty, _Ty, bool>
     129                 :         {       // functor for operator>
     130                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     131                 :                 {       // apply operator> to operands
     132                 :                 return (_Left > _Right);
     133                 :                 }
     134                 :         };
     135                 : 
     136                 :                 // TEMPLATE STRUCT less
     137                 : template<class _Ty>
     138                 :         struct less
     139                 :                 : public binary_function<_Ty, _Ty, bool>
     140                 :         {       // functor for operator<
     141                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     142               2 :                 {       // apply operator< to operands

     143               2 :                 return (_Left < _Right);

     144               2 :                 }

     145                 :         };
     146                 : 
     147                 :                 // TEMPLATE STRUCT greater_equal
     148                 : template<class _Ty>
     149                 :         struct greater_equal
     150                 :                 : public binary_function<_Ty, _Ty, bool>
     151                 :         {       // functor for operator>=
     152                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     153                 :                 {       // apply operator>= to operands
     154                 :                 return (_Left >= _Right);
     155                 :                 }
     156                 :         };
     157                 : 
     158                 :                 // TEMPLATE STRUCT less_equal
     159                 : template<class _Ty>
     160                 :         struct less_equal
     161                 :                 : public binary_function<_Ty, _Ty, bool>
     162                 :         {       // functor for operator<=
     163                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     164                 :                 {       // apply operator<= to operands
     165                 :                 return (_Left <= _Right);
     166                 :                 }
     167                 :         };
     168                 : 
     169                 :                 // TEMPLATE STRUCT logical_and
     170                 : template<class _Ty>
     171                 :         struct logical_and
     172                 :                 : public binary_function<_Ty, _Ty, bool>
     173                 :         {       // functor for operator&&
     174                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     175                 :                 {       // apply operator&& to operands
     176                 :                 return (_Left && _Right);
     177                 :                 }
     178                 :         };
     179                 : 
     180                 :                 // TEMPLATE STRUCT logical_or
     181                 : template<class _Ty>
     182                 :         struct logical_or
     183                 :                 : public binary_function<_Ty, _Ty, bool>
     184                 :         {       // functor for operator||
     185                 :         bool operator()(const _Ty& _Left, const _Ty& _Right) const
     186                 :                 {       // apply operator|| to operands
     187                 :                 return (_Left || _Right);
     188                 :                 }
     189                 :         };
     190                 : 
     191                 :                 // TEMPLATE STRUCT logical_not
     192                 : template<class _Ty>
     193                 :         struct logical_not
     194                 :                 : public unary_function<_Ty, bool>
     195                 :         {       // functor for unary operator!
     196                 :         bool operator()(const _Ty& _Left) const
     197                 :                 {       // apply operator! to operand
     198                 :                 return (!_Left);
     199                 :                 }
     200                 :         };
     201                 : 
     202                 :                 // TEMPLATE CLASS unary_negate
     203                 : template<class _Fn1>
     204                 :         class unary_negate
     205                 :         : public unary_function<typename _Fn1::argument_type, bool>
     206                 :         {       // functor adapter !_Func(left)
     207                 : public:
     208                 :         explicit unary_negate(const _Fn1& _Func)
     209                 :                 : _Functor(_Func)
     210                 :                 {       // construct from functor
     211                 :                 }
     212                 : 
     213                 :         bool operator()(const typename _Fn1::argument_type& _Left) const
     214                 :                 {       // apply functor to operand
     215                 :                 return (!_Functor(_Left));
     216                 :                 }
     217                 : 
     218                 : protected:
     219                 :         _Fn1 _Functor;  // the functor to apply
     220                 :         };
     221                 : 
     222                 :                 // TEMPLATE FUNCTION not1
     223                 : template<class _Fn1> inline
     224                 :         unary_negate<_Fn1> not1(const _Fn1& _Func)
     225                 :         {       // return a unary_negate functor adapter
     226                 :         return (std::unary_negate<_Fn1>(_Func));
     227                 :         }
     228                 : 
     229                 :                 // TEMPLATE CLASS binary_negate
     230                 : template<class _Fn2>
     231                 :         class binary_negate
     232                 :                 : public binary_function<typename _Fn2::first_argument_type,
     233                 :                         typename _Fn2::second_argument_type, bool>
     234                 :         {       // functor adapter !_Func(left, right)
     235                 : public:
     236                 :         explicit binary_negate(const _Fn2& _Func)
     237                 :                 : _Functor(_Func)
     238                 :                 {       // construct from functor
     239                 :                 }
     240                 : 
     241                 :         bool operator()(const typename _Fn2::first_argument_type& _Left,
     242                 :                 const typename _Fn2::second_argument_type& _Right) const
     243                 :                 {       // apply functor to operands
     244                 :                 return (!_Functor(_Left, _Right));
     245                 :                 }
     246                 : 
     247                 : protected:
     248                 :         _Fn2 _Functor;  // the functor to apply
     249                 :         };
     250                 : 
     251                 :                 // TEMPLATE FUNCTION not2
     252                 : template<class _Fn2> inline
     253                 :         binary_negate<_Fn2> not2(const _Fn2& _Func)
     254                 :         {       // return a binary_negate functor adapter
     255                 :         return (std::binary_negate<_Fn2>(_Func));
     256                 :         }
     257                 : 
     258                 :                 // TEMPLATE CLASS binder1st
     259                 : template<class _Fn2>
     260                 :         class binder1st
     261                 :                 : public unary_function<typename _Fn2::second_argument_type,
     262                 :                         typename _Fn2::result_type>
     263                 :         {       // functor adapter _Func(stored, right)
     264                 : public:
     265                 :         typedef unary_function<typename _Fn2::second_argument_type,
     266                 :                 typename _Fn2::result_type> _Base;
     267                 :         typedef typename _Base::argument_type argument_type;
     268                 :         typedef typename _Base::result_type result_type;
     269                 : 
     270                 :         binder1st(const _Fn2& _Func,
     271                 :                 const typename _Fn2::first_argument_type& _Left)
     272                 :                 : op(_Func), value(_Left)
     273                 :                 {       // construct from functor and left operand
     274                 :                 }
     275                 : 
     276                 :         result_type operator()(const argument_type& _Right) const
     277                 :                 {       // apply functor to operands
     278                 :                 return (op(value, _Right));
     279                 :                 }
     280                 : 
     281                 :         result_type operator()(argument_type& _Right) const
     282                 :                 {       // apply functor to operands
     283                 :                 return (op(value, _Right));
     284                 :                 }
     285                 : 
     286                 : protected:
     287                 :         _Fn2 op;        // the functor to apply
     288                 :         typename _Fn2::first_argument_type value;       // the left operand
     289                 :         };
     290                 : 
     291                 :                 // TEMPLATE FUNCTION bind1st
     292                 : template<class _Fn2,
     293                 :         class _Ty> inline
     294                 :         binder1st<_Fn2> bind1st(const _Fn2& _Func, const _Ty& _Left)
     295                 :                 {       // return a binder1st functor adapter
     296                 :                 typename _Fn2::first_argument_type _Val(_Left);
     297                 :                 return (std::binder1st<_Fn2>(_Func, _Val));
     298                 :                 }
     299                 : 
     300                 :                 // TEMPLATE CLASS binder2nd
     301                 : template<class _Fn2>
     302                 :         class binder2nd
     303                 :                 : public unary_function<typename _Fn2::first_argument_type,
     304                 :                         typename _Fn2::result_type>
     305                 :         {       // functor adapter _Func(left, stored)
     306                 : public:
     307                 :         typedef unary_function<typename _Fn2::first_argument_type,
     308                 :                 typename _Fn2::result_type> _Base;
     309                 :         typedef typename _Base::argument_type argument_type;
     310                 :         typedef typename _Base::result_type result_type;
     311                 : 
     312                 :         binder2nd(const _Fn2& _Func,
     313                 :                 const typename _Fn2::second_argument_type& _Right)
     314                 :                 : op(_Func), value(_Right)
     315                 :                 {       // construct from functor and right operand
     316                 :                 }
     317                 : 
     318                 :         result_type operator()(const argument_type& _Left) const
     319                 :                 {       // apply functor to operands
     320                 :                 return (op(_Left, value));
     321                 :                 }
     322                 : 
     323                 :         result_type operator()(argument_type& _Left) const
     324                 :                 {       // apply functor to operands
     325                 :                 return (op(_Left, value));
     326                 :                 }
     327                 : 
     328                 : protected:
     329                 :         _Fn2 op;        // the functor to apply
     330                 :         typename _Fn2::second_argument_type value;      // the right operand
     331                 :         };
     332                 : 
     333                 :                 // TEMPLATE FUNCTION bind2nd
     334                 : template<class _Fn2,
     335                 :         class _Ty> inline
     336                 :         binder2nd<_Fn2> bind2nd(const _Fn2& _Func, const _Ty& _Right)
     337                 :         {       // return a binder2nd functor adapter
     338                 :         typename _Fn2::second_argument_type _Val(_Right);
     339                 :         return (std::binder2nd<_Fn2>(_Func, _Val));
     340                 :         }
     341                 : 
     342                 :                 // TEMPLATE CLASS pointer_to_unary_function
     343                 : template<class _Arg,
     344                 :         class _Result,
     345                 :         class _Fn = _Result (*)(_Arg)>
     346                 :         class pointer_to_unary_function
     347                 :                 : public unary_function<_Arg, _Result>
     348                 :         {       // functor adapter (*pfunc)(left)
     349                 : public:
     350                 :         explicit pointer_to_unary_function(_Fn _Left)
     351                 :                 : _Pfun(_Left)
     352                 :                 {       // construct from pointer
     353                 :                 }
     354                 : 
     355                 :         _Result operator()(_Arg _Left) const
     356                 :                 {       // call function with operand
     357                 :                 return (_Pfun(_Left));
     358                 :                 }
     359                 : 
     360                 : protected:
     361                 :         _Fn _Pfun;      // the function pointer
     362                 :         };
     363                 : 
     364                 :                 // TEMPLATE CLASS pointer_to_binary_function
     365                 : template<class _Arg1,
     366                 :         class _Arg2,
     367                 :         class _Result,
     368                 :         class _Fn = _Result (*)(_Arg1, _Arg2)>
     369                 :         class pointer_to_binary_function
     370                 :                 : public binary_function<_Arg1, _Arg2, _Result>
     371                 :         {       // functor adapter (*pfunc)(left, right)
     372                 : public:
     373                 :         explicit pointer_to_binary_function(_Fn _Left)
     374                 :                 : _Pfun(_Left)
     375                 :                 {       // construct from pointer
     376                 :                 }
     377                 : 
     378                 :         _Result operator()(_Arg1 _Left, _Arg2 _Right) const
     379                 :                 {       // call function with operands
     380                 :                 return (_Pfun(_Left, _Right));
     381                 :                 }
     382                 : 
     383                 : protected:
     384                 :         _Fn _Pfun;      // the function pointer
     385                 :         };
     386                 : 
     387                 :                 // TEMPLATE FUNCTION ptr_fun
     388                 : template<class _Arg,
     389                 :         class _Result> inline
     390                 :         pointer_to_unary_function<_Arg, _Result,
     391                 :                 _Result (__cdecl *)(_Arg)>
     392                 :                         ptr_fun(_Result (__cdecl *_Left)(_Arg))
     393                 :         {       // return pointer_to_unary_function functor adapter
     394                 :         return (std::pointer_to_unary_function<_Arg, _Result,
     395                 :                 _Result (__cdecl *)(_Arg)>(_Left));
     396                 :         }
     397                 : 
     398                 :  #ifdef _M_IX86
     399                 : template<class _Arg,
     400                 :         class _Result> inline
     401                 :         pointer_to_unary_function<_Arg, _Result,
     402                 :                 _Result (__stdcall *)(_Arg)>
     403                 :                         ptr_fun(_Result (__stdcall *_Left)(_Arg))
     404                 :         {       // return pointer_to_unary_function functor adapter
     405                 :         return (std::pointer_to_unary_function<_Arg, _Result,
     406                 :                 _Result (__stdcall *)(_Arg)>(_Left));
     407                 :         }
     408                 : 
     409                 :   #ifndef _M_CEE
     410                 : template<class _Arg,
     411                 :         class _Result> inline
     412                 :         pointer_to_unary_function<_Arg, _Result,
     413                 :                 _Result (__fastcall *)(_Arg)>
     414                 :                         ptr_fun(_Result (__fastcall *_Left)(_Arg))
     415                 :         {       // return pointer_to_unary_function functor adapter
     416                 :         return (std::pointer_to_unary_function<_Arg, _Result,
     417                 :                 _Result (__fastcall *)(_Arg)>(_Left));
     418                 :         }
     419                 :   #endif /* _M_CEE */
     420                 :  #endif /* _M_IX86 */
     421                 : 
     422                 :  #ifdef _M_CEE
     423                 : template<class _Arg,
     424                 :         class _Result> inline
     425                 :         pointer_to_unary_function<_Arg, _Result,
     426                 :                 _Result (__clrcall *)(_Arg)>
     427                 :                         ptr_fun(_Result (__clrcall *_Left)(_Arg))
     428                 :         {       // return pointer_to_unary_function functor adapter
     429                 :         return (std::pointer_to_unary_function<_Arg, _Result,
     430                 :                 _Result (__clrcall *)(_Arg)>(_Left));
     431                 :         }
     432                 :  #endif /* _M_CEE */
     433                 : 
     434                 : template<class _Arg1,
     435                 :         class _Arg2,
     436                 :         class _Result> inline
     437                 :         pointer_to_binary_function<_Arg1, _Arg2, _Result,
     438                 :                 _Result(__cdecl *)(_Arg1, _Arg2)>
     439                 :                         ptr_fun(_Result (__cdecl *_Left)(_Arg1, _Arg2))
     440                 :         {       // return pointer_to_binary_function functor adapter
     441                 :         return (std::pointer_to_binary_function<_Arg1, _Arg2, _Result,
     442                 :                 _Result (__cdecl *)(_Arg1, _Arg2)>(_Left));
     443                 :         }
     444                 : 
     445                 :  #ifdef _M_IX86
     446                 : template<class _Arg1,
     447                 :         class _Arg2,
     448                 :         class _Result> inline
     449                 :         pointer_to_binary_function<_Arg1, _Arg2, _Result,
     450                 :                 _Result(__stdcall *)(_Arg1, _Arg2)>
     451                 :                         ptr_fun(_Result (__stdcall *_Left)(_Arg1, _Arg2))
     452                 :         {       // return pointer_to_binary_function functor adapter
     453                 :         return (std::pointer_to_binary_function<_Arg1, _Arg2, _Result,
     454                 :                 _Result (__stdcall *)(_Arg1, _Arg2)>(_Left));
     455                 :         }
     456                 : 
     457                 :   #ifndef _M_CEE
     458                 : template<class _Arg1,
     459                 :         class _Arg2,
     460                 :         class _Result> inline
     461                 :         pointer_to_binary_function<_Arg1, _Arg2, _Result,
     462                 :                 _Result(__fastcall *)(_Arg1, _Arg2)>
     463                 :                         ptr_fun(_Result (__fastcall *_Left)(_Arg1, _Arg2))
     464                 :         {       // return pointer_to_binary_function functor adapter
     465                 :         return (std::pointer_to_binary_function<_Arg1, _Arg2, _Result,
     466                 :                 _Result (__fastcall *)(_Arg1, _Arg2)>(_Left));
     467                 :         }
     468                 :   #endif /* _M_CEE */
     469                 :  #endif /* _M_IX86 */
     470                 : 
     471                 :  #ifdef _M_CEE
     472                 : template<class _Arg1,
     473                 :         class _Arg2,
     474                 :         class _Result> inline
     475                 :         pointer_to_binary_function<_Arg1, _Arg2, _Result,
     476                 :                 _Result(__clrcall *)(_Arg1, _Arg2)>
     477                 :                         ptr_fun(_Result (__clrcall *_Left)(_Arg1, _Arg2))
     478                 :         {       // return pointer_to_binary_function functor adapter
     479                 :         return (std::pointer_to_binary_function<_Arg1, _Arg2, _Result,
     480                 :                 _Result (__clrcall *)(_Arg1, _Arg2)>(_Left));
     481                 :         }
     482                 :  #endif /* _M_CEE */
     483                 : 
     484                 :                 // TEMPLATE CLASS mem_fun_t
     485                 : template<class _Result,
     486                 :         class _Ty>
     487                 :         class mem_fun_t
     488                 :                 : public unary_function<_Ty *, _Result>
     489                 :         {       // functor adapter (*p->*pfunc)(), non-const *pfunc
     490                 : public:
     491                 :         explicit mem_fun_t(_Result (_Ty::*_Pm)())
     492                 :                 : _Pmemfun(_Pm)
     493                 :                 {       // construct from pointer
     494                 :                 }
     495                 : 
     496                 :         _Result operator()(_Ty *_Pleft) const
     497                 :                 {       // call function
     498                 :                 return ((_Pleft->*_Pmemfun)());
     499                 :                 }
     500                 : 
     501                 : private:
     502                 :         _Result (_Ty::*_Pmemfun)();     // the member function pointer
     503                 :         };
     504                 : 
     505                 :                 // TEMPLATE CLASS mem_fun1_t
     506                 : template<class _Result,
     507                 :         class _Ty,
     508                 :         class _Arg>
     509                 :         class mem_fun1_t
     510                 :                 : public binary_function<_Ty *, _Arg, _Result>
     511                 :         {       // functor adapter (*p->*pfunc)(val), non-const *pfunc
     512                 : public:
     513                 :         explicit mem_fun1_t(_Result (_Ty::*_Pm)(_Arg))
     514                 :                 : _Pmemfun(_Pm)
     515                 :                 {       // construct from pointer
     516                 :                 }
     517                 : 
     518                 :         _Result operator()(_Ty *_Pleft, _Arg _Right) const
     519                 :                 {       // call function with operand
     520                 :                 return ((_Pleft->*_Pmemfun)(_Right));
     521                 :                 }
     522                 : 
     523                 : private:
     524                 :         _Result (_Ty::*_Pmemfun)(_Arg); // the member function pointer
     525                 :         };
     526                 : 
     527                 :                 // TEMPLATE CLASS const_mem_fun_t
     528                 : template<class _Result,
     529                 :         class _Ty>
     530                 :         class const_mem_fun_t
     531                 :                 : public unary_function<const _Ty *, _Result>
     532                 :         {       // functor adapter (*p->*pfunc)(), const *pfunc
     533                 : public:
     534                 :         explicit const_mem_fun_t(_Result (_Ty::*_Pm)() const)
     535                 :                 : _Pmemfun(_Pm)
     536                 :                 {       // construct from pointer
     537                 :                 }
     538                 : 
     539                 :         _Result operator()(const _Ty *_Pleft) const
     540                 :                 {       // call function
     541                 :                 return ((_Pleft->*_Pmemfun)());
     542                 :                 }
     543                 : 
     544                 : private:
     545                 :         _Result (_Ty::*_Pmemfun)() const;       // the member function pointer
     546                 :         };
     547                 : 
     548                 :                 // TEMPLATE CLASS const_mem_fun1_t
     549                 : template<class _Result,
     550                 :         class _Ty,
     551                 :         class _Arg>
     552                 :         class const_mem_fun1_t
     553                 :                 : public binary_function<const _Ty *, _Arg, _Result>
     554                 :         {       // functor adapter (*p->*pfunc)(val), const *pfunc
     555                 : public:
     556                 :         explicit const_mem_fun1_t(_Result (_Ty::*_Pm)(_Arg) const)
     557                 :                 : _Pmemfun(_Pm)
     558                 :                 {       // construct from pointer
     559                 :                 }
     560                 : 
     561                 :         _Result operator()(const _Ty *_Pleft, _Arg _Right) const
     562                 :                 {       // call function with operand
     563                 :                 return ((_Pleft->*_Pmemfun)(_Right));
     564                 :                 }
     565                 : 
     566                 : private:
     567                 :         _Result (_Ty::*_Pmemfun)(_Arg) const;   // the member function pointer
     568                 :         };
     569                 : 
     570                 :                 // TEMPLATE FUNCTION mem_fun
     571                 : template<class _Result,
     572                 :         class _Ty> inline
     573                 :         mem_fun_t<_Result, _Ty> mem_fun(_Result (_Ty::*_Pm)())
     574                 :         {       // return a mem_fun_t functor adapter
     575                 :         return (std::mem_fun_t<_Result, _Ty>(_Pm));
     576                 :         }
     577                 : 
     578                 : template<class _Result,
     579                 :         class _Ty,
     580                 :         class _Arg> inline
     581                 :         mem_fun1_t<_Result, _Ty, _Arg> mem_fun(_Result (_Ty::*_Pm)(_Arg))
     582                 :         {       // return a mem_fun1_t functor adapter
     583                 :         return (std::mem_fun1_t<_Result, _Ty, _Arg>(_Pm));
     584                 :         }
     585                 : 
     586                 : template<class _Result,
     587                 :         class _Ty> inline
     588                 :         const_mem_fun_t<_Result, _Ty>
     589                 :                 mem_fun(_Result (_Ty::*_Pm)() const)
     590                 :         {       // return a const_mem_fun_t functor adapter
     591                 :         return (std::const_mem_fun_t<_Result, _Ty>(_Pm));
     592                 :         }
     593                 : 
     594                 : template<class _Result,
     595                 :         class _Ty,
     596                 :         class _Arg> inline
     597                 :         const_mem_fun1_t<_Result, _Ty, _Arg>
     598                 :                 mem_fun(_Result (_Ty::*_Pm)(_Arg) const)
     599                 :         {       // return a const_mem_fun1_t functor adapter
     600                 :         return (std::const_mem_fun1_t<_Result, _Ty, _Arg>(_Pm));
     601                 :         }
     602                 : 
     603                 :                 // TEMPLATE FUNCTION mem_fun1 (retained)
     604                 : template<class _Result,
     605                 :         class _Ty,
     606                 :         class _Arg> inline
     607                 :         mem_fun1_t<_Result, _Ty, _Arg> mem_fun1(_Result (_Ty::*_Pm)(_Arg))
     608                 :         {       // return a mem_fun1_t functor adapter
     609                 :         return (std::mem_fun1_t<_Result, _Ty, _Arg>(_Pm));
     610                 :         }
     611                 : 
     612                 :                 // TEMPLATE CLASS mem_fun_ref_t
     613                 : template<class _Result,
     614                 :         class _Ty>
     615                 :         class mem_fun_ref_t
     616                 :                 : public unary_function<_Ty, _Result>
     617                 :         {       // functor adapter (*left.*pfunc)(), non-const *pfunc
     618                 : public:
     619                 :         explicit mem_fun_ref_t(_Result (_Ty::*_Pm)())
     620                 :                 : _Pmemfun(_Pm)
     621                 :                 {       // construct from pointer
     622                 :                 }
     623                 : 
     624                 :         _Result operator()(_Ty& _Left) const
     625                 :                 {       // call function
     626                 :                 return ((_Left.*_Pmemfun)());
     627                 :                 }
     628                 : 
     629                 : private:
     630                 :         _Result (_Ty::*_Pmemfun)();     // the member function pointer
     631                 :         };
     632                 : 
     633                 :                 // TEMPLATE CLASS mem_fun1_ref_t
     634                 : template<class _Result,
     635                 :         class _Ty,
     636                 :         class _Arg>
     637                 :         class mem_fun1_ref_t
     638                 :                 : public binary_function<_Ty, _Arg, _Result>
     639                 :         {       // functor adapter (*left.*pfunc)(val), non-const *pfunc
     640                 : public:
     641                 :         explicit mem_fun1_ref_t(_Result (_Ty::*_Pm)(_Arg))
     642                 :                 : _Pmemfun(_Pm)
     643                 :                 {       // construct from pointer
     644                 :                 }
     645                 : 
     646                 :         _Result operator()(_Ty& _Left, _Arg _Right) const
     647                 :                 {       // call function with operand
     648                 :                 return ((_Left.*_Pmemfun)(_Right));
     649                 :                 }
     650                 : 
     651                 : private:
     652                 :         _Result (_Ty::*_Pmemfun)(_Arg); // the member function pointer
     653                 :         };
     654                 : 
     655                 :                 // TEMPLATE CLASS const_mem_fun_ref_t
     656                 : template<class _Result,
     657                 :         class _Ty>
     658                 :         class const_mem_fun_ref_t
     659                 :                 : public unary_function<_Ty, _Result>
     660                 :         {       // functor adapter (*left.*pfunc)(), const *pfunc
     661                 : public:
     662                 :         explicit const_mem_fun_ref_t(_Result (_Ty::*_Pm)() const)
     663                 :                 : _Pmemfun(_Pm)
     664                 :                 {       // construct from pointer
     665                 :                 }
     666                 : 
     667                 :         _Result operator()(const _Ty& _Left) const
     668                 :                 {       // call function
     669                 :                 return ((_Left.*_Pmemfun)());
     670                 :                 }
     671                 : 
     672                 : private:
     673                 :         _Result (_Ty::*_Pmemfun)() const;       // the member function pointer
     674                 :         };
     675                 : 
     676                 :                 // TEMPLATE CLASS const_mem_fun1_ref_t
     677                 : template<class _Result,
     678                 :         class _Ty,
     679                 :         class _Arg>
     680                 :         class const_mem_fun1_ref_t
     681                 :                 : public binary_function<_Ty, _Arg, _Result>
     682                 :         {       // functor adapter (*left.*pfunc)(val), const *pfunc
     683                 : public:
     684                 :         explicit const_mem_fun1_ref_t(_Result (_Ty::*_Pm)(_Arg) const)
     685                 :                 : _Pmemfun(_Pm)
     686                 :                 {       // construct from pointer
     687                 :                 }
     688                 : 
     689                 :         _Result operator()(const _Ty& _Left, _Arg _Right) const
     690                 :                 {       // call function with operand
     691                 :                 return ((_Left.*_Pmemfun)(_Right));
     692                 :                 }
     693                 : 
     694                 : private:
     695                 :         _Result (_Ty::*_Pmemfun)(_Arg) const;   // the member function pointer
     696                 :         };
     697                 : 
     698                 :                 // TEMPLATE FUNCTION mem_fun_ref
     699                 : template<class _Result,
     700                 :         class _Ty> inline
     701                 :         mem_fun_ref_t<_Result, _Ty> mem_fun_ref(_Result (_Ty::*_Pm)())
     702                 :         {       // return a mem_fun_ref_t functor adapter
     703                 :         return (std::mem_fun_ref_t<_Result, _Ty>(_Pm));
     704                 :         }
     705                 : 
     706                 : template<class _Result,
     707                 :         class _Ty,
     708                 :         class _Arg> inline
     709                 :         mem_fun1_ref_t<_Result, _Ty, _Arg>
     710                 :                 mem_fun_ref(_Result (_Ty::*_Pm)(_Arg))
     711                 :         {       // return a mem_fun1_ref_t functor adapter
     712                 :         return (std::mem_fun1_ref_t<_Result, _Ty, _Arg>(_Pm));
     713                 :         }
     714                 : 
     715                 : template<class _Result,
     716                 :         class _Ty> inline
     717                 :         const_mem_fun_ref_t<_Result, _Ty>
     718                 :                 mem_fun_ref(_Result (_Ty::*_Pm)() const)
     719                 :         {       // return a const_mem_fun_ref_t functor adapter
     720                 :         return (std::const_mem_fun_ref_t<_Result, _Ty>(_Pm));
     721                 :         }
     722                 : 
     723                 : template<class _Result,
     724                 :         class _Ty,
     725                 :         class _Arg> inline
     726                 :         const_mem_fun1_ref_t<_Result, _Ty, _Arg>
     727                 :                 mem_fun_ref(_Result (_Ty::*_Pm)(_Arg) const)
     728                 :         {       // return a const_mem_fun1_ref_t functor adapter
     729                 :         return (std::const_mem_fun1_ref_t<_Result, _Ty, _Arg>(_Pm));
     730                 :         }
     731                 : 
     732                 :                 // TEMPLATE FUNCTION mem_fun1_ref (retained)
     733                 : template<class _Result,
     734                 :         class _Ty,
     735                 :         class _Arg> inline
     736                 :         mem_fun1_ref_t<_Result, _Ty, _Arg> mem_fun1_ref(_Result (_Ty::*_Pm)(_Arg))
     737                 :         {       // return a mem_fun1_ref_t functor adapter
     738                 :         return (std::mem_fun1_ref_t<_Result, _Ty, _Arg>(_Pm));
     739                 :         }
     740                 : 
     741                 :  #if _HAS_TRADITIONAL_STL
     742                 :                 // TEMPLATE STRUCT identity
     743                 : template<class _Arg>
     744                 :         struct identity
     745                 :                 : public unary_function<_Arg, _Arg>
     746                 :         {       // functor for unary identity operator
     747                 :         _Arg operator()(const _Arg& _Left) const
     748                 :                 {       // apply identity operator to operand
     749                 :                 return (_Left);
     750                 :                 }
     751                 :         };
     752                 : 
     753                 :                 // TEMPLATE STRUCT project1st
     754                 : template<class _Arg1,
     755                 :         class _Arg2>
     756                 :         struct project1st
     757                 :                 : public binary_function<_Arg1, _Arg2, _Arg1>
     758                 :         {       // functor for binary first of two arg selector operator
     759                 :         _Arg1 operator()(const _Arg1& _Left, const _Arg2&) const
     760                 :                 {       // apply first selector operator to two operands
     761                 :                 return (_Left);
     762                 :                 }
     763                 :         };
     764                 : 
     765                 :                 // TEMPLATE STRUCT project2nd
     766                 : template<class _Arg1,
     767                 :         class _Arg2>
     768                 :         struct project2nd
     769                 :                 : public binary_function<_Arg1, _Arg2, _Arg2>
     770                 :         {       // functor for binary second of two arg selector operator
     771                 :         _Arg2 operator()(const _Arg1&, const _Arg2& _Right) const
     772                 :                 {       // apply second selector operator to two operands
     773                 :                 return (_Right);
     774                 :                 }
     775                 :         };
     776                 : 
     777                 :                 // TEMPLATE STRUCT select1st
     778                 : template<class _Pair>
     779                 :         struct select1st
     780                 :                 : public unary_function<_Pair, typename _Pair::first_type>
     781                 :         {       // functor for unary first of pair selector operator
     782                 :         const typename _Pair::first_type& operator()(const _Pair& _Left) const
     783                 :                 {       // apply first selector operator to pair operand
     784                 :                 return (_Left.first);
     785                 :                 }
     786                 :         };
     787                 : 
     788                 :                 // TEMPLATE STRUCT select2nd
     789                 : template<class _Pair>
     790                 :         struct select2nd
     791                 :                 : public unary_function<_Pair, typename _Pair::second_type>
     792                 :         {       // functor for unary second of pair selector operator
     793                 :         const typename _Pair::second_type& operator()(const _Pair& _Left) const
     794                 :                 {       // apply second selector operator to pair operand
     795                 :                 return (_Left.second);
     796                 :                 }
     797                 :         };
     798                 : 
     799                 :                 // TEMPLATE CLASS unary_compose
     800                 : template<class _Fn1,
     801                 :         class _Fn2>
     802                 :         class unary_compose
     803                 :                 : public unary_function<typename _Fn2::argument_type,
     804                 :                         typename _Fn1::result_type>
     805                 :         {       // functor for f1(f2(x))
     806                 : public:
     807                 :         unary_compose(const _Fn1& _Func1, const _Fn2& _Func2)
     808                 :                 : _Functor1(_Func1), _Functor2(_Func2)
     809                 :                 {       // construct from functors
     810                 :                 }
     811                 : 
     812                 :         typename _Fn1::result_type operator()(
     813                 :                 const typename _Fn2::argument_type& _Left) const
     814                 :                 {       // apply functors to operand
     815                 :                 return (_Functor1(_Functor2(_Left)));
     816                 :                 }
     817                 : 
     818                 : protected:
     819                 :         _Fn1 _Functor1;
     820                 :         _Fn2 _Functor2;
     821                 :         };
     822                 : 
     823                 :                 // TEMPLATE FUNCTION compose1
     824                 : template<class _Fn1,
     825                 :         class _Fn2> inline
     826                 :         unary_compose<_Fn1, _Fn2> compose1(const _Fn1& _Func1,
     827                 :                 const _Fn2& _Func2)
     828                 :         {       // return a unary_compose<_Fn1, _Fn2> functor adapter
     829                 :         return (unary_compose<_Fn1, _Fn2>(_Func1, _Func2));
     830                 :         }
     831                 : 
     832                 :                 // TEMPLATE CLASS binary_compose
     833                 : template<class _Fn1,
     834                 :         class _Fn2,
     835                 :         class _Fn3>
     836                 :         class binary_compose
     837                 :                 : public unary_function<typename _Fn2::argument_type,
     838                 :                         typename _Fn1::result_type>
     839                 :         {       // functor for f1(f2(x), f3(x))
     840                 : public:
     841                 :         binary_compose(const _Fn1& _Func1, const _Fn2& _Func2, const _Fn3& _Func3)
     842                 :                 : _Functor1(_Func1), _Functor2(_Func2), _Functor3(_Func3)
     843                 :                 {       // construct from functors
     844                 :                 }
     845                 : 
     846                 :         typename _Fn1::result_type operator()(
     847                 :                 const typename _Fn2::argument_type& _Left) const
     848                 :                 {       // apply functors to operand
     849                 :                 return (_Functor1(_Functor2(_Left), _Functor3(_Left)));
     850                 :                 }
     851                 : 
     852                 : protected:
     853                 :         _Fn1 _Functor1;
     854                 :         _Fn2 _Functor2;
     855                 :         _Fn3 _Functor3;
     856                 :         };
     857                 : 
     858                 :                 // TEMPLATE FUNCTION compose2
     859                 : template<class _Fn1,
     860                 :         class _Fn2,
     861                 :         class _Fn3> inline
     862                 :         binary_compose<_Fn1, _Fn2, _Fn3> compose2(const _Fn1& _Func1,
     863                 :                 const _Fn2& _Func2, const _Fn3& _Func3)
     864                 :         {       // return a binary_compose<_Fn1, _Fn2, _Fn3> functor adapter
     865                 :         return (binary_compose<_Fn1, _Fn2, _Fn3>(_Func1, _Func2, _Func3));
     866                 :         }
     867                 :  #endif /* _HAS_TRADITIONAL_STL */
     868                 : 
     869                 : _STD_END
     870                 : 
     871                 :  #if _HAS_TR1
     872                 :  #include <exception>
     873                 :  #include <typeinfo>
     874                 :  #include <xrefwrap>
     875                 : 
     876                 :  #ifndef _XSTD2
     877                 :   #define _XSTD2
     878                 :  #endif /* _XSTD2 */
     879                 : 
     880                 : _STD_BEGIN
     881                 :         namespace tr1 { // TR1 additions
     882                 : 
     883                 : // IMPLEMENT std::tr1::mem_fn
     884                 :         // TEMPLATE FUNCTION mem_fn
     885                 : template<class _Rx,
     886                 :         class _Arg0>
     887                 :         _Call_wrapper<_Callable_pmd<_Rx _Arg0::*const, _Arg0> >
     888                 :                 mem_fn(_Rx _Arg0::*const _Pmd)
     889                 :         {       // return data object wrapper
     890                 :         return (_Call_wrapper<_Callable_pmd<_Rx _Arg0::*const, _Arg0> >(_Pmd));
     891                 :         }
     892                 : 
     893                 : // define multiple-argument variants of mem_fn
     894                 :  #define _INCL_FILE <xxmem_fn>
     895                 :  #define _NOZERO
     896                 :  #include <xfwrap>
     897                 : 
     898                 : // IMPLEMENT std::tr1::function
     899                 :         // HELPERS
     900                 : 
     901                 :  #if _NO_SFINAE
     902                 :   #define _NOT_INTEGRAL(ty)
     903                 : typedef int _Unutterable;
     904                 : 
     905                 :  #else /* _NO_SFINAE */
     906                 : template<bool,
     907                 :         class _Ty>
     908                 :         struct _Not_integral;
     909                 : 
     910                 : template<class _Ty>
     911                 :         struct _Not_integral<true, _Ty>
     912                 :         {       // distinguish non-integral types
     913                 :         typedef _Ty _Type;
     914                 :         };
     915                 : 
     916                 :   #define _NOT_INTEGRAL(ty)     , \
     917                 :         typename _Not_integral<!_Is_integral<ty>::value, int>::_Type = 0
     918                 : 
     919                 : typedef struct _Unnamed *_Unutterable;
     920                 :  #endif /* _NO_SFINAE */
     921                 : 
     922                 :         // CLASS bad_function_call
     923                 : class bad_function_call
     924                 :         : public _XSTD exception
     925                 :         {       // null function pointer exception
     926                 : public:
     927                 :         explicit bad_function_call(const char * = 0)
     928                 :                 {       // construct with ignored message
     929                 :                 }
     930                 : 
     931                 :         virtual const char *__CLR_OR_THIS_CALL what() const _THROW0()
     932                 :                 {       // return pointer to message string
     933                 :                 return ("bad function call");
     934                 :                 }
     935                 :         };
     936                 : 
     937                 : _CRTIMP2_PURE __declspec(noreturn) void __CLRCALL_PURE_OR_CDECL _Xfunc();
     938                 : 
     939                 :         // TEMPLATE FUNCTION _Get_function_impl
     940                 : template<class _Tx>
     941                 :         struct _Get_function_impl;
     942                 : 
     943                 : // function implementation:
     944                 :  #define _INCL_FILE <xxfunction>
     945                 :  #include <xfwrap>
     946                 : 
     947                 :         // TEMPLATE CLASS function
     948                 : template<class _Fty>
     949                 :         class function
     950                 :                 : public _Get_function_impl<_Fty>::_Type
     951                 :         {       // wrapper for callable objects
     952                 : public:
     953                 :         typedef function<_Fty> _Myt;
     954                 :         typedef typename _Get_function_impl<_Fty>::_Type _Mybase;
     955                 :         typedef std::allocator<int> _Alty0;
     956                 : 
     957                 :         explicit function()
     958                 :                 {       // construct empty function wrapper
     959                 :                 this->_Reset();
     960                 :                 }
     961                 : 
     962                 :         function(const _Myt& _Right)
     963                 :                 {       // construct holding copy of _Right
     964                 :                 this->_Reset((const _Mybase&)_Right);
     965                 :                 }
     966                 : 
     967                 :         template<class _Fx>
     968                 :                 function(_Fx _Func _NOT_INTEGRAL(_Fx))
     969                 :                 {       // construct wrapper holding copy of _Func
     970                 :                 this->_Reset(_Func, _Alty0());
     971                 :                 }
     972                 : 
     973                 :         template<class _Fx,
     974                 :                 class _Alloc>
     975                 :                 function(_Fx _Func _NOT_INTEGRAL(_Fx), _Alloc _Ax)
     976                 :                 {       // construct wrapper holding copy of _Func
     977                 :                 this->_Reset(_Func, _Ax);
     978                 :                 }
     979                 : 
     980                 :         template<class _Fx>
     981                 :                 function(reference_wrapper<_Fx> _Func)
     982                 :                 {       // construct wrapper holding reference to_Func
     983                 :                 this->_Reset(_Func.get(), _Alty0());
     984                 :                 }
     985                 : 
     986                 :         template<class _Fx,
     987                 :                 class _Alloc>
     988                 :                 function(reference_wrapper<_Fx> _Func, _Alloc _Ax)
     989                 :                 {       // construct wrapper holding reference to_Func
     990                 :                 this->_Reset(_Func.get(), _Ax);
     991                 :                 }
     992                 : 
     993                 :         function(_Unutterable)
     994                 :                 {       // construct empty function wrapper from null pointer
     995                 :                 this->_Reset();
     996                 :                 }
     997                 : 
     998                 :         ~function()
     999                 :                 {       // destroy the object
    1000                 :                 this->_Tidy();
    1001                 :                 }
    1002                 : 
    1003                 :         _Myt& operator=(const _Myt& _Right)
    1004                 :                 {       // assign _Right
    1005                 :                 if (this != &_Right)
    1006                 :                         {       // clean up and copy
    1007                 :                         this->_Tidy();
    1008                 :                         this->_Reset((const _Mybase&)_Right);
    1009                 :                         }
    1010                 :                 return (*this);
    1011                 :                 }
    1012                 : 
    1013                 :         template<class _Fx>
    1014                 :                 _Myt& operator=(_Fx _Func _NOT_INTEGRAL(_Fx))
    1015                 :                 {       // assign function object _Func
    1016                 :                 this->_Tidy();
    1017                 :                 this->_Reset(_Func, _Alty0());
    1018                 :                 return (*this);
    1019                 :                 }
    1020                 : 
    1021                 :         function& operator=(_Unutterable)
    1022                 :                 {       // clear function object
    1023                 :                 this->_Tidy();
    1024                 :                 this->_Reset();
    1025                 :                 return (*this);
    1026                 :                 }
    1027                 : 
    1028                 :         template<class _Fx>
    1029                 :                 _Myt& operator=(reference_wrapper<_Fx> _Func)
    1030                 :                 {       // assign wrapper holding reference to_Func
    1031                 :                 this->_Reset(_Func.get(), _Alty0());
    1032                 :                 return (*this);
    1033                 :                 }
    1034                 : 
    1035                 :         template<class _Fx,
    1036                 :                 class _Alloc>
    1037                 :                 void assign(_Fx _Func _NOT_INTEGRAL(_Fx), _Alloc _Ax)
    1038                 :                 {       // construct wrapper holding copy of _Func
    1039                 :                 this->_Reset(_Func, _Ax);
    1040                 :                 }
    1041                 : 
    1042                 :         template<class _Fx,
    1043                 :                 class _Alloc>
    1044                 :                 void assign(reference_wrapper<_Fx> _Func, _Alloc _Ax)
    1045                 :                 {       // construct wrapper holding reference to_Func
    1046                 :                 this->_Reset(_Func.get(), _Ax);
    1047                 :                 }
    1048                 : 
    1049                 :         void swap(_Myt& _Right)
    1050                 :                 {       // swap with _Right
    1051                 :                 this->_Swap(_Right);
    1052                 :                 }
    1053                 : 
    1054                 : 
    1055                 :         operator _STD _Bool_type() const
    1056                 :                 {       // test if wrapper holds null function pointer
    1057                 :                 return (!this->_Empty() ? _CONVERTIBLE_TO_TRUE : 0);
    1058                 :                 }
    1059                 : 
    1060                 :         const _XSTD2 type_info& target_type() const
    1061                 :                 {       // return type_info object for target type
    1062                 :                 return (this->_Target_type());
    1063                 :                 }
    1064                 : 
    1065                 :         template<class _Fty2>
    1066                 :                 _Fty2 *target()
    1067                 :                 {       // return pointer to target object
    1068                 :                 return ((_Fty2*)this->_Target(typeid(_Fty2)));
    1069                 :                 }
    1070                 : 
    1071                 :         template<class _Fty2>
    1072                 :                 const _Fty2 *target() const
    1073                 :                 {       // return pointer to target object
    1074                 :                 return ((const _Fty2*)this->_Target(typeid(_Fty2)));
    1075                 :                 }
    1076                 : 
    1077                 : private:
    1078                 :         //      not defined
    1079                 :         template<class _Fty2>
    1080                 :                 void operator==(const function<_Fty2>&);
    1081                 :         template<class _Fty2>
    1082                 :                 void operator!=(const function<_Fty2>&);
    1083                 :         };
    1084                 : 
    1085                 :         // TEMPLATE FUNCTION swap
    1086                 : template<class _Fty>
    1087                 :         void swap(function<_Fty>& _Left, function<_Fty>& _Right)
    1088                 :         {   // swap contents of _Left with contents of _Right
    1089                 :         _Left.swap(_Right);
    1090                 :         }
    1091                 : 
    1092                 :         // TEMPLATE NULL POINTER COMPARISONS
    1093                 : template<class _Fty>
    1094                 :         bool operator==(const function<_Fty>& _Other, _Unutterable)
    1095                 :         {       // compare to null pointer
    1096                 :         return (!_Other);
    1097                 :         }
    1098                 : 
    1099                 : template<class _Fty>
    1100                 :         bool operator==(_Unutterable _Npc, const function<_Fty>& _Other)
    1101                 :         {       // compare to null pointer
    1102                 :         return (operator==(_Other, _Npc));
    1103                 :         }
    1104                 : 
    1105                 : template<class _Fty>
    1106                 :         bool operator!=(const function<_Fty>& _Other, _Unutterable _Npc)
    1107                 :         {       // compare to null pointer
    1108                 :         return (!operator==(_Other, _Npc));
    1109                 :         }
    1110                 : 
    1111                 : template<class _Fty>
    1112                 :         bool operator!=(_Unutterable _Npc, const function<_Fty>& _Other)
    1113                 :         {       // compare to null pointer
    1114                 :         return (!operator==(_Other, _Npc));
    1115                 :         }
    1116                 : 
    1117                 : // IMPLEMENT std::tr1::bind
    1118                 : 
    1119                 :  #define _CLASS_BARG0           _LIST_MAX(class _Barg)
    1120                 :  #define _BARG0_B0                      _LIST2_MAX(_Barg, _Bx)
    1121                 :  #define _BARG0_B0_REF          _LIST2_MAX(_Barg, &_Bx)
    1122                 :  #define _BARG0_BARG1           _LIST_MAX(_Barg)
    1123                 :  #define _BARG0_BARG1_REF       _LIST15_MAX(_Barg, &)
    1124                 :  #define _B0_B1                         _LIST_MAX(_Bx)
    1125                 : 
    1126                 :         // PLACEHOLDERS
    1127                 : template<int _Nx>
    1128                 :         class _Ph
    1129                 :         {       // placeholder
    1130                 :         };
    1131                 : 
    1132                 : template<class _Tx>
    1133                 :         struct is_placeholder
    1134                 :         {       // template to indicate that _Tx is not a placeholder
    1135                 :         static const int value = 0;
    1136                 :         };
    1137                 : 
    1138                 : template<int _Nx>
    1139                 :         struct is_placeholder<_Ph<_Nx> >
    1140                 :         {       // template specialization to indicate that _Ph<_Nx> is a placeholder
    1141                 :         static const int value = _Nx;
    1142                 :         };
    1143                 : 
    1144                 :         // TEMPLATE STRUCT _Bindret
    1145                 : struct _Notforced
    1146                 :         {       // operator() returns result_of<...>::type
    1147                 :         };
    1148                 : 
    1149                 : template<class _Override,
    1150                 :         class _Natural>
    1151                 :         struct _Bindret
    1152                 :         {       // use user-specified override
    1153                 :         typedef _Override _Type;
    1154                 :         };
    1155                 : 
    1156                 : template<class _Natural>
    1157                 :         struct _Bindret<_Notforced, _Natural>
    1158                 :         {       // use natural type
    1159                 :         typedef _Natural _Type;
    1160                 :         };
    1161                 : 
    1162                 :         // TEMPLATE CLASS _Bind
    1163                 : template<class _Ret,
    1164                 :         class _BindN>
    1165                 :         class _Bind
    1166                 :         {       // template class for objects returned by bind
    1167                 : public:
    1168                 :         typedef typename _BindN::_MyTy _MyTy;
    1169                 :         typedef _BindN _MyBind;
    1170                 : 
    1171                 :         _Bind(_BindN _B0)
    1172                 :                 : _Bx(_B0)
    1173                 :                 {       // construct
    1174                 :                 }
    1175                 : 
    1176                 : // define operator() member functions:
    1177                 :  #define _INCL_FILE <xxbind0>
    1178                 :  #include <xawrap>
    1179                 : private:
    1180                 :         _BindN _Bx;
    1181                 :         };
    1182                 : 
    1183                 :         // TEMPLATE CLASS is_bind_expression
    1184                 : template<class _Tx>
    1185                 :         struct is_bind_expression
    1186                 :         {       // template to indicate that _Tx is not a bind expression
    1187                 :         static const bool value = false;
    1188                 :         };
    1189                 : 
    1190                 : template<class _Rx,
    1191                 :         class _BindN>
    1192                 :         struct is_bind_expression<_Bind<_Rx, _BindN> >
    1193                 :         {       // specialization to indicate a bind expression
    1194                 :         static const bool value = true;
    1195                 :         };
    1196                 : 
    1197                 :         // TEMPLATE CLASS _Binder
    1198                 : template<bool _Expr,
    1199                 :         int _Nx>
    1200                 :         struct _Binder;
    1201                 : 
    1202                 : template<>
    1203                 :         struct _Binder<true, 0>
    1204                 :         {       // bind argument to result of bind expression
    1205                 :         template<class _Arg,
    1206                 :                 _CLASS_BARG0>
    1207                 :                 static typename _Arg::
    1208                 :                         _MyBind::template _Return<_BARG0_BARG1_REF>::_Type
    1209                 :                                 _Get(_Arg _Ax, _BARG0_B0_REF)
    1210                 :                 {       // return result
    1211                 :                 return (_Ax(_B0_B1));
    1212                 :                 }
    1213                 : 
    1214                 :         template<class _Arg,
    1215                 :                 _CLASS_BARG0>
    1216                 :                 struct _Ret
    1217                 :                 {       // describe type of result
    1218                 :                 typedef typename _Arg::
    1219                 :                         _MyBind::template _Return<_BARG0_BARG1>::_Type
    1220                 :                                 _Type;
    1221                 :                 };
    1222                 :         };
    1223                 : 
    1224                 : template<>
    1225                 :         struct _Binder<false, 0>
    1226                 :         {       // bind argument to passed value
    1227                 :         template<class _Arg,
    1228                 :                 _CLASS_BARG0>
    1229                 :                 static _Arg& _Get(_Arg& _Val, _BARG0_B0_REF)
    1230                 :                 {       // return passed value
    1231                 :                 return (_Val);
    1232                 :                 }
    1233                 :         template<class _Arg,
    1234                 :                 _CLASS_BARG0>
    1235                 :                 struct _Ret
    1236                 :                 {       // describe type of result
    1237                 :                 typedef _Arg& _Type;
    1238                 :                 };
    1239                 :         };
    1240                 : 
    1241                 : // define _Binder<false, N>, _BindN:
    1242                 :  #define _INCL_FILE <xxbind1>
    1243                 :  #include <xfwrap>
    1244                 :         }       // namespace tr1
    1245                 : 
    1246                 : template<class _Fty>
    1247                 :         class _Move_operation_category<tr1::function<_Fty> >
    1248                 :         {       // function implements a performant swap
    1249                 : public:
    1250                 :         typedef _Swap_move_tag _Move_cat;
    1251                 :         };
    1252                 : _STD_END
    1253                 :  #endif /* _HAS_TR1 */
    1254                 : 
    1255                 : _STD_BEGIN
    1256                 :         namespace tr1 { // always include std::tr1::hash for unordered_map/set
    1257                 :         // TEMPLATE CLASS hash
    1258                 : template<class _Kty>
    1259                 :         class hash
    1260                 :                 : public unary_function<_Kty, size_t>
    1261                 :         {       // hash functor
    1262                 : public:
    1263                 :         size_t operator()(const _Kty& _Keyval) const
    1264                 :                 {       // hash _Keyval to size_t value by pseudorandomizing transform
    1265                 :                 ldiv_t _Qrem = ldiv((long)(size_t)_Keyval, 127773);
    1266                 : 
    1267                 :                 _Qrem.rem = 16807 * _Qrem.rem - 2836 * _Qrem.quot;
    1268                 :                 if (_Qrem.rem < 0)
    1269                 :                         _Qrem.rem += 2147483647;
    1270                 :                 return ((size_t)_Qrem.rem);
    1271                 :                 }
    1272                 :         };
    1273                 : 
    1274                 : template<>
    1275                 :         class hash<std::string>
    1276                 :                 : public unary_function<_STD string, size_t>
    1277                 :         {       // hash functor
    1278                 : public:
    1279                 :         typedef std::string _Kty;
    1280                 : 
    1281                 :         size_t operator()(const _Kty& _Keyval) const
    1282                 :                 {       // hash _Keyval to size_t value by pseudorandomizing transform
    1283                 :                 size_t _Val = 2166136261U;
    1284                 :                 size_t _First = 0;
    1285                 :                 size_t _Last = _Keyval.size();
    1286                 :                 size_t _Stride = 1 + _Last / 10;
    1287                 : 
    1288                 :                 if (_Stride < _Last)
    1289                 :                         _Last -= _Stride;
    1290                 :                 for(; _First < _Last; _First += _Stride)
    1291                 :                         _Val = 16777619U * _Val ^ (size_t)_Keyval[_First];
    1292                 :                 return (_Val);
    1293                 :                 }
    1294                 :         };
    1295                 : 
    1296                 : template<>
    1297                 :         class hash<std::wstring>
    1298                 :                 : public unary_function<_STD wstring, size_t>
    1299                 :         {       // hash functor
    1300                 : public:
    1301                 :         typedef std::wstring _Kty;
    1302                 : 
    1303                 :         size_t operator()(const _Kty& _Keyval) const
    1304                 :                 {       // hash _Keyval to size_t value by pseudorandomizing transform
    1305                 :                 size_t _Val = 2166136261U;
    1306                 :                 size_t _First = 0;
    1307                 :                 size_t _Last = _Keyval.size();
    1308                 :                 size_t _Stride = 1 + _Last / 10;
    1309                 : 
    1310                 :                 if (_Stride < _Last)
    1311                 :                         _Last -= _Stride;
    1312                 :                 for(; _First < _Last; _First += _Stride)
    1313                 :                         _Val = 16777619U * _Val ^ (size_t)_Keyval[_First];
    1314                 :                 return (_Val);
    1315                 :                 }
    1316                 :         };
    1317                 : 
    1318                 :         }       // namespace tr1
    1319                 : _STD_END
    1320                 : 
    1321                 : #ifdef _MSC_VER
    1322                 :  #pragma warning(default: 4100 4180 4244)
    1323                 :  #pragma warning(pop)
    1324                 :  #pragma pack(pop)
    1325                 : #endif  /* _MSC_VER */
    1326                 : 
    1327                 : #endif /* RC_INVOKED */
    1328                 : #endif /* _FUNCTIONAL_ */
    1329                 : 
    1330                 : /*
    1331                 :  * This file is derived from software bearing the following
    1332                 :  * restrictions:
    1333                 :  *
    1334                 :  * Copyright (c) 1994
    1335                 :  * Hewlett-Packard Company
    1336                 :  *
    1337                 :  * Permission to use, copy, modify, distribute and sell this
    1338                 :  * software and its documentation for any purpose is hereby
    1339                 :  * granted without fee, provided that the above copyright notice
    1340                 :  * appear in all copies and that both that copyright notice and
    1341                 :  * this permission notice appear in supporting documentation.
    1342                 :  * Hewlett-Packard Company makes no representations about the
    1343                 :  * suitability of this software for any purpose. It is provided
    1344                 :  * "as is" without express or implied warranty.
    1345                 :  */
    1346                 : 
    1347                 : /*
    1348                 :  * Copyright (c) 1992-2008 by P.J. Plauger.  ALL RIGHTS RESERVED.
    1349                 :  * Consult your license regarding permissions and restrictions.
    1350                 :  V5.05:0009 */
    1351                 : 
    1352                 : 

Generated by: LCOV version 1.7