diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h')
-rw-r--r-- | contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h index c3906fe1c5..a7879f4d38 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.h @@ -28,29 +28,29 @@ #define ABSL_STRINGS_STRING_VIEW_H_ #include <algorithm> -#include <cassert> -#include <cstddef> -#include <cstring> -#include <iosfwd> -#include <iterator> -#include <limits> -#include <util/generic/string.h> - +#include <cassert> +#include <cstddef> +#include <cstring> +#include <iosfwd> +#include <iterator> +#include <limits> +#include <util/generic/string.h> + #include "y_absl/base/attributes.h" #include "y_absl/base/config.h" -#include "y_absl/base/internal/throw_delegate.h" -#include "y_absl/base/macros.h" -#include "y_absl/base/optimization.h" -#include "y_absl/base/port.h" +#include "y_absl/base/internal/throw_delegate.h" +#include "y_absl/base/macros.h" +#include "y_absl/base/optimization.h" +#include "y_absl/base/port.h" #ifdef ABSL_USES_STD_STRING_VIEW #include <string_view> // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using string_view = std::string_view; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_STRING_VIEW @@ -71,7 +71,7 @@ ABSL_NAMESPACE_END #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // y_absl::string_view // @@ -125,17 +125,17 @@ ABSL_NAMESPACE_BEGIN // provides string_view objects that point to the successive pieces of a Cord // object. // -// When constructed from a source which is NUL-terminated, the `string_view` -// itself will not include the NUL-terminator unless a specific size (including -// the NUL) is passed to the constructor. As a result, common idioms that work -// on NUL-terminated strings do not work on `string_view` objects. If you write +// When constructed from a source which is NUL-terminated, the `string_view` +// itself will not include the NUL-terminator unless a specific size (including +// the NUL) is passed to the constructor. As a result, common idioms that work +// on NUL-terminated strings do not work on `string_view` objects. If you write // code that scans a `string_view`, you must check its length rather than test // for nul, for example. Note, however, that nuls may still be embedded within // a `string_view` explicitly. // // You may create a null `string_view` in two ways: // -// y_absl::string_view sv; +// y_absl::string_view sv; // y_absl::string_view sv(nullptr, 0); // // For the above, `sv.data() == nullptr`, `sv.length() == 0`, and @@ -197,7 +197,7 @@ class string_view { // code bloat. : string_view(str.data(), str.size(), SkipCheckLengthTag{}) {} - // Implicit constructor of a `string_view` from NUL-terminated `str`. When + // Implicit constructor of a `string_view` from NUL-terminated `str`. When // accepting possibly null strings, use `y_absl::NullSafeStringView(str)` // instead (see below). // The length check is skipped since it is unnecessary and causes code bloat. @@ -296,9 +296,9 @@ class string_view { // // Returns the ith element of the `string_view` using the array operator. // Note that this operator does not perform any bounds checking. - constexpr const_reference operator[](size_type i) const { + constexpr const_reference operator[](size_type i) const { return ABSL_HARDENING_ASSERT(i < size()), ptr_[i]; - } + } // string_view::at() // @@ -316,23 +316,23 @@ class string_view { // string_view::front() // // Returns the first element of a `string_view`. - constexpr const_reference front() const { + constexpr const_reference front() const { return ABSL_HARDENING_ASSERT(!empty()), ptr_[0]; - } + } // string_view::back() // // Returns the last element of a `string_view`. - constexpr const_reference back() const { + constexpr const_reference back() const { return ABSL_HARDENING_ASSERT(!empty()), ptr_[size() - 1]; - } + } // string_view::data() // // Returns a pointer to the underlying character array (which is of course // stored elsewhere). Note that `string_view::data()` may contain embedded nul - // characters, but the returned buffer may or may not be NUL-terminated; - // therefore, do not pass `data()` to a routine that expects a NUL-terminated + // characters, but the returned buffer may or may not be NUL-terminated; + // therefore, do not pass `data()` to a routine that expects a NUL-terminated // string. constexpr const_pointer data() const noexcept { return ptr_; } @@ -412,11 +412,11 @@ class string_view { // than `x`, 0 if `*this` is equal to `x`, and a positive value if `*this` // is greater than `x`. constexpr int compare(string_view x) const noexcept { - return CompareImpl(length_, x.length_, - Min(length_, x.length_) == 0 - ? 0 - : ABSL_INTERNAL_STRING_VIEW_MEMCMP( - ptr_, x.ptr_, Min(length_, x.length_))); + return CompareImpl(length_, x.length_, + Min(length_, x.length_) == 0 + ? 0 + : ABSL_INTERNAL_STRING_VIEW_MEMCMP( + ptr_, x.ptr_, Min(length_, x.length_))); } // Overload of `string_view::compare()` for comparing a substring of the @@ -629,15 +629,15 @@ class string_view { #endif } - static constexpr size_t Min(size_type length_a, size_type length_b) { - return length_a < length_b ? length_a : length_b; - } - + static constexpr size_t Min(size_type length_a, size_type length_b) { + return length_a < length_b ? length_a : length_b; + } + static constexpr int CompareImpl(size_type length_a, size_type length_b, int compare_result) { return compare_result == 0 ? static_cast<int>(length_a > length_b) - static_cast<int>(length_a < length_b) - : (compare_result < 0 ? -1 : 1); + : (compare_result < 0 ? -1 : 1); } const char* ptr_; @@ -676,7 +676,7 @@ constexpr bool operator>=(string_view x, string_view y) noexcept { // IO Insertion Operator std::ostream& operator<<(std::ostream& o, string_view piece); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #undef ABSL_INTERNAL_STRING_VIEW_CXX14_CONSTEXPR @@ -685,7 +685,7 @@ ABSL_NAMESPACE_END #endif // ABSL_USES_STD_STRING_VIEW namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ClippedSubstr() // @@ -702,11 +702,11 @@ inline string_view ClippedSubstr(string_view s, size_t pos, // Creates an `y_absl::string_view` from a pointer `p` even if it's null-valued. // This function should be used where an `y_absl::string_view` can be created from // a possibly-null pointer. -constexpr string_view NullSafeStringView(const char* p) { +constexpr string_view NullSafeStringView(const char* p) { return p ? string_view(p) : string_view(); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STRING_VIEW_H_ |