mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
ircd::json: Allow stack objects to have dtor called manually to close JSON.
This commit is contained in:
parent
102ef2cb47
commit
bc4cb5cf8c
1 changed files with 18 additions and 0 deletions
18
ircd/json.cc
18
ircd/json.cc
|
@ -578,6 +578,12 @@ noexcept
|
|||
if(!s)
|
||||
return; // std::move()'ed away
|
||||
|
||||
const unwind _{[this]
|
||||
{
|
||||
// Allows ~dtor to be called to close the JSON manually
|
||||
s = nullptr;
|
||||
}};
|
||||
|
||||
assert(cm == nullptr);
|
||||
s->printer(json::printer.object_end);
|
||||
|
||||
|
@ -663,6 +669,12 @@ noexcept
|
|||
if(!s)
|
||||
return; // std::move()'ed away
|
||||
|
||||
const unwind _{[this]
|
||||
{
|
||||
// Allows ~dtor to be called to close the JSON manually
|
||||
s = nullptr;
|
||||
}};
|
||||
|
||||
assert(co == nullptr);
|
||||
assert(ca == nullptr);
|
||||
s->printer(json::printer.array_end);
|
||||
|
@ -766,6 +778,12 @@ noexcept
|
|||
if(!s)
|
||||
return; // std::move()'ed away
|
||||
|
||||
const unwind _{[this]
|
||||
{
|
||||
// Allows ~dtor to be called to close the JSON manually
|
||||
s = nullptr;
|
||||
}};
|
||||
|
||||
assert(co == nullptr);
|
||||
assert(ca == nullptr);
|
||||
assert(po);
|
||||
|
|
Loading…
Add table
Reference in a new issue