mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
cpp: zone::push_finalizer supports std::auto_ptr<T>
This commit is contained in:
parent
0d44348c7d
commit
5aa47d6677
1 changed files with 13 additions and 0 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "msgpack/object.hpp"
|
||||
#include "msgpack/zone.h"
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
<% GENERATION_LIMIT = 15 %>
|
||||
|
|
@ -38,6 +39,9 @@ public:
|
|||
|
||||
void push_finalizer(void (*func)(void*), void* data);
|
||||
|
||||
template <typename T>
|
||||
void push_finalizer(std::auto_ptr<T> obj);
|
||||
|
||||
void clear();
|
||||
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
|
|
@ -94,6 +98,15 @@ inline void zone::push_finalizer(void (*func)(void*), void* data)
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void zone::push_finalizer(std::auto_ptr<T> obj)
|
||||
{
|
||||
if(!msgpack_zone_push_finalizer(this, &zone::object_destructor<T>, obj.get())) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
obj.release();
|
||||
}
|
||||
|
||||
inline void zone::clear()
|
||||
{
|
||||
msgpack_zone_clear(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue