]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/refptr.h
Mark boolean conversion operators as explicit
[libs/core.git] / source / core / refptr.h
index a2160a52c50b1799ce45d87903de94ff2474eaf5..70cb17607361364de990f8828643f80af8d8da00 100644 (file)
@@ -31,11 +31,11 @@ class RefPtr
        template<typename U> friend class WeakPtr;
 
 private:
-       T *data;
-       RefCounts *counts;
+       T *data = 0;
+       RefCounts *counts = 0;
 
 public:
-       RefPtr(): data(0), counts(0) { }
+       RefPtr() = default;
        RefPtr(T *d): data(d), counts(data ? new RefCounts : 0) { incref(); }
 private:
        RefPtr(T *d, RefCounts *c): data(d), counts(d ? c : 0) { incref(); }
@@ -81,7 +81,7 @@ public:
        T *get() const { return data; }
        T &operator*() const { return *data; }
        T *operator->() const { return data; }
-       operator bool() const { return data!=0; }
+       explicit operator bool() const { return data!=0; }
 
        unsigned refcount() const { return (data ? counts->count : 0); }
 
@@ -102,11 +102,11 @@ class WeakPtr
        template<typename U> friend class WeakPtr;
 
 private:
-       T *data;
-       RefCounts *counts;
+       T *data = 0;
+       RefCounts *counts = 0;
 
 public:
-       WeakPtr(): data(0), counts(0) { }
+       WeakPtr() = default;
 private:
        WeakPtr(T *d, RefCounts *c): data(d), counts(d ? c : 0) { incref(); }