diff options
author | Arslan Urtashev <urtashev@gmail.com> | 2022-02-10 16:48:55 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:55 +0300 |
commit | b97740540e7302cec9efa181e106ae1990a0cc1c (patch) | |
tree | 1a2a0bfe523c3272d207e2d75254a41d3945a3bb /util/generic/string.h | |
parent | 31789673dc3562bc7540e00fe031ba84ae282c24 (diff) | |
download | ydb-b97740540e7302cec9efa181e106ae1990a0cc1c.tar.gz |
Restoring authorship annotation for Arslan Urtashev <urtashev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic/string.h')
-rw-r--r-- | util/generic/string.h | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917f..e3e2a4912a0 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -104,20 +104,20 @@ private: }; template <class TStringType> -class TBasicCharRef { -public: +class TBasicCharRef { +public: using TChar = typename TStringType::TChar; - + TBasicCharRef(TStringType& s, size_t pos) : S_(s) , Pos_(pos) { } - - operator TChar() const { - return S_.at(Pos_); - } - + + operator TChar() const { + return S_.at(Pos_); + } + TChar* operator&() { return S_.begin() + Pos_; } @@ -126,14 +126,14 @@ public: return S_.cbegin() + Pos_; } - TBasicCharRef& operator=(TChar c) { + TBasicCharRef& operator=(TChar c) { Y_ASSERT(Pos_ < S_.size() || (Pos_ == S_.size() && !c)); - + S_.Detach()[Pos_] = c; - - return *this; - } - + + return *this; + } + TBasicCharRef& operator=(const TBasicCharRef& other) { return this->operator=(static_cast<TChar>(other)); } @@ -149,12 +149,12 @@ public: */ TBasicCharRef(const TBasicCharRef&) = default; -private: +private: TStringType& S_; - size_t Pos_; -}; + size_t Pos_; +}; #endif - + template <typename TCharType, typename TTraits> class TBasicString: public TStringBase<TBasicString<TCharType, TTraits>, TCharType, TTraits> { public: @@ -252,7 +252,7 @@ public: inline const_reference operator[](size_t pos) const noexcept { Y_ASSERT(pos <= length()); - + return this->data()[pos]; } @@ -264,8 +264,8 @@ public: #else return reference(*this, pos); #endif - } - + } + using TBase::back; inline reference back() noexcept { @@ -468,9 +468,9 @@ public: explicit TBasicString(const reference& c) : TBasicString(&c, 1) { - } + } #endif - + TBasicString(size_t n, TCharType c) #ifdef TSTRING_IS_STD_STRING : Storage_(n, c) |