diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2015-05-26 14:38:10 -0700 |
---|---|---|
committer | Paul Yang <TeBoring@users.noreply.github.com> | 2015-05-26 14:38:10 -0700 |
commit | 850fe8bfc6839eede94f5d3a39be0e55978f0375 (patch) | |
tree | 256a16b82c9e5e910fb5ee94c3d6d0097c77a48a /src | |
parent | 1b540d5729b6e09eafe09261664a5b981761464b (diff) | |
parent | bdd105d9787fd8c0402f45e8d071f8d76b020496 (diff) | |
download | protobuf-850fe8bfc6839eede94f5d3a39be0e55978f0375.tar.gz protobuf-850fe8bfc6839eede94f5d3a39be0e55978f0375.tar.bz2 protobuf-850fe8bfc6839eede94f5d3a39be0e55978f0375.zip |
Merge pull request #430 from xfxyjwf/std11_fix
Make MapAllocator work with C++11.
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/map.h | 12 |
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 { |