Require GCC 7 and enable C++17

Fix MSVC2019
- result type of conditional expression is ambiguous:
  types 'const char [1]' and 'QByteArray' can be converted
  to multiple common types

Fix MinGW 8.1
- undefined reference to SemanticHighlightNotification::methodName

Fix Utils::transform with std::vector for GCC & MSVC

Unfortunately we cannot get rid of the special variant and optional
implementations, because Apple Clang requires deployment target >= 10.14
for the functions that can throw std::bad_optional_access.

Fixes: QTCREATORBUG-20520
Change-Id: I5c36a70f21f8b0215d2f4fc5c0653a022778d928
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2020-06-30 15:11:15 +02:00
parent e210bcf3eb
commit d400dce35d
13 changed files with 75 additions and 15 deletions

View File

@@ -32,7 +32,43 @@
See std(::experimental)::optional.
*/
// TODO: replace by #include <(experimental/)optional> depending on compiler and C++ version
// std::optional from Apple's Clang supports methods that throw std::bad_optional_access only
// with deployment target >= macOS 10.14
// TODO: Use std::optional everywhere when we can require macOS 10.14
#if !defined(__apple_build_version__)
#include <optional>
namespace Utils {
using std::optional;
using std::nullopt;
using std::nullopt_t;
using std::in_place;
// make_optional is a copy, since there is no sensible way to import functions in C++
template<class T>
constexpr optional<std::decay_t<T>> make_optional(T &&v)
{
return optional<std::decay_t<T>>(std::forward<T>(v));
}
template<class T, class... Args>
optional<T> make_optional(Args &&... args)
{
return optional<T>(in_place, std::forward<Args>(args)...);
}
template<class T, class Up, class... Args>
constexpr optional<T> make_optional(std::initializer_list<Up> il, Args &&... args)
{
return optional<T>(in_place, il, std::forward<Args>(args)...);
}
} // namespace Utils
#else
#include <3rdparty/optional/optional.hpp>
namespace Utils {
@@ -59,3 +95,5 @@ constexpr optional<X&> make_optional(std::reference_wrapper<X> v)
}
} // Utils
#endif