[gjs] autofree: Avoid using local typedefs in classes
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] autofree: Avoid using local typedefs in classes
- Date: Fri, 16 Jun 2017 00:16:15 +0000 (UTC)
commit 4d32b0ba18fdcb51d166235e36d57db74af7ad49
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Jun 10 20:25:46 2017 -0700
autofree: Avoid using local typedefs in classes
We can make the GjsAutoChar and GjsAutoUnref declarations a bit more
readable by just writing 'unique_ptr' directly. This is more idiomatic
C++ style.
Thanks to Daniel Boles for pointing this out.
https://bugzilla.gnome.org/show_bug.cgi?id=777597
gjs/jsapi-util.h | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 44bc372..6842e8d 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -35,9 +35,7 @@
class GjsAutoChar : public std::unique_ptr<char, decltype(&g_free)> {
public:
- typedef std::unique_ptr<char, decltype(&g_free)> U;
-
- GjsAutoChar(char *str = nullptr) : U(str, g_free) {}
+ GjsAutoChar(char *str = nullptr) : unique_ptr(str, g_free) {}
operator const char *() {
return get();
@@ -51,12 +49,10 @@ public:
template <typename T>
class GjsAutoUnref : public std::unique_ptr<T, decltype(&g_object_unref)> {
public:
- typedef std::unique_ptr<T, decltype(&g_object_unref)> U;
-
- GjsAutoUnref(T *ptr = nullptr) : U(ptr, g_object_unref) {}
+ GjsAutoUnref(T *ptr = nullptr) : GjsAutoUnref::unique_ptr(ptr, g_object_unref) {}
operator T *() {
- return U::get();
+ return GjsAutoUnref::unique_ptr::get();
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]