diff --git a/src/blackmisc/aviation/callsignobjectlist.cpp b/src/blackmisc/aviation/callsignobjectlist.cpp index ee65fd1ff..4d9dc74e5 100644 --- a/src/blackmisc/aviation/callsignobjectlist.cpp +++ b/src/blackmisc/aviation/callsignobjectlist.cpp @@ -93,7 +93,7 @@ namespace BlackMisc CONTAINER r; if (suffix.isEmpty()) { return r; } QString sfxUpper(suffix.trimmed().toUpper()); - r = this->container().findBy([ = ](const OBJ & csObj) -> bool + r = this->container().findBy([ = ](const OBJ & csObj) { return (csObj.getCallsign().getSuffix() == sfxUpper); }); diff --git a/src/blackmisc/iterator.h b/src/blackmisc/iterator.h index ee6eef6d0..b2902e346 100644 --- a/src/blackmisc/iterator.h +++ b/src/blackmisc/iterator.h @@ -53,16 +53,16 @@ namespace BlackMisc //! @} //! Return the value at this iterator position. - auto value() const -> decltype(std::declval().value()) { return m_iterator.value(); } + auto value() const { return m_iterator.value(); } //! Return the key at this iterator position. //! @{ - auto key() const -> decltype(std::declval().key()) { return m_iterator.key(); } - auto operator *() const -> decltype(std::declval().key()) { return key(); } + auto key() const { return m_iterator.key(); } + auto operator *() const { return key(); } //! @} //! Indirection operator: pointer to the key at this iterator position. - auto operator ->() const -> typename std::remove_reference().key())>::type * { return &key(); } + auto operator ->() const { return &key(); } //! Equality operators. //! @{ diff --git a/src/blackmisc/lockfree.h b/src/blackmisc/lockfree.h index 1d10a5aab..56252939f 100644 --- a/src/blackmisc/lockfree.h +++ b/src/blackmisc/lockfree.h @@ -275,7 +275,7 @@ namespace BlackMisc //! Pass the current value to the functor inspector, and return whatever inspector returns. template - auto read(F &&inspector) -> decltype(inspector(std::declval())) + auto read(F &&inspector) { return std::forward(inspector)(read().get()); } @@ -314,14 +314,14 @@ namespace BlackMisc //! \param function The LockFree values from which this LockFreeMulti was constructed will be passed as arguments to this functor. //! \return The value returned by the functor, if any. template - auto operator ()(F &&function) && -> decltype(function(std::declval()...)) + auto operator ()(F &&function) && { return call(std::forward(function), Private::make_index_sequence()); } private: template - auto call(F &&function, Private::index_sequence) -> decltype(function(std::declval()...)) + auto call(F &&function, Private::index_sequence) { return std::forward(function)(std::get(m_tup).get()...); } diff --git a/src/blackmisc/predicates.h b/src/blackmisc/predicates.h index 4d34bb8f7..1924d80cd 100644 --- a/src/blackmisc/predicates.h +++ b/src/blackmisc/predicates.h @@ -71,31 +71,6 @@ namespace BlackMisc template bool operator()(const T &a, const T &b) const { return head.isStable(a, b) ? head(a, b) : tail(a, b); } }; - //! \private - template struct MemberTransform - { - M m; - MemberTransform(M m_) : m(m_) {} - auto operator()(const T &v) const -> decltype((v.*std::declval())()) { return (v.*m)(); } - }; - - //! \private - template struct MemberValid - { - M m; - MemberValid(M m_) : m(m_) {} - bool operator()(const T &v) const { return (v.*m)().isValid(); } - }; - - //! \private - template struct MemberIsAnyOf - { - M m; - const C &c; - MemberIsAnyOf(M m_, const C &c_) : m(m_), c(c_) {} - bool operator()(const T &v) const { return c.contains((v.*m)()); } - }; - //! \private template struct Equals { @@ -137,58 +112,44 @@ namespace BlackMisc } /*! - * Transformation function object which returns the value returned by one of it's argument member functions. - * - * A lambda would usually be easier, but it is difficult to directly return a lambda from a function - * without C++14 deduced return types. + * Returns a function object that returns the value returned by one of it's argument member functions. */ template - auto MemberTransform(R(T::*memberFunc)() const) -> Private::MemberTransform + auto MemberTransform(R(T::*memberFunc)() const) { - return { memberFunc }; + return [memberFunc](const T &object) { return (object.*memberFunc)(); }; } /*! - * Predicate which is true if the isValid() method of the value returned from one of its member functions returns true. - * - * A lambda would usually be easier, but it is difficult to directly return a lambda from a function - * without C++14 deduced return types. + * Returns a predicate that returns true if the isValid() method of the value returned from one of its member functions returns true. */ template - auto MemberValid(R(T::*memberFunc)() const) -> Private::MemberValid + auto MemberValid(R(T::*memberFunc)() const) { - return { memberFunc }; + return [memberFunc](const T &object) { return (object.*memberFunc)().isValid(); }; } /*! - * Predicate which is true if the value returned by its argument's member function can be found in a captured container. - * - * A lambda would usually be easier, but it is difficult to directly return a lambda from a function - * without C++14 deduced return types. - * + * Returns a predicate that returns true if the value returned by its argument's member function can be found in a captured container. * \warning The container is captured by reference, so be careful that it remains valid for the lifetime of the predicate. */ template - auto MemberIsAnyOf(R(T::*memberFunc)() const, const C &container) -> Private::MemberIsAnyOf + auto MemberIsAnyOf(R(T::*memberFunc)() const, const C &container) { - return { memberFunc, container }; + return [memberFunc, &container](const T &object) { return container.contains((object.*memberFunc)()); }; } /*! - * Predicate which is true if its argument compares equal with another, captured value. - * - * A lambda would usually be easier, but it is difficult to directly return a lambda from a function - * without C++14 deduced return types. It is also a generic function object, which is only possible - * with C++14 generic lambdas. + * Returns a predicate that returns true if its argument compares equal with another, captured value. */ template - auto Equals(T &&value) -> Private::Equals::type> + auto Equals(T &&value) { - return { std::forward(value), 0 }; + return [value = std::forward(value)](const T &object) { return object == value; }; } /*! - * Predicate which is true if its argument matches a captured CPropertyIndexVariantMap. + * Returns a predicate that returns true if its argument matches a captured CPropertyIndexVariantMap. */ inline auto Matches(const CPropertyIndexVariantMap &map) -> Private::Matches { diff --git a/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp b/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp index 9eeb69e75..c5e23acfc 100644 --- a/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp +++ b/src/blackmisc/simulation/fscommon/aircraftcfgentrieslist.cpp @@ -27,7 +27,7 @@ namespace BlackMisc { if (title.isEmpty()) { return false; } return this->containsBy( - [ = ](const CAircraftCfgEntries & entries) -> bool { return title.compare(entries.getTitle(), caseSensitivity) == 0; } + [ = ](const CAircraftCfgEntries & entries) { return title.compare(entries.getTitle(), caseSensitivity) == 0; } ); } @@ -82,7 +82,7 @@ namespace BlackMisc CAircraftCfgEntriesList CAircraftCfgEntriesList::findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) const { - return this->findBy([ = ](const CAircraftCfgEntries & entries) -> bool + return this->findBy([ = ](const CAircraftCfgEntries & entries) { return title.compare(entries.getTitle(), caseSensitivity) == 0; }); } diff --git a/src/blackmisc/tuple.h b/src/blackmisc/tuple.h index 7b1e7bfaf..656faffce 100644 --- a/src/blackmisc/tuple.h +++ b/src/blackmisc/tuple.h @@ -75,21 +75,21 @@ namespace BlackMisc friend class BlackMisc::Private::EncapsulationBreaker; \ static_assert(Private::HasEnabledTupleConversion::value, \ "Missing BLACK_ENABLE_TUPLE_CONVERSION macro in " #T); \ - static auto toTuple(const T &o) -> decltype(BlackMisc::tie MEMBERS) \ + static auto toTuple(const T &o) \ { \ return BlackMisc::tie MEMBERS; \ } \ - static auto toTuple(T &o) -> decltype(BlackMisc::tie MEMBERS) \ + static auto toTuple(T &o) \ { \ return BlackMisc::tie MEMBERS; \ } \ - static auto toMetaTuple(const T &o) -> decltype(BlackMisc::tieMeta MEMBERS) \ + static auto toMetaTuple(const T &o) \ { \ auto tu = BlackMisc::tieMeta MEMBERS; \ parser().extendMetaTuple(tu); \ return tu; \ } \ - static auto toMetaTuple(T &o) -> decltype(BlackMisc::tieMeta MEMBERS) \ + static auto toMetaTuple(T &o) \ { \ auto tu = BlackMisc::tieMeta MEMBERS; \ parser().extendMetaTuple(tu); \ @@ -105,7 +105,7 @@ namespace BlackMisc return parser().m_names; \ } \ public: \ - static auto constToTuple(const T &o) -> decltype(BlackMisc::tie MEMBERS) \ + static auto constToTuple(const T &o) \ { \ return BlackMisc::tie MEMBERS; \ } \ @@ -127,21 +127,21 @@ namespace BlackMisc friend class BlackMisc::Private::EncapsulationBreaker; \ static_assert(Private::HasEnabledTupleConversion>::value, \ "Missing BLACK_ENABLE_TUPLE_CONVERSION macro in " #T); \ - static auto toTuple(const T &o) -> decltype(BlackMisc::tie MEMBERS) \ + static auto toTuple(const T &o) \ { \ return BlackMisc::tie MEMBERS; \ } \ - static auto toTuple(T &o) -> decltype(BlackMisc::tie MEMBERS) \ + static auto toTuple(T &o) \ { \ return BlackMisc::tie MEMBERS; \ } \ - static auto toMetaTuple(const T &o) -> decltype(BlackMisc::tieMeta MEMBERS) \ + static auto toMetaTuple(const T &o) \ { \ auto tu = BlackMisc::tieMeta MEMBERS; \ parser().extendMetaTuple(tu); \ return tu; \ } \ - static auto toMetaTuple(T &o) -> decltype(BlackMisc::tieMeta MEMBERS) \ + static auto toMetaTuple(T &o) \ { \ auto tu = BlackMisc::tieMeta MEMBERS; \ parser().extendMetaTuple(tu); \ @@ -157,7 +157,7 @@ namespace BlackMisc return parser().m_names; \ } \ public: \ - static auto constToTuple(const T &o) -> decltype(BlackMisc::tie MEMBERS) \ + static auto constToTuple(const T &o) \ { \ return BlackMisc::tie MEMBERS; \ } \ @@ -286,7 +286,7 @@ namespace BlackMisc * \ingroup Tuples */ template - auto tie(Ts &&... args) -> decltype(std::make_tuple(Private::tieHelper(args)...)) + auto tie(Ts &&... args) { return std::make_tuple(Private::tieHelper(args)...); } @@ -296,7 +296,7 @@ namespace BlackMisc * \ingroup Tuples */ template - auto tieMeta(Ts &&... args) -> decltype(std::make_tuple(Private::tieMetaHelper(args)...)) + auto tieMeta(Ts &&... args) { return std::make_tuple(Private::tieMetaHelper(args)...); } diff --git a/src/blackmisc/tupleprivate.h b/src/blackmisc/tupleprivate.h index ee59ec553..eb4f65c6f 100644 --- a/src/blackmisc/tupleprivate.h +++ b/src/blackmisc/tupleprivate.h @@ -40,7 +40,7 @@ namespace BlackMisc { protected: template - static auto toMetaTuple(T &o) -> decltype(TupleConverter::type>::toMetaTuple(o)) + static auto toMetaTuple(T &o) { return TupleConverter::type>::toMetaTuple(o); } @@ -213,14 +213,14 @@ namespace BlackMisc // Convert a meta tuple to a value tuple template - auto stripMeta(Tu &&tu, index_sequence) -> decltype(std::make_tuple(tieHelper(std::get(std::forward(tu)))...)) + auto stripMeta(Tu &&tu, index_sequence) { return std::make_tuple(tieHelper(std::get(std::forward(tu)))...); } // Convert a value tuple to a meta tuple with default metadata template - auto recoverMeta(Tu &&tu, index_sequence) -> decltype(std::make_tuple(tieMetaHelper(std::get(std::forward(tu)))...)) + auto recoverMeta(Tu &&tu, index_sequence) { return std::make_tuple(tieMetaHelper(std::get(std::forward(tu)))...); } @@ -297,7 +297,7 @@ namespace BlackMisc private: template - static auto get_ref(Tu &&tu) -> decltype(tieHelper(std::get(std::forward(tu)))) + static auto get_ref(Tu &&tu) { return tieHelper(std::get(std::forward(tu))); } diff --git a/src/blackmisc/valuecache.h b/src/blackmisc/valuecache.h index 296e99adf..5f7224230 100644 --- a/src/blackmisc/valuecache.h +++ b/src/blackmisc/valuecache.h @@ -191,18 +191,14 @@ namespace BlackMisc //! If the derived class does not handle such requests, the signal can be ignored. void valuesSaveRequested(const BlackMisc::CValueCachePacket &values); - private: - struct Element; // remove forward declaration (and uncomment the one below) when elementsStartingWith uses C++14 auto deduced return type - protected: //! Returns a range referring to all elements which start with the given prefix. - //! \todo Use C++14 auto deduced return type. //! @{ - CRange>::iterator> elementsStartingWith(const QString &keyPrefix) + auto elementsStartingWith(const QString &keyPrefix) { return makeRange(m_elements.lowerBound(keyPrefix), m_elements.lowerBound(keyPrefix + QChar(QChar::LastValidCodePoint))); } - CRange>::const_iterator> elementsStartingWith(const QString &keyPrefix) const + auto elementsStartingWith(const QString &keyPrefix) const { return makeRange(m_elements.lowerBound(keyPrefix), m_elements.lowerBound(keyPrefix + QChar(QChar::LastValidCodePoint))); } @@ -234,7 +230,7 @@ namespace BlackMisc private: friend class Private::CValuePage; - // struct Element; // to be uncommented when the forward declaration above elementsStartingWith is removed + struct Element; using ElementPtr = QSharedPointer; // QMap doesn't support move-only types QMap m_elements;