My problem may be related to http://ift.tt/1LPRtHz. But in my case I have const complex types:
class Complex {
public:
int data;
Complex(int i) : data(i) {}
bool operator < (const Complex& other) const { return data < other.data; }
};
class Holder {
public:
Complex data;
Holder(int i) : data(i) {}
operator const Complex&() const { return data; }
};
//...
Holder a(1), b(2);
assert(a < b); //Error
Compiler error in g++ 4.9: no match for ‘operator<’ (operand types are ‘Holder‘ and ‘Holder‘)
Any idear how to fix this?
Btw. I need that conversion to only allow casts to const types.
Aucun commentaire:
Enregistrer un commentaire