From dc39e377e1a3923e63569020beb29f9662c1a3ee Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 4 Jan 2017 11:31:47 -0800 Subject: Add missing operator<() to CFX_RetainPtr. Use std::less<>() rather than a direct ptr1 < ptr2 comparison to be strictly correct in face of unspecified behaviour when ptr1 and ptr2 don't point within the same "object" (e.g. segment of memory on a brain-dead segmented architecture). This will allow their use as keys in maps. Review-Url: https://codereview.chromium.org/2616683002 --- core/fxcrt/cfx_retain_ptr_unittest.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/fxcrt/cfx_retain_ptr_unittest.cpp') diff --git a/core/fxcrt/cfx_retain_ptr_unittest.cpp b/core/fxcrt/cfx_retain_ptr_unittest.cpp index f9a4ecb74f..3168b5a4c7 100644 --- a/core/fxcrt/cfx_retain_ptr_unittest.cpp +++ b/core/fxcrt/cfx_retain_ptr_unittest.cpp @@ -225,6 +225,14 @@ TEST(fxcrt, RetainPtrNotEquals) { EXPECT_TRUE(obj1_ptr1 != obj2_ptr1); } +TEST(fxcrt, RetainPtrLessThan) { + PseudoRetainable objs[2]; + CFX_RetainPtr obj1_ptr(&objs[0]); + CFX_RetainPtr obj2_ptr(&objs[1]); + EXPECT_TRUE(obj1_ptr < obj2_ptr); + EXPECT_FALSE(obj2_ptr < obj1_ptr); +} + TEST(fxcrt, RetainPtrBool) { PseudoRetainable obj1; CFX_RetainPtr null_ptr; -- cgit v1.2.3