I am developing with Qt and strongHercul struct has members defined as uint64_t min
and uint64_t max
(I just don't want to use quint64 for this). While trying to overload << operator as below.
QDataStream &operator<<(QDataStream &ds, const strongHercul& hercul)
{
ds << hercul.min << hercul.max;
return ds;
}
QDataStream &operator>>(QDataStream &ds, strongHercul& hercul)
{
ds >> hercul.min >> hercul.max;
return ds;
}
I got following error:
error: ambiguous overload for 'operator<<'
(operand types are 'QDataStream' and 'const uint64_t {aka const long unsigned int}')
data_stream << hercul.min << hercul.max;
^
error: no match for 'operator>>'
(operand types are 'QDataStream' and 'uint64_t {aka long unsigned int}')
data_stream >> hercul.min >> hercul.max;
^
Didn't really understand what's wrong? I assume that might cause 64-bit system that I'm running cause this code works smoothly on 32-bit Windows? The question is how to overload while using uint64_t
?
From the looks of it, QDataStream
doesn't have overloads for uint64_t
. As a result the output operator tries to convert to one of multiple choices, ie, there is an ambiguity and for the input operator a non- const
reference is required and there is no matching operator. You should probably travel in terms of quint64
which seems to be a unsigned long long int
while it seems uint64_t
is a unsigned long int
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.