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
25template <class _Sp, class _Tp>
26class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> {
27 _Sp (_Tp::*__p_)();
28
29public:
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
34template <class _Sp, class _Tp, class _Ap>
35class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t : public __binary_function<_Tp*, _Ap, _Sp> {
36 _Sp (_Tp::*__p_)(_Ap);
37
38public:
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
43template <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
48template <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
53template <class _Sp, class _Tp>
54class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t : public __unary_function<_Tp, _Sp> {
55 _Sp (_Tp::*__p_)();
56
57public:
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
62template <class _Sp, class _Tp, class _Ap>
63class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {
64 _Sp (_Tp::*__p_)(_Ap);
65
66public:
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
71template <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
76template <class _Sp, class _Tp, class _Ap>
77_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_ref_t<_Sp, _Tp, _Ap>
78mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {
79 return mem_fun1_ref_t<_Sp, _Tp, _Ap>(__f);
80}
81
82template <class _Sp, class _Tp>
83class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t : public __unary_function<const _Tp*, _Sp> {
84 _Sp (_Tp::*__p_)() const;
85
86public:
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
91template <class _Sp, class _Tp, class _Ap>
92class _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;
95
96public:
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
101template <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
106template <class _Sp, class _Tp, class _Ap>
107_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun1_t<_Sp, _Tp, _Ap>
108mem_fun(_Sp (_Tp::*__f)(_Ap) const) {
109 return const_mem_fun1_t<_Sp, _Tp, _Ap>(__f);
110}
111
112template <class _Sp, class _Tp>
113class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t : public __unary_function<_Tp, _Sp> {
114 _Sp (_Tp::*__p_)() const;
115
116public:
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
121template <class _Sp, class _Tp, class _Ap>
122class _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
125public:
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
130template <class _Sp, class _Tp>
131_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun_ref_t<_Sp, _Tp>
132mem_fun_ref(_Sp (_Tp::*__f)() const) {
133 return const_mem_fun_ref_t<_Sp, _Tp>(__f);
134}
135
136template <class _Sp, class _Tp, class _Ap>
137_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun1_ref_t<_Sp, _Tp, _Ap>
138mem_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