diff options
author | Jisi Liu <jisi.liu@gmail.com> | 2016-03-30 11:43:44 -0700 |
---|---|---|
committer | Jisi Liu <jisi.liu@gmail.com> | 2016-03-30 11:43:44 -0700 |
commit | 0de06f54bc8253ba39eee9e8cc4c5de487a48835 (patch) | |
tree | e66dec08e23df554f5c29a1dbb4592388815e4ec /src/google/protobuf/map.h | |
parent | 3b3c8abb9635eb3ea078a821a99c9ef29d66dff7 (diff) | |
parent | a25e9964b126a79e8a99bced2207ddca22d6a1a9 (diff) |
Merge branch 'master' of github.com:google/protobuf
Diffstat (limited to 'src/google/protobuf/map.h')
-rw-r--r-- | src/google/protobuf/map.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index a182abe6..b5f34042 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -608,11 +608,17 @@ class Map { } } -#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ - !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) +#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ + !defined(GOOGLE_PROTOBUF_OS_NACL) && \ + !defined(GOOGLE_PROTOBUF_OS_ANDROID) && \ + !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) template<class NodeType, class... Args> void construct(NodeType* p, Args&&... args) { - new (static_cast<void*>(p)) NodeType(std::forward<Args>(args)...); + // Clang 3.6 doesn't compile static casting to void* directly. (Issue #1266) + // According C++ standard 5.2.9/1: "The static_cast operator shall not cast + // away constness". So first the maybe const pointer is casted to const void* and + // after the const void* is const casted. + new (const_cast<void*>(static_cast<const void*>(p))) NodeType(std::forward<Args>(args)...); } template<class NodeType> |