Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: stlstuff.h
  7. *
  8. * Contents: Interface file for STL helpers
  9. *
  10. * History: 26-Apr-99 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef STLSTUFF_H
  14. #define STLSTUFF_H
  15. #pragma once
  16. /*+-------------------------------------------------------------------------*
  17. * const member function adapters
  18. *
  19. * These member function adapters are used to adapt const member functions
  20. * in the same way that
  21. *
  22. * std::mem_fun
  23. * std::mem_fun1
  24. * std::mem_fun_ref
  25. * std::mem_fun_ref1
  26. *
  27. * adapt non-const member functions.
  28. *--------------------------------------------------------------------------*/
  29. // TEMPLATE CLASS const_mem_fun_t
  30. template<class _R, class _Ty>
  31. class const_mem_fun_t : public std::unary_function<_Ty *, _R> {
  32. public:
  33. explicit const_mem_fun_t(_R (_Ty::*_Pm)() const)
  34. : _Ptr(_Pm) {}
  35. _R operator()(_Ty *_P)
  36. {return ((_P->*_Ptr)()); }
  37. private:
  38. _R (_Ty::*_Ptr)() const;
  39. };
  40. // TEMPLATE FUNCTION const_mem_fun
  41. template<class _R, class _Ty> inline
  42. const_mem_fun_t<_R, _Ty> const_mem_fun(_R (_Ty::*_Pm)() const)
  43. {return (const_mem_fun_t<_R, _Ty>(_Pm)); }
  44. // TEMPLATE CLASS const_mem_fun1_t
  45. template<class _R, class _Ty, class _A>
  46. class const_mem_fun1_t : public std::binary_function<_Ty *, _A, _R> {
  47. public:
  48. explicit const_mem_fun1_t(_R (_Ty::*_Pm)(_A) const)
  49. : _Ptr(_Pm) {}
  50. _R operator()(_Ty *_P, _A _Arg)
  51. {return ((_P->*_Ptr)(_Arg)); }
  52. private:
  53. _R (_Ty::*_Ptr)(_A) const;
  54. };
  55. // TEMPLATE FUNCTION const_mem_fun1
  56. template<class _R, class _Ty, class _A> inline
  57. const_mem_fun1_t<_R, _Ty, _A> const_mem_fun1(_R (_Ty::*_Pm)(_A) const)
  58. {return (const_mem_fun1_t<_R, _Ty, _A>(_Pm)); }
  59. // TEMPLATE CLASS const_mem_fun_ref_t
  60. template<class _R, class _Ty>
  61. class const_mem_fun_ref_t : public std::unary_function<_Ty *, _R> {
  62. public:
  63. explicit const_mem_fun_ref_t(_R (_Ty::*_Pm)() const)
  64. : _Ptr(_Pm) {}
  65. _R operator()(_Ty& _X)
  66. {return ((_X.*_Ptr)()); }
  67. private:
  68. _R (_Ty::*_Ptr)() const;
  69. };
  70. // TEMPLATE FUNCTION const_mem_fun_ref
  71. template<class _R, class _Ty> inline
  72. const_mem_fun_ref_t<_R, _Ty> const_mem_fun_ref(_R (_Ty::*_Pm)() const)
  73. {return (const_mem_fun_ref_t<_R, _Ty>(_Pm)); }
  74. // TEMPLATE CLASS const_mem_fun1_ref_t
  75. template<class _R, class _Ty, class _A>
  76. class const_mem_fun1_ref_t : public std::binary_function<_Ty *, _A, _R> {
  77. public:
  78. explicit const_mem_fun1_ref_t(_R (_Ty::*_Pm)(_A) const)
  79. : _Ptr(_Pm) {}
  80. _R operator()(_Ty& _X, _A _Arg)
  81. {return ((_X.*_Ptr)(_Arg)); }
  82. private:
  83. _R (_Ty::*_Ptr)(_A) const;
  84. };
  85. // TEMPLATE FUNCTION const_mem_fun1_ref
  86. template<class _R, class _Ty, class _A> inline
  87. const_mem_fun1_ref_t<_R, _Ty, _A> const_mem_fun1_ref(_R (_Ty::*_Pm)(_A) const)
  88. {return (const_mem_fun1_ref_t<_R, _Ty, _A>(_Pm)); }
  89. #endif /* STLSTUFF_H */