From 37eaae20069cd356d80d034b05eddb234cb21194 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 15 Jun 2016 20:42:30 -0700 Subject: Remove a friend-class template that is only used for the constructor, and instead create an _internal_only getter that gets the needed information. This is a workaround for a deficiency in gcc-4.4 that does not properly support templated friend classes. --- src/google/protobuf/map.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 6f1a71e4..7f4acd0d 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -587,7 +587,7 @@ class Map { explicit MapAllocator(Arena* arena) : arena_(arena) {} template MapAllocator(const MapAllocator& allocator) - : arena_(allocator.arena_) {} + : arena_(allocator.arena_internal_only()) {} pointer allocate(size_type n, const_pointer hint = 0) { // If arena is not given, malloc needs to be called which doesn't @@ -650,12 +650,15 @@ class Map { return std::numeric_limits::max(); } + // To support gcc-4.4, which does not properly + // support templated friend classes + Arena* arena_internal_only() const { + return arena_; + } + private: typedef void DestructorSkippable_; Arena* const arena_; - - template - friend class MapAllocator; }; // InnerMap's key type is Key and its value type is value_type*. We use a -- cgit v1.2.3 From 6daf3d2c4ae612e46c17df693ea9b0ea04c1f079 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 16 Jun 2016 15:43:23 -0700 Subject: Address review comments on function name --- src/google/protobuf/map.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 7f4acd0d..31593c1a 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -587,7 +587,7 @@ class Map { explicit MapAllocator(Arena* arena) : arena_(arena) {} template MapAllocator(const MapAllocator& allocator) - : arena_(allocator.arena_internal_only()) {} + : arena_(allocator.arena()) {} pointer allocate(size_type n, const_pointer hint = 0) { // If arena is not given, malloc needs to be called which doesn't @@ -652,7 +652,7 @@ class Map { // To support gcc-4.4, which does not properly // support templated friend classes - Arena* arena_internal_only() const { + Arena* arena() const { return arena_; } -- cgit v1.2.3