QLatin1/String/View: don't decay the arg() arguments

This turns const char[] arrays into const char* pointers and
therefore prevents the implicit conversion of string literals
to QString in QT_RESTRICTED_CAST_FROM_ASCII.

Fix by avoiding the decay.

Also simplify the template magic.

Change-Id: I88164a1866ac71b41d9cd1564f3a5e83d2d42aaa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ba52b29d336cc32a462306d9011b75e9948c7040)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2022-12-06 14:49:07 +01:00 committed by Qt Cherry-pick Bot
parent 4a68590fb3
commit 92d13e933d

View File

@ -525,14 +525,11 @@ public:
QChar fillChar = u' ') const;
private:
template <typename T>
struct is_convertible_to_view_or_qstring_helper
: std::integral_constant<bool,
std::is_convertible<T, QString>::value ||
std::is_convertible<T, QStringView>::value ||
std::is_convertible<T, QLatin1StringView>::value> {};
template <typename T>
struct is_convertible_to_view_or_qstring
: is_convertible_to_view_or_qstring_helper<typename std::decay<T>::type> {};
using is_convertible_to_view_or_qstring = std::disjunction<
std::is_convertible<T, QString>,
std::is_convertible<T, QStringView>,
std::is_convertible<T, QLatin1StringView>
>;
public:
template <typename...Args>
[[nodiscard]]