1050b064fSChristopher Di Bella // -*- C++ -*- 2050b064fSChristopher Di Bella //===----------------------------------------------------------------------===// 3050b064fSChristopher Di Bella // 4050b064fSChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5050b064fSChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information. 6050b064fSChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7050b064fSChristopher Di Bella // 8050b064fSChristopher Di Bella //===----------------------------------------------------------------------===// 9050b064fSChristopher Di Bella 10050b064fSChristopher Di Bella #ifndef _LIBCPP___FUNCTIONAL_MEM_FN_H 11050b064fSChristopher Di Bella #define _LIBCPP___FUNCTIONAL_MEM_FN_H 12050b064fSChristopher Di Bella 13050b064fSChristopher Di Bella #include <__config> 14050b064fSChristopher Di Bella #include <__functional/binary_function.h> 154d81a46fSArthur O'Dwyer #include <__functional/weak_result_type.h> 1609e3a360SLouis Dionne #include <__type_traits/invoke.h> 17ea2206d7SArthur O'Dwyer #include <__utility/forward.h> 18050b064fSChristopher Di Bella 19050b064fSChristopher Di Bella #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 20050b064fSChristopher Di Bella # pragma GCC system_header 21050b064fSChristopher Di Bella #endif 22050b064fSChristopher Di Bella 23050b064fSChristopher Di Bella _LIBCPP_BEGIN_NAMESPACE_STD 24050b064fSChristopher Di Bella 25050b064fSChristopher Di Bella template <class _Tp> 269783f28cSLouis Dionne class __mem_fn : public __weak_result_type<_Tp> { 27050b064fSChristopher Di Bella public: 28050b064fSChristopher Di Bella // types 29050b064fSChristopher Di Bella typedef _Tp type; 309783f28cSLouis Dionne 31050b064fSChristopher Di Bella private: 32050b064fSChristopher Di Bella type __f_; 33050b064fSChristopher Di Bella 34050b064fSChristopher Di Bella public: 359783f28cSLouis Dionne _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} 36050b064fSChristopher Di Bella 37050b064fSChristopher Di Bella // invoke 38050b064fSChristopher Di Bella template <class... _ArgTypes> 39*0fa05456SNikolas Klauser _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<const _Tp&, _ArgTypes...> 40*0fa05456SNikolas Klauser operator()(_ArgTypes&&... __args) const _NOEXCEPT_(__is_nothrow_invocable_v<const _Tp&, _ArgTypes...>) { 416f27eb6eSNikolas Klauser return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...); 42050b064fSChristopher Di Bella } 43050b064fSChristopher Di Bella }; 44050b064fSChristopher Di Bella 45050b064fSChristopher Di Bella template <class _Rp, class _Tp> 469783f28cSLouis Dionne inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::*__pm) _NOEXCEPT { 47050b064fSChristopher Di Bella return __mem_fn<_Rp _Tp::*>(__pm); 48050b064fSChristopher Di Bella } 49050b064fSChristopher Di Bella 50050b064fSChristopher Di Bella _LIBCPP_END_NAMESPACE_STD 51050b064fSChristopher Di Bella 52050b064fSChristopher Di Bella #endif // _LIBCPP___FUNCTIONAL_MEM_FN_H 53