From f8e88e8ce45a462f27d274c654e31a67032da757 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 31 May 2018 11:31:59 +0200 Subject: Fix compilation issues with C++17 Testable on Linux/macOS by changing c++14 to c++1z in qtcreator.pri. Testable with latest MSVC2017 by setting _CL_=/std:c++17. unary_function, binary_function, and a few other things that were deprecated are removed in C++17. std::string got a non-const overload for its "data" member function, so we cannot create a function pointer on it without specifying its type. Use std::declval instead (though it requires a default constructor for the type). MSVC seems to have an issue with Utils::transform for std::vector (used in Nim plugin), but that looks like a compiler issue. Change-Id: I94f9a93d591d55b610f86fabfc618158927d6221 Reviewed-by: Tobias Hunger --- src/libs/3rdparty/botan/botan.cpp | 2 +- src/libs/3rdparty/cplusplus/Name.h | 2 +- src/libs/3rdparty/cplusplus/Names.h | 2 +- src/libs/glsl/glslengine.h | 2 +- src/libs/qtcreatorcdbext/containers.cpp | 2 +- src/libs/qtcreatorcdbext/stringutils.h | 2 +- src/libs/qtcreatorcdbext/symbolgroup.cpp | 2 +- src/libs/utils/smallstringview.h | 4 +--- src/plugins/cpptools/cppfindreferences.cpp | 14 +++++++++++--- src/plugins/qmljseditor/qmljsfindreferences.cpp | 19 ++++++++++++++++--- src/plugins/texteditor/behaviorsettingswidget.cpp | 2 +- src/plugins/texteditor/generichighlighter/rule.cpp | 8 ++++++-- 12 files changed, 42 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/libs/3rdparty/botan/botan.cpp b/src/libs/3rdparty/botan/botan.cpp index 87736d5fe3..0d912062b3 100644 --- a/src/libs/3rdparty/botan/botan.cpp +++ b/src/libs/3rdparty/botan/botan.cpp @@ -465,7 +465,7 @@ inline V search_map(const std::map& mapping, * Function adaptor for delete operation */ template -class del_fun : public std::unary_function +class del_fun { public: void operator()(T* ptr) { delete ptr; } diff --git a/src/libs/3rdparty/cplusplus/Name.h b/src/libs/3rdparty/cplusplus/Name.h index 200ccac75d..460f0bca11 100644 --- a/src/libs/3rdparty/cplusplus/Name.h +++ b/src/libs/3rdparty/cplusplus/Name.h @@ -59,7 +59,7 @@ public: bool match(const Name *other, Matcher *matcher = 0) const; public: - struct Compare: std::binary_function { + struct Compare { bool operator()(const Name *name, const Name *other) const; }; diff --git a/src/libs/3rdparty/cplusplus/Names.h b/src/libs/3rdparty/cplusplus/Names.h index 41f3e761b4..b8d090da2f 100644 --- a/src/libs/3rdparty/cplusplus/Names.h +++ b/src/libs/3rdparty/cplusplus/Names.h @@ -101,7 +101,7 @@ public: bool isSpecialization() const { return _isSpecialization; } // Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::map) - struct Compare: std::binary_function { + struct Compare { bool operator()(const TemplateNameId *name, const TemplateNameId *other) const; }; diff --git a/src/libs/glsl/glslengine.h b/src/libs/glsl/glslengine.h index 6b126111f6..7cf6e2d164 100644 --- a/src/libs/glsl/glslengine.h +++ b/src/libs/glsl/glslengine.h @@ -71,7 +71,7 @@ template class TypeTable { public: - struct Compare: std::binary_function { + struct Compare { bool operator()(const Type &value, const Type &other) const { return value.isLessThan(&other); } diff --git a/src/libs/qtcreatorcdbext/containers.cpp b/src/libs/qtcreatorcdbext/containers.cpp index 1248fca175..128f450caf 100644 --- a/src/libs/qtcreatorcdbext/containers.cpp +++ b/src/libs/qtcreatorcdbext/containers.cpp @@ -245,7 +245,7 @@ AbstractSymbolGroupNodePtrVector linkedListChildList(SymbolGroupValue headNode, } // Helper function for linkedListChildList that returns a member by name -class MemberByName : public std::unary_function +class MemberByName { public: explicit MemberByName(const char *name) : m_name(name) {} diff --git a/src/libs/qtcreatorcdbext/stringutils.h b/src/libs/qtcreatorcdbext/stringutils.h index 89316d7e9a..e8297d44a4 100644 --- a/src/libs/qtcreatorcdbext/stringutils.h +++ b/src/libs/qtcreatorcdbext/stringutils.h @@ -52,7 +52,7 @@ void split(const std::string &s, char sep, Iterator it) // A boolean predicate that can be used for grepping sequences // of strings for a 'needle' substring. -class SubStringPredicate : public std::unary_function +class SubStringPredicate { public: explicit SubStringPredicate(const char *needle) : m_needle(needle) {} diff --git a/src/libs/qtcreatorcdbext/symbolgroup.cpp b/src/libs/qtcreatorcdbext/symbolgroup.cpp index 5ea3e8930e..52cf5d1645 100644 --- a/src/libs/qtcreatorcdbext/symbolgroup.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroup.cpp @@ -251,7 +251,7 @@ std::string SymbolGroup::debug(const std::string &iname, typedef std::pair InamePathEntry; -struct InamePathEntryLessThan : public std::binary_function { +struct InamePathEntryLessThan bool operator()(const InamePathEntry &i1, const InamePathEntry& i2) const { if (i1.first < i2.first) diff --git a/src/libs/utils/smallstringview.h b/src/libs/utils/smallstringview.h index 0d8600e5de..7881500ce6 100644 --- a/src/libs/utils/smallstringview.h +++ b/src/libs/utils/smallstringview.h @@ -39,9 +39,7 @@ using enable_if_has_char_data_pointer = typename std::enable_if_t< std::is_same< std::remove_const_t< std::remove_pointer_t< - std::result_of_t< - decltype(&String::data)(String) - > + decltype(std::declval().data()) > >, char>::value , int>; diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index d2ae4e9f43..b017cb7e8f 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -168,7 +168,7 @@ static QList fullIdForSymbol(CPlusPlus::Symbol *symbol) namespace { -class ProcessFile: public std::unary_function > +class ProcessFile { const WorkingCopy workingCopy; const CPlusPlus::Snapshot snapshot; @@ -177,6 +177,10 @@ class ProcessFile: public std::unary_function > QFutureInterface *future; public: + // needed by QtConcurrent + using argument_type = const Utils::FileName &; + using result_type = QList; + ProcessFile(const WorkingCopy &workingCopy, const CPlusPlus::Snapshot snapshot, CPlusPlus::Document::Ptr symbolDocument, @@ -230,7 +234,7 @@ public: } }; -class UpdateUI: public std::binary_function &, QList, void> +class UpdateUI { QFutureInterface *future; @@ -596,7 +600,7 @@ static void searchFinished(SearchResult *search, QFutureWatcher > +class FindMacroUsesInFile { const WorkingCopy workingCopy; const CPlusPlus::Snapshot snapshot; @@ -604,6 +608,10 @@ class FindMacroUsesInFile: public std::unary_function *future; public: + // needed by QtConcurrent + using argument_type = const Utils::FileName &; + using result_type = QList; + FindMacroUsesInFile(const WorkingCopy &workingCopy, const CPlusPlus::Snapshot snapshot, const CPlusPlus::Macro ¯o, diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 7806d9c385..af2750de0c 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -683,7 +683,7 @@ static QString matchingLine(unsigned position, const QString &source) return source.mid(start, end - start); } -class ProcessFile: public std::unary_function > +class ProcessFile { ContextPtr context; typedef FindReferences::Usage Usage; @@ -692,6 +692,10 @@ class ProcessFile: public std::unary_function *future; public: + // needed by QtConcurrent + using argument_type = const QString &; + using result_type = QList; + ProcessFile(const ContextPtr &context, QString name, const ObjectValue *scope, @@ -721,7 +725,7 @@ public: } }; -class SearchFileForType: public std::unary_function > +class SearchFileForType { ContextPtr context; typedef FindReferences::Usage Usage; @@ -730,6 +734,10 @@ class SearchFileForType: public std::unary_function *future; public: + // needed by QtConcurrent + using argument_type = const QString &; + using result_type = QList; + SearchFileForType(const ContextPtr &context, QString name, const ObjectValue *scope, @@ -759,12 +767,17 @@ public: } }; -class UpdateUI: public std::binary_function &, QList, void> +class UpdateUI { typedef FindReferences::Usage Usage; QFutureInterface *future; public: + // needed by QtConcurrent + using first_argument_type = QList &; + using second_argument_type = const QList &; + using result_type = void; + UpdateUI(QFutureInterface *future): future(future) {} void operator()(QList &, const QList &usages) diff --git a/src/plugins/texteditor/behaviorsettingswidget.cpp b/src/plugins/texteditor/behaviorsettingswidget.cpp index 718ea5e6e9..65bb8d5717 100644 --- a/src/plugins/texteditor/behaviorsettingswidget.cpp +++ b/src/plugins/texteditor/behaviorsettingswidget.cpp @@ -59,7 +59,7 @@ BehaviorSettingsWidget::BehaviorSettingsWidget(QWidget *parent) QList mibs = QTextCodec::availableMibs(); Utils::sort(mibs); QList::iterator firstNonNegative = - std::find_if(mibs.begin(), mibs.end(), std::bind2nd(std::greater_equal(), 0)); + std::find_if(mibs.begin(), mibs.end(), [](int n) { return n >=0; }); if (firstNonNegative != mibs.end()) std::rotate(mibs.begin(), firstNonNegative, mibs.end()); foreach (int mib, mibs) { diff --git a/src/plugins/texteditor/generichighlighter/rule.cpp b/src/plugins/texteditor/generichighlighter/rule.cpp index 29be2fe6a3..701c6ac459 100644 --- a/src/plugins/texteditor/generichighlighter/rule.cpp +++ b/src/plugins/texteditor/generichighlighter/rule.cpp @@ -144,7 +144,9 @@ bool Rule::charPredicateMatchSucceed(const QString &text, ProgressData *progress, bool (QChar::* predicate)() const) const { - return predicateMatchSucceed(text, length, progress, std::mem_fun_ref(predicate)); + return predicateMatchSucceed(text, length, progress, [predicate](const QChar &c) { + return (c.*predicate)(); + }); } bool Rule::charPredicateMatchSucceed(const QString &text, @@ -152,7 +154,9 @@ bool Rule::charPredicateMatchSucceed(const QString &text, ProgressData *progress, bool (*predicate)(const QChar &)) const { - return predicateMatchSucceed(text, length, progress, std::ptr_fun(predicate)); + return predicateMatchSucceed(text, length, progress, [predicate](const QChar &c) { + return predicate(c); + }); } bool Rule::matchSucceed(const QString &text, const int length, ProgressData *progress) -- cgit v1.2.1