Ensure the allocator types in the string keyed tests have value_types matching the...
authorChristopher Dykes <cdykes@fb.com>
Tue, 18 Jul 2017 17:01:30 +0000 (10:01 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 18 Jul 2017 17:05:08 +0000 (10:05 -0700)
Summary:
Because MSVC's standard library implementation is now checking that this is actually the case:
```
error C2338: set<T, Compare, Allocator> requires that Allocator's value_type match T (See N4659 26.2.1 [container.requirements.general]/16 allocator_type) Either fix the allocator value_type or define _ENFORCE_MATCHING_ALLOCATORS=0 to suppress this diagnostic.
```

I've gone with the "Fix the `value_type`" approach.

Reviewed By: yfeldblum

Differential Revision: D5441017

fbshipit-source-id: b30403d2e48f815177cac29c4e6eec4e79583660

folly/experimental/test/StringKeyedTest.cpp

index 3fbcc021f9a907458bd5065f7af7211b4a5b7a4d..1a9a6c41384c3329e88c07d9cb291010a1c10828 100644 (file)
@@ -110,21 +110,22 @@ private:
   Alloc alloc_;
 };
 
-typedef MemoryLeakCheckerAllocator<std::allocator<char>> KeyLeakChecker;
-typedef MemoryLeakCheckerAllocator<
-  std::allocator<std::pair<const StringPiece, int>>> ValueLeakChecker;
+using KeyValuePairLeakChecker = MemoryLeakCheckerAllocator<
+    std::allocator<std::pair<const StringPiece, int>>>;
+using ValueLeakChecker =
+    MemoryLeakCheckerAllocator<std::allocator<StringPiece>>;
 
 typedef StringKeyedUnorderedMap<
     int,
     folly::Hash,
     std::equal_to<StringPiece>,
-    ValueLeakChecker>
+    KeyValuePairLeakChecker>
     LeakCheckedUnorderedMap;
 
 typedef StringKeyedSetBase<std::less<StringPiece>, ValueLeakChecker>
     LeakCheckedSet;
 
-typedef StringKeyedMap<int, std::less<StringPiece>, ValueLeakChecker>
+typedef StringKeyedMap<int, std::less<StringPiece>, KeyValuePairLeakChecker>
     LeakCheckedMap;
 
 using LeakCheckedUnorderedSet = BasicStringKeyedUnorderedSet<