diff options
| author | vvvv <[email protected]> | 2025-10-08 11:41:14 +0300 |
|---|---|---|
| committer | vvvv <[email protected]> | 2025-10-08 12:20:42 +0300 |
| commit | d73f13cfdb331365ddad0da51ec36e0a3e4cf187 (patch) | |
| tree | 88cab10170ce9aa3389be7f1a09247386dcf5ebd /yql/essentials/public/udf/udf_ptr.h | |
| parent | f377d8ad9e0741cd904c1d4934afdf24af517d93 (diff) | |
YQL-20086 public
commit_hash:68b0c2e9c2960587af7d57ecedcb38f4d05890b7
Diffstat (limited to 'yql/essentials/public/udf/udf_ptr.h')
| -rw-r--r-- | yql/essentials/public/udf/udf_ptr.h | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/yql/essentials/public/udf/udf_ptr.h b/yql/essentials/public/udf/udf_ptr.h index 98945c5f5fe..e0a62ce4d30 100644 --- a/yql/essentials/public/udf/udf_ptr.h +++ b/yql/essentials/public/udf/udf_ptr.h @@ -13,14 +13,13 @@ struct TDelete { delete ptr; } }; -} +} // namespace NDetails /////////////////////////////////////////////////////////////////////////////// // TUniquePtr /////////////////////////////////////////////////////////////////////////////// template <typename T, typename D = NDetails::TDelete> -class TUniquePtr -{ +class TUniquePtr { public: inline TUniquePtr(T* ptr = nullptr) : Ptr_(ptr) @@ -66,15 +65,24 @@ public: rhs.Ptr_ = tmp; } - inline T* Get() const { return Ptr_; } - inline T& operator*() const { return *Ptr_; } - inline T* operator->() const { return Ptr_; } - inline explicit operator bool() const { return Ptr_ != nullptr; } + inline T* Get() const { + return Ptr_; + } + inline T& operator*() const { + return *Ptr_; + } + inline T* operator->() const { + return Ptr_; + } + inline explicit operator bool() const { + return Ptr_ != nullptr; + } private: inline void DoDestroy() { - if (Ptr_) + if (Ptr_) { D::DoDelete(Ptr_); + } } private: @@ -85,8 +93,7 @@ private: // TRefCountedPtr /////////////////////////////////////////////////////////////////////////////// template <class T> -class TDefaultRefCountedPtrOps -{ +class TDefaultRefCountedPtrOps { public: static inline void Ref(T* t) { Y_ASSERT(t); @@ -105,11 +112,14 @@ public: }; template <typename T, typename Ops = TDefaultRefCountedPtrOps<T>> -class TRefCountedPtr -{ +class TRefCountedPtr { public: - enum AddRef { ADD_REF }; - enum StealRef { STEAL_REF }; + enum AddRef { + ADD_REF + }; + enum StealRef { + STEAL_REF + }; public: inline TRefCountedPtr(T* ptr = nullptr) @@ -188,10 +198,18 @@ public: return tmp; } - inline T* Get() const { return Ptr_; } - inline T& operator*() const { return *Ptr_; } - inline T* operator->() const { return Ptr_; } - inline explicit operator bool() const { return Ptr_ != nullptr; } + inline T* Get() const { + return Ptr_; + } + inline T& operator*() const { + return *Ptr_; + } + inline T* operator->() const { + return Ptr_; + } + inline explicit operator bool() const { + return Ptr_ != nullptr; + } inline ui32 RefCount() const { return Ptr_ ? Ops::RefCount(Ptr_) : 0; @@ -199,7 +217,7 @@ public: private: inline void Ref() { - if (Ptr_){ + if (Ptr_) { Ops::Ref(Ptr_); } } @@ -244,5 +262,5 @@ private: UDF_ASSERT_TYPE_SIZE(IRefCounted, 16); -} // namspace NUdf -} // namspace NYql +} // namespace NUdf +} // namespace NYql |
