The following codes related to conditional expression:
typedef unsigned char uchar;
uchar data[100];
// assign something to array[] here
uchar *start = data;
uchar *end = data+100;
bool cond = f(); // f() could return true or false
char *itr = std::upper_bound(start, end, uchar(20),
cond? std::greater<uchar>() : std::less<uchar>());
got an error like this:
error: operands to ?: have different types
‘std::greater<unsigned char>’ and ‘std::less<unsigned char>’
Is this a compiler bug? In my instinct, the two functor should have the same type.
Aucun commentaire:
Enregistrer un commentaire