[Interest] >> operator and NoImplicitBoolcast

Tamás Nagy tamas.nagy.001 at gmail.com
Wed Jun 29 21:27:08 CEST 2016


Hi,

I have made a custom QByteArray class with instantiation from QByteArray.
I overrided the << operator:

(1)

template <class T>
MyQByteArray &operator << (const T myParam)
{ ... }

It is working, but the other direction doesn't work at all:

(2)

template <class T>
MyQByteArray &operator >>(T myParam)
{ ... }

Doesn't compile: it tells NoImplicitBoolCast() operator is private in
QByteArray.
Goal is with this direction is to remove the prefix of my array and convert it
to a variable. (with dynamic_cast). But even if funtion bodies are commented,
it doesn't compile.

Usage: (1)   myByteArray << myIntVar;
(2) myByteArray >> myIntVar;  // depackages prefix to an int variable,
but drops error: NoImplicitBoolcast

Tamas



More information about the Interest mailing list