File tree Expand file tree Collapse file tree 2 files changed +35
-25
lines changed
include/openPMD/auxiliary Expand file tree Collapse file tree 2 files changed +35
-25
lines changed Original file line number Diff line number Diff line change @@ -58,31 +58,11 @@ namespace auxiliary
5858 using parent_t = std::shared_ptr<UniquePtrWithLambda<void >>;
5959
6060 public:
61- MovableUniquePtr () = default ;
62- MovableUniquePtr (UniquePtrWithLambda<void > ptr_in)
63- : parent_t {std::make_shared<UniquePtrWithLambda<void >>(
64- std::move (ptr_in))}
65- {}
66- auto get () -> void *
67- {
68- return (**this ).get ();
69- }
70- [[nodiscard]] auto get () const -> void const *
71- {
72- return (**this ).get ();
73- }
74- [[nodiscard]] auto release () -> UniquePtrWithLambda<void>
75- {
76- if (parent_t::use_count () > 1 )
77- {
78- throw error::Internal (
79- " Control flow error: UniquePtr variant of WriteBuffer "
80- " has been copied." );
81- }
82- UniquePtrWithLambda<void > res = std::move (**this );
83- this ->reset ();
84- return res;
85- }
61+ MovableUniquePtr ();
62+ MovableUniquePtr (UniquePtrWithLambda<void > ptr_in);
63+ auto get () -> void *;
64+ [[nodiscard]] auto get () const -> void const *;
65+ [[nodiscard]] auto release () -> UniquePtrWithLambda<void>;
8666 };
8767 using SharedPtr = std::shared_ptr<void const >;
8868 /*
Original file line number Diff line number Diff line change @@ -161,6 +161,36 @@ allocatePtr(Datatype dtype, Extent const &e)
161161 return allocatePtr (dtype, numPoints);
162162}
163163
164+ WriteBuffer::MovableUniquePtr::MovableUniquePtr () = default ;
165+
166+ WriteBuffer::MovableUniquePtr::MovableUniquePtr (
167+ UniquePtrWithLambda<void > ptr_in)
168+ : parent_t {std::make_shared<UniquePtrWithLambda<void >>(std::move (ptr_in))}
169+ {}
170+
171+ auto WriteBuffer::MovableUniquePtr::get () -> void *
172+ {
173+ return (**this ).get ();
174+ }
175+
176+ auto WriteBuffer::MovableUniquePtr::get () const -> void const *
177+ {
178+ return (**this ).get ();
179+ }
180+
181+ auto WriteBuffer::MovableUniquePtr::release () -> UniquePtrWithLambda<void>
182+ {
183+ if (parent_t::use_count () > 1 )
184+ {
185+ throw error::Internal (
186+ " Control flow error: UniquePtr variant of WriteBuffer "
187+ " has been copied." );
188+ }
189+ UniquePtrWithLambda<void > res = std::move (**this );
190+ this ->reset ();
191+ return res;
192+ }
193+
164194WriteBuffer::WriteBuffer () : m_buffer(std::make_any<MovableUniquePtr>())
165195{}
166196
You can’t perform that action at this time.
0 commit comments