
2 Nov
2011
2 Nov
'11
5:54 p.m.
On Wed, Nov 2, 2011 at 4:48 PM, Nevin Liber <nevin@eviloverlord.com> wrote:
We tend to be imprecise with (or just plain leave out) those preconditions. Take you example of string and const char*; the following asserts will either sometimes fire or invoke undefined behavior for a given std::string s, const char* p, or string literal l:
assert(s == s.c_str()); assert(std::string(p) == p); assert(std::string(l, sizeof(l) - 1) == l);
For what values does this fail? Isn't the operator== with std::string and const char* well defined? Olaf