Add operator== and operator!= to folly::StlAllocator
authorXiaoyang Gao <xiaoyang@fb.com>
Tue, 7 Aug 2012 01:53:02 +0000 (18:53 -0700)
committerTudor Bosman <tudorb@fb.com>
Wed, 8 Aug 2012 22:40:32 +0000 (15:40 -0700)
Summary: Add operator== and operator!= to folly::StlAllocator, which are required by some other libraries.

Test Plan: Tested by running with recursive_wrapper in boost::variant, and unit tests in folly/test.

Reviewed By: delong.j@fb.com

FB internal diff: D541237

folly/StlAllocator.h

index 5cefb24004bd7c0c7e96e241f66c246a21ffc170..3848343d4b47a2dc580fdf6267e37cc17aeb8c2e 100644 (file)
@@ -116,6 +116,14 @@ class StlAllocator {
     typedef StlAllocator<Alloc, U> other;
   };
 
+  bool operator!=(const StlAllocator<Alloc, T>& other) const {
+    return alloc_ != other.alloc_;
+  }
+
+  bool operator==(const StlAllocator<Alloc, T>& other) const {
+    return alloc_ == other.alloc_;
+  }
+
  private:
   Alloc* alloc_;
 };