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