Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
reference_wrapper.h108 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//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX___FUNCTIONAL_REFERENCE_WRAPPER_H11#define _LIBCUDACXX___FUNCTIONAL_REFERENCE_WRAPPER_H12 13#ifndef __cuda_std__14#include <__config>15#endif // __cuda_std__16 17#include "../__functional/weak_result_type.h"18#include "../__memory/addressof.h"19 20#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)21#  pragma GCC system_header22#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)23#  pragma clang system_header24#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)25#  pragma system_header26#endif // no system header27 28_LIBCUDACXX_BEGIN_NAMESPACE_STD29 30template <class _Tp>31class _LIBCUDACXX_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp>32{33public:34    // types35    typedef _Tp type;36private:37    type* __f_;38 39    static _LIBCUDACXX_INLINE_VISIBILITY void __fun(_Tp&) noexcept;40    static void __fun(_Tp&&) = delete;41 42public:43    template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) > >44    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1745    reference_wrapper(_Up&& __u) noexcept(noexcept(__fun(declval<_Up>()))) {46        type& __f = static_cast<_Up&&>(__u);47        __f_ = _CUDA_VSTD::addressof(__f);48    }49 50    // access51    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1752    operator type&() const noexcept {return *__f_;}53    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1754    type& get() const noexcept {return *__f_;}55 56    // invoke57    template <class... _ArgTypes>58    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1759    typename __invoke_of<type&, _ArgTypes...>::type60    operator() (_ArgTypes&&... __args) const {61        return _CUDA_VSTD::__invoke(get(), _CUDA_VSTD::forward<_ArgTypes>(__args)...);62    }63};64 65#if _LIBCUDACXX_STD_VER > 14 && !defined(_LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES)66template <class _Tp>67_LIBCUDACXX_HOST_DEVICE reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;68#endif69 70template <class _Tp>71inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1772reference_wrapper<_Tp>73ref(_Tp& __t) noexcept74{75    return reference_wrapper<_Tp>(__t);76}77 78template <class _Tp>79inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1780reference_wrapper<_Tp>81ref(reference_wrapper<_Tp> __t) noexcept82{83    return __t;84}85 86template <class _Tp>87inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1788reference_wrapper<const _Tp>89cref(const _Tp& __t) noexcept90{91    return reference_wrapper<const _Tp>(__t);92}93 94template <class _Tp>95inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1796reference_wrapper<const _Tp>97cref(reference_wrapper<_Tp> __t) noexcept98{99    return __t;100}101 102template <class _Tp> void ref(const _Tp&&) = delete;103template <class _Tp> void cref(const _Tp&&) = delete;104 105_LIBCUDACXX_END_NAMESPACE_STD106 107#endif // _LIBCUDACXX___FUNCTIONAL_REFERENCE_WRAPPER_H108 
codekingpro/portable-devtools · Team Ai