aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/ptr.h
diff options
context:
space:
mode:
authormowgli <mowgli@yandex-team.ru>2022-02-10 16:49:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:25 +0300
commit89afbbe4ca0e02e386dd4df08f7945f190dc1b84 (patch)
treec4772201af6215d48734691b8796e4cfc77c2ac8 /util/generic/ptr.h
parent7510cec1516d17cbc8d7749974e36aa45f547a26 (diff)
downloadydb-89afbbe4ca0e02e386dd4df08f7945f190dc1b84.tar.gz
Restoring authorship annotation for <mowgli@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/ptr.h')
-rw-r--r--util/generic/ptr.h92
1 files changed, 46 insertions, 46 deletions
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 19db0e3ec5..731930a2ed 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -294,7 +294,7 @@ public:
inline void Reset(TAutoPtr<T, D> t) noexcept {
Reset(t.Release());
}
-
+
inline void Reset() noexcept {
Destroy();
}
@@ -1054,50 +1054,50 @@ private:
T* T_;
};
-// Copy-on-write pointer
+// Copy-on-write pointer
template <class TPtr, class TCopy>
-class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> {
+class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> {
using T = typename TPtr::TValueType;
-public:
+public:
inline TCowPtr() = default;
-
- inline TCowPtr(const TPtr& p)
- : T_(p)
- {
- }
-
- inline TCowPtr(T* p)
- : T_(p)
- {
- }
-
+
+ inline TCowPtr(const TPtr& p)
+ : T_(p)
+ {
+ }
+
+ inline TCowPtr(T* p)
+ : T_(p)
+ {
+ }
+
inline const T* Get() const noexcept {
- return Const();
- }
-
+ return Const();
+ }
+
inline const T* Const() const noexcept {
- return T_.Get();
- }
-
+ return T_.Get();
+ }
+
inline T* Mutable() {
- Unshare();
-
- return T_.Get();
- }
-
+ Unshare();
+
+ return T_.Get();
+ }
+
inline bool Shared() const noexcept {
- return T_.RefCount() > 1;
- }
-
+ return T_.RefCount() > 1;
+ }
+
inline void Swap(TCowPtr& r) noexcept {
- T_.Swap(r.T_);
- }
-
- inline void Reset(TCowPtr p) {
- p.Swap(*this);
- }
-
+ T_.Swap(r.T_);
+ }
+
+ inline void Reset(TCowPtr p) {
+ p.Swap(*this);
+ }
+
inline void Reset() {
T_.Reset();
}
@@ -1108,17 +1108,17 @@ public:
return (p == Get());
}
#endif
-private:
+private:
inline void Unshare() {
- if (Shared()) {
- Reset(TCopy::Copy(T_.Get()));
- }
- }
-
-private:
- TPtr T_;
-};
-
+ if (Shared()) {
+ Reset(TCopy::Copy(T_.Get()));
+ }
+ }
+
+private:
+ TPtr T_;
+};
+
// saves .Get() on argument passing. Intended usage: Func(TPtrArg<X> p); ... TIntrusivePtr<X> p2; Func(p2);
template <class T>
class TPtrArg {