cuda-cccl 0.3.1__cp311-cp311-manylinux_2_24_aarch64.whl → 0.3.2__cp311-cp311-manylinux_2_24_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cuda-cccl might be problematic. Click here for more details.

Files changed (185) hide show
  1. cuda/cccl/headers/include/cub/agent/agent_histogram.cuh +354 -572
  2. cuda/cccl/headers/include/cub/block/block_adjacent_difference.cuh +6 -8
  3. cuda/cccl/headers/include/cub/block/block_discontinuity.cuh +24 -14
  4. cuda/cccl/headers/include/cub/block/block_exchange.cuh +5 -0
  5. cuda/cccl/headers/include/cub/block/block_histogram.cuh +4 -0
  6. cuda/cccl/headers/include/cub/block/block_load.cuh +4 -0
  7. cuda/cccl/headers/include/cub/block/block_radix_rank.cuh +1 -0
  8. cuda/cccl/headers/include/cub/block/block_reduce.cuh +1 -0
  9. cuda/cccl/headers/include/cub/block/block_scan.cuh +12 -2
  10. cuda/cccl/headers/include/cub/block/block_store.cuh +3 -2
  11. cuda/cccl/headers/include/cub/detail/mdspan_utils.cuh +34 -30
  12. cuda/cccl/headers/include/cub/detail/ptx-json-parser.h +1 -1
  13. cuda/cccl/headers/include/cub/device/device_for.cuh +118 -40
  14. cuda/cccl/headers/include/cub/device/device_reduce.cuh +6 -7
  15. cuda/cccl/headers/include/cub/device/device_segmented_reduce.cuh +12 -13
  16. cuda/cccl/headers/include/cub/device/device_transform.cuh +122 -91
  17. cuda/cccl/headers/include/cub/device/dispatch/dispatch_merge.cuh +2 -3
  18. cuda/cccl/headers/include/cub/device/dispatch/dispatch_reduce.cuh +4 -3
  19. cuda/cccl/headers/include/cub/device/dispatch/dispatch_reduce_deterministic.cuh +1 -1
  20. cuda/cccl/headers/include/cub/device/dispatch/dispatch_streaming_reduce.cuh +4 -5
  21. cuda/cccl/headers/include/cub/device/dispatch/dispatch_streaming_reduce_by_key.cuh +0 -1
  22. cuda/cccl/headers/include/cub/device/dispatch/dispatch_topk.cuh +3 -5
  23. cuda/cccl/headers/include/cub/device/dispatch/dispatch_transform.cuh +13 -5
  24. cuda/cccl/headers/include/cub/device/dispatch/kernels/for_each.cuh +72 -37
  25. cuda/cccl/headers/include/cub/device/dispatch/kernels/transform.cuh +22 -27
  26. cuda/cccl/headers/include/cub/device/dispatch/tuning/tuning_transform.cuh +61 -70
  27. cuda/cccl/headers/include/cub/thread/thread_reduce.cuh +24 -17
  28. cuda/cccl/headers/include/cub/warp/warp_load.cuh +6 -6
  29. cuda/cccl/headers/include/cub/warp/warp_reduce.cuh +7 -2
  30. cuda/cccl/headers/include/cub/warp/warp_scan.cuh +7 -3
  31. cuda/cccl/headers/include/cub/warp/warp_store.cuh +1 -0
  32. cuda/cccl/headers/include/cuda/__barrier/barrier_block_scope.h +19 -0
  33. cuda/cccl/headers/include/cuda/__cccl_config +1 -0
  34. cuda/cccl/headers/include/cuda/__cmath/fast_modulo_division.h +3 -74
  35. cuda/cccl/headers/include/cuda/__cmath/mul_hi.h +146 -0
  36. cuda/cccl/headers/include/cuda/__complex/get_real_imag.h +0 -4
  37. cuda/cccl/headers/include/cuda/__device/arch_id.h +176 -0
  38. cuda/cccl/headers/include/cuda/__device/arch_traits.h +239 -317
  39. cuda/cccl/headers/include/cuda/__device/attributes.h +4 -3
  40. cuda/cccl/headers/include/cuda/__device/compute_capability.h +171 -0
  41. cuda/cccl/headers/include/cuda/__device/device_ref.h +0 -10
  42. cuda/cccl/headers/include/cuda/__device/physical_device.h +1 -26
  43. cuda/cccl/headers/include/cuda/__event/event.h +26 -26
  44. cuda/cccl/headers/include/cuda/__event/event_ref.h +5 -5
  45. cuda/cccl/headers/include/cuda/__event/timed_event.h +9 -7
  46. cuda/cccl/headers/include/cuda/__fwd/devices.h +4 -4
  47. cuda/cccl/headers/include/cuda/__iterator/constant_iterator.h +46 -31
  48. cuda/cccl/headers/include/cuda/__iterator/strided_iterator.h +79 -47
  49. cuda/cccl/headers/include/cuda/__iterator/tabulate_output_iterator.h +59 -36
  50. cuda/cccl/headers/include/cuda/__iterator/transform_input_output_iterator.h +79 -49
  51. cuda/cccl/headers/include/cuda/__iterator/transform_iterator.h +74 -48
  52. cuda/cccl/headers/include/cuda/__iterator/transform_output_iterator.h +80 -55
  53. cuda/cccl/headers/include/cuda/__iterator/zip_common.h +2 -12
  54. cuda/cccl/headers/include/cuda/__iterator/zip_iterator.h +15 -19
  55. cuda/cccl/headers/include/cuda/__iterator/zip_transform_iterator.h +59 -60
  56. cuda/cccl/headers/include/cuda/__mdspan/host_device_accessor.h +127 -60
  57. cuda/cccl/headers/include/cuda/__mdspan/host_device_mdspan.h +178 -3
  58. cuda/cccl/headers/include/cuda/__mdspan/restrict_accessor.h +38 -8
  59. cuda/cccl/headers/include/cuda/__mdspan/restrict_mdspan.h +67 -1
  60. cuda/cccl/headers/include/cuda/__memory/ptr_in_range.h +93 -0
  61. cuda/cccl/headers/include/cuda/__memory_resource/get_memory_resource.h +4 -4
  62. cuda/cccl/headers/include/cuda/__memory_resource/properties.h +44 -0
  63. cuda/cccl/headers/include/cuda/__memory_resource/resource.h +1 -1
  64. cuda/cccl/headers/include/cuda/__memory_resource/resource_ref.h +4 -6
  65. cuda/cccl/headers/include/cuda/__nvtx/nvtx3.h +2 -1
  66. cuda/cccl/headers/include/cuda/__runtime/ensure_current_context.h +5 -4
  67. cuda/cccl/headers/include/cuda/__stream/stream.h +8 -8
  68. cuda/cccl/headers/include/cuda/__stream/stream_ref.h +17 -16
  69. cuda/cccl/headers/include/cuda/__utility/in_range.h +65 -0
  70. cuda/cccl/headers/include/cuda/cmath +1 -0
  71. cuda/cccl/headers/include/cuda/devices +3 -0
  72. cuda/cccl/headers/include/cuda/memory +1 -0
  73. cuda/cccl/headers/include/cuda/std/__algorithm/equal_range.h +2 -2
  74. cuda/cccl/headers/include/cuda/std/__algorithm/find.h +1 -1
  75. cuda/cccl/headers/include/cuda/std/__algorithm/includes.h +2 -4
  76. cuda/cccl/headers/include/cuda/std/__algorithm/lower_bound.h +1 -1
  77. cuda/cccl/headers/include/cuda/std/__algorithm/make_projected.h +7 -15
  78. cuda/cccl/headers/include/cuda/std/__algorithm/min_element.h +1 -1
  79. cuda/cccl/headers/include/cuda/std/__algorithm/minmax_element.h +1 -2
  80. cuda/cccl/headers/include/cuda/std/__algorithm/partial_sort_copy.h +2 -2
  81. cuda/cccl/headers/include/cuda/std/__algorithm/upper_bound.h +1 -1
  82. cuda/cccl/headers/include/cuda/std/__cccl/algorithm_wrapper.h +36 -0
  83. cuda/cccl/headers/include/cuda/std/__cccl/builtin.h +46 -49
  84. cuda/cccl/headers/include/cuda/std/__cccl/execution_space.h +6 -0
  85. cuda/cccl/headers/include/cuda/std/__cccl/host_std_lib.h +52 -0
  86. cuda/cccl/headers/include/cuda/std/__cccl/memory_wrapper.h +36 -0
  87. cuda/cccl/headers/include/cuda/std/__cccl/numeric_wrapper.h +36 -0
  88. cuda/cccl/headers/include/cuda/std/__cmath/isnan.h +3 -2
  89. cuda/cccl/headers/include/cuda/std/__complex/complex.h +3 -2
  90. cuda/cccl/headers/include/cuda/std/__complex/literals.h +14 -34
  91. cuda/cccl/headers/include/cuda/std/__complex/nvbf16.h +2 -1
  92. cuda/cccl/headers/include/cuda/std/__complex/nvfp16.h +4 -3
  93. cuda/cccl/headers/include/cuda/std/__concepts/invocable.h +2 -2
  94. cuda/cccl/headers/include/cuda/std/__cstdlib/malloc.h +3 -2
  95. cuda/cccl/headers/include/cuda/std/__functional/bind.h +10 -13
  96. cuda/cccl/headers/include/cuda/std/__functional/function.h +5 -8
  97. cuda/cccl/headers/include/cuda/std/__functional/invoke.h +71 -335
  98. cuda/cccl/headers/include/cuda/std/__functional/mem_fn.h +1 -2
  99. cuda/cccl/headers/include/cuda/std/__functional/reference_wrapper.h +3 -3
  100. cuda/cccl/headers/include/cuda/std/__functional/weak_result_type.h +0 -6
  101. cuda/cccl/headers/include/cuda/std/__fwd/allocator.h +13 -0
  102. cuda/cccl/headers/include/cuda/std/__fwd/char_traits.h +13 -0
  103. cuda/cccl/headers/include/cuda/std/__fwd/complex.h +13 -4
  104. cuda/cccl/headers/include/cuda/std/__fwd/mdspan.h +23 -0
  105. cuda/cccl/headers/include/cuda/std/__fwd/pair.h +13 -0
  106. cuda/cccl/headers/include/cuda/std/__fwd/string.h +22 -0
  107. cuda/cccl/headers/include/cuda/std/__fwd/string_view.h +14 -0
  108. cuda/cccl/headers/include/cuda/std/__internal/features.h +0 -5
  109. cuda/cccl/headers/include/cuda/std/__internal/namespaces.h +21 -0
  110. cuda/cccl/headers/include/cuda/std/__iterator/iterator_traits.h +5 -5
  111. cuda/cccl/headers/include/cuda/std/__mdspan/extents.h +7 -1
  112. cuda/cccl/headers/include/cuda/std/__mdspan/mdspan.h +53 -39
  113. cuda/cccl/headers/include/cuda/std/__memory/allocator.h +3 -3
  114. cuda/cccl/headers/include/cuda/std/__memory/construct_at.h +1 -3
  115. cuda/cccl/headers/include/cuda/std/__optional/optional_base.h +1 -0
  116. cuda/cccl/headers/include/cuda/std/__ranges/compressed_movable_box.h +892 -0
  117. cuda/cccl/headers/include/cuda/std/__ranges/movable_box.h +2 -2
  118. cuda/cccl/headers/include/cuda/std/__type_traits/is_primary_template.h +7 -5
  119. cuda/cccl/headers/include/cuda/std/__type_traits/result_of.h +1 -1
  120. cuda/cccl/headers/include/cuda/std/__utility/pair.h +0 -5
  121. cuda/cccl/headers/include/cuda/std/bitset +1 -1
  122. cuda/cccl/headers/include/cuda/std/detail/libcxx/include/__config +15 -12
  123. cuda/cccl/headers/include/cuda/std/detail/libcxx/include/variant +11 -9
  124. cuda/cccl/headers/include/cuda/std/inplace_vector +4 -4
  125. cuda/cccl/headers/include/cuda/std/numbers +5 -0
  126. cuda/cccl/headers/include/cuda/std/string_view +146 -11
  127. cuda/cccl/headers/include/cuda/stream_ref +5 -0
  128. cuda/cccl/headers/include/cuda/utility +1 -0
  129. cuda/cccl/headers/include/nv/target +7 -2
  130. cuda/cccl/headers/include/thrust/allocate_unique.h +1 -1
  131. cuda/cccl/headers/include/thrust/detail/allocator/allocator_traits.h +309 -33
  132. cuda/cccl/headers/include/thrust/detail/allocator/copy_construct_range.h +151 -4
  133. cuda/cccl/headers/include/thrust/detail/allocator/destroy_range.h +60 -3
  134. cuda/cccl/headers/include/thrust/detail/allocator/fill_construct_range.h +45 -3
  135. cuda/cccl/headers/include/thrust/detail/allocator/malloc_allocator.h +31 -6
  136. cuda/cccl/headers/include/thrust/detail/allocator/tagged_allocator.h +29 -16
  137. cuda/cccl/headers/include/thrust/detail/allocator/temporary_allocator.h +41 -4
  138. cuda/cccl/headers/include/thrust/detail/allocator/value_initialize_range.h +42 -4
  139. cuda/cccl/headers/include/thrust/detail/complex/ccosh.h +3 -3
  140. cuda/cccl/headers/include/thrust/detail/internal_functional.h +1 -1
  141. cuda/cccl/headers/include/thrust/detail/memory_algorithms.h +1 -1
  142. cuda/cccl/headers/include/thrust/detail/temporary_array.h +1 -1
  143. cuda/cccl/headers/include/thrust/detail/type_traits.h +1 -1
  144. cuda/cccl/headers/include/thrust/device_delete.h +18 -3
  145. cuda/cccl/headers/include/thrust/device_free.h +16 -3
  146. cuda/cccl/headers/include/thrust/device_new.h +29 -8
  147. cuda/cccl/headers/include/thrust/host_vector.h +1 -1
  148. cuda/cccl/headers/include/thrust/iterator/tabulate_output_iterator.h +5 -2
  149. cuda/cccl/headers/include/thrust/mr/disjoint_pool.h +1 -1
  150. cuda/cccl/headers/include/thrust/mr/pool.h +1 -1
  151. cuda/cccl/headers/include/thrust/system/cuda/detail/find.h +13 -115
  152. cuda/cccl/headers/include/thrust/system/cuda/detail/mismatch.h +8 -2
  153. cuda/cccl/headers/include/thrust/type_traits/is_contiguous_iterator.h +7 -7
  154. cuda/compute/__init__.py +2 -0
  155. cuda/compute/_bindings.pyi +43 -1
  156. cuda/compute/_bindings_impl.pyx +156 -7
  157. cuda/compute/algorithms/_scan.py +108 -36
  158. cuda/compute/algorithms/_transform.py +32 -11
  159. cuda/compute/cu12/_bindings_impl.cpython-311-aarch64-linux-gnu.so +0 -0
  160. cuda/compute/cu12/cccl/libcccl.c.parallel.so +0 -0
  161. cuda/compute/cu13/_bindings_impl.cpython-311-aarch64-linux-gnu.so +0 -0
  162. cuda/compute/cu13/cccl/libcccl.c.parallel.so +0 -0
  163. cuda/compute/iterators/__init__.py +2 -0
  164. cuda/compute/iterators/_factories.py +28 -0
  165. cuda/compute/iterators/_iterators.py +206 -1
  166. cuda/compute/numba_utils.py +2 -2
  167. cuda/compute/typing.py +2 -0
  168. {cuda_cccl-0.3.1.dist-info → cuda_cccl-0.3.2.dist-info}/METADATA +1 -1
  169. {cuda_cccl-0.3.1.dist-info → cuda_cccl-0.3.2.dist-info}/RECORD +171 -175
  170. cuda/cccl/headers/include/thrust/detail/algorithm_wrapper.h +0 -37
  171. cuda/cccl/headers/include/thrust/detail/allocator/allocator_traits.inl +0 -371
  172. cuda/cccl/headers/include/thrust/detail/allocator/copy_construct_range.inl +0 -242
  173. cuda/cccl/headers/include/thrust/detail/allocator/destroy_range.inl +0 -137
  174. cuda/cccl/headers/include/thrust/detail/allocator/fill_construct_range.inl +0 -99
  175. cuda/cccl/headers/include/thrust/detail/allocator/malloc_allocator.inl +0 -68
  176. cuda/cccl/headers/include/thrust/detail/allocator/tagged_allocator.inl +0 -86
  177. cuda/cccl/headers/include/thrust/detail/allocator/temporary_allocator.inl +0 -79
  178. cuda/cccl/headers/include/thrust/detail/allocator/value_initialize_range.inl +0 -98
  179. cuda/cccl/headers/include/thrust/detail/device_delete.inl +0 -52
  180. cuda/cccl/headers/include/thrust/detail/device_free.inl +0 -47
  181. cuda/cccl/headers/include/thrust/detail/device_new.inl +0 -61
  182. cuda/cccl/headers/include/thrust/detail/memory_wrapper.h +0 -40
  183. cuda/cccl/headers/include/thrust/detail/numeric_wrapper.h +0 -37
  184. {cuda_cccl-0.3.1.dist-info → cuda_cccl-0.3.2.dist-info}/WHEEL +0 -0
  185. {cuda_cccl-0.3.1.dist-info → cuda_cccl-0.3.2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,892 @@
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // Part of libcu++, the C++ Standard Library for your entire system,
4
+ // 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-exception
7
+ // SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
8
+ //
9
+ //===----------------------------------------------------------------------===//
10
+
11
+ #ifndef _CUDA_STD___RANGES_COMPRESSED_MOVABLE_BOX_H
12
+ #define _CUDA_STD___RANGES_COMPRESSED_MOVABLE_BOX_H
13
+
14
+ #include <cuda/std/detail/__config>
15
+
16
+ #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
17
+ # pragma GCC system_header
18
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
19
+ # pragma clang system_header
20
+ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
21
+ # pragma system_header
22
+ #endif // no system header
23
+
24
+ #include <cuda/std/__concepts/concept_macros.h>
25
+ #include <cuda/std/__concepts/constructible.h>
26
+ #include <cuda/std/__concepts/copyable.h>
27
+ #include <cuda/std/__concepts/movable.h>
28
+ #include <cuda/std/__memory/addressof.h>
29
+ #include <cuda/std/__memory/construct_at.h>
30
+ #include <cuda/std/__tuple_dir/sfinae_helpers.h>
31
+ #include <cuda/std/__type_traits/is_copy_assignable.h>
32
+ #include <cuda/std/__type_traits/is_copy_constructible.h>
33
+ #include <cuda/std/__type_traits/is_default_constructible.h>
34
+ #include <cuda/std/__type_traits/is_empty.h>
35
+ #include <cuda/std/__type_traits/is_final.h>
36
+ #include <cuda/std/__type_traits/is_move_constructible.h>
37
+ #include <cuda/std/__type_traits/is_nothrow_constructible.h>
38
+ #include <cuda/std/__type_traits/is_nothrow_copy_assignable.h>
39
+ #include <cuda/std/__type_traits/is_nothrow_copy_constructible.h>
40
+ #include <cuda/std/__type_traits/is_nothrow_default_constructible.h>
41
+ #include <cuda/std/__type_traits/is_nothrow_move_assignable.h>
42
+ #include <cuda/std/__type_traits/is_nothrow_move_constructible.h>
43
+ #include <cuda/std/__type_traits/is_trivially_copy_assignable.h>
44
+ #include <cuda/std/__type_traits/is_trivially_copy_constructible.h>
45
+ #include <cuda/std/__type_traits/is_trivially_destructible.h>
46
+ #include <cuda/std/__type_traits/is_trivially_move_assignable.h>
47
+ #include <cuda/std/__type_traits/is_trivially_move_constructible.h>
48
+ #include <cuda/std/__type_traits/remove_cv.h>
49
+ #include <cuda/std/__utility/forward.h>
50
+ #include <cuda/std/__utility/in_place.h>
51
+ #include <cuda/std/__utility/move.h>
52
+
53
+ #include <cuda/std/__cccl/prologue.h>
54
+
55
+ _CCCL_BEGIN_NAMESPACE_CUDA_STD
56
+
57
+ //! @brief Different alternatives for @c __compressed_box_base
58
+ // This is effectively a __movable-box__ that does not rely on `[[no_unique_address]]`
59
+ enum class __compressed_box_specialization
60
+ {
61
+ __with_engaged, //!< We must store an empty state to represent failure of assignment
62
+ __store_inline, //!< We can directly store the type inline because it behaves nice
63
+ __empty_non_final, //!< We can directly store the type inline and employ EBCO because it is empty and non-final
64
+ };
65
+
66
+ //! @brief Determines which specialization of @c __compressed_box_base we can select
67
+ template <class _Tp>
68
+ [[nodiscard]] _CCCL_API _CCCL_CONSTEVAL __compressed_box_specialization __compressed_box_choose()
69
+ {
70
+ constexpr bool __can_ebco = is_empty_v<_Tp> && !is_final_v<_Tp>;
71
+ // See __movable_box for a more in depth explanation
72
+ if constexpr (copy_constructible<_Tp>)
73
+ {
74
+ // 1. If copy_constructible<T> is true, we should only store a T if either T models
75
+ // copyable, or is_nothrow_move_constructible_v<T> && is_nothrow_copy_constructible_v<T> is true.
76
+ constexpr bool __can_store_inline =
77
+ copyable<_Tp> || (is_nothrow_move_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Tp>);
78
+ return __can_store_inline
79
+ ? __can_ebco ? __compressed_box_specialization::__empty_non_final
80
+ : __compressed_box_specialization::__store_inline
81
+ : __compressed_box_specialization::__with_engaged;
82
+ }
83
+ else
84
+ {
85
+ // 2. Otherwise, movable-box<T> should store only a T if either T models movable or
86
+ // is_nothrow_move_constructible_v<T> is true.
87
+ constexpr bool __can_store_inline = movable<_Tp> || is_nothrow_move_constructible_v<_Tp>;
88
+ return __can_store_inline
89
+ ? __can_ebco ? __compressed_box_specialization::__empty_non_final
90
+ : __compressed_box_specialization::__store_inline
91
+ : __compressed_box_specialization::__with_engaged;
92
+ }
93
+ }
94
+
95
+ //! @brief Base class for @c __compressed_movable_box to store a T and ensure it is always copyable
96
+ template <size_t _Index, class _Tp, __compressed_box_specialization = __compressed_box_choose<_Tp>()>
97
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_base;
98
+
99
+ //! @brief Simple wrapper around a non-empty T to access it within a @c __compressed_movable_box
100
+ template <size_t _Index, class _Tp>
101
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_base<_Index, _Tp, __compressed_box_specialization::__store_inline>
102
+ {
103
+ _Tp __elem_;
104
+
105
+ _CCCL_EXEC_CHECK_DISABLE
106
+ _CCCL_TEMPLATE(class _Tp2 = _Tp)
107
+ _CCCL_REQUIRES(is_default_constructible_v<_Tp2>)
108
+ _CCCL_API constexpr __compressed_box_base() noexcept(is_nothrow_default_constructible_v<_Tp2>)
109
+ : __elem_()
110
+ {}
111
+
112
+ _CCCL_EXEC_CHECK_DISABLE
113
+ _CCCL_TEMPLATE(class... _Args)
114
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
115
+ _CCCL_API constexpr __compressed_box_base(in_place_t,
116
+ _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
117
+ : __elem_(::cuda::std::forward<_Args>(__args)...)
118
+ {}
119
+
120
+ [[nodiscard]] _CCCL_API constexpr _Tp& __get() noexcept
121
+ {
122
+ return __elem_;
123
+ }
124
+ [[nodiscard]] _CCCL_API constexpr const _Tp& __get() const noexcept
125
+ {
126
+ return __elem_;
127
+ }
128
+
129
+ [[nodiscard]] _CCCL_API static constexpr bool __engaged() noexcept
130
+ {
131
+ return true;
132
+ }
133
+
134
+ _CCCL_API static constexpr void __set_engaged(const bool) noexcept {}
135
+
136
+ template <class... _Args>
137
+ _CCCL_API constexpr void __construct(_Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
138
+ {
139
+ ::cuda::std::__construct_at(cuda::std::addressof(__elem_), ::cuda::std::forward<_Args>(__args)...);
140
+ }
141
+ };
142
+
143
+ //! @brief Simple wrapper around an empty T to access it within a @c __compressed_movable_box using EBCO
144
+ template <size_t _Index, class _Tp>
145
+ struct _CCCL_DECLSPEC_EMPTY_BASES
146
+ __compressed_box_base<_Index, _Tp, __compressed_box_specialization::__empty_non_final> : _Tp
147
+ {
148
+ _CCCL_EXEC_CHECK_DISABLE
149
+ _CCCL_TEMPLATE(class _Tp2 = _Tp)
150
+ _CCCL_REQUIRES(is_default_constructible_v<_Tp2>)
151
+ _CCCL_API constexpr __compressed_box_base() noexcept(is_nothrow_default_constructible_v<_Tp2>)
152
+ : _Tp()
153
+ {}
154
+
155
+ _CCCL_EXEC_CHECK_DISABLE
156
+ _CCCL_TEMPLATE(class... _Args)
157
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
158
+ _CCCL_API constexpr __compressed_box_base(in_place_t,
159
+ _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
160
+ : _Tp(::cuda::std::forward<_Args>(__args)...)
161
+ {}
162
+
163
+ [[nodiscard]] _CCCL_API constexpr _Tp& __get() noexcept
164
+ {
165
+ return *static_cast<_Tp*>(this);
166
+ }
167
+ [[nodiscard]] _CCCL_API constexpr const _Tp& __get() const noexcept
168
+ {
169
+ return *static_cast<const _Tp*>(this);
170
+ }
171
+
172
+ [[nodiscard]] _CCCL_API static constexpr bool __engaged() noexcept
173
+ {
174
+ return true;
175
+ }
176
+
177
+ _CCCL_API static constexpr void __set_engaged(const bool) noexcept {}
178
+
179
+ template <class... _Args>
180
+ _CCCL_API constexpr void __construct(_Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
181
+ {
182
+ ::cuda::std::__construct_at(static_cast<_Tp*>(this), ::cuda::std::forward<_Args>(__args)...);
183
+ }
184
+ };
185
+
186
+ template <size_t _Index, class _Tp, bool = is_trivially_destructible_v<_Tp>>
187
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_storage
188
+ {
189
+ union __storage
190
+ {
191
+ char __null_state_;
192
+ remove_cv_t<_Tp> __val_;
193
+
194
+ _CCCL_API constexpr __storage() noexcept
195
+ : __null_state_()
196
+ {}
197
+ _CCCL_EXEC_CHECK_DISABLE
198
+ _CCCL_TEMPLATE(class... _Args)
199
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
200
+ _CCCL_API constexpr __storage(in_place_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
201
+ : __val_(::cuda::std::forward<_Args>(__args)...)
202
+ {}
203
+ _CCCL_API _CCCL_CONSTEXPR_CXX20 ~__storage() noexcept {}
204
+ };
205
+ __storage __storage_{};
206
+ bool __engaged_{};
207
+
208
+ _CCCL_API constexpr __compressed_box_storage(bool __engaged) noexcept
209
+ : __storage_()
210
+ , __engaged_(__engaged)
211
+ {}
212
+
213
+ _CCCL_EXEC_CHECK_DISABLE
214
+ _CCCL_TEMPLATE(class _Tp2 = _Tp)
215
+ _CCCL_REQUIRES(is_default_constructible_v<_Tp2>)
216
+ _CCCL_API constexpr __compressed_box_storage() noexcept(is_nothrow_default_constructible_v<_Tp2>)
217
+ : __storage_(in_place)
218
+ , __engaged_(true)
219
+ {}
220
+
221
+ _CCCL_EXEC_CHECK_DISABLE
222
+ _CCCL_TEMPLATE(class... _Args)
223
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
224
+ _CCCL_API constexpr explicit __compressed_box_storage(in_place_t, _Args&&... __args) noexcept(
225
+ is_nothrow_constructible_v<_Tp, _Args...>)
226
+ : __storage_(in_place, ::cuda::std::forward<_Args>(__args)...)
227
+ , __engaged_(true)
228
+ {}
229
+
230
+ _CCCL_EXEC_CHECK_DISABLE
231
+ _CCCL_API inline _CCCL_CONSTEXPR_CXX20 ~__compressed_box_storage()
232
+ {
233
+ if (__engaged_)
234
+ {
235
+ __storage_.__val_.~_Tp();
236
+ }
237
+ }
238
+ };
239
+
240
+ template <size_t _Index, class _Tp>
241
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_storage<_Index, _Tp, true>
242
+ {
243
+ union __storage
244
+ {
245
+ char __null_state_;
246
+ remove_cv_t<_Tp> __val_;
247
+
248
+ _CCCL_API constexpr __storage() noexcept
249
+ : __null_state_()
250
+ {}
251
+ _CCCL_EXEC_CHECK_DISABLE
252
+ _CCCL_TEMPLATE(class... _Args)
253
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
254
+ _CCCL_API constexpr __storage(in_place_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
255
+ : __val_(::cuda::std::forward<_Args>(__args)...)
256
+ {}
257
+ };
258
+ __storage __storage_{};
259
+ bool __engaged_{};
260
+
261
+ _CCCL_API constexpr __compressed_box_storage(bool __engaged) noexcept
262
+ : __storage_()
263
+ , __engaged_(__engaged)
264
+ {}
265
+
266
+ _CCCL_EXEC_CHECK_DISABLE
267
+ _CCCL_TEMPLATE(class _Tp2 = _Tp)
268
+ _CCCL_REQUIRES(is_default_constructible_v<_Tp2>)
269
+ _CCCL_API constexpr __compressed_box_storage() noexcept(is_nothrow_default_constructible_v<_Tp2>)
270
+ : __storage_(in_place)
271
+ , __engaged_(true)
272
+ {}
273
+
274
+ _CCCL_EXEC_CHECK_DISABLE
275
+ _CCCL_TEMPLATE(class... _Args)
276
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
277
+ _CCCL_API constexpr explicit __compressed_box_storage(in_place_t, _Args&&... __args) noexcept(
278
+ is_nothrow_constructible_v<_Tp, _Args...>)
279
+ : __storage_(in_place, ::cuda::std::forward<_Args>(__args)...)
280
+ , __engaged_(true)
281
+ {}
282
+ };
283
+
284
+ //! @brief Wrapper around T that might not be assignable to access within a @c __compressed_movable_box
285
+ template <size_t _Index, class _Tp>
286
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_base<_Index, _Tp, __compressed_box_specialization::__with_engaged>
287
+ : __compressed_box_storage<_Index, _Tp>
288
+ {
289
+ using __base = __compressed_box_storage<_Index, _Tp>;
290
+
291
+ _CCCL_API constexpr __compressed_box_base(bool __engaged) noexcept
292
+ : __base(__engaged)
293
+ {}
294
+
295
+ _CCCL_EXEC_CHECK_DISABLE
296
+ _CCCL_TEMPLATE(class _Tp2 = _Tp)
297
+ _CCCL_REQUIRES(is_default_constructible_v<_Tp2>)
298
+ _CCCL_API constexpr __compressed_box_base() noexcept(is_nothrow_default_constructible_v<_Tp2>)
299
+ : __base(in_place)
300
+ {}
301
+
302
+ _CCCL_EXEC_CHECK_DISABLE
303
+ _CCCL_TEMPLATE(class... _Args)
304
+ _CCCL_REQUIRES(is_constructible_v<_Tp, _Args...>)
305
+ _CCCL_API constexpr __compressed_box_base(in_place_t,
306
+ _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
307
+ : __base(in_place, ::cuda::std::forward<_Args>(__args)...)
308
+ {}
309
+
310
+ [[nodiscard]] _CCCL_API constexpr _Tp& __get() noexcept
311
+ {
312
+ return this->__storage_.__val_;
313
+ }
314
+ [[nodiscard]] _CCCL_API constexpr const _Tp& __get() const noexcept
315
+ {
316
+ return this->__storage_.__val_;
317
+ }
318
+
319
+ [[nodiscard]] _CCCL_API constexpr bool __engaged() const noexcept
320
+ {
321
+ return this->__engaged_;
322
+ }
323
+
324
+ _CCCL_API constexpr void __set_engaged(const bool __engaged) noexcept
325
+ {
326
+ this->__engaged_ = __engaged;
327
+ }
328
+
329
+ template <class... _Args>
330
+ _CCCL_API constexpr void __construct(_Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
331
+ {
332
+ ::cuda::std::__construct_at(::cuda::std::addressof(this->__storage_.__val_), ::cuda::std::forward<_Args>(__args)...);
333
+ }
334
+ };
335
+
336
+ //! @brief We only need to do something for types that require the engaged state
337
+ template <class _Tp>
338
+ inline constexpr __smf_availability __compressed_box_copy_construct_available =
339
+ (is_copy_constructible_v<_Tp> && __compressed_box_choose<_Tp>() != __compressed_box_specialization::__with_engaged)
340
+ ? __smf_availability::__trivial
341
+ : is_copy_constructible_v<_Tp>
342
+ ? __smf_availability::__available
343
+ : __smf_availability::__deleted;
344
+
345
+ //! @brief Nothing to do for copy constructible types
346
+ template <size_t _Index, class _Tp, __smf_availability = __compressed_box_copy_construct_available<_Tp>>
347
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_copy_base : __compressed_box_base<_Index, _Tp>
348
+ {
349
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_copy_base, __compressed_box_base, _Index, _Tp);
350
+ };
351
+
352
+ //! @brief We must ensure we only copy when engaged
353
+ template <size_t _Index, class _Tp>
354
+ struct _CCCL_DECLSPEC_EMPTY_BASES
355
+ __compressed_box_copy_base<_Index, _Tp, __smf_availability::__available> : __compressed_box_base<_Index, _Tp>
356
+ {
357
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_copy_base, __compressed_box_base, _Index, _Tp);
358
+
359
+ _CCCL_API _CCCL_CONSTEXPR_CXX20
360
+ __compressed_box_copy_base(const __compressed_box_copy_base& __other) noexcept(is_nothrow_copy_constructible_v<_Tp>)
361
+ : __base(__other.__engaged())
362
+ {
363
+ if (__other.__engaged())
364
+ {
365
+ this->__construct(__other.__get());
366
+ }
367
+ }
368
+
369
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base(__compressed_box_copy_base&&) = default;
370
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base& operator=(const __compressed_box_copy_base&) = default;
371
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base& operator=(__compressed_box_copy_base&&) = default;
372
+ };
373
+
374
+ //! @brief Copy construction is deleted
375
+ template <size_t _Index, class _Tp>
376
+ struct _CCCL_DECLSPEC_EMPTY_BASES
377
+ __compressed_box_copy_base<_Index, _Tp, __smf_availability::__deleted> : __compressed_box_base<_Index, _Tp>
378
+ {
379
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_copy_base, __compressed_box_base, _Index, _Tp);
380
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base(const __compressed_box_copy_base&) = delete;
381
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base(__compressed_box_copy_base&&) = default;
382
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base& operator=(const __compressed_box_copy_base&) = default;
383
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_base& operator=(__compressed_box_copy_base&&) = default;
384
+ };
385
+
386
+ //! @brief We only need to do something for types that require the engaged state
387
+ template <class _Tp>
388
+ inline constexpr __smf_availability __compressed_box_move_construct_available =
389
+ (is_move_constructible_v<_Tp> && __compressed_box_choose<_Tp>() != __compressed_box_specialization::__with_engaged)
390
+ ? __smf_availability::__trivial
391
+ : is_move_constructible_v<_Tp>
392
+ ? __smf_availability::__available
393
+ : __smf_availability::__deleted;
394
+
395
+ //! @brief Nothing to do for move constructible types
396
+ template <size_t _Index, class _Tp, __smf_availability = __compressed_box_move_construct_available<_Tp>>
397
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_move_base : __compressed_box_copy_base<_Index, _Tp>
398
+ {
399
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_move_base, __compressed_box_copy_base, _Index, _Tp);
400
+ };
401
+
402
+ //! @brief We must ensure we only move when engaged
403
+ template <size_t _Index, class _Tp>
404
+ struct _CCCL_DECLSPEC_EMPTY_BASES
405
+ __compressed_box_move_base<_Index, _Tp, __smf_availability::__available> : __compressed_box_copy_base<_Index, _Tp>
406
+ {
407
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_move_base, __compressed_box_copy_base, _Index, _Tp);
408
+
409
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base(const __compressed_box_move_base&) = default;
410
+ _CCCL_API _CCCL_CONSTEXPR_CXX20
411
+ __compressed_box_move_base(__compressed_box_move_base&& __other) noexcept(is_nothrow_move_constructible_v<_Tp>)
412
+ : __base(__other.__engaged())
413
+ {
414
+ if (__other.__engaged())
415
+ {
416
+ this->__construct(::cuda::std::move(__other.__get()));
417
+ }
418
+ }
419
+
420
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base& operator=(const __compressed_box_move_base&) = default;
421
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base& operator=(__compressed_box_move_base&&) = default;
422
+ };
423
+
424
+ //! @brief Move construction is deleted
425
+ template <size_t _Index, class _Tp>
426
+ struct _CCCL_DECLSPEC_EMPTY_BASES
427
+ __compressed_box_move_base<_Index, _Tp, __smf_availability::__deleted> : __compressed_box_copy_base<_Index, _Tp>
428
+ {
429
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_move_base, __compressed_box_copy_base, _Index, _Tp);
430
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base(const __compressed_box_move_base&) = default;
431
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base(__compressed_box_move_base&&) = delete;
432
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base& operator=(const __compressed_box_move_base&) = default;
433
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_base& operator=(__compressed_box_move_base&&) = default;
434
+ };
435
+
436
+ template <class _Tp>
437
+ inline constexpr __smf_availability __compressed_box_copy_assign_available =
438
+ copyable<_Tp> && is_trivially_copy_assignable_v<_Tp> ? __smf_availability::__trivial
439
+ : copyable<_Tp> || copy_constructible<_Tp>
440
+ ? __smf_availability::__available
441
+ : __smf_availability::__deleted;
442
+
443
+ //! @brief Nothing to do for trivially copy assignable types
444
+ template <size_t _Index, class _Tp, __smf_availability = __compressed_box_copy_assign_available<_Tp>>
445
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_copy_assign_base : __compressed_box_move_base<_Index, _Tp>
446
+ {
447
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_copy_assign_base, __compressed_box_move_base, _Index, _Tp);
448
+ };
449
+
450
+ //! @brief If we can either assign or copy construct we do so
451
+ template <size_t _Index, class _Tp>
452
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_copy_assign_base<_Index, _Tp, __smf_availability::__available>
453
+ : __compressed_box_move_base<_Index, _Tp>
454
+ {
455
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_copy_assign_base, __compressed_box_move_base, _Index, _Tp);
456
+
457
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base(const __compressed_box_copy_assign_base&) = default;
458
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base(__compressed_box_copy_assign_base&&) = default;
459
+
460
+ static constexpr bool __nothrow_copy_assignable =
461
+ copyable<_Tp> ? is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_assignable_v<_Tp>
462
+ : is_nothrow_copy_constructible_v<_Tp>;
463
+
464
+ _CCCL_API _CCCL_CONSTEXPR_CXX20 __compressed_box_copy_assign_base&
465
+ operator=(const __compressed_box_copy_assign_base& __other) noexcept(__nothrow_copy_assignable)
466
+ {
467
+ if (::cuda::std::addressof(__other) == this)
468
+ {
469
+ return *this;
470
+ }
471
+
472
+ // We can assign if there is something, or destroy
473
+ if constexpr (copyable<_Tp>)
474
+ {
475
+ if (this->__engaged())
476
+ {
477
+ if (__other.__engaged())
478
+ {
479
+ this->__get() = __other.__get();
480
+ }
481
+ else
482
+ {
483
+ this->__get().~_Tp();
484
+ this->__set_engaged(false);
485
+ }
486
+ }
487
+ else
488
+ {
489
+ if (__other.__engaged())
490
+ {
491
+ this->__construct(__other.__get());
492
+ this->__set_engaged(true);
493
+ }
494
+ else
495
+ {
496
+ // nothing to do
497
+ }
498
+ }
499
+ }
500
+ else
501
+ { // we must always destroy first
502
+ if (this->__engaged())
503
+ {
504
+ this->__get().~_Tp();
505
+ this->__set_engaged(false);
506
+ }
507
+
508
+ if (__other.__engaged())
509
+ {
510
+ this->__construct(__other.__get());
511
+ this->__set_engaged(true);
512
+ }
513
+ }
514
+ return *this;
515
+ }
516
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base& operator=(__compressed_box_copy_assign_base&&) = default;
517
+ };
518
+
519
+ //! @brief No copy assignment
520
+ template <size_t _Index, class _Tp>
521
+ struct _CCCL_DECLSPEC_EMPTY_BASES
522
+ __compressed_box_copy_assign_base<_Index, _Tp, __smf_availability::__deleted> : __compressed_box_move_base<_Index, _Tp>
523
+ {
524
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_copy_assign_base, __compressed_box_move_base, _Index, _Tp);
525
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base(const __compressed_box_copy_assign_base&) = default;
526
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base(__compressed_box_copy_assign_base&&) = default;
527
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base& operator=(const __compressed_box_copy_assign_base&) = delete;
528
+ _CCCL_HIDE_FROM_ABI __compressed_box_copy_assign_base& operator=(__compressed_box_copy_assign_base&&) = default;
529
+ };
530
+
531
+ template <class _Tp>
532
+ inline constexpr __smf_availability __compressed_box_move_assign_available =
533
+ movable<_Tp> && is_trivially_move_assignable_v<_Tp> ? __smf_availability::__trivial
534
+ : movable<_Tp> || is_move_constructible_v<_Tp>
535
+ ? __smf_availability::__available
536
+ : __smf_availability::__deleted;
537
+
538
+ //! @brief Nothing to do for trivially copy assignable types
539
+ template <size_t _Index, class _Tp, __smf_availability = __compressed_box_move_assign_available<_Tp>>
540
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_move_assign_base : __compressed_box_copy_assign_base<_Index, _Tp>
541
+ {
542
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_move_assign_base, __compressed_box_copy_assign_base, _Index, _Tp);
543
+ };
544
+
545
+ //! @brief If we can either assign or copy construct we do so
546
+ template <size_t _Index, class _Tp>
547
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_move_assign_base<_Index, _Tp, __smf_availability::__available>
548
+ : __compressed_box_copy_assign_base<_Index, _Tp>
549
+ {
550
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_move_assign_base, __compressed_box_copy_assign_base, _Index, _Tp);
551
+
552
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base(const __compressed_box_move_assign_base&) = default;
553
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base(__compressed_box_move_assign_base&&) = default;
554
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base& operator=(const __compressed_box_move_assign_base&) = default;
555
+
556
+ static constexpr bool __nothrow_move_assignable =
557
+ movable<_Tp> ? is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>
558
+ : is_nothrow_move_constructible_v<_Tp>;
559
+
560
+ _CCCL_API _CCCL_CONSTEXPR_CXX20 __compressed_box_move_assign_base&
561
+ operator=(__compressed_box_move_assign_base&& __other) noexcept(__nothrow_move_assignable)
562
+ {
563
+ if (::cuda::std::addressof(__other) == this)
564
+ {
565
+ return *this;
566
+ }
567
+
568
+ // We can assign if there is something, or destroyx
569
+ if constexpr (movable<_Tp>)
570
+ {
571
+ if (this->__engaged())
572
+ {
573
+ if (__other.__engaged())
574
+ {
575
+ this->__get() = ::cuda::std::move(__other.__get());
576
+ }
577
+ else
578
+ {
579
+ this->__get().~_Tp();
580
+ this->__set_engaged(false);
581
+ }
582
+ }
583
+ else
584
+ {
585
+ if (__other.__engaged())
586
+ {
587
+ this->__construct(::cuda::std::move(__other.__get()));
588
+ this->__set_engaged(true);
589
+ }
590
+ else
591
+ {
592
+ // nothing to do
593
+ }
594
+ }
595
+ }
596
+ else
597
+ { // we must always destroy first
598
+ if (this->__engaged())
599
+ {
600
+ this->__get().~_Tp();
601
+ this->__set_engaged(false);
602
+ }
603
+
604
+ if (__other.__engaged())
605
+ {
606
+ this->__construct(::cuda::std::move(__other.__get()));
607
+ this->__set_engaged(true);
608
+ }
609
+ }
610
+ return *this;
611
+ }
612
+ };
613
+
614
+ //! @brief No copy assignment
615
+ template <size_t _Index, class _Tp>
616
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box_move_assign_base<_Index, _Tp, __smf_availability::__deleted>
617
+ : __compressed_box_copy_assign_base<_Index, _Tp>
618
+ {
619
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box_move_assign_base, __compressed_box_copy_assign_base, _Index, _Tp);
620
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base(const __compressed_box_move_assign_base&) = default;
621
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base(__compressed_box_move_assign_base&&) = default;
622
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base& operator=(const __compressed_box_move_assign_base&) = default;
623
+ _CCCL_HIDE_FROM_ABI __compressed_box_move_assign_base& operator=(__compressed_box_move_assign_base&&) = delete;
624
+ };
625
+
626
+ template <size_t _Index, class _Tp>
627
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_box : __compressed_box_move_assign_base<_Index, _Tp>
628
+ {
629
+ _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__compressed_box, __compressed_box_move_assign_base, _Index, _Tp);
630
+ };
631
+
632
+ template <class...>
633
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_movable_box;
634
+
635
+ template <class _Elem1>
636
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_movable_box<_Elem1> : __compressed_box<0, _Elem1>
637
+ {
638
+ using __base1 = __compressed_box<0, _Elem1>;
639
+
640
+ _CCCL_EXEC_CHECK_DISABLE
641
+ _CCCL_TEMPLATE(class _Elem1_ = _Elem1)
642
+ _CCCL_REQUIRES(is_default_constructible_v<_Elem1_>)
643
+ _CCCL_API constexpr __compressed_movable_box() noexcept(is_nothrow_default_constructible_v<_Elem1_>)
644
+ : __base1()
645
+ {}
646
+
647
+ _CCCL_EXEC_CHECK_DISABLE
648
+ _CCCL_TEMPLATE(class... _Args)
649
+ _CCCL_REQUIRES((sizeof...(_Args) != 0) _CCCL_AND is_constructible_v<_Elem1, _Args...>)
650
+ _CCCL_API constexpr __compressed_movable_box(_Args&&... __args) noexcept(is_nothrow_constructible_v<_Elem1, _Args...>)
651
+ : __base1(in_place, ::cuda::std::forward<_Args>(__args)...)
652
+ {}
653
+
654
+ _CCCL_TEMPLATE(size_t _Index)
655
+ _CCCL_REQUIRES((_Index < 1))
656
+ [[nodiscard]] _CCCL_API constexpr _Elem1& __get() noexcept
657
+ {
658
+ return static_cast<__base1*>(this)->__get();
659
+ }
660
+
661
+ _CCCL_TEMPLATE(size_t _Index)
662
+ _CCCL_REQUIRES((_Index < 1))
663
+ [[nodiscard]] _CCCL_API constexpr const _Elem1& __get() const noexcept
664
+ {
665
+ return static_cast<const __base1*>(this)->__get();
666
+ }
667
+
668
+ _CCCL_EXEC_CHECK_DISABLE
669
+ _CCCL_API friend constexpr void swap(__compressed_movable_box& __x, __compressed_movable_box& __y)
670
+ {
671
+ swap(__x.__get<0>(), __y.__get<0>());
672
+ }
673
+ };
674
+
675
+ template <class _Elem1, class _Elem2>
676
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_movable_box<_Elem1, _Elem2>
677
+ : __compressed_box<0, _Elem1>
678
+ , __compressed_box<1, _Elem2>
679
+ {
680
+ using __base1 = __compressed_box<0, _Elem1>;
681
+ using __base2 = __compressed_box<1, _Elem2>;
682
+
683
+ _CCCL_EXEC_CHECK_DISABLE
684
+ _CCCL_TEMPLATE(class _Elem1_ = _Elem1, class _Elem2_ = _Elem2)
685
+ _CCCL_REQUIRES(is_default_constructible_v<_Elem1_> _CCCL_AND is_default_constructible_v<_Elem2_>)
686
+ _CCCL_API constexpr __compressed_movable_box() noexcept(
687
+ is_nothrow_default_constructible_v<_Elem1_> && is_nothrow_default_constructible_v<_Elem2_>)
688
+ : __base1()
689
+ , __base2()
690
+ {}
691
+
692
+ template <class _Arg1>
693
+ static constexpr bool __is_constructible_from_one_arg =
694
+ is_constructible_v<_Elem1, _Arg1> && is_default_constructible_v<_Elem2>;
695
+
696
+ template <class _Arg1>
697
+ static constexpr bool __is_nothrow_constructible_from_one_arg =
698
+ is_nothrow_constructible_v<_Elem1, _Arg1> && is_nothrow_default_constructible_v<_Elem2>;
699
+
700
+ _CCCL_EXEC_CHECK_DISABLE
701
+ _CCCL_TEMPLATE(class _Arg1)
702
+ _CCCL_REQUIRES(__is_constructible_from_one_arg<_Arg1>)
703
+ _CCCL_API constexpr __compressed_movable_box(_Arg1&& __arg1) noexcept(__is_nothrow_constructible_from_one_arg<_Arg1>)
704
+ : __base1(in_place, ::cuda::std::forward<_Arg1>(__arg1))
705
+ , __base2()
706
+ {}
707
+
708
+ template <class _Arg1, class _Arg2>
709
+ static constexpr bool __is_constructible_from_two_args =
710
+ is_constructible_v<_Elem1, _Arg1> && is_constructible_v<_Elem2, _Arg2>;
711
+
712
+ template <class _Arg1, class _Arg2>
713
+ static constexpr bool __is_nothrow_constructible_from_two_args =
714
+ is_nothrow_constructible_v<_Elem1, _Arg1> && is_nothrow_constructible_v<_Elem2, _Arg2>;
715
+
716
+ _CCCL_EXEC_CHECK_DISABLE
717
+ _CCCL_TEMPLATE(class _Arg1, class _Arg2)
718
+ _CCCL_REQUIRES(__is_constructible_from_two_args<_Arg1, _Arg2>)
719
+ _CCCL_API constexpr __compressed_movable_box(_Arg1&& __arg1, _Arg2&& __arg2) noexcept(
720
+ __is_nothrow_constructible_from_two_args<_Arg1, _Arg2>)
721
+ : __base1(in_place, ::cuda::std::forward<_Arg1>(__arg1))
722
+ , __base2(in_place, ::cuda::std::forward<_Arg2>(__arg2))
723
+ {}
724
+
725
+ _CCCL_TEMPLATE(size_t _Index)
726
+ _CCCL_REQUIRES((_Index < 2))
727
+ [[nodiscard]] _CCCL_API constexpr decltype(auto) __get() noexcept
728
+ {
729
+ if constexpr (_Index == 0)
730
+ {
731
+ return static_cast<__base1*>(this)->__get();
732
+ }
733
+ else // if constexpr (_Index == 1)
734
+ {
735
+ return static_cast<__base2*>(this)->__get();
736
+ }
737
+ _CCCL_UNREACHABLE();
738
+ }
739
+
740
+ _CCCL_TEMPLATE(size_t _Index)
741
+ _CCCL_REQUIRES((_Index < 2))
742
+ [[nodiscard]] _CCCL_API constexpr decltype(auto) __get() const noexcept
743
+ {
744
+ if constexpr (_Index == 0)
745
+ {
746
+ return static_cast<const __base1*>(this)->__get();
747
+ }
748
+ else // if constexpr (_Index == 1)
749
+ {
750
+ return static_cast<const __base2*>(this)->__get();
751
+ }
752
+ _CCCL_UNREACHABLE();
753
+ }
754
+
755
+ _CCCL_EXEC_CHECK_DISABLE
756
+ _CCCL_API friend constexpr void swap(__compressed_movable_box& __x, __compressed_movable_box& __y)
757
+ {
758
+ swap(__x.__get<0>(), __y.__get<0>());
759
+ swap(__x.__get<1>(), __y.__get<1>());
760
+ }
761
+ };
762
+
763
+ template <class _Elem1, class _Elem2, class _Elem3>
764
+ struct _CCCL_DECLSPEC_EMPTY_BASES __compressed_movable_box<_Elem1, _Elem2, _Elem3>
765
+ : __compressed_box<0, _Elem1>
766
+ , __compressed_box<1, _Elem2>
767
+ , __compressed_box<2, _Elem3>
768
+ {
769
+ using __base1 = __compressed_box<0, _Elem1>;
770
+ using __base2 = __compressed_box<1, _Elem2>;
771
+ using __base3 = __compressed_box<2, _Elem3>;
772
+
773
+ _CCCL_EXEC_CHECK_DISABLE
774
+ _CCCL_TEMPLATE(class _Elem1_ = _Elem1, class _Elem2_ = _Elem2, class _Elem3_ = _Elem3)
775
+ _CCCL_REQUIRES(is_default_constructible_v<_Elem1_> _CCCL_AND is_default_constructible_v<_Elem2_> _CCCL_AND
776
+ is_default_constructible_v<_Elem3_>)
777
+ _CCCL_API constexpr __compressed_movable_box() noexcept(
778
+ is_nothrow_default_constructible_v<_Elem1_> && is_nothrow_default_constructible_v<_Elem2_>
779
+ && is_nothrow_default_constructible_v<_Elem3_>)
780
+ : __base1()
781
+ , __base2()
782
+ , __base3()
783
+ {}
784
+
785
+ template <class _Arg1>
786
+ static constexpr bool __is_constructible_from_one_arg =
787
+ is_constructible_v<_Elem1, _Arg1> && is_default_constructible_v<_Elem2> && is_default_constructible_v<_Elem3>;
788
+
789
+ template <class _Arg1>
790
+ static constexpr bool __is_nothrow_constructible_from_one_arg =
791
+ is_nothrow_constructible_v<_Elem1, _Arg1> && is_nothrow_default_constructible_v<_Elem2>
792
+ && is_nothrow_default_constructible_v<_Elem3>;
793
+
794
+ _CCCL_EXEC_CHECK_DISABLE
795
+ _CCCL_TEMPLATE(class _Arg1)
796
+ _CCCL_REQUIRES(__is_constructible_from_one_arg<_Arg1>)
797
+ _CCCL_API constexpr __compressed_movable_box(_Arg1&& __arg1) noexcept(__is_nothrow_constructible_from_one_arg<_Arg1>)
798
+ : __base1(in_place, ::cuda::std::forward<_Arg1>(__arg1))
799
+ , __base2()
800
+ , __base3()
801
+ {}
802
+
803
+ template <class _Arg1, class _Arg2>
804
+ static constexpr bool __is_constructible_from_two_args =
805
+ is_constructible_v<_Elem1, _Arg1> && is_constructible_v<_Elem2, _Arg2> && is_default_constructible_v<_Elem3>;
806
+
807
+ template <class _Arg1, class _Arg2>
808
+ static constexpr bool __is_nothrow_constructible_from_two_args =
809
+ is_nothrow_constructible_v<_Elem1, _Arg1> && is_nothrow_constructible_v<_Elem2, _Arg2>
810
+ && is_nothrow_default_constructible_v<_Elem3>;
811
+
812
+ _CCCL_EXEC_CHECK_DISABLE
813
+ _CCCL_TEMPLATE(class _Arg1, class _Arg2)
814
+ _CCCL_REQUIRES(__is_constructible_from_two_args<_Arg1, _Arg2>)
815
+ _CCCL_API constexpr __compressed_movable_box(_Arg1&& __arg1, _Arg2&& __arg2) noexcept(
816
+ __is_nothrow_constructible_from_two_args<_Arg1, _Arg2>)
817
+ : __base1(in_place, ::cuda::std::forward<_Arg1>(__arg1))
818
+ , __base2(in_place, ::cuda::std::forward<_Arg2>(__arg2))
819
+ , __base3()
820
+ {}
821
+
822
+ template <class _Arg1, class _Arg2, class _Arg3>
823
+ static constexpr bool __is_constructible_from_three_args =
824
+ is_constructible_v<_Elem1, _Arg1> && is_constructible_v<_Elem2, _Arg2> && is_constructible_v<_Elem3, _Arg3>;
825
+
826
+ template <class _Arg1, class _Arg2, class _Arg3>
827
+ static constexpr bool __is_nothrow_constructible_from_three_args =
828
+ is_nothrow_constructible_v<_Elem1, _Arg1> && is_nothrow_constructible_v<_Elem2, _Arg2>
829
+ && is_nothrow_constructible_v<_Elem3, _Arg3>;
830
+
831
+ _CCCL_EXEC_CHECK_DISABLE
832
+ _CCCL_TEMPLATE(class _Arg1, class _Arg2, class _Arg3)
833
+ _CCCL_REQUIRES(__is_constructible_from_three_args<_Arg1, _Arg2, _Arg3>)
834
+ _CCCL_API constexpr __compressed_movable_box(_Arg1&& __arg1, _Arg2&& __arg2, _Arg3&& __arg3) noexcept(
835
+ __is_nothrow_constructible_from_three_args<_Arg1, _Arg2, _Arg3>)
836
+ : __base1(in_place, ::cuda::std::forward<_Arg1>(__arg1))
837
+ , __base2(in_place, ::cuda::std::forward<_Arg2>(__arg2))
838
+ , __base3(in_place, ::cuda::std::forward<_Arg3>(__arg3))
839
+ {}
840
+
841
+ _CCCL_TEMPLATE(size_t _Index)
842
+ _CCCL_REQUIRES((_Index < 3))
843
+ [[nodiscard]] _CCCL_API constexpr decltype(auto) __get() noexcept
844
+ {
845
+ if constexpr (_Index == 0)
846
+ {
847
+ return static_cast<__base1*>(this)->__get();
848
+ }
849
+ else if constexpr (_Index == 1)
850
+ {
851
+ return static_cast<__base2*>(this)->__get();
852
+ }
853
+ else // if constexpr (_Index == 2)
854
+ {
855
+ return static_cast<__base3*>(this)->__get();
856
+ }
857
+ _CCCL_UNREACHABLE();
858
+ }
859
+
860
+ _CCCL_TEMPLATE(size_t _Index)
861
+ _CCCL_REQUIRES((_Index < 3))
862
+ [[nodiscard]] _CCCL_API constexpr decltype(auto) __get() const noexcept
863
+ {
864
+ if constexpr (_Index == 0)
865
+ {
866
+ return static_cast<const __base1*>(this)->__get();
867
+ }
868
+ else if constexpr (_Index == 1)
869
+ {
870
+ return static_cast<const __base2*>(this)->__get();
871
+ }
872
+ else // if constexpr (_Index == 2)
873
+ {
874
+ return static_cast<const __base3*>(this)->__get();
875
+ }
876
+ _CCCL_UNREACHABLE();
877
+ }
878
+
879
+ _CCCL_EXEC_CHECK_DISABLE
880
+ _CCCL_API friend constexpr void swap(__compressed_movable_box& __x, __compressed_movable_box& __y)
881
+ {
882
+ swap(__x.__get<0>(), __y.__get<0>());
883
+ swap(__x.__get<1>(), __y.__get<1>());
884
+ swap(__x.__get<2>(), __y.__get<2>());
885
+ }
886
+ };
887
+
888
+ _CCCL_END_NAMESPACE_CUDA_STD
889
+
890
+ #include <cuda/std/__cccl/epilogue.h>
891
+
892
+ #endif // _CUDA_STD___RANGES_COMPRESSED_MOVABLE_BOX_H