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
: public __unary_function
<_Tp
*, _Sp
> {
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_
)(); }
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
);
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
); }
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
);
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
);
53 template <class _Sp
, class _Tp
>
54 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
: public __unary_function
<_Tp
, _Sp
> {
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_
)(); }
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
);
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
); }
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
);
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
);
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;
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_
)(); }
91 template <class _Sp
, class _Tp
, class _Ap
>
92 class _LIBCPP_TEMPLATE_VIS
93 _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
: public __binary_function
<const _Tp
*, _Ap
, _Sp
> {
94 _Sp (_Tp::*__p_
)(_Ap
) const;
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
); }
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
);
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
);
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;
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_
)(); }
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;
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
); }
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
);
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
);
142 #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
144 _LIBCPP_END_NAMESPACE_STD
146 #endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H