summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--device/hid/hid_service_linux.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/device/hid/hid_service_linux.h b/device/hid/hid_service_linux.h
index 415db80..ba58fad 100644
--- a/device/hid/hid_service_linux.h
+++ b/device/hid/hid_service_linux.h
@@ -18,6 +18,11 @@ namespace device {
class HidConnection;
template<typename T, void func(T*)>
+void DiscardReturnType(T* arg) { func(arg); }
+template<typename T, T* func(T*)>
+void DiscardReturnType(T* arg) { func(arg); }
+
+template<typename T, void func(T*)>
struct Deleter {
void operator()(T* enumerate) const {
if (enumerate != NULL)
@@ -25,10 +30,17 @@ struct Deleter {
}
};
-typedef Deleter<udev_enumerate, udev_enumerate_unref> UdevEnumerateDeleter;
-typedef Deleter<udev_device, udev_device_unref> UdevDeviceDeleter;
-typedef Deleter<udev, udev_unref> UdevDeleter;
-typedef Deleter<udev_monitor, udev_monitor_unref> UdevMonitorDeleter;
+typedef Deleter<
+ udev_enumerate,
+ DiscardReturnType<udev_enumerate, udev_enumerate_unref> >
+ UdevEnumerateDeleter;
+typedef Deleter<
+ udev_device,
+ DiscardReturnType<udev_device, udev_device_unref> > UdevDeviceDeleter;
+typedef Deleter<udev, DiscardReturnType<udev, udev_unref> > UdevDeleter;
+typedef Deleter<
+ udev_monitor,
+ DiscardReturnType<udev_monitor, udev_monitor_unref> > UdevMonitorDeleter;
typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr;
typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr;