From bdd105d9787fd8c0402f45e8d071f8d76b020496 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Tue, 26 May 2015 14:24:10 -0700 Subject: Make MapAllocator work with C++11. Change-Id: I0e1d9e248403631cb57ebed5231e85d19b9bb3df --- src/google/protobuf/map.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/google/protobuf/map.h') 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 + void construct(NodeType* p, Args&&... args) { + new (p) NodeType(std::forward(args)...); + } + + template + 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 struct rebind { -- cgit v1.2.3