File size: 4,401 Bytes
2f705f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | // -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCUDACXX_FUNCTIONAL_BASE
#define _LIBCUDACXX_FUNCTIONAL_BASE
#ifndef __cuda_std__
#include <__config>
#include <typeinfo>
#include <exception>
#include <new>
#endif // __cuda_std__
#include "__functional/binary_function.h"
#include "__functional/operations.h"
#include "__functional/reference_wrapper.h"
#include "__functional/unary_function.h"
#include "__functional/weak_result_type.h"
#include "__type_traits/integral_constant.h"
#include "__type_traits/is_constructible.h"
#include "__type_traits/is_convertible.h"
#include "__type_traits/remove_cvref.h"
#include "__utility/forward.h"
#ifndef __cuda_std__
#include <__pragma_push>
#endif // __cuda_std__
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
_LIBCUDACXX_BEGIN_NAMESPACE_STD
// allocator_arg_t
struct _LIBCUDACXX_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; };
#if defined(_LIBCUDACXX_BUILDING_LIBRARY)
extern _LIBCUDACXX_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
#else
/* _LIBCUDACXX_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
#endif
// uses_allocator
template <class _Tp>
struct __has_allocator_type
{
private:
struct __two {char __lx; char __lxx;};
template <class _Up> _LIBCUDACXX_INLINE_VISIBILITY static __two __test(...);
template <class _Up> _LIBCUDACXX_INLINE_VISIBILITY static char __test(typename _Up::allocator_type* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
struct __uses_allocator
: public integral_constant<bool,
is_convertible<_Alloc, typename _Tp::allocator_type>::value>
{
};
template <class _Tp, class _Alloc>
struct __uses_allocator<_Tp, _Alloc, false>
: public false_type
{
};
template <class _Tp, class _Alloc>
struct _LIBCUDACXX_TEMPLATE_VIS uses_allocator
: public __uses_allocator<_Tp, _Alloc>
{
};
#if _LIBCUDACXX_STD_VER > 14
template <class _Tp, class _Alloc>
_LIBCUDACXX_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
#endif
// allocator construction
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp
{
typedef _LIBCUDACXX_NODEBUG_TYPE __remove_cvref_t<_Alloc> _RawAlloc;
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
static const bool __ic =
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
static const int value = __ua ? 2 - __ic : 0;
};
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor
: integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
{};
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCUDACXX_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
{
new (__storage) _Tp (_CUDA_VSTD::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCUDACXX_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
{
new (__storage) _Tp (allocator_arg, __a, _CUDA_VSTD::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline _LIBCUDACXX_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
{
new (__storage) _Tp (_CUDA_VSTD::forward<_Args>(__args)..., __a);
}
_LIBCUDACXX_END_NAMESPACE_STD
#ifndef __cuda_std__
#include <__pragma_pop>
#endif // __cuda_std__
#endif // _LIBCUDACXX_FUNCTIONAL_BASE
|