MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / AllocateShared

Function AllocateShared

common/memory.h:995–1016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993
994template <typename T, typename... Args>
995Owned<T> AllocateShared(Allocator<> allocator, Args&&... args) {
996 using U = std::remove_cv_t<T>;
997 static_assert(!std::is_reference_v<U>, "T must not be a reference");
998 static_assert(!std::is_array_v<U>, "T must not be an array");
999
1000 U* object;
1001 Owner owner;
1002 if (google::protobuf::Arena* absl_nullable arena = allocator.arena();
1003 arena != nullptr) {
1004 object = ArenaAllocator(arena).template new_object<U>(
1005 std::forward<Args>(args)...);
1006 owner.ptr_ = reinterpret_cast<uintptr_t>(arena) |
1007 common_internal::kMetadataOwnerArenaBit;
1008 } else {
1009 const common_internal::ReferenceCount* refcount;
1010 std::tie(object, refcount) = common_internal::MakeEmplacedReferenceCount<U>(
1011 std::forward<Args>(args)...);
1012 owner.ptr_ = reinterpret_cast<uintptr_t>(refcount) |
1013 common_internal::kMetadataOwnerReferenceCountBit;
1014 }
1015 return Owned<U>(object, std::move(owner));
1016}
1017
1018template <typename T>
1019Owned<T> WrapShared(T* object, Allocator<> allocator) {

Callers

nothing calls this directly

Calls 2

ArenaAllocatorClass · 0.85
arenaMethod · 0.45

Tested by

no test coverage detected