Kaynağa Gözat

Make MapAllocator work with C++11.

Change-Id: I0e1d9e248403631cb57ebed5231e85d19b9bb3df
Feng Xiao 10 yıl önce
ebeveyn
işleme
bdd105d978
1 değiştirilmiş dosya ile 12 ekleme ve 0 silme
  1. 12 0
      src/google/protobuf/map.h

+ 12 - 0
src/google/protobuf/map.h

@@ -167,11 +167,23 @@ class Map {
       }
       }
     }
     }
 
 
+#if __cplusplus >= 201103L
+    template<class NodeType, class... Args>
+    void construct(NodeType* p, Args&&... args) {
+      new (p) NodeType(std::forward<Args>(args)...);
+    }
+
+    template<class NodeType>
+    void destroy(NodeType* p) {
+      if (arena_ == NULL) p->~NodeType();
+    }
+#else
     void construct(pointer p, const_reference t) { new (p) value_type(t); }
     void construct(pointer p, const_reference t) { new (p) value_type(t); }
 
 
     void destroy(pointer p) {
     void destroy(pointer p) {
       if (arena_ == NULL) p->~value_type();
       if (arena_ == NULL) p->~value_type();
     }
     }
+#endif
 
 
     template <typename X>
     template <typename X>
     struct rebind {
     struct rebind {