I am writing the following ternary condition in my code:
auto shift =
(auto diff1 = setPositions.back() - setPositions.front()) ==
(auto diff2 = posM - posN) ?
diff1 :
diff1 > diff2 ?
diff2 - (diff1 - diff2) :
diff1 + (diff2 - diff1);
The above code appears within the constructor definition. The class declaration is as given below:
typedef int32_t THIRTY_TWO_BIT_INT;
class setBits{
public:
setBits(THIRTY_TWO_BIT_INT, THIRTY_TWO_BIT_INT,
unsigned short, unsigned short
);
~setBits();
private:
THIRTY_TWO_BIT_INT valA;
THIRTY_TWO_BIT_INT valB;
unsigned short posN;
unsigned short posM;
THIRTY_TWO_BIT_INT result;
vector<int>setPositions;
void calcSetPositions(THIRTY_TWO_BIT_INT&);
THIRTY_TWO_BIT_INT bm;
void calcBitMask();
void remRedSetBits(THIRTY_TWO_BIT_INT&);
};
For the above ternary condition code, I get the following compilation error:
1 In file included from main.cpp:1:
2 ./code.hpp:42:15: error: expected ')'
3 (auto diff1 = setPositions.back() - setPositions.front()) ==
4 ^
5 ./code.hpp:42:9: note: to match this '('
6 (auto diff1 = setPositions.back() - setPositions.front()) ==
7 ^
Can anyone point out the cause of this error?
Aucun commentaire:
Enregistrer un commentaire