Silence MSVC warning on constructing QList from initializer_list
MSVC complains because we call Data::allocate(args.size()) and, of course, initializer_list::size() returns unsigned std::size_type, while the relevant Data::allocate() overload takes a signed qsizetype. The constructor from iterators potentially has the same problem, if the iterator type's difference_type is unsigned, so make the type-conversion overt there, too. Pick-to: 6.2 6.5 Change-Id: I521eca26a48aed570855b13242bf2df8bfa38f96 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e0cec08480
commit
3fd7086878
@ -274,7 +274,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline QList(std::initializer_list<T> args)
|
inline QList(std::initializer_list<T> args)
|
||||||
: d(Data::allocate(args.size()))
|
: d(Data::allocate(qsizetype(args.size())))
|
||||||
{
|
{
|
||||||
if (args.size())
|
if (args.size())
|
||||||
d->copyAppend(args.begin(), args.end());
|
d->copyAppend(args.begin(), args.end());
|
||||||
@ -282,7 +282,7 @@ public:
|
|||||||
|
|
||||||
QList<T> &operator=(std::initializer_list<T> args)
|
QList<T> &operator=(std::initializer_list<T> args)
|
||||||
{
|
{
|
||||||
d = DataPointer(Data::allocate(args.size()));
|
d = DataPointer(Data::allocate(qsizetype(args.size())));
|
||||||
if (args.size())
|
if (args.size())
|
||||||
d->copyAppend(args.begin(), args.end());
|
d->copyAppend(args.begin(), args.end());
|
||||||
return *this;
|
return *this;
|
||||||
@ -295,7 +295,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
const auto distance = std::distance(i1, i2);
|
const auto distance = std::distance(i1, i2);
|
||||||
if (distance) {
|
if (distance) {
|
||||||
d = DataPointer(Data::allocate(distance));
|
d = DataPointer(Data::allocate(qsizetype(distance)));
|
||||||
// appendIteratorRange can deal with contiguous iterators on its own,
|
// appendIteratorRange can deal with contiguous iterators on its own,
|
||||||
// this is an optimization for C++17 code.
|
// this is an optimization for C++17 code.
|
||||||
if constexpr (std::is_same_v<std::decay_t<InputIterator>, iterator> ||
|
if constexpr (std::is_same_v<std::decay_t<InputIterator>, iterator> ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user