Make Qt::Initialization a C++11 class enum

And declare Qt::Uninitialized to be the same value because we're not
interested in the scoping rules of C++11 class enums. We're only
interested in avoiding the cast from Qt::Uninitialized to an integer.
That is to avoid the mistaken:

    QVector<Custom> vector(5, Qt::Uninitialized);

which is actually implicitly:

    QVector<Custom> vector(5, Custom(Qt::Uninitialized));

and likely not what the developer wanted.

Change-Id: I27eaacb532114dd188c4ffff13d374eb698bfbab
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Thiago Macieira 2015-04-09 14:14:21 -07:00
parent d9d9420d8d
commit 3bf4c222e5

View File

@ -1536,9 +1536,16 @@ public:
TitleBarArea // For move
};
#if defined(Q_COMPILER_CLASS_ENUM) && defined(Q_COMPILER_CONSTEXPR)
enum class Initialization {
Uninitialized
};
static constexpr Q_DECL_UNUSED Initialization Uninitialized = Initialization::Uninitialized;
#else
enum Initialization {
Uninitialized
};
#endif
enum CoordinateSystem {
DeviceCoordinates,