diff --git a/include/openPMD/RecordComponent.hpp b/include/openPMD/RecordComponent.hpp index d30f7684f2..da5833794b 100644 --- a/include/openPMD/RecordComponent.hpp +++ b/include/openPMD/RecordComponent.hpp @@ -241,6 +241,9 @@ class RecordComponent : public BaseRecordComponent template void storeChunk(std::shared_ptr, Offset, Extent); + template + void storeChunk(std::shared_ptr, Offset, Extent); + template typename std::enable_if< traits::IsContiguousContainer::value>::type diff --git a/include/openPMD/RecordComponent.tpp b/include/openPMD/RecordComponent.tpp index 7e757fd7fd..a4731d5434 100644 --- a/include/openPMD/RecordComponent.tpp +++ b/include/openPMD/RecordComponent.tpp @@ -208,6 +208,16 @@ RecordComponent::storeChunk(std::shared_ptr data, Offset o, Extent e) rc.m_chunks.push(IOTask(this, dWrite)); } +template +inline void +RecordComponent::storeChunk(std::shared_ptr data, Offset o, Extent e) +{ + storeChunk( + std::static_pointer_cast(std::move(data)), + std::move(o), + std::move(e)); +} + template< typename T_ContiguousContainer > inline typename std::enable_if< traits::IsContiguousContainer< T_ContiguousContainer >::value @@ -310,6 +320,8 @@ RecordComponent::storeChunk( Offset o, Extent e, F && createBuffer ) auto &out = *getBufferView.out; if (!out.backendManagedBuffer) { + // note that data might have either + // type shared_ptr or shared_ptr auto data = std::forward(createBuffer)(size); out.ptr = static_cast(data.get()); storeChunk(std::move(data), std::move(o), std::move(e)); @@ -326,8 +338,12 @@ RecordComponent::storeChunk( Offset offset, Extent extent ) std::move( extent ), []( size_t size ) { +#if defined(__clang_major__) && __clang_major__ < 7 return std::shared_ptr< T >{ new T[ size ], []( auto * ptr ) { delete[] ptr; } }; +#else + return std::shared_ptr< T[] >{ new T[ size ] }; +#endif } ); } }