From 6f1cf8e3d758d675f3e32a23e1443f85ded161d4 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Sun, 20 Mar 2016 21:52:49 +0000 Subject: [PATCH] refs #624 Replace typedef with using. --- src/blackcore/airspaceanalyzer.h | 2 +- src/blackmisc/collection.h | 4 ++-- src/blackmisc/dictionary.h | 2 +- src/blackmisc/indexsequence.h | 6 +++--- src/blackmisc/inheritancetraits.h | 4 ++-- src/blackmisc/iterator.h | 6 +++--- src/blackmisc/pq/physicalquantity.h | 2 +- src/blackmisc/pq/units.h | 12 ++++++------ src/blackmisc/sequence.h | 2 +- .../simulation/fsx/simconnectutilities.h | 2 +- .../simulation/remoteaircraftprovider.h | 4 ++-- src/blackmisc/tuple.h | 2 +- src/blackmisc/tupleprivate.h | 16 ++++++++-------- src/blackmisc/valueobject.h | 2 +- src/blackmisc/variantprivate.h | 2 +- src/plugins/simulator/fs9/callbackwrapper.h | 2 +- src/plugins/simulator/fs9/directplaypeer.h | 2 +- src/plugins/simulator/fs9/lobbyclient.h | 2 +- src/xbus/datarefs.h | 8 ++++---- src/xbus/service.h | 2 +- tests/blackcore/expect.h | 2 +- tests/blackmisc/testvalueobject.h | 8 ++++---- 22 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/blackcore/airspaceanalyzer.h b/src/blackcore/airspaceanalyzer.h index 282bb5406..95898a1b4 100644 --- a/src/blackcore/airspaceanalyzer.h +++ b/src/blackcore/airspaceanalyzer.h @@ -42,7 +42,7 @@ namespace BlackCore public: //! List of callsigns and their last activity - typedef QHash CCallsignTimestampSet; + using CCallsignTimestampSet = QHash; //! Constructor CAirspaceAnalyzer(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, diff --git a/src/blackmisc/collection.h b/src/blackmisc/collection.h index 4286881e5..de3ff4475 100644 --- a/src/blackmisc/collection.h +++ b/src/blackmisc/collection.h @@ -34,7 +34,7 @@ namespace BlackMisc { public: //! Type of values stored in the set. - typedef T value_type; + using value_type = T; //! Insert a new value into the set. typename QMap::iterator insert(const T &value) { return QMap::insert(value, value); } @@ -447,7 +447,7 @@ namespace BlackMisc template static I insertHelper(std::pair p) { return p.first; } }; - typedef QScopedPointer PimplPtr; + using PimplPtr = QScopedPointer; PimplPtr m_pimpl; CCollection(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl() diff --git a/src/blackmisc/dictionary.h b/src/blackmisc/dictionary.h index 606cd419f..45252a73f 100644 --- a/src/blackmisc/dictionary.h +++ b/src/blackmisc/dictionary.h @@ -93,7 +93,7 @@ namespace BlackMisc public: //! The implementation container - typedef Impl impl_type; + using impl_type = Impl; //! STL compatibility //! @{ diff --git a/src/blackmisc/indexsequence.h b/src/blackmisc/indexsequence.h index 9fcf27c1e..803404e88 100644 --- a/src/blackmisc/indexsequence.h +++ b/src/blackmisc/indexsequence.h @@ -27,17 +27,17 @@ namespace BlackMisc struct index_sequence { static const size_t size = sizeof...(Is); - typedef std::tuple...> tuple_type; + using tuple_type = std::tuple...>; }; template struct GenSequence { - typedef typename GenSequence::type type; + using type = typename GenSequence::type; }; template struct GenSequence { - typedef index_sequence type; + using type = index_sequence; }; template using make_index_sequence = typename GenSequence<0, C>::type; diff --git a/src/blackmisc/inheritancetraits.h b/src/blackmisc/inheritancetraits.h index ad3568a3a..4ec97460a 100644 --- a/src/blackmisc/inheritancetraits.h +++ b/src/blackmisc/inheritancetraits.h @@ -54,7 +54,7 @@ namespace BlackMisc // http://en.wikibooks.org/wiki/More_C++_Idioms/Member_Detector struct Empty {}; struct Fallback { int propertyByIndex; }; - template struct int_t { typedef int type; }; + template struct int_t { using type = int; }; template struct Derived : public Fallback, public std::conditional_t::value, Empty, U> {}; template static void test(typename int_t<&Derived::propertyByIndex>::type); @@ -62,7 +62,7 @@ namespace BlackMisc public: //! Type of T::base_type, or void if not declared. - typedef decltype(test::type>(0)) type; + using type = decltype(test::type>(0)); }; /*! diff --git a/src/blackmisc/iterator.h b/src/blackmisc/iterator.h index 64fe86d1b..aea6294ef 100644 --- a/src/blackmisc/iterator.h +++ b/src/blackmisc/iterator.h @@ -426,7 +426,7 @@ namespace BlackMisc I m_impl; }; - typedef QScopedPointer PimplPtr; + using PimplPtr = QScopedPointer; PimplPtr m_pimpl; explicit ConstForwardIterator(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl() @@ -633,7 +633,7 @@ namespace BlackMisc I m_impl; }; - typedef QScopedPointer PimplPtr; + using PimplPtr = QScopedPointer; PimplPtr m_pimpl; explicit ConstBidirectionalIterator(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl() @@ -854,7 +854,7 @@ namespace BlackMisc I m_impl; }; - typedef QScopedPointer PimplPtr; + using PimplPtr = QScopedPointer; PimplPtr m_pimpl; explicit BidirectionalIterator(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl() diff --git a/src/blackmisc/pq/physicalquantity.h b/src/blackmisc/pq/physicalquantity.h index 540616a07..213ed1909 100644 --- a/src/blackmisc/pq/physicalquantity.h +++ b/src/blackmisc/pq/physicalquantity.h @@ -228,7 +228,7 @@ namespace BlackMisc MU m_unit; //!< unit part //! Which subclass of CMeasurementUnit is used? - typedef MU UnitClass; + using UnitClass = MU; //! Implementation of compare static int compareImpl(const PQ &, const PQ &); diff --git a/src/blackmisc/pq/units.h b/src/blackmisc/pq/units.h index eb429d1a4..9ae6f8df1 100644 --- a/src/blackmisc/pq/units.h +++ b/src/blackmisc/pq/units.h @@ -55,7 +55,7 @@ namespace BlackMisc struct FeetToMeters { static double factor() { return 0.3048; } }; struct MilesToMeters { static double factor() { return 1609.344; } }; struct StatuteMilesToMeters { static double factor() { return 1609.3472; } }; - typedef One MetersToMeters; + using MetersToMeters = One; public: //! Base type @@ -170,7 +170,7 @@ namespace BlackMisc {} struct RadiansToDegrees { static double factor() { return 180.0 / M_PI; } }; - typedef One DegreesToDegrees; + using DegreesToDegrees = One; public: //! Base type @@ -268,7 +268,7 @@ namespace BlackMisc CMeasurementUnit(name, symbol, nullptr) {} - typedef One HertzToHertz; + using HertzToHertz = One; public: //! Base type @@ -358,7 +358,7 @@ namespace BlackMisc CMeasurementUnit(name, symbol, nullptr) {} - typedef Milli GramsToKilograms; + using GramsToKilograms = Milli; struct PoundsToKilograms { static double factor() { return 0.45359237; } }; public: @@ -457,7 +457,7 @@ namespace BlackMisc CMeasurementUnit(name, symbol, nullptr) {} - typedef Centi PascalsToHectopascals; + using PascalsToHectopascals = Centi; struct PsiToHectopascals { static double factor() { return 68.948; } }; struct InchesToHectopascals { static double factor() { return 33.86389; } }; struct MillimetersToHectopascals { static double factor() { return 860.142806; } }; @@ -773,7 +773,7 @@ namespace BlackMisc CMeasurementUnit(name, symbol, nullptr) {} - typedef One SecondsToSeconds; + using SecondsToSeconds = One; struct DaysToSeconds { static double factor() { return 60.0 * 60.0 * 24.0; } }; struct HoursToSeconds { static double factor() { return 60.0 * 60.0; } }; struct MinutesToSeconds { static double factor() { return 60.0; } }; diff --git a/src/blackmisc/sequence.h b/src/blackmisc/sequence.h index 0ea50aaca..ffe39b49f 100644 --- a/src/blackmisc/sequence.h +++ b/src/blackmisc/sequence.h @@ -704,7 +704,7 @@ namespace BlackMisc C m_impl; }; - typedef QScopedPointer PimplPtr; + using PimplPtr = QScopedPointer; PimplPtr m_pimpl; explicit CSequence(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl() diff --git a/src/blackmisc/simulation/fsx/simconnectutilities.h b/src/blackmisc/simulation/fsx/simconnectutilities.h index 186d7690d..23335dbc0 100644 --- a/src/blackmisc/simulation/fsx/simconnectutilities.h +++ b/src/blackmisc/simulation/fsx/simconnectutilities.h @@ -25,7 +25,7 @@ #endif #include #else -typedef unsigned long DWORD; //!< Fake Windows DWORD +using DWORD = unsigned long; //!< Fake Windows DWORD #endif namespace BlackMisc diff --git a/src/blackmisc/simulation/remoteaircraftprovider.h b/src/blackmisc/simulation/remoteaircraftprovider.h index 0164fec3e..8247f59ab 100644 --- a/src/blackmisc/simulation/remoteaircraftprovider.h +++ b/src/blackmisc/simulation/remoteaircraftprovider.h @@ -36,10 +36,10 @@ namespace BlackMisc static const int MaxPartsPerCallsign = 3; //!< How many parts per callsign //! Situations per callsign - typedef QHash CSituationsPerCallsign; + using CSituationsPerCallsign = QHash; //! Parts per callsign - typedef QHash CPartsPerCallsign; + using CPartsPerCallsign = QHash; //! All remote aircraft //! \threadsafe diff --git a/src/blackmisc/tuple.h b/src/blackmisc/tuple.h index 7e32d72c3..8754e6253 100644 --- a/src/blackmisc/tuple.h +++ b/src/blackmisc/tuple.h @@ -43,7 +43,7 @@ namespace BlackMisc * \ingroup Tuples */ #define BLACK_ENABLE_TUPLE_CONVERSION(T) \ - public: typedef std::true_type EnabledTupleConversion; \ + public: using EnabledTupleConversion = std::true_type; \ private: friend class BlackMisc::TupleConverter; /*! diff --git a/src/blackmisc/tupleprivate.h b/src/blackmisc/tupleprivate.h index 94274d839..0eca529f6 100644 --- a/src/blackmisc/tupleprivate.h +++ b/src/blackmisc/tupleprivate.h @@ -53,7 +53,7 @@ namespace BlackMisc template struct HasEnabledTupleConversion { - typedef decltype(hasEnabledTupleConversionHelper(static_cast(nullptr))) type; + using type = decltype(hasEnabledTupleConversionHelper(static_cast(nullptr))); static const bool value = type::value; }; @@ -80,23 +80,23 @@ namespace BlackMisc struct GenSequenceOnPredicate { static const bool test = P::template test::value; - typedef typename GenSequenceOnPredicate::type type; + using type = typename GenSequenceOnPredicate::type; }; template struct GenSequenceOnPredicate { static const bool test = P::template test::value; - typedef typename GenSequenceOnPredicate::type type; + using type = typename GenSequenceOnPredicate::type; }; template struct GenSequenceOnPredicate { - typedef index_sequence type; + using type = index_sequence; }; template struct GenSequenceOnPredicate { - typedef index_sequence type; + using type = index_sequence; }; template using make_index_sequence_if = typename GenSequenceOnPredicate::value>::type; @@ -105,14 +105,14 @@ namespace BlackMisc template struct FlagPresent { - typedef Tu tuple_type; + using tuple_type = Tu; template struct test : std::integral_constant::flags & F)> {}; }; template struct FlagMissing { - typedef Tu tuple_type; + using tuple_type = Tu; template struct test : std::integral_constant::flags & F)> {}; }; @@ -171,7 +171,7 @@ namespace BlackMisc template struct Attribute : public AttributeComparable, bool(Flags & DisabledForComparison), bool(Flags & CaseInsensitiveComparison)> { - typedef T type; + using type = T; static const qint64 flags = Flags; Attribute(T &obj, QString jsonName = {}) : m_obj(obj), m_jsonName(jsonName) {} diff --git a/src/blackmisc/valueobject.h b/src/blackmisc/valueobject.h index c4dd2a873..972c8e34d 100644 --- a/src/blackmisc/valueobject.h +++ b/src/blackmisc/valueobject.h @@ -42,7 +42,7 @@ namespace BlackMisc //! \private SFINAE for CValueObject constructor to avoid being selected as a viable copy constructor. template struct DecayFirst { - typedef void type; + using type = void; }; //! \private template struct DecayFirst diff --git a/src/blackmisc/variantprivate.h b/src/blackmisc/variantprivate.h index ea7236e9b..fa8d6936e 100644 --- a/src/blackmisc/variantprivate.h +++ b/src/blackmisc/variantprivate.h @@ -122,7 +122,7 @@ namespace BlackMisc //! \cond PRIVATE // http://en.wikibooks.org/wiki/More_C++_Idioms/Member_Detector struct Fallback { int toJson, convertFromJson, setPropertyByIndex, propertyByIndex, propertyByIndexAsString, equalsPropertyByIndex, toIcon; }; - template struct int_t { typedef int type; }; + template struct int_t { using type = int; }; template struct Derived : public U, public Fallback {}; # define DISABLE_IF_HAS(MEMBER) typename int_t<&Derived::MEMBER>::type //! \endcond diff --git a/src/plugins/simulator/fs9/callbackwrapper.h b/src/plugins/simulator/fs9/callbackwrapper.h index 2f6e2c310..bd7c08b0c 100644 --- a/src/plugins/simulator/fs9/callbackwrapper.h +++ b/src/plugins/simulator/fs9/callbackwrapper.h @@ -24,7 +24,7 @@ namespace BlackSimPlugin struct CallbackWrapper { //! Typedef to a MemberFunction - typedef ReturnType (Object::*MemberFunction)(Argument1, Argument2); + using MemberFunction = ReturnType (Object::*)(Argument1, Argument2); //! Constructor CallbackWrapper(Object *obj, MemberFunction memberFunction) : diff --git a/src/plugins/simulator/fs9/directplaypeer.h b/src/plugins/simulator/fs9/directplaypeer.h index c26f4225f..7c2e56809 100644 --- a/src/plugins/simulator/fs9/directplaypeer.h +++ b/src/plugins/simulator/fs9/directplaypeer.h @@ -87,7 +87,7 @@ namespace BlackSimPlugin QMutex m_mutexHostList; //!< Host list mutex - typedef CallbackWrapper TCallbackWrapper; //!< DirectPlay peer message handler wrapper + using TCallbackWrapper = CallbackWrapper; //!< DirectPlay peer message handler wrapper TCallbackWrapper m_callbackWrapper; //!< Callback wrapper }; } diff --git a/src/plugins/simulator/fs9/lobbyclient.h b/src/plugins/simulator/fs9/lobbyclient.h index dfd381c5f..a4712b715 100644 --- a/src/plugins/simulator/fs9/lobbyclient.h +++ b/src/plugins/simulator/fs9/lobbyclient.h @@ -61,7 +61,7 @@ namespace BlackSimPlugin DPNHANDLE m_applicationHandle = 0; - typedef CallbackWrapper TCallbackWrapper; //!< DirectPlay message handler wrapper + using TCallbackWrapper = CallbackWrapper; //!< DirectPlay message handler wrapper TCallbackWrapper m_callbackWrapper; //!< Callback wrapper TCallbackWrapper m_lobbyCallbackWrapper; //!< Callback wrapper diff --git a/src/xbus/datarefs.h b/src/xbus/datarefs.h index 43824c415..7fbdb0e20 100644 --- a/src/xbus/datarefs.h +++ b/src/xbus/datarefs.h @@ -89,10 +89,10 @@ namespace XBus DataRef() : DataRefImpl(DataRefTraits::name()) {} //! Traits type - typedef DataRefTraits TraitsType; + using TraitsType = DataRefTraits; //! Dataref type - typedef typename DataRefTraits::type DataRefType; + using DataRefType = typename DataRefTraits::type; //! Set the value of the dataref (if it is writable) void set(DataRefType d) { DataRefImpl::implSet(d); } @@ -114,10 +114,10 @@ namespace XBus ArrayDataRef() : ArrayDataRefImpl(DataRefTraits::name(), DataRefTraits::size) {} //! Traits type - typedef DataRefTraits TraitsType; + using TraitsType = DataRefTraits; //! Dataref type - typedef typename DataRefTraits::type DataRefType; + using DataRefType = typename DataRefTraits::type; //! Set the value of the whole array (if it is writable) void setAll(std::vector const& a) { ArrayDataRefImpl::implSetAll(a); } diff --git a/src/xbus/service.h b/src/xbus/service.h index b0867e652..e528ca954 100644 --- a/src/xbus/service.h +++ b/src/xbus/service.h @@ -31,7 +31,7 @@ class QTimer; //! \endcond //! Typedef needed to use QList as a DBus argument -typedef QList QDoubleList; +using QDoubleList = QList; //! Typedef needed to use QList as a DBus argument Q_DECLARE_METATYPE(QDoubleList) diff --git a/tests/blackcore/expect.h b/tests/blackcore/expect.h index baab0ba43..635504240 100644 --- a/tests/blackcore/expect.h +++ b/tests/blackcore/expect.h @@ -172,7 +172,7 @@ namespace BlackCoreTest // Helper traits class. Given T is a pointer-to-member-of-U, ClassOf::type is U. template struct ClassOf; - template struct ClassOf { typedef U type; }; + template struct ClassOf { using type = U; }; // Given T is a pointer-to-member-of-U, subject() returns Expect's subject casted to U*. template typename ClassOf::type *subject() const { return qobject_cast::type *>(m_subject.data()); } diff --git a/tests/blackmisc/testvalueobject.h b/tests/blackmisc/testvalueobject.h index 1a8f8cb05..6155ae66c 100644 --- a/tests/blackmisc/testvalueobject.h +++ b/tests/blackmisc/testvalueobject.h @@ -96,16 +96,16 @@ Q_DECLARE_METATYPE(BlackMisc::CNotHashable) // https://bugreports.qt-project.org/browse/QTBUG-11485 //! Test value object dictionary using ordered container -typedef BlackMisc::CDictionary CValueObjectDictionary; +using CValueObjectDictionary = BlackMisc::CDictionary; //! Test value object dictionary using unordered container -typedef BlackMisc::CDictionary CValueObjectHashDictionary; +using CValueObjectHashDictionary = BlackMisc::CDictionary; //! Test value object dictionary using ordered container with not hashable key -typedef BlackMisc::CDictionary CNotHashableDictionary; +using CNotHashableDictionary = BlackMisc::CDictionary; //! Test value object dictionary using unordered container with not hashable key -typedef BlackMisc::CDictionary CNotHashableMapDictionary; +using CNotHashableMapDictionary = BlackMisc::CDictionary; Q_DECLARE_METATYPE(CValueObjectDictionary) Q_DECLARE_METATYPE(CNotHashableDictionary)