P
Philippe Guglielmetti
I spent hours chasing a stupid bug of this kind:
std::string bad='x'+"yz"; // results in anything except "xyz"
("yz" was in fact returned by some class:perator char*() conversion...)
Any idea on how to prevent this to compile ?
I tried to define an operator+(const char lhs, const char* rhs) that would
fail, but my compiler (VC 7.1) says one of the operands must be a class...
std::string bad='x'+"yz"; // results in anything except "xyz"
("yz" was in fact returned by some class:perator char*() conversion...)
Any idea on how to prevent this to compile ?
I tried to define an operator+(const char lhs, const char* rhs) that would
fail, but my compiler (VC 7.1) says one of the operands must be a class...