Can't understand return type of qBinaryFind();
-
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.
-
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>
-
@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.
-
No they are not, Qt's containers are implicitly shared which is not the case of the STD containers.