aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/map.h
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2015-05-26 14:24:10 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2015-05-26 14:34:53 -0700
commitbdd105d9787fd8c0402f45e8d071f8d76b020496 (patch)
tree216d75e4b70b278c13aa6047fd86500d6465d16a /src/google/protobuf/map.h
parentda0afba8f82d77e112d006eef6bde3754f71365b (diff)
Make MapAllocator work with C++11.
Change-Id: I0e1d9e248403631cb57ebed5231e85d19b9bb3df
Diffstat (limited to 'src/google/protobuf/map.h')
-rw-r--r--src/google/protobuf/map.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index f246dd10..543b45d7 100644
--- a/src/google/protobuf/map.h
+++ b/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 destroy(pointer p) {
if (arena_ == NULL) p->~value_type();
}
+#endif
template <typename X>
struct rebind {