From a1861c69f008e2459a3f85195133860cd749cda0 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Sun, 20 Mar 2016 21:54:04 +0000 Subject: [PATCH] refs #624 Some more occurrences of constexpr. --- src/blackgui/components/dbstashcomponent.h | 2 +- src/blackgui/guiutility.cpp | 2 +- src/blackgui/models/listmodelbase.h | 2 +- src/blackgui/views/viewbase.h | 4 ++-- src/blackmisc/audio/settings/settingsaudio.cpp | 2 +- src/blackmisc/aviation/flightplan.h | 4 ++-- src/blackmisc/input/joystickbutton.h | 2 +- src/blackmisc/simulation/remoteaircraftprovider.h | 4 ++-- src/blackmisc/tupleprivate.h | 8 ++++---- src/plugins/simulator/fsx/simulatorfsx.h | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/blackgui/components/dbstashcomponent.h b/src/blackgui/components/dbstashcomponent.h index dcf962a1f..42251bb2e 100644 --- a/src/blackgui/components/dbstashcomponent.h +++ b/src/blackgui/components/dbstashcomponent.h @@ -39,7 +39,7 @@ namespace BlackGui public: //! Number of models which can be published at once - static const int MaxModelPublished = 1000; + static constexpr int MaxModelPublished = 1000; //! Constructor explicit CDbStashComponent(QWidget *parent = nullptr); diff --git a/src/blackgui/guiutility.cpp b/src/blackgui/guiutility.cpp index 5b2aefb16..9d59f3713 100644 --- a/src/blackgui/guiutility.cpp +++ b/src/blackgui/guiutility.cpp @@ -149,7 +149,7 @@ namespace BlackGui int CGuiUtility::metaTypeIdFromSwiftDragAndDropData(const QMimeData *mime) { - static const int Unknown = static_cast(QMetaType::UnknownType); + constexpr int Unknown = static_cast(QMetaType::UnknownType); if (!hasSwiftVariantMimeType(mime)) { return Unknown; } QJsonDocument jsonDoc(QJsonDocument::fromJson(mime->data(swiftJsonDragAndDropMimeType()))); diff --git a/src/blackgui/models/listmodelbase.h b/src/blackgui/models/listmodelbase.h index 86e2d7ce9..aeed4cbd3 100644 --- a/src/blackgui/models/listmodelbase.h +++ b/src/blackgui/models/listmodelbase.h @@ -33,7 +33,7 @@ namespace BlackGui public: //! Number of elements when to use asynchronous updates - static const int asyncThreshold = 50; + static constexpr int asyncThreshold = 50; //! Destructor virtual ~CListModelBaseNonTemplate() {} diff --git a/src/blackgui/views/viewbase.h b/src/blackgui/views/viewbase.h index 1cdd293b1..0d7dd2681 100644 --- a/src/blackgui/views/viewbase.h +++ b/src/blackgui/views/viewbase.h @@ -96,10 +96,10 @@ namespace BlackGui Q_DECLARE_FLAGS(Menu, MenuFlag) //! When (row count) to use asynchronous updates - static const int ASyncRowsCountThreshold = 50; + static constexpr int ASyncRowsCountThreshold = 50; //! When to use pre-sizing with random elements - static const int ResizeSubsetThreshold = 50; + static constexpr int ResizeSubsetThreshold = 50; //! Clear data virtual void clear() = 0; diff --git a/src/blackmisc/audio/settings/settingsaudio.cpp b/src/blackmisc/audio/settings/settingsaudio.cpp index c41634301..c5fee18a9 100644 --- a/src/blackmisc/audio/settings/settingsaudio.cpp +++ b/src/blackmisc/audio/settings/settingsaudio.cpp @@ -47,7 +47,7 @@ namespace BlackMisc void CSettingsAudio::initNotificationFlags() { // if we add flags in the future, we automatically extend ... - static const int l = 1 + static_cast(CNotificationSounds::Notification::NotificationsLoadSounds); + constexpr int l = 1 + static_cast(CNotificationSounds::Notification::NotificationsLoadSounds); if (this->m_notificationFlags.length() < l) { int cl = m_notificationFlags.length(); diff --git a/src/blackmisc/aviation/flightplan.h b/src/blackmisc/aviation/flightplan.h index 1555bec9b..687970eba 100644 --- a/src/blackmisc/aviation/flightplan.h +++ b/src/blackmisc/aviation/flightplan.h @@ -37,8 +37,8 @@ namespace BlackMisc DVFR //!< Defense VFR }; - static const int MaxRemarksLength = 150; //!< Max remarks length - static const int MaxRouteLength = 150; //!< Max route length + static constexpr int MaxRemarksLength = 150; //!< Max remarks length + static constexpr int MaxRouteLength = 150; //!< Max route length //! Default constructor CFlightPlan() = default; diff --git a/src/blackmisc/input/joystickbutton.h b/src/blackmisc/input/joystickbutton.h index ff8586e9f..7a5b14a66 100644 --- a/src/blackmisc/input/joystickbutton.h +++ b/src/blackmisc/input/joystickbutton.h @@ -75,7 +75,7 @@ namespace BlackMisc BLACK_ENABLE_TUPLE_CONVERSION(CJoystickButton) int m_buttonIndex = m_invalidIndex; - static const int m_invalidIndex = -1; + static constexpr int m_invalidIndex = -1; }; } } diff --git a/src/blackmisc/simulation/remoteaircraftprovider.h b/src/blackmisc/simulation/remoteaircraftprovider.h index 8247f59ab..c37467252 100644 --- a/src/blackmisc/simulation/remoteaircraftprovider.h +++ b/src/blackmisc/simulation/remoteaircraftprovider.h @@ -32,8 +32,8 @@ namespace BlackMisc class BLACKMISC_EXPORT IRemoteAircraftProvider { public: - static const int MaxSituationsPerCallsign = 6; //!< How many situations per callsign - static const int MaxPartsPerCallsign = 3; //!< How many parts per callsign + static constexpr int MaxSituationsPerCallsign = 6; //!< How many situations per callsign + static constexpr int MaxPartsPerCallsign = 3; //!< How many parts per callsign //! Situations per callsign using CSituationsPerCallsign = QHash; diff --git a/src/blackmisc/tupleprivate.h b/src/blackmisc/tupleprivate.h index 0eca529f6..aa881d3dc 100644 --- a/src/blackmisc/tupleprivate.h +++ b/src/blackmisc/tupleprivate.h @@ -54,7 +54,7 @@ namespace BlackMisc struct HasEnabledTupleConversion { using type = decltype(hasEnabledTupleConversionHelper(static_cast(nullptr))); - static const bool value = type::value; + static constexpr bool value = type::value; }; // Using tag dispatch to select which implementation of compare() to use @@ -79,13 +79,13 @@ namespace BlackMisc template struct GenSequenceOnPredicate { - static const bool test = P::template test::value; + static constexpr bool test = P::template test::value; using type = typename GenSequenceOnPredicate::type; }; template struct GenSequenceOnPredicate { - static const bool test = P::template test::value; + static constexpr bool test = P::template test::value; using type = typename GenSequenceOnPredicate::type; }; template @@ -172,7 +172,7 @@ namespace BlackMisc struct Attribute : public AttributeComparable, bool(Flags & DisabledForComparison), bool(Flags & CaseInsensitiveComparison)> { using type = T; - static const qint64 flags = Flags; + static constexpr qint64 flags = Flags; Attribute(T &obj, QString jsonName = {}) : m_obj(obj), m_jsonName(jsonName) {} void extend(QString jsonName) { if (m_jsonName.isEmpty()) m_jsonName = jsonName; } diff --git a/src/plugins/simulator/fsx/simulatorfsx.h b/src/plugins/simulator/fsx/simulatorfsx.h index 53e14242e..ab89b985c 100644 --- a/src/plugins/simulator/fsx/simulatorfsx.h +++ b/src/plugins/simulator/fsx/simulatorfsx.h @@ -182,7 +182,7 @@ namespace BlackSimPlugin //! Inject weather grid to simulator void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid); - static const int SkipUpdateCyclesForCockpit = 10; //!< skip x cycles before updating cockpit again + static constexpr int SkipUpdateCyclesForCockpit = 10; //!< skip x cycles before updating cockpit again bool m_simConnected = false; //!< Is simulator connected? bool m_simSimulating = false; //!< Simulator running? bool m_useSbOffsets = true; //!< with SB offsets