brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · fb9ffcf Raw
52 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___CXX03___FUNCTIONAL_MEM_FN_H11#define _LIBCPP___CXX03___FUNCTIONAL_MEM_FN_H12 13#include <__cxx03/__config>14#include <__cxx03/__functional/binary_function.h>15#include <__cxx03/__functional/weak_result_type.h>16#include <__cxx03/__type_traits/invoke.h>17#include <__cxx03/__utility/forward.h>18 19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#  pragma GCC system_header21#endif22 23_LIBCPP_BEGIN_NAMESPACE_STD24 25template <class _Tp>26class __mem_fn : public __weak_result_type<_Tp> {27public:28  // types29  typedef _Tp type;30 31private:32  type __f_;33 34public:35  _LIBCPP_HIDE_FROM_ABI __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}36 37  // invoke38  template <class... _ArgTypes>39  _LIBCPP_HIDE_FROM_ABI typename __invoke_return<type, _ArgTypes...>::type operator()(_ArgTypes&&... __args) const {40    return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);41  }42};43 44template <class _Rp, class _Tp>45inline _LIBCPP_HIDE_FROM_ABI __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::* __pm) _NOEXCEPT {46  return __mem_fn<_Rp _Tp::*>(__pm);47}48 49_LIBCPP_END_NAMESPACE_STD50 51#endif // _LIBCPP___CXX03___FUNCTIONAL_MEM_FN_H52