summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-05-31 11:31:59 +0200
committerEike Ziller <eike.ziller@qt.io>2018-06-05 12:04:59 +0000
commitf8e88e8ce45a462f27d274c654e31a67032da757 (patch)
treeafc9e80462531ba4852db36533a1787bbf966a1b /src
parent8798990fb1fad04dca8337479e22d17c1fcbfebd (diff)
downloadqt-creator-f8e88e8ce45a462f27d274c654e31a67032da757.tar.gz
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 <tobias.hunger@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/3rdparty/botan/botan.cpp2
-rw-r--r--src/libs/3rdparty/cplusplus/Name.h2
-rw-r--r--src/libs/3rdparty/cplusplus/Names.h2
-rw-r--r--src/libs/glsl/glslengine.h2
-rw-r--r--src/libs/qtcreatorcdbext/containers.cpp2
-rw-r--r--src/libs/qtcreatorcdbext/stringutils.h2
-rw-r--r--src/libs/qtcreatorcdbext/symbolgroup.cpp2
-rw-r--r--src/libs/utils/smallstringview.h4
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp14
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp19
-rw-r--r--src/plugins/texteditor/behaviorsettingswidget.cpp2
-rw-r--r--src/plugins/texteditor/generichighlighter/rule.cpp8
12 files changed, 42 insertions, 19 deletions
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<K, V>& mapping,
* Function adaptor for delete operation
*/
template<class T>
-class del_fun : public std::unary_function<T, void>
+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<const Name *, const Name *, bool> {
+ 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<const TemplateNameId *, const TemplateNameId *, bool> {
+ 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 <typename Type>
class TypeTable
{
public:
- struct Compare: std::binary_function<Type, Type, bool> {
+ 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<const SymbolGroupValue &, SymbolGroupValue>
+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<const std::string &, bool>
+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<unsigned, std::string> InamePathEntry;
-struct InamePathEntryLessThan : public std::binary_function<InamePathEntry, InamePathEntry, bool> {
+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<const String>().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<QByteArray> fullIdForSymbol(CPlusPlus::Symbol *symbol)
namespace {
-class ProcessFile: public std::unary_function<QString, QList<CPlusPlus::Usage> >
+class ProcessFile
{
const WorkingCopy workingCopy;
const CPlusPlus::Snapshot snapshot;
@@ -177,6 +177,10 @@ class ProcessFile: public std::unary_function<QString, QList<CPlusPlus::Usage> >
QFutureInterface<CPlusPlus::Usage> *future;
public:
+ // needed by QtConcurrent
+ using argument_type = const Utils::FileName &;
+ using result_type = QList<CPlusPlus::Usage>;
+
ProcessFile(const WorkingCopy &workingCopy,
const CPlusPlus::Snapshot snapshot,
CPlusPlus::Document::Ptr symbolDocument,
@@ -230,7 +234,7 @@ public:
}
};
-class UpdateUI: public std::binary_function<QList<CPlusPlus::Usage> &, QList<CPlusPlus::Usage>, void>
+class UpdateUI
{
QFutureInterface<CPlusPlus::Usage> *future;
@@ -596,7 +600,7 @@ static void searchFinished(SearchResult *search, QFutureWatcher<CPlusPlus::Usage
namespace {
-class FindMacroUsesInFile: public std::unary_function<QString, QList<CPlusPlus::Usage> >
+class FindMacroUsesInFile
{
const WorkingCopy workingCopy;
const CPlusPlus::Snapshot snapshot;
@@ -604,6 +608,10 @@ class FindMacroUsesInFile: public std::unary_function<QString, QList<CPlusPlus::
QFutureInterface<CPlusPlus::Usage> *future;
public:
+ // needed by QtConcurrent
+ using argument_type = const Utils::FileName &;
+ using result_type = QList<CPlusPlus::Usage>;
+
FindMacroUsesInFile(const WorkingCopy &workingCopy,
const CPlusPlus::Snapshot snapshot,
const CPlusPlus::Macro &macro,
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<QString, QList<FindReferences::Usage> >
+class ProcessFile
{
ContextPtr context;
typedef FindReferences::Usage Usage;
@@ -692,6 +692,10 @@ class ProcessFile: public std::unary_function<QString, QList<FindReferences::Usa
QFutureInterface<Usage> *future;
public:
+ // needed by QtConcurrent
+ using argument_type = const QString &;
+ using result_type = QList<Usage>;
+
ProcessFile(const ContextPtr &context,
QString name,
const ObjectValue *scope,
@@ -721,7 +725,7 @@ public:
}
};
-class SearchFileForType: public std::unary_function<QString, QList<FindReferences::Usage> >
+class SearchFileForType
{
ContextPtr context;
typedef FindReferences::Usage Usage;
@@ -730,6 +734,10 @@ class SearchFileForType: public std::unary_function<QString, QList<FindReference
QFutureInterface<Usage> *future;
public:
+ // needed by QtConcurrent
+ using argument_type = const QString &;
+ using result_type = QList<Usage>;
+
SearchFileForType(const ContextPtr &context,
QString name,
const ObjectValue *scope,
@@ -759,12 +767,17 @@ public:
}
};
-class UpdateUI: public std::binary_function<QList<FindReferences::Usage> &, QList<FindReferences::Usage>, void>
+class UpdateUI
{
typedef FindReferences::Usage Usage;
QFutureInterface<Usage> *future;
public:
+ // needed by QtConcurrent
+ using first_argument_type = QList<Usage> &;
+ using second_argument_type = const QList<Usage> &;
+ using result_type = void;
+
UpdateUI(QFutureInterface<Usage> *future): future(future) {}
void operator()(QList<Usage> &, const QList<Usage> &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<int> mibs = QTextCodec::availableMibs();
Utils::sort(mibs);
QList<int>::iterator firstNonNegative =
- std::find_if(mibs.begin(), mibs.end(), std::bind2nd(std::greater_equal<int>(), 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)