MCPcopy Create free account
hub / github.com/apache/fory / borrow

Method borrow

cpp/fory/util/pool.h:60–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59 template <typename Handler>
60 auto borrow(Handler &&handler)
61 -> decltype(std::forward<Handler>(handler)(std::declval<T &>())) {
62 // Provide a convenient scoped access pattern while guaranteeing the object
63 // is returned even if the handler throws.
64 Ptr item = acquire();
65 using ResultType =
66 decltype(std::forward<Handler>(handler)(std::declval<T &>()));
67 if constexpr (std::is_void_v<ResultType>) {
68 std::forward<Handler>(handler)(*item);
69 return;
70 } else {
71 ResultType result = std::forward<Handler>(handler)(*item);
72 return result;
73 }
74 }
75
76private:
77 std::unique_ptr<T> acquire_raw() {

Callers 8

TESTFunction · 0.80
fory_writeMethod · 0.80
fory_write_dataMethod · 0.80
fory_type_id_dynMethod · 0.80
get_struct_nameFunction · 0.80
is_debug_enabledFunction · 0.80

Calls

no outgoing calls

Tested by 2

TESTFunction · 0.64