diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /util/generic/ptr.h | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/ptr.h')
-rw-r--r-- | util/generic/ptr.h | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec5..221519cb38 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -122,7 +122,7 @@ public: #endif inline explicit operator bool() const noexcept { - return nullptr != AsT(); + return nullptr != AsT(); } protected: @@ -132,7 +132,7 @@ protected: static inline T* DoRelease(T*& t) noexcept { T* ret = t; - t = nullptr; + t = nullptr; return ret; } }; @@ -141,13 +141,13 @@ template <class Base, class T> class TPointerBase: public TPointerCommon<Base, T> { public: inline T& operator*() const noexcept { - Y_ASSERT(this->AsT()); + Y_ASSERT(this->AsT()); return *(this->AsT()); } inline T& operator[](size_t n) const noexcept { - Y_ASSERT(this->AsT()); + Y_ASSERT(this->AsT()); return (this->AsT())[n]; } @@ -253,11 +253,11 @@ public: } template <class U, class = TGuardConversion<T, U>> - inline THolder(TAutoPtr<U, D> t) noexcept - : T_(t.Release()) - { - } - + inline THolder(TAutoPtr<U, D> t) noexcept + : T_(t.Release()) + { + } + inline THolder(THolder&& that) noexcept : T_(that.Release()) { @@ -277,7 +277,7 @@ public: } inline void Destroy() noexcept { - Reset(nullptr); + Reset(nullptr); } inline T* Release() noexcept Y_WARN_UNUSED_RESULT { @@ -379,7 +379,7 @@ public: inline void UnRef(TAtomicBase d) noexcept { auto resultCount = Counter_.Sub(d); - Y_ASSERT(resultCount >= 0); + Y_ASSERT(resultCount >= 0); if (resultCount == 0) { D::Destroy(static_cast<T*>(this)); } @@ -427,7 +427,7 @@ struct TThrRefBase: public TRefCounted<TThrRefBase, TAtomicCounter> { * * @warning Additional care should be taken with regard to inheritance. If used * as a base class, @p T should either declare a virtual destructor, or be - * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T + * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T * would be called, potentially slicing the object and creating memory leaks. * * @note To avoid accidental inheritance when it is not originally intended, @@ -449,31 +449,31 @@ template <class T> class TDefaultIntrusivePtrOps { public: static inline void Ref(T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); t->Ref(); } static inline void UnRef(T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); t->UnRef(); } static inline void DecRef(T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); t->DecRef(); } static inline long RefCount(const T* t) noexcept { - Y_ASSERT(t); + Y_ASSERT(t); return t->RefCount(); } }; -template <class T, class Ops> +template <class T, class Ops> class TIntrusivePtr: public TPointerBase<TIntrusivePtr<T, Ops>, T> { template <class U, class O> friend class TIntrusivePtr; @@ -509,7 +509,7 @@ public: } // NOTE: - // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately + // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately // e.g. // struct A {}; // struct B {}; @@ -611,7 +611,7 @@ struct THash<TIntrusivePtr<T, Ops>>: THash<const T*> { }; // Behaves like TIntrusivePtr but returns const T* to prevent user from accidentally modifying the referenced object. -template <class T, class Ops> +template <class T, class Ops> class TIntrusiveConstPtr: public TPointerBase<TIntrusiveConstPtr<T, Ops>, const T> { public: inline TIntrusiveConstPtr(T* t = nullptr) noexcept // we need a non-const pointer to Ref(), UnRef() and eventually delete it. @@ -683,7 +683,7 @@ public: } inline void Drop() noexcept { - TIntrusiveConstPtr(nullptr).Swap(*this); + TIntrusiveConstPtr(nullptr).Swap(*this); } inline long RefCount() const noexcept { @@ -698,13 +698,13 @@ public: #endif private: inline void Ref() noexcept { - if (T_ != nullptr) { + if (T_ != nullptr) { Ops::Ref(T_); } } inline void UnRef() noexcept { - if (T_ != nullptr) { + if (T_ != nullptr) { Ops::UnRef(T_); } } @@ -773,10 +773,10 @@ private: }; template <class T, class Ops> -typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr; +typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr; template <class T, class Ops> -typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr; +typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr; template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args> [[nodiscard]] TIntrusivePtr<T, Ops> MakeIntrusive(Args&&... args) { @@ -903,7 +903,7 @@ public: private: template <class X> inline void Init(X& t) { - C_ = !!t ? new C(1) : nullptr; + C_ = !!t ? new C(1) : nullptr; T_ = t.Release(); } @@ -968,7 +968,7 @@ public: static inline T* Copy(T* t) { if (t) return t->Clone(); - return nullptr; + return nullptr; } }; @@ -978,7 +978,7 @@ public: static inline T* Copy(T* t) { if (t) return new T(*t); - return nullptr; + return nullptr; } }; @@ -1027,7 +1027,7 @@ public: } inline void Destroy() noexcept { - Reset(nullptr); + Reset(nullptr); } inline void Swap(TCopyPtr& r) noexcept { @@ -1055,7 +1055,7 @@ private: }; // Copy-on-write pointer -template <class TPtr, class TCopy> +template <class TPtr, class TCopy> class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> { using T = typename TPtr::TValueType; |