mem_fun_ref.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
  10. #define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
  11. #include <__config>
  12. #include <__functional/binary_function.h>
  13. #include <__functional/unary_function.h>
  14. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  15. # pragma GCC system_header
  16. #endif
  17. _LIBCPP_BEGIN_NAMESPACE_STD
  18. #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
  19. template<class _Sp, class _Tp>
  20. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
  21. : public __unary_function<_Tp*, _Sp>
  22. {
  23. _Sp (_Tp::*__p_)();
  24. public:
  25. _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
  26. : __p_(__p) {}
  27. _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
  28. {return (__p->*__p_)();}
  29. };
  30. template<class _Sp, class _Tp, class _Ap>
  31. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
  32. : public __binary_function<_Tp*, _Ap, _Sp>
  33. {
  34. _Sp (_Tp::*__p_)(_Ap);
  35. public:
  36. _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
  37. : __p_(__p) {}
  38. _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
  39. {return (__p->*__p_)(__x);}
  40. };
  41. template<class _Sp, class _Tp>
  42. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  43. mem_fun_t<_Sp,_Tp>
  44. mem_fun(_Sp (_Tp::*__f)())
  45. {return mem_fun_t<_Sp,_Tp>(__f);}
  46. template<class _Sp, class _Tp, class _Ap>
  47. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  48. mem_fun1_t<_Sp,_Tp,_Ap>
  49. mem_fun(_Sp (_Tp::*__f)(_Ap))
  50. {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
  51. template<class _Sp, class _Tp>
  52. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
  53. : public __unary_function<_Tp, _Sp>
  54. {
  55. _Sp (_Tp::*__p_)();
  56. public:
  57. _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
  58. : __p_(__p) {}
  59. _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
  60. {return (__p.*__p_)();}
  61. };
  62. template<class _Sp, class _Tp, class _Ap>
  63. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
  64. : public __binary_function<_Tp, _Ap, _Sp>
  65. {
  66. _Sp (_Tp::*__p_)(_Ap);
  67. public:
  68. _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
  69. : __p_(__p) {}
  70. _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
  71. {return (__p.*__p_)(__x);}
  72. };
  73. template<class _Sp, class _Tp>
  74. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  75. mem_fun_ref_t<_Sp,_Tp>
  76. mem_fun_ref(_Sp (_Tp::*__f)())
  77. {return mem_fun_ref_t<_Sp,_Tp>(__f);}
  78. template<class _Sp, class _Tp, class _Ap>
  79. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  80. mem_fun1_ref_t<_Sp,_Tp,_Ap>
  81. mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
  82. {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
  83. template <class _Sp, class _Tp>
  84. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
  85. : public __unary_function<const _Tp*, _Sp>
  86. {
  87. _Sp (_Tp::*__p_)() const;
  88. public:
  89. _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
  90. : __p_(__p) {}
  91. _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
  92. {return (__p->*__p_)();}
  93. };
  94. template <class _Sp, class _Tp, class _Ap>
  95. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
  96. : public __binary_function<const _Tp*, _Ap, _Sp>
  97. {
  98. _Sp (_Tp::*__p_)(_Ap) const;
  99. public:
  100. _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
  101. : __p_(__p) {}
  102. _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
  103. {return (__p->*__p_)(__x);}
  104. };
  105. template <class _Sp, class _Tp>
  106. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  107. const_mem_fun_t<_Sp,_Tp>
  108. mem_fun(_Sp (_Tp::*__f)() const)
  109. {return const_mem_fun_t<_Sp,_Tp>(__f);}
  110. template <class _Sp, class _Tp, class _Ap>
  111. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  112. const_mem_fun1_t<_Sp,_Tp,_Ap>
  113. mem_fun(_Sp (_Tp::*__f)(_Ap) const)
  114. {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
  115. template <class _Sp, class _Tp>
  116. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
  117. : public __unary_function<_Tp, _Sp>
  118. {
  119. _Sp (_Tp::*__p_)() const;
  120. public:
  121. _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
  122. : __p_(__p) {}
  123. _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
  124. {return (__p.*__p_)();}
  125. };
  126. template <class _Sp, class _Tp, class _Ap>
  127. class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
  128. : public __binary_function<_Tp, _Ap, _Sp>
  129. {
  130. _Sp (_Tp::*__p_)(_Ap) const;
  131. public:
  132. _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
  133. : __p_(__p) {}
  134. _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
  135. {return (__p.*__p_)(__x);}
  136. };
  137. template <class _Sp, class _Tp>
  138. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  139. const_mem_fun_ref_t<_Sp,_Tp>
  140. mem_fun_ref(_Sp (_Tp::*__f)() const)
  141. {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
  142. template <class _Sp, class _Tp, class _Ap>
  143. _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
  144. const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
  145. mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
  146. {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
  147. #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
  148. _LIBCPP_END_NAMESPACE_STD
  149. #endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H