[gjs] jsapi-util: Add GjsAutoPointerSimple to avoid repeating the same type



commit 90490b04ec23008ee5f25f20ca1006dbf2a38f86
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed May 12 13:23:47 2021 +0200

    jsapi-util: Add GjsAutoPointerSimple to avoid repeating the same type
    
    It would be very nice to be able to do this using templates
    specialization, but it's hard to do given that the main template uses
    an order that we don't want to change, so let's just use another name.

 gjs/jsapi-util.h | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 9af700f1..5c21b750 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -183,6 +183,12 @@ struct GjsAutoPointer {
     Ptr m_ptr;
 };
 
+template <typename T, GjsAutoPointerFreeFunction<T> free_func = free,
+          GjsAutoPointerRefFunction<T> ref_func = nullptr>
+struct GjsAutoPointerSimple : GjsAutoPointer<T, T, free_func, ref_func> {
+    using GjsAutoPointer<T, T, free_func, ref_func>::GjsAutoPointer;
+};
+
 template <typename T, typename F = void,
           GjsAutoPointerFreeFunction<F> free_func,
           GjsAutoPointerRefFunction<F> ref_func>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]