mem_fun_ref.h revision 1.1.1.1
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/unary_function.h> 15#include <__functional/binary_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 27 : public unary_function<_Tp*, _Sp> 28{ 29 _Sp (_Tp::*__p_)(); 30public: 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 37template<class _Sp, class _Tp, class _Ap> 38class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t 39 : public binary_function<_Tp*, _Ap, _Sp> 40{ 41 _Sp (_Tp::*__p_)(_Ap); 42public: 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 49template<class _Sp, class _Tp> 50_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 51mem_fun_t<_Sp,_Tp> 52mem_fun(_Sp (_Tp::*__f)()) 53 {return mem_fun_t<_Sp,_Tp>(__f);} 54 55template<class _Sp, class _Tp, class _Ap> 56_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 57mem_fun1_t<_Sp,_Tp,_Ap> 58mem_fun(_Sp (_Tp::*__f)(_Ap)) 59 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 60 61template<class _Sp, class _Tp> 62class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t 63 : public unary_function<_Tp, _Sp> 64{ 65 _Sp (_Tp::*__p_)(); 66public: 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 73template<class _Sp, class _Tp, class _Ap> 74class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t 75 : public binary_function<_Tp, _Ap, _Sp> 76{ 77 _Sp (_Tp::*__p_)(_Ap); 78public: 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 85template<class _Sp, class _Tp> 86_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 87mem_fun_ref_t<_Sp,_Tp> 88mem_fun_ref(_Sp (_Tp::*__f)()) 89 {return mem_fun_ref_t<_Sp,_Tp>(__f);} 90 91template<class _Sp, class _Tp, class _Ap> 92_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 93mem_fun1_ref_t<_Sp,_Tp,_Ap> 94mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 95 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 96 97template <class _Sp, class _Tp> 98class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t 99 : public unary_function<const _Tp*, _Sp> 100{ 101 _Sp (_Tp::*__p_)() const; 102public: 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 109template <class _Sp, class _Tp, class _Ap> 110class _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; 114public: 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 121template <class _Sp, class _Tp> 122_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 123const_mem_fun_t<_Sp,_Tp> 124mem_fun(_Sp (_Tp::*__f)() const) 125 {return const_mem_fun_t<_Sp,_Tp>(__f);} 126 127template <class _Sp, class _Tp, class _Ap> 128_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 129const_mem_fun1_t<_Sp,_Tp,_Ap> 130mem_fun(_Sp (_Tp::*__f)(_Ap) const) 131 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 132 133template <class _Sp, class _Tp> 134class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t 135 : public unary_function<_Tp, _Sp> 136{ 137 _Sp (_Tp::*__p_)() const; 138public: 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 145template <class _Sp, class _Tp, class _Ap> 146class _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; 150public: 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 157template <class _Sp, class _Tp> 158_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 159const_mem_fun_ref_t<_Sp,_Tp> 160mem_fun_ref(_Sp (_Tp::*__f)() const) 161 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 162 163template <class _Sp, class _Tp, class _Ap> 164_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY 165const_mem_fun1_ref_t<_Sp,_Tp,_Ap> 166mem_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