codekingpro/portable-devtools
114k
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// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.8//9//===----------------------------------------------------------------------===//10 11#ifndef _LIBCUDACXX___FUNCTIONAL_MEM_FN_H12#define _LIBCUDACXX___FUNCTIONAL_MEM_FN_H13 14#ifndef __cuda_std__15#include <__config>16#endif // __cuda_std__17 18#include "../__functional/binary_function.h"19#include "../__functional/invoke.h"20#include "../__functional/weak_result_type.h"21#include "../__utility/forward.h"22 23#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)24# pragma GCC system_header25#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)26# pragma clang system_header27#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)28# pragma system_header29#endif // no system header30 31_LIBCUDACXX_BEGIN_NAMESPACE_STD32 33template <class _Tp>34class __mem_fn : public __weak_result_type<_Tp>35{36public:37 // types38 typedef _Tp type;39private:40 type __f_;41 42public:43 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1744 __mem_fn(type __f) noexcept : __f_(__f) {}45 46 // invoke47 template <class... _ArgTypes>48 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1749 typename __invoke_return<type, _ArgTypes...>::type50 operator() (_ArgTypes&&... __args) const {51 return _CUDA_VSTD::__invoke(__f_, _CUDA_VSTD::forward<_ArgTypes>(__args)...);52 }53};54 55template<class _Rp, class _Tp>56inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1757__mem_fn<_Rp _Tp::*>58mem_fn(_Rp _Tp::* __pm) noexcept59{60 return __mem_fn<_Rp _Tp::*>(__pm);61}62 63_LIBCUDACXX_END_NAMESPACE_STD64 65#endif // _LIBCUDACXX___FUNCTIONAL_MEM_FN_H66 