diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-09-04 18:45:02 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-09-04 18:45:02 +0000 |
| commit | d3b15e5d989099a6eb47aaa165b13ebca20fa7c0 (patch) | |
| tree | 8938df1222d7f19c3107b7ea114a788e1690f14f /include/llvm/ADT/StringMap.h | |
| parent | f723cfaea47b0555b80b93f3a00fbb4fb08b5302 (diff) | |
| download | external_llvm-d3b15e5d989099a6eb47aaa165b13ebca20fa7c0.zip external_llvm-d3b15e5d989099a6eb47aaa165b13ebca20fa7c0.tar.gz external_llvm-d3b15e5d989099a6eb47aaa165b13ebca20fa7c0.tar.bz2 | |
fix this to work with allocators that have reference type with compilers
that diagnose invalid references to references.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringMap.h')
| -rw-r--r-- | include/llvm/ADT/StringMap.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 59ff6aa..1b20f4f 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -242,6 +242,9 @@ public: }; +template <typename T> struct ReferenceAdder { typedef T& result; }; +template <typename T> struct ReferenceAdder<T&> { typedef T result; }; + /// StringMap - This is an unconventional map that is specialized for handling /// keys that are "strings", which are basically ranges of bytes. This does some /// funky memory allocation and hashing things to make it extremely efficient, @@ -269,9 +272,10 @@ public: clear(); } - - AllocatorTy &getAllocator() { return Allocator; } - const AllocatorTy &getAllocator() const { return Allocator; } + typedef typename ReferenceAdder<AllocatorTy>::result AllocatorRefTy; + typedef typename ReferenceAdder<const AllocatorTy>::result AllocatorCRefTy; + AllocatorRefTy getAllocator() { return Allocator; } + AllocatorCRefTy getAllocator() const { return Allocator; } typedef const char* key_type; typedef ValueTy mapped_type; |
