Can't understand return type of qBinaryFind();
-
wrote on 9 Nov 2018, 17:07 last edited by Engelard 11 Sept 2018, 17:08
I read all documentation which concerning this function(all 3 variations), and still can't get why developers did'nt make as return type just vector of ints... I tried as at example, and it gives an error:
P.S. tried to set return value to *uchar as compiler asks, it always return 253 in any case. Confused.
-
wrote on 9 Nov 2018, 18:06 last edited by
I'm guessing that tempByte is a QVector<uchar>. if that is the case then the iterator must be of type QVector<uchar>, not QVector<int>
-
Hi,
In addition to @mranger90, as suggested in the current documentation, you should
use std::binary_search or std::lower_bound instead
. -
I'm guessing that tempByte is a QVector<uchar>. if that is the case then the iterator must be of type QVector<uchar>, not QVector<int>
wrote on 12 Nov 2018, 12:57 last edited by Engelard 11 Dec 2018, 13:09@mranger90 Thanks! Did'nt notice such a small mistake.
@SGaist oh.. but why they went obsolete? What's wrong with those functions?
P.S. still can't understand the point of iterator type, why dont use simple int instead?
-
@mranger90 Thanks! Did'nt notice such a small mistake.
@SGaist oh.. but why they went obsolete? What's wrong with those functions?
P.S. still can't understand the point of iterator type, why dont use simple int instead?
@Engelard said in Can't understand return type of qBinaryFind();:
P.S. still can't understand the point of iterator type, why dont use simple int instead?
Because you can use the iterator as parameter to any other function which expects an iterator.
I guess these functions are deprecated because the standard C++ library now provides same functionality.
-
@jsulm's guess is correct. The goal of Qt is not to duplicate the STD. Since the original functions provided by Qt have been integrated in the STD, there's no reason to keep them hence they are now considered obsolete.
-
@jsulm's guess is correct. The goal of Qt is not to duplicate the STD. Since the original functions provided by Qt have been integrated in the STD, there's no reason to keep them hence they are now considered obsolete.
-
Lifetime Qt Championwrote on 12 Nov 2018, 22:22 last edited by SGaist 11 Dec 2018, 22:22
No they are not, Qt's containers are implicitly shared which is not the case of the STD containers.
6/8