QScopedValueRollback: make constructor explicit
authorMarc Mutz <marc.mutz@kdab.com>
Tue, 28 Feb 2012 21:27:48 +0000 (22:27 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 29 Feb 2012 12:52:01 +0000 (13:52 +0100)
I'm not even sure whether you could implicitly
convert a T& into a QScopedValueRollback<T>,
seeing as the constructor takes a non-const
reference, but it looks wrong without explicit
and

  QObject o = new QObject(parent);

also won't compile even with implicit QObject(QObject*)
under a conformant compiler because of the disabled
copy constructor, and we still make QObject(QObject*)
explicit, so add it here, too.

Change-Id: I722a6e8431644e450fe2b401ccfb707a8e982380
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
src/corelib/tools/qscopedvaluerollback.h

index 23d2d9e..d53cabd 100644 (file)
@@ -51,7 +51,7 @@ template <typename T>
 class QScopedValueRollback
 {
 public:
-    QScopedValueRollback(T &var) :
+    explicit QScopedValueRollback(T &var) :
         varRef(var)
     {
         oldValue = varRef;