Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
bind_front.h83 linesDownload Raw Back to __functional
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_BIND_FRONT_H12#define _LIBCUDACXX___FUNCTIONAL_BIND_FRONT_H13 14#ifndef __cuda_std__15#include <__config>16#endif // __cuda_std__17 18#include "../__concepts/__concept_macros.h"19#include "../__functional/invoke.h"20#include "../__functional/perfect_forward.h"21#include "../__type_traits/decay.h"22#include "../__type_traits/enable_if.h"23#include "../__type_traits/is_constructible.h"24#include "../__type_traits/is_move_constructible.h"25#include "../__type_traits/is_nothrow_constructible.h"26#include "../__utility/forward.h"27 28#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)29#  pragma GCC system_header30#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)31#  pragma clang system_header32#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)33#  pragma system_header34#endif // no system header35 36_LIBCUDACXX_BEGIN_NAMESPACE_STD37 38#if _LIBCUDACXX_STD_VER > 1439 40struct __bind_front_op {41    template <class ..._Args>42    _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY43    constexpr auto operator()(_Args&& ...__args) const44        noexcept(noexcept(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Args>(__args)...)))45        -> decltype(      _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Args>(__args)...))46        { return          _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Args>(__args)...); }47};48 49template <class _Fn, class ..._BoundArgs>50struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {51    using __base = __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>;52#if defined(_LIBCUDACXX_COMPILER_NVRTC)53    constexpr __bind_front_t() noexcept = default;54 55    template<class... _Args>56    _LIBCUDACXX_INLINE_VISIBILITY constexpr57    __bind_front_t(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))58        : __base(_CUDA_VSTD::forward<_Args>(__args)...)59    {}60#else61    using __base::__base;62#endif63};64 65template<class _Fn, class... _Args>66_LIBCUDACXX_CONCEPT __can_bind_front = is_constructible_v<decay_t<_Fn>, _Fn> &&67                                       is_move_constructible_v<decay_t<_Fn>> &&68                                       (is_constructible_v<decay_t<_Args>, _Args> && ...) &&69                                       (is_move_constructible_v<decay_t<_Args>> && ... );70 71_LIBCUDACXX_TEMPLATE(class _Fn, class... _Args)72  _LIBCUDACXX_REQUIRES( __can_bind_front<_Fn, _Args...>)73_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY74constexpr auto bind_front(_Fn&& __f, _Args&&... __args) noexcept(is_nothrow_constructible_v<tuple<decay_t<_Args>...>, _Args&&...>) {75    return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward<_Args>(__args)...);76}77 78#endif // _LIBCUDACXX_STD_VER > 1479 80_LIBCUDACXX_END_NAMESPACE_STD81 82#endif // _LIBCUDACXX___FUNCTIONAL_BIND_FRONT_H83 
codekingpro/portable-devtools · Team Ai