Skip to content

Commit e5178d9

Browse files
committed
extract definitions
1 parent ab8b59b commit e5178d9

File tree

2 files changed

+35
-25
lines changed

2 files changed

+35
-25
lines changed

include/openPMD/auxiliary/Memory.hpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff 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
/*

src/auxiliary/Memory.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
164194
WriteBuffer::WriteBuffer() : m_buffer(std::make_any<MovableUniquePtr>())
165195
{}
166196

0 commit comments

Comments
 (0)