Path: blob/main/contrib/llvm-project/libcxx/include/__functional/mem_fn.h
35260 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___FUNCTIONAL_MEM_FN_H10#define _LIBCPP___FUNCTIONAL_MEM_FN_H1112#include <__config>13#include <__functional/binary_function.h>14#include <__functional/invoke.h>15#include <__functional/weak_result_type.h>16#include <__utility/forward.h>1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19# pragma GCC system_header20#endif2122_LIBCPP_BEGIN_NAMESPACE_STD2324template <class _Tp>25class __mem_fn : public __weak_result_type<_Tp> {26public:27// types28typedef _Tp type;2930private:31type __f_;3233public:34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}3536// invoke37template <class... _ArgTypes>38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX203940typename __invoke_return<type, _ArgTypes...>::type41operator()(_ArgTypes&&... __args) const {42return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);43}44};4546template <class _Rp, class _Tp>47inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::*__pm) _NOEXCEPT {48return __mem_fn<_Rp _Tp::*>(__pm);49}5051_LIBCPP_END_NAMESPACE_STD5253#endif // _LIBCPP___FUNCTIONAL_MEM_FN_H545556