diff options
author | Chris Kennelly <ckennelly@google.com> | 2017-01-31 13:10:13 -0800 |
---|---|---|
committer | Chris Kennelly <ckennelly@google.com> | 2017-02-15 11:35:24 -0800 |
commit | 0026dff9f6e7fbea541fd293cbf8ebcd254e374d (patch) | |
tree | 56c1af9b7e1ca9da51a61bdcf97e18a50d4252f3 /src/google/protobuf/arena.h | |
parent | 38b14408c5f58737cfa3a5433ef319e90e891702 (diff) |
Expose rvalue setters for repeated string fields.
rvalue setters for scalar string fields were added in #2506.
Diffstat (limited to 'src/google/protobuf/arena.h')
-rw-r--r-- | src/google/protobuf/arena.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 879fd0d3..05e05ebc 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -322,6 +322,17 @@ class LIBPROTOBUF_EXPORT Arena { arg); } } +#if LANG_CXX11 + template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + static T* Create(::google::protobuf::Arena* arena, Arg&& arg) { + if (arena == NULL) { + return new T(std::move(arg)); + } else { + return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value, + std::move(arg)); + } + } +#endif // Version of the above with two constructor arguments for the created object. template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE @@ -662,6 +673,18 @@ class LIBPROTOBUF_EXPORT Arena { return t; } +#if LANG_CXX11 + template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE + T* CreateInternal(bool skip_explicit_ownership, Arg&& arg) { + T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T( + std::move(arg)); + if (!skip_explicit_ownership) { + AddListNode(t, &internal::arena_destruct_object<T>); + } + return t; + } +#endif + template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal( bool skip_explicit_ownership, const Arg1& arg1, const Arg2& arg2) { |