RE: [Boost-users] Determinism of operator< on shared_ptr
From Peter Dimov
In other words, in the following code i would like to know if is_less will always have the same value or not ?
shared_ptr<int> p1(new int(0)); shared_ptr<int> p2(new int(0)); bool is_less(p1 < p2);
I'm not sure what you are asking. is_less will be either true or false, and it will remain the same value if you don't modify p1 or p2. p2 < p1 will have the opposite value of p1 < p2.
I was not clear, if we consider the following code bool f() { shared_ptr<int> p1(new int(0)); shared_ptr<int> p2(new int(0)); return (p1 < p2); } int main() { // some function calls bool b1(f()); // some other function calls bool b2(f(()); assert(b1 == b2); return 0; } will the assertion be always true (is f() a deterministic function). Thanks, Renaud
Renaud Lepere wrote:
I was not clear, if we consider the following code
bool f() { shared_ptr<int> p1(new int(0)); shared_ptr<int> p2(new int(0)); return (p1 < p2); }
int main() { // some function calls bool b1(f()); // some other function calls bool b2(f(()); assert(b1 == b2); return 0; }
will the assertion be always true (is f() a deterministic function).
No, the assertion is not guaranteed to be true.
participants (2)
-
Peter Dimov
-
Renaud Lepere