xref: /freebsd/contrib/llvm-project/libcxx/include/__functional/mem_fun_ref.h (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
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
27     : public __unary_function<_Tp*, _Sp>
28 {
29     _Sp (_Tp::*__p_)();
30 public:
31     _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
32         : __p_(__p) {}
33     _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
34         {return (__p->*__p_)();}
35 };
36 
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>
40 {
41     _Sp (_Tp::*__p_)(_Ap);
42 public:
43     _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
44         : __p_(__p) {}
45     _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
46         {return (__p->*__p_)(__x);}
47 };
48 
49 template<class _Sp, class _Tp>
50 _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
51 mem_fun_t<_Sp,_Tp>
52 mem_fun(_Sp (_Tp::*__f)())
53     {return mem_fun_t<_Sp,_Tp>(__f);}
54 
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);}
60 
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>
64 {
65     _Sp (_Tp::*__p_)();
66 public:
67     _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
68         : __p_(__p) {}
69     _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
70         {return (__p.*__p_)();}
71 };
72 
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>
76 {
77     _Sp (_Tp::*__p_)(_Ap);
78 public:
79     _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
80         : __p_(__p) {}
81     _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
82         {return (__p.*__p_)(__x);}
83 };
84 
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);}
90 
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);}
96 
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>
100 {
101     _Sp (_Tp::*__p_)() const;
102 public:
103     _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
104         : __p_(__p) {}
105     _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
106         {return (__p->*__p_)();}
107 };
108 
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>
112 {
113     _Sp (_Tp::*__p_)(_Ap) const;
114 public:
115     _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
116         : __p_(__p) {}
117     _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
118         {return (__p->*__p_)(__x);}
119 };
120 
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);}
126 
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);}
132 
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>
136 {
137     _Sp (_Tp::*__p_)() const;
138 public:
139     _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
140         : __p_(__p) {}
141     _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
142         {return (__p.*__p_)();}
143 };
144 
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>
148 {
149     _Sp (_Tp::*__p_)(_Ap) const;
150 public:
151     _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
152         : __p_(__p) {}
153     _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
154         {return (__p.*__p_)(__x);}
155 };
156 
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);}
162 
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);}
168 
169 #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
170 
171 _LIBCPP_END_NAMESPACE_STD
172 
173 #endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
174