2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
11 #define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
14 #include <__functional/binary_function.h>
15 #include <__functional/unary_function.h>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #pragma GCC system_header
21 _LIBCPP_BEGIN_NAMESPACE_STD
23 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
25 template<class _Sp
, class _Tp
>
26 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
27 : public unary_function
<_Tp
*, _Sp
>
31 _LIBCPP_INLINE_VISIBILITY
explicit mem_fun_t(_Sp (_Tp::*__p
)())
33 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(_Tp
* __p
) const
34 {return (__p
->*__p_
)();}
37 template<class _Sp
, class _Tp
, class _Ap
>
38 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
39 : public binary_function
<_Tp
*, _Ap
, _Sp
>
41 _Sp (_Tp::*__p_
)(_Ap
);
43 _LIBCPP_INLINE_VISIBILITY
explicit mem_fun1_t(_Sp (_Tp::*__p
)(_Ap
))
45 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(_Tp
* __p
, _Ap __x
) const
46 {return (__p
->*__p_
)(__x
);}
49 template<class _Sp
, class _Tp
>
50 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
52 mem_fun(_Sp (_Tp::*__f
)())
53 {return mem_fun_t
<_Sp
,_Tp
>(__f
);}
55 template<class _Sp
, class _Tp
, class _Ap
>
56 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
57 mem_fun1_t
<_Sp
,_Tp
,_Ap
>
58 mem_fun(_Sp (_Tp::*__f
)(_Ap
))
59 {return mem_fun1_t
<_Sp
,_Tp
,_Ap
>(__f
);}
61 template<class _Sp
, class _Tp
>
62 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
63 : public unary_function
<_Tp
, _Sp
>
67 _LIBCPP_INLINE_VISIBILITY
explicit mem_fun_ref_t(_Sp (_Tp::*__p
)())
69 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(_Tp
& __p
) const
70 {return (__p
.*__p_
)();}
73 template<class _Sp
, class _Tp
, class _Ap
>
74 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
75 : public binary_function
<_Tp
, _Ap
, _Sp
>
77 _Sp (_Tp::*__p_
)(_Ap
);
79 _LIBCPP_INLINE_VISIBILITY
explicit mem_fun1_ref_t(_Sp (_Tp::*__p
)(_Ap
))
81 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(_Tp
& __p
, _Ap __x
) const
82 {return (__p
.*__p_
)(__x
);}
85 template<class _Sp
, class _Tp
>
86 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
87 mem_fun_ref_t
<_Sp
,_Tp
>
88 mem_fun_ref(_Sp (_Tp::*__f
)())
89 {return mem_fun_ref_t
<_Sp
,_Tp
>(__f
);}
91 template<class _Sp
, class _Tp
, class _Ap
>
92 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
93 mem_fun1_ref_t
<_Sp
,_Tp
,_Ap
>
94 mem_fun_ref(_Sp (_Tp::*__f
)(_Ap
))
95 {return mem_fun1_ref_t
<_Sp
,_Tp
,_Ap
>(__f
);}
97 template <class _Sp
, class _Tp
>
98 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
99 : public unary_function
<const _Tp
*, _Sp
>
101 _Sp (_Tp::*__p_
)() const;
103 _LIBCPP_INLINE_VISIBILITY
explicit const_mem_fun_t(_Sp (_Tp::*__p
)() const)
105 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(const _Tp
* __p
) const
106 {return (__p
->*__p_
)();}
109 template <class _Sp
, class _Tp
, class _Ap
>
110 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
111 : public binary_function
<const _Tp
*, _Ap
, _Sp
>
113 _Sp (_Tp::*__p_
)(_Ap
) const;
115 _LIBCPP_INLINE_VISIBILITY
explicit const_mem_fun1_t(_Sp (_Tp::*__p
)(_Ap
) const)
117 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(const _Tp
* __p
, _Ap __x
) const
118 {return (__p
->*__p_
)(__x
);}
121 template <class _Sp
, class _Tp
>
122 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
123 const_mem_fun_t
<_Sp
,_Tp
>
124 mem_fun(_Sp (_Tp::*__f
)() const)
125 {return const_mem_fun_t
<_Sp
,_Tp
>(__f
);}
127 template <class _Sp
, class _Tp
, class _Ap
>
128 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
129 const_mem_fun1_t
<_Sp
,_Tp
,_Ap
>
130 mem_fun(_Sp (_Tp::*__f
)(_Ap
) const)
131 {return const_mem_fun1_t
<_Sp
,_Tp
,_Ap
>(__f
);}
133 template <class _Sp
, class _Tp
>
134 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
135 : public unary_function
<_Tp
, _Sp
>
137 _Sp (_Tp::*__p_
)() const;
139 _LIBCPP_INLINE_VISIBILITY
explicit const_mem_fun_ref_t(_Sp (_Tp::*__p
)() const)
141 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(const _Tp
& __p
) const
142 {return (__p
.*__p_
)();}
145 template <class _Sp
, class _Tp
, class _Ap
>
146 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
147 : public binary_function
<_Tp
, _Ap
, _Sp
>
149 _Sp (_Tp::*__p_
)(_Ap
) const;
151 _LIBCPP_INLINE_VISIBILITY
explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p
)(_Ap
) const)
153 _LIBCPP_INLINE_VISIBILITY _Sp
operator()(const _Tp
& __p
, _Ap __x
) const
154 {return (__p
.*__p_
)(__x
);}
157 template <class _Sp
, class _Tp
>
158 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
159 const_mem_fun_ref_t
<_Sp
,_Tp
>
160 mem_fun_ref(_Sp (_Tp::*__f
)() const)
161 {return const_mem_fun_ref_t
<_Sp
,_Tp
>(__f
);}
163 template <class _Sp
, class _Tp
, class _Ap
>
164 _LIBCPP_DEPRECATED_IN_CXX11
inline _LIBCPP_INLINE_VISIBILITY
165 const_mem_fun1_ref_t
<_Sp
,_Tp
,_Ap
>
166 mem_fun_ref(_Sp (_Tp::*__f
)(_Ap
) const)
167 {return const_mem_fun1_ref_t
<_Sp
,_Tp
,_Ap
>(__f
);}
169 #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
171 _LIBCPP_END_NAMESPACE_STD
173 #endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H