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.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I88164a1866ac71b41d9cd1564f3a5e83d2d42aaa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2022-12-06 14:49:07 +01:00
parent 67d7d8746c
commit ba52b29d33
1 changed files with 5 additions and 8 deletions

View File

@ -538,14 +538,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]]