summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-01-21 14:23:25 +0100
committerDavid Robillard <d@drobilla.net>2018-01-21 14:23:25 +0100
commit95e74234a923dcd7bd7c43f76919c61cf46b4e69 (patch)
treeef3a849f177b6c2ebbc11cb029d219a64bdfe27c /ingen
parent64de386aea724126e70c5186fe5e0166e0a79d35 (diff)
downloadingen-95e74234a923dcd7bd7c43f76919c61cf46b4e69.tar.gz
ingen-95e74234a923dcd7bd7c43f76919c61cf46b4e69.tar.bz2
ingen-95e74234a923dcd7bd7c43f76919c61cf46b4e69.zip
Allow custom deleters to be used with UPtr
Diffstat (limited to 'ingen')
-rw-r--r--ingen/types.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/ingen/types.hpp b/ingen/types.hpp
index 90823b70..7cd1c386 100644
--- a/ingen/types.hpp
+++ b/ingen/types.hpp
@@ -17,6 +17,7 @@
#ifndef INGEN_TYPES_HPP
#define INGEN_TYPES_HPP
+#include <cstdlib>
#include <memory>
#include "raul/Maid.hpp"
@@ -24,7 +25,13 @@
namespace Ingen {
template <class T>
-using UPtr = std::unique_ptr<T>;
+void NullDeleter(T* ptr) {}
+
+template <class T>
+struct FreeDeleter { void operator()(T* const ptr) { free(ptr); } };
+
+template <class T, class Deleter = std::default_delete<T>>
+using UPtr = std::unique_ptr<T, Deleter>;
template <class T>
using SPtr = std::shared_ptr<T>;
@@ -35,9 +42,6 @@ using WPtr = std::weak_ptr<T>;
template <class T>
using MPtr = Raul::managed_ptr<T>;
-template <class T>
-void NullDeleter(T* ptr) {}
-
template<class T, class U>
SPtr<T> static_ptr_cast(const SPtr<U>& r) {
return std::static_pointer_cast<T>(r);