summaryrefslogtreecommitdiff
path: root/src/libaudcore/templates.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libaudcore/templates.h')
-rw-r--r--src/libaudcore/templates.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libaudcore/templates.h b/src/libaudcore/templates.h
index e78aea0..d14c3d8 100644
--- a/src/libaudcore/templates.h
+++ b/src/libaudcore/templates.h
@@ -98,6 +98,25 @@ inline T from_ptr (void * v)
return u.t;
}
+// Function wrappers (or "casts") for interaction with C-style APIs
+// ================================================================
+
+template<class T>
+void delete_obj (void * obj)
+ { (void) sizeof (T); delete (T *) obj; }
+
+template<class T>
+void delete_typed (T * obj)
+ { (void) sizeof (T); delete obj; }
+
+template<class T, void (* func) (void *)>
+void typed_func (T * obj)
+ { func (obj); }
+
+template<class T, void (T::* func) ()>
+static void obj_member (void * obj)
+ { (((T *) obj)->* func) (); }
+
// Wrapper class allowing enumerations to be used as array indexes;
// the enumeration must begin with zero and have a "count" constant
// ================================================================