@@ -82,6 +82,41 @@ RecordComponent::storeChunk(Offset o, Extent e, F &&createBuffer)
8282 .enqueueStore <T>(std::forward<F>(createBuffer));
8383}
8484
85+ namespace detail
86+ {
87+ template <typename T>
88+ struct pointer_as_void ;
89+
90+ template <typename T>
91+ struct pointer_as_void <std::shared_ptr<T>>
92+ {
93+ static auto call (std::shared_ptr<T> const &ptr)
94+ -> std::shared_ptr<void const >
95+ {
96+ return std::static_pointer_cast<void const >(ptr);
97+ }
98+ };
99+
100+ template <typename T>
101+ struct pointer_as_void <std::unique_ptr<T>>
102+ {
103+ static auto call (std::unique_ptr<T> &&ptr) -> UniquePtrWithLambda<void>
104+ {
105+ return UniquePtrWithLambda<void >(std::move (ptr));
106+ }
107+ };
108+ template <typename T>
109+ struct pointer_as_void <std::unique_ptr<T[]>>
110+ {
111+ static auto call (std::unique_ptr<T[]> &&ptr)
112+ -> UniquePtrWithLambda<void>
113+ {
114+ return UniquePtrWithLambda<T[]>(std::move (ptr))
115+ .template static_cast_ <void >();
116+ }
117+ };
118+ } // namespace detail
119+
85120template <typename T, typename F>
86121inline DynamicMemoryView<T> RecordComponent::storeChunkSpanCreateBuffer_impl (
87122 internal::LoadStoreConfig cfg, F &&createBuffer)
@@ -131,11 +166,13 @@ inline DynamicMemoryView<T> RecordComponent::storeChunkSpanCreateBuffer_impl(
131166 // note that data might have either
132167 // type shared_ptr<T> or shared_ptr<T[]>
133168 auto data = std::forward<F>(createBuffer)(size);
169+ using ptr_type = decltype (data);
134170 out.ptr = static_cast <void *>(data.get ());
135171 internal::LoadStoreConfigWithBuffer ls_cfg{
136172 std::move (o), std::move (e), std::nullopt };
137173 storeChunk_impl (
138- auxiliary::WriteBuffer (std::move (data)),
174+ auxiliary::WriteBuffer (
175+ detail::pointer_as_void<ptr_type>::call (std::move (data))),
139176 getBufferView.dtype ,
140177 std::move (ls_cfg),
141178 /* flush_immediately=*/ false );
0 commit comments