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 | |
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')
299 files changed, 7815 insertions, 7815 deletions
diff --git a/contrib/restricted/abseil-cpp-tstring/CONTRIBUTING.md b/contrib/restricted/abseil-cpp-tstring/CONTRIBUTING.md index a252cfac31..8457588d41 100644 --- a/contrib/restricted/abseil-cpp-tstring/CONTRIBUTING.md +++ b/contrib/restricted/abseil-cpp-tstring/CONTRIBUTING.md @@ -123,13 +123,13 @@ will be expected to conform to the style outlined ## Running Tests -If you have [Bazel](https://bazel.build/) installed, use `bazel test ---test_tag_filters="-benchmark" ...` to run the unit tests. +If you have [Bazel](https://bazel.build/) installed, use `bazel test +--test_tag_filters="-benchmark" ...` to run the unit tests. -If you are running the Linux operating system and have -[Docker](https://www.docker.com/) installed, you can also run the `linux_*.sh` -scripts under the `ci/`(https://github.com/abseil/abseil-cpp/tree/master/ci) -directory to test Abseil under a variety of conditions. +If you are running the Linux operating system and have +[Docker](https://www.docker.com/) installed, you can also run the `linux_*.sh` +scripts under the `ci/`(https://github.com/abseil/abseil-cpp/tree/master/ci) +directory to test Abseil under a variety of conditions. ## Abseil Committers diff --git a/contrib/restricted/abseil-cpp-tstring/FAQ.md b/contrib/restricted/abseil-cpp-tstring/FAQ.md index fc2192a89e..2df87867a6 100644 --- a/contrib/restricted/abseil-cpp-tstring/FAQ.md +++ b/contrib/restricted/abseil-cpp-tstring/FAQ.md @@ -1,167 +1,167 @@ -# Abseil FAQ - -## Is Abseil the right home for my utility library? - -Most often the answer to the question is "no." As both the [About -Abseil](https://abseil.io/about/) page and our [contributing -guidelines](https://github.com/abseil/abseil-cpp/blob/master/CONTRIBUTING.md#contribution-guidelines) -explain, Abseil contains a variety of core C++ library code that is widely used -at [Google](https://www.google.com/). As such, Abseil's primary purpose is to be -used as a dependency by Google's open source C++ projects. While we do hope that -Abseil is also useful to the C++ community at large, this added constraint also -means that we are unlikely to accept a contribution of utility code that isn't -already widely used by Google. - -## How to I set the C++ dialect used to build Abseil? - -The short answer is that whatever mechanism you choose, you need to make sure -that you set this option consistently at the global level for your entire -project. If, for example, you want to set the C++ dialect to C++17, with -[Bazel](https://bazel/build/) as the build system and `gcc` or `clang` as the -compiler, there several ways to do this: -* Pass `--cxxopt=-std=c++17` on the command line (for example, `bazel build - --cxxopt=-std=c++17 ...`) -* Set the environment variable `BAZEL_CXXOPTS` (for example, - `BAZEL_CXXOPTS=-std=c++17`) -* Add `build --cxxopt=-std=c++17` to your [`.bazelrc` - file](https://docs.bazel.build/versions/master/guide.html#bazelrc) - -If you are using CMake as the build system, you'll need to add a line like +# Abseil FAQ + +## Is Abseil the right home for my utility library? + +Most often the answer to the question is "no." As both the [About +Abseil](https://abseil.io/about/) page and our [contributing +guidelines](https://github.com/abseil/abseil-cpp/blob/master/CONTRIBUTING.md#contribution-guidelines) +explain, Abseil contains a variety of core C++ library code that is widely used +at [Google](https://www.google.com/). As such, Abseil's primary purpose is to be +used as a dependency by Google's open source C++ projects. While we do hope that +Abseil is also useful to the C++ community at large, this added constraint also +means that we are unlikely to accept a contribution of utility code that isn't +already widely used by Google. + +## How to I set the C++ dialect used to build Abseil? + +The short answer is that whatever mechanism you choose, you need to make sure +that you set this option consistently at the global level for your entire +project. If, for example, you want to set the C++ dialect to C++17, with +[Bazel](https://bazel/build/) as the build system and `gcc` or `clang` as the +compiler, there several ways to do this: +* Pass `--cxxopt=-std=c++17` on the command line (for example, `bazel build + --cxxopt=-std=c++17 ...`) +* Set the environment variable `BAZEL_CXXOPTS` (for example, + `BAZEL_CXXOPTS=-std=c++17`) +* Add `build --cxxopt=-std=c++17` to your [`.bazelrc` + file](https://docs.bazel.build/versions/master/guide.html#bazelrc) + +If you are using CMake as the build system, you'll need to add a line like `set(CMAKE_CXX_STANDARD 17)` to your top level `CMakeLists.txt` file. If you are developing a library designed to be used by other clients, you should instead leave `CMAKE_CXX_STANDARD` unset and configure the minimum C++ standard required by each of your library targets via `target_compile_features`. See the -[CMake build -instructions](https://github.com/abseil/abseil-cpp/blob/master/CMake/README.md) -for more information. - -For a longer answer to this question and to understand why some other approaches -don't work, see the answer to ["What is ABI and why don't you recommend using a -pre-compiled version of -Abseil?"](#what-is-abi-and-why-dont-you-recommend-using-a-pre-compiled-version-of-abseil) - -## What is ABI and why don't you recommend using a pre-compiled version of Abseil? - -For the purposes of this discussion, you can think of -[ABI](https://en.wikipedia.org/wiki/Application_binary_interface) as the -compiled representation of the interfaces in code. This is in contrast to -[API](https://en.wikipedia.org/wiki/Application_programming_interface), which -you can think of as the interfaces as defined by the code itself. [Abseil has a -strong promise of API compatibility, but does not make any promise of ABI -compatibility](https://abseil.io/about/compatibility). Let's take a look at what -this means in practice. - -You might be tempted to do something like this in a -[Bazel](https://bazel.build/) `BUILD` file: - -``` -# DON'T DO THIS!!! -cc_library( - name = "my_library", - srcs = ["my_library.cc"], - copts = ["-std=c++17"], # May create a mixed-mode compile! - deps = ["@com_google_absl//y_absl/strings"], -) -``` - -Applying `-std=c++17` to an individual target in your `BUILD` file is going to -compile that specific target in C++17 mode, but it isn't going to ensure the -Abseil library is built in C++17 mode, since the Abseil library itself is a -different build target. If your code includes an Abseil header, then your -program may contain conflicting definitions of the same -class/function/variable/enum, etc. As a rule, all compile options that affect -the ABI of a program need to be applied to the entire build on a global basis. - -C++ has something called the [One Definition -Rule](https://en.wikipedia.org/wiki/One_Definition_Rule) (ODR). C++ doesn't -allow multiple definitions of the same class/function/variable/enum, etc. ODR -violations sometimes result in linker errors, but linkers do not always catch -violations. Uncaught ODR violations can result in strange runtime behaviors or -crashes that can be hard to debug. - -If you build the Abseil library and your code using different compile options -that affect ABI, there is a good chance you will run afoul of the One Definition -Rule. Examples of GCC compile options that affect ABI include (but aren't -limited to) language dialect (e.g. `-std=`), optimization level (e.g. `-O2`), -code generation flags (e.g. `-fexceptions`), and preprocessor defines -(e.g. `-DNDEBUG`). - -If you use a pre-compiled version of Abseil, (for example, from your Linux -distribution package manager or from something like -[vcpkg](https://github.com/microsoft/vcpkg)) you have to be very careful to -ensure ABI compatibility across the components of your program. The only way you -can be sure your program is going to be correct regarding ABI is to ensure -you've used the exact same compile options as were used to build the -pre-compiled library. This does not mean that Abseil cannot work as part of a -Linux distribution since a knowledgeable binary packager will have ensured that -all packages have been built with consistent compile options. This is one of the -reasons we warn against - though do not outright reject - using Abseil as a -pre-compiled library. - -Another possible way that you might afoul of ABI issues is if you accidentally -include two versions of Abseil in your program. Multiple versions of Abseil can -end up within the same binary if your program uses the Abseil library and -another library also transitively depends on Abseil (resulting in what is -sometimes called the diamond dependency problem). In cases such as this you must -structure your build so that all libraries use the same version of Abseil. -[Abseil's strong promise of API compatibility between -releases](https://abseil.io/about/compatibility) means the latest "HEAD" release -of Abseil is almost certainly the right choice if you are doing as we recommend -and building all of your code from source. - -For these reasons we recommend you avoid pre-compiled code and build the Abseil -library yourself in a consistent manner with the rest of your code. - -## What is "live at head" and how do I do it? - -From Abseil's point-of-view, "live at head" means that every Abseil source -release (which happens on an almost daily basis) is either API compatible with -the previous release, or comes with an automated tool that you can run over code -to make it compatible. In practice, the need to use an automated tool is -extremely rare. This means that upgrading from one source release to another -should be a routine practice that can and should be performed often. - -We recommend you update to the [latest commit in the `master` branch of -Abseil](https://github.com/abseil/abseil-cpp/commits/master) as often as -possible. Not only will you pick up bug fixes more quickly, but if you have good -automated testing, you will catch and be able to fix any [Hyrum's -Law](https://www.hyrumslaw.com/) dependency problems on an incremental basis -instead of being overwhelmed by them and having difficulty isolating them if you -wait longer between updates. - -If you are using the [Bazel](https://bazel.build/) build system and its -[external dependencies](https://docs.bazel.build/versions/master/external.html) -feature, updating the -[`http_archive`](https://docs.bazel.build/versions/master/repo/http.html#http_archive) -rule in your -[`WORKSPACE`](https://docs.bazel.build/versions/master/be/workspace.html) for -`com_google_abseil` to point to the [latest commit in the `master` branch of -Abseil](https://github.com/abseil/abseil-cpp/commits/master) is all you need to -do. For example, on February 11, 2020, the latest commit to the master branch -was `98eb410c93ad059f9bba1bf43f5bb916fc92a5ea`. To update to this commit, you -would add the following snippet to your `WORKSPACE` file: - -``` -http_archive( - name = "com_google_absl", - urls = ["https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip"], # 2020-02-11T18:50:53Z - strip_prefix = "abseil-cpp-98eb410c93ad059f9bba1bf43f5bb916fc92a5ea", - sha256 = "aabf6c57e3834f8dc3873a927f37eaf69975d4b28117fc7427dfb1c661542a87", -) -``` - -To get the `sha256` of this URL, run `curl -sL --output - -https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip -| sha256sum -`. - -You can commit the updated `WORKSPACE` file to your source control every time -you update, and if you have good automated testing, you might even consider -automating this. - -One thing we don't recommend is using GitHub's `master.zip` files (for example -[https://github.com/abseil/abseil-cpp/archive/master.zip](https://github.com/abseil/abseil-cpp/archive/master.zip)), -which are always the latest commit in the `master` branch, to implement live at -head. Since these `master.zip` URLs are not versioned, you will lose build -reproducibility. In addition, some build systems, including Bazel, will simply -cache this file, which means you won't actually be updating to the latest -release until your cache is cleared or invalidated. +[CMake build +instructions](https://github.com/abseil/abseil-cpp/blob/master/CMake/README.md) +for more information. + +For a longer answer to this question and to understand why some other approaches +don't work, see the answer to ["What is ABI and why don't you recommend using a +pre-compiled version of +Abseil?"](#what-is-abi-and-why-dont-you-recommend-using-a-pre-compiled-version-of-abseil) + +## What is ABI and why don't you recommend using a pre-compiled version of Abseil? + +For the purposes of this discussion, you can think of +[ABI](https://en.wikipedia.org/wiki/Application_binary_interface) as the +compiled representation of the interfaces in code. This is in contrast to +[API](https://en.wikipedia.org/wiki/Application_programming_interface), which +you can think of as the interfaces as defined by the code itself. [Abseil has a +strong promise of API compatibility, but does not make any promise of ABI +compatibility](https://abseil.io/about/compatibility). Let's take a look at what +this means in practice. + +You might be tempted to do something like this in a +[Bazel](https://bazel.build/) `BUILD` file: + +``` +# DON'T DO THIS!!! +cc_library( + name = "my_library", + srcs = ["my_library.cc"], + copts = ["-std=c++17"], # May create a mixed-mode compile! + deps = ["@com_google_absl//y_absl/strings"], +) +``` + +Applying `-std=c++17` to an individual target in your `BUILD` file is going to +compile that specific target in C++17 mode, but it isn't going to ensure the +Abseil library is built in C++17 mode, since the Abseil library itself is a +different build target. If your code includes an Abseil header, then your +program may contain conflicting definitions of the same +class/function/variable/enum, etc. As a rule, all compile options that affect +the ABI of a program need to be applied to the entire build on a global basis. + +C++ has something called the [One Definition +Rule](https://en.wikipedia.org/wiki/One_Definition_Rule) (ODR). C++ doesn't +allow multiple definitions of the same class/function/variable/enum, etc. ODR +violations sometimes result in linker errors, but linkers do not always catch +violations. Uncaught ODR violations can result in strange runtime behaviors or +crashes that can be hard to debug. + +If you build the Abseil library and your code using different compile options +that affect ABI, there is a good chance you will run afoul of the One Definition +Rule. Examples of GCC compile options that affect ABI include (but aren't +limited to) language dialect (e.g. `-std=`), optimization level (e.g. `-O2`), +code generation flags (e.g. `-fexceptions`), and preprocessor defines +(e.g. `-DNDEBUG`). + +If you use a pre-compiled version of Abseil, (for example, from your Linux +distribution package manager or from something like +[vcpkg](https://github.com/microsoft/vcpkg)) you have to be very careful to +ensure ABI compatibility across the components of your program. The only way you +can be sure your program is going to be correct regarding ABI is to ensure +you've used the exact same compile options as were used to build the +pre-compiled library. This does not mean that Abseil cannot work as part of a +Linux distribution since a knowledgeable binary packager will have ensured that +all packages have been built with consistent compile options. This is one of the +reasons we warn against - though do not outright reject - using Abseil as a +pre-compiled library. + +Another possible way that you might afoul of ABI issues is if you accidentally +include two versions of Abseil in your program. Multiple versions of Abseil can +end up within the same binary if your program uses the Abseil library and +another library also transitively depends on Abseil (resulting in what is +sometimes called the diamond dependency problem). In cases such as this you must +structure your build so that all libraries use the same version of Abseil. +[Abseil's strong promise of API compatibility between +releases](https://abseil.io/about/compatibility) means the latest "HEAD" release +of Abseil is almost certainly the right choice if you are doing as we recommend +and building all of your code from source. + +For these reasons we recommend you avoid pre-compiled code and build the Abseil +library yourself in a consistent manner with the rest of your code. + +## What is "live at head" and how do I do it? + +From Abseil's point-of-view, "live at head" means that every Abseil source +release (which happens on an almost daily basis) is either API compatible with +the previous release, or comes with an automated tool that you can run over code +to make it compatible. In practice, the need to use an automated tool is +extremely rare. This means that upgrading from one source release to another +should be a routine practice that can and should be performed often. + +We recommend you update to the [latest commit in the `master` branch of +Abseil](https://github.com/abseil/abseil-cpp/commits/master) as often as +possible. Not only will you pick up bug fixes more quickly, but if you have good +automated testing, you will catch and be able to fix any [Hyrum's +Law](https://www.hyrumslaw.com/) dependency problems on an incremental basis +instead of being overwhelmed by them and having difficulty isolating them if you +wait longer between updates. + +If you are using the [Bazel](https://bazel.build/) build system and its +[external dependencies](https://docs.bazel.build/versions/master/external.html) +feature, updating the +[`http_archive`](https://docs.bazel.build/versions/master/repo/http.html#http_archive) +rule in your +[`WORKSPACE`](https://docs.bazel.build/versions/master/be/workspace.html) for +`com_google_abseil` to point to the [latest commit in the `master` branch of +Abseil](https://github.com/abseil/abseil-cpp/commits/master) is all you need to +do. For example, on February 11, 2020, the latest commit to the master branch +was `98eb410c93ad059f9bba1bf43f5bb916fc92a5ea`. To update to this commit, you +would add the following snippet to your `WORKSPACE` file: + +``` +http_archive( + name = "com_google_absl", + urls = ["https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip"], # 2020-02-11T18:50:53Z + strip_prefix = "abseil-cpp-98eb410c93ad059f9bba1bf43f5bb916fc92a5ea", + sha256 = "aabf6c57e3834f8dc3873a927f37eaf69975d4b28117fc7427dfb1c661542a87", +) +``` + +To get the `sha256` of this URL, run `curl -sL --output - +https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip +| sha256sum -`. + +You can commit the updated `WORKSPACE` file to your source control every time +you update, and if you have good automated testing, you might even consider +automating this. + +One thing we don't recommend is using GitHub's `master.zip` files (for example +[https://github.com/abseil/abseil-cpp/archive/master.zip](https://github.com/abseil/abseil-cpp/archive/master.zip)), +which are always the latest commit in the `master` branch, to implement live at +head. Since these `master.zip` URLs are not versioned, you will lose build +reproducibility. In addition, some build systems, including Bazel, will simply +cache this file, which means you won't actually be updating to the latest +release until your cache is cleared or invalidated. diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/algorithm.h b/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/algorithm.h index b1003bd0a9..db8ae6f835 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/algorithm.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/algorithm.h @@ -26,10 +26,10 @@ #include <iterator> #include <type_traits> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace algorithm_internal { @@ -153,7 +153,7 @@ ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator>()); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_ALGORITHM_ALGORITHM_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/container.h b/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/container.h index d6bf385964..1b5080aa70 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/container.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/algorithm/container.h @@ -55,7 +55,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_algorithm_internal { // NOTE: it is important to defer to ADL lookup for building with C++ modules, @@ -269,8 +269,8 @@ container_algorithm_internal::ContainerIter<Sequence1> c_find_end( // c_find_first_of() // // Container-based version of the <algorithm> `std::find_first_of()` function to -// find the first element within the container that is also within the options -// container. +// find the first element within the container that is also within the options +// container. template <typename C1, typename C2> container_algorithm_internal::ContainerIter<C1> c_find_first_of(C1& container, C2& options) { @@ -1768,7 +1768,7 @@ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first, output_first, std::forward<BinaryOp>(op)); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_ALGORITHM_CONTAINER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/attributes.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/attributes.h index 8321acda51..17f7a7f956 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/attributes.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/attributes.h @@ -555,9 +555,9 @@ // ABSL_ATTRIBUTE_PACKED // -// Instructs the compiler not to use natural alignment for a tagged data +// Instructs the compiler not to use natural alignment for a tagged data // structure, but instead to reduce its alignment to 1. -// +// // Therefore, DO NOT APPLY THIS ATTRIBUTE TO STRUCTS CONTAINING ATOMICS. Doing // so can cause atomic variables to be mis-aligned and silently violate // atomicity on x86. @@ -570,10 +570,10 @@ // structure. Instead, apply this attribute only to structure members that need // it. // -// When applying ABSL_ATTRIBUTE_PACKED only to specific structure members the -// natural alignment of structure members not annotated is preserved. Aligned -// member accesses are faster than non-aligned member accesses even if the -// targeted microprocessor supports non-aligned accesses. +// When applying ABSL_ATTRIBUTE_PACKED only to specific structure members the +// natural alignment of structure members not annotated is preserved. Aligned +// member accesses are faster than non-aligned member accesses even if the +// targeted microprocessor supports non-aligned accesses. #if ABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__)) #define ABSL_ATTRIBUTE_PACKED __attribute__((__packed__)) #else diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/call_once.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/call_once.h index 5d80e4e7ca..7adec8b0a4 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/call_once.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/call_once.h @@ -41,7 +41,7 @@ #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class once_flag; @@ -213,7 +213,7 @@ void call_once(y_absl::once_flag& flag, Callable&& fn, Args&&... args) { } } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_CALL_ONCE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/casts.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/casts.h index 6270ede21e..417961d5c9 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/casts.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/casts.h @@ -34,7 +34,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace internal_casts { @@ -181,7 +181,7 @@ inline Dest bit_cast(const Source& source) { return dest; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_CASTS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h index 162843aa00..4ff163154e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/config.h @@ -95,76 +95,76 @@ #define ABSL_LTS_RELEASE_VERSION 20211102 #define ABSL_LTS_RELEASE_PATCH_LEVEL 0 -// Helper macro to convert a CPP variable to a string literal. -#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x -#define ABSL_INTERNAL_TOKEN_STR(x) ABSL_INTERNAL_DO_TOKEN_STR(x) - -// ----------------------------------------------------------------------------- -// Abseil namespace annotations +// Helper macro to convert a CPP variable to a string literal. +#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x +#define ABSL_INTERNAL_TOKEN_STR(x) ABSL_INTERNAL_DO_TOKEN_STR(x) + // ----------------------------------------------------------------------------- - -// ABSL_NAMESPACE_BEGIN/ABSL_NAMESPACE_END -// -// An annotation placed at the beginning/end of each `namespace y_absl` scope. -// This is used to inject an inline namespace. -// -// The proper way to write Abseil code in the `y_absl` namespace is: -// -// namespace y_absl { -// ABSL_NAMESPACE_BEGIN -// -// void Foo(); // y_absl::Foo(). -// -// ABSL_NAMESPACE_END -// } // namespace y_absl -// -// Users of Abseil should not use these macros, because users of Abseil should -// not write `namespace y_absl {` in their own code for any reason. (Abseil does -// not support forward declarations of its own types, nor does it support -// user-provided specialization of Abseil templates. Code that violates these -// rules may be broken without warning.) -#if !defined(ABSL_OPTION_USE_INLINE_NAMESPACE) || \ - !defined(ABSL_OPTION_INLINE_NAMESPACE_NAME) -#error options.h is misconfigured. -#endif - -// Check that ABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" -#if defined(__cplusplus) && ABSL_OPTION_USE_INLINE_NAMESPACE == 1 - -#define ABSL_INTERNAL_INLINE_NAMESPACE_STR \ - ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) - -static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', - "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " - "not be empty."); -static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || - ABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', - "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " - "be changed to a new, unique identifier name."); - -#endif - -#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define ABSL_NAMESPACE_BEGIN -#define ABSL_NAMESPACE_END +// Abseil namespace annotations +// ----------------------------------------------------------------------------- + +// ABSL_NAMESPACE_BEGIN/ABSL_NAMESPACE_END +// +// An annotation placed at the beginning/end of each `namespace y_absl` scope. +// This is used to inject an inline namespace. +// +// The proper way to write Abseil code in the `y_absl` namespace is: +// +// namespace y_absl { +// ABSL_NAMESPACE_BEGIN +// +// void Foo(); // y_absl::Foo(). +// +// ABSL_NAMESPACE_END +// } // namespace y_absl +// +// Users of Abseil should not use these macros, because users of Abseil should +// not write `namespace y_absl {` in their own code for any reason. (Abseil does +// not support forward declarations of its own types, nor does it support +// user-provided specialization of Abseil templates. Code that violates these +// rules may be broken without warning.) +#if !defined(ABSL_OPTION_USE_INLINE_NAMESPACE) || \ + !defined(ABSL_OPTION_INLINE_NAMESPACE_NAME) +#error options.h is misconfigured. +#endif + +// Check that ABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor "" +#if defined(__cplusplus) && ABSL_OPTION_USE_INLINE_NAMESPACE == 1 + +#define ABSL_INTERNAL_INLINE_NAMESPACE_STR \ + ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) + +static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', + "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " + "not be empty."); +static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || + ABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', + "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must " + "be changed to a new, unique identifier name."); + +#endif + +#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 +#define ABSL_NAMESPACE_BEGIN +#define ABSL_NAMESPACE_END #define ABSL_INTERNAL_C_SYMBOL(x) x -#elif ABSL_OPTION_USE_INLINE_NAMESPACE == 1 -#define ABSL_NAMESPACE_BEGIN \ - inline namespace ABSL_OPTION_INLINE_NAMESPACE_NAME { -#define ABSL_NAMESPACE_END } +#elif ABSL_OPTION_USE_INLINE_NAMESPACE == 1 +#define ABSL_NAMESPACE_BEGIN \ + inline namespace ABSL_OPTION_INLINE_NAMESPACE_NAME { +#define ABSL_NAMESPACE_END } #define ABSL_INTERNAL_C_SYMBOL_HELPER_2(x, v) x##_##v #define ABSL_INTERNAL_C_SYMBOL_HELPER_1(x, v) \ ABSL_INTERNAL_C_SYMBOL_HELPER_2(x, v) #define ABSL_INTERNAL_C_SYMBOL(x) \ ABSL_INTERNAL_C_SYMBOL_HELPER_1(x, ABSL_OPTION_INLINE_NAMESPACE_NAME) -#else -#error options.h is misconfigured. -#endif - -// ----------------------------------------------------------------------------- +#else +#error options.h is misconfigured. +#endif + +// ----------------------------------------------------------------------------- // Compiler Feature Checks // ----------------------------------------------------------------------------- @@ -365,13 +365,13 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || #ifdef ABSL_HAVE_EXCEPTIONS #error ABSL_HAVE_EXCEPTIONS cannot be directly set. #elif ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(3, 6) -// Clang >= 3.6 +// Clang >= 3.6 #if ABSL_HAVE_FEATURE(cxx_exceptions) -#define ABSL_HAVE_EXCEPTIONS 1 +#define ABSL_HAVE_EXCEPTIONS 1 #endif // ABSL_HAVE_FEATURE(cxx_exceptions) #elif defined(__clang__) -// Clang < 3.6 -// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro +// Clang < 3.6 +// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro #if defined(__EXCEPTIONS) && ABSL_HAVE_FEATURE(cxx_exceptions) #define ABSL_HAVE_EXCEPTIONS 1 #endif // defined(__EXCEPTIONS) && ABSL_HAVE_FEATURE(cxx_exceptions) @@ -678,49 +678,49 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || #define ABSL_INTERNAL_MSVC_2017_DBG_MODE #endif -// ABSL_INTERNAL_MANGLED_NS -// ABSL_INTERNAL_MANGLED_BACKREFERENCE -// -// Internal macros for building up mangled names in our internal fork of CCTZ. -// This implementation detail is only needed and provided for the MSVC build. -// -// These macros both expand to string literals. ABSL_INTERNAL_MANGLED_NS is -// the mangled spelling of the `y_absl` namespace, and -// ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing -// the proper count to skip past the CCTZ fork namespace names. (This number -// is one larger when there is an inline namespace name to skip.) -#if defined(_MSC_VER) -#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 -#define ABSL_INTERNAL_MANGLED_NS "y_absl" -#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "5" -#else -#define ABSL_INTERNAL_MANGLED_NS \ - ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) "@y_absl" -#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "6" -#endif -#endif - +// ABSL_INTERNAL_MANGLED_NS +// ABSL_INTERNAL_MANGLED_BACKREFERENCE +// +// Internal macros for building up mangled names in our internal fork of CCTZ. +// This implementation detail is only needed and provided for the MSVC build. +// +// These macros both expand to string literals. ABSL_INTERNAL_MANGLED_NS is +// the mangled spelling of the `y_absl` namespace, and +// ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing +// the proper count to skip past the CCTZ fork namespace names. (This number +// is one larger when there is an inline namespace name to skip.) +#if defined(_MSC_VER) +#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0 +#define ABSL_INTERNAL_MANGLED_NS "y_absl" +#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "5" +#else +#define ABSL_INTERNAL_MANGLED_NS \ + ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) "@y_absl" +#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "6" +#endif +#endif + #undef ABSL_INTERNAL_HAS_KEYWORD -// ABSL_DLL -// -// When building Abseil as a DLL, this macro expands to `__declspec(dllexport)` -// so we can annotate symbols appropriately as being exported. When used in -// headers consuming a DLL, this macro expands to `__declspec(dllimport)` so -// that consumers know the symbol is defined inside the DLL. In all other cases, -// the macro expands to nothing. -#if defined(_MSC_VER) -#if defined(ABSL_BUILD_DLL) -#define ABSL_DLL __declspec(dllexport) -#elif defined(ABSL_CONSUME_DLL) -#define ABSL_DLL __declspec(dllimport) -#else -#define ABSL_DLL -#endif -#else -#define ABSL_DLL -#endif // defined(_MSC_VER) - +// ABSL_DLL +// +// When building Abseil as a DLL, this macro expands to `__declspec(dllexport)` +// so we can annotate symbols appropriately as being exported. When used in +// headers consuming a DLL, this macro expands to `__declspec(dllimport)` so +// that consumers know the symbol is defined inside the DLL. In all other cases, +// the macro expands to nothing. +#if defined(_MSC_VER) +#if defined(ABSL_BUILD_DLL) +#define ABSL_DLL __declspec(dllexport) +#elif defined(ABSL_CONSUME_DLL) +#define ABSL_DLL __declspec(dllimport) +#else +#define ABSL_DLL +#endif +#else +#define ABSL_DLL +#endif // defined(_MSC_VER) + // ABSL_HAVE_MEMORY_SANITIZER // // MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/const_init.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/const_init.h index 4bab055dda..3e2c1478b5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/const_init.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/const_init.h @@ -22,8 +22,8 @@ #ifndef ABSL_BASE_CONST_INIT_H_ #define ABSL_BASE_CONST_INIT_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + // In general, objects with static storage duration (such as global variables) // can trigger tricky object lifetime situations. Attempting to access them // from the constructors or destructors of other global objects can result in @@ -64,13 +64,13 @@ // or thread_local storage duration. namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN enum ConstInitType { kConstInit, }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_CONST_INIT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook.h index 5bdf360a57..2cd11ffe50 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook.h @@ -20,37 +20,37 @@ #include <cstdint> #include <utility> -#include "y_absl/base/attributes.h" -#include "y_absl/base/config.h" - -#if defined(_MSC_VER) && !defined(__clang__) +#include "y_absl/base/attributes.h" +#include "y_absl/base/config.h" + +#if defined(_MSC_VER) && !defined(__clang__) #define ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT 0 #else #define ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT 1 #endif -#if defined(_MSC_VER) -#define ABSL_HAVE_WORKING_ATOMIC_POINTER 0 -#else -#define ABSL_HAVE_WORKING_ATOMIC_POINTER 1 -#endif - +#if defined(_MSC_VER) +#define ABSL_HAVE_WORKING_ATOMIC_POINTER 0 +#else +#define ABSL_HAVE_WORKING_ATOMIC_POINTER 1 +#endif + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { template <typename T> class AtomicHook; -// To workaround AtomicHook not being constant-initializable on some platforms, -// prefer to annotate instances with `ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES` -// instead of `ABSL_CONST_INIT`. -#if ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT -#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_CONST_INIT -#else -#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES -#endif - +// To workaround AtomicHook not being constant-initializable on some platforms, +// prefer to annotate instances with `ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES` +// instead of `ABSL_CONST_INIT`. +#if ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT +#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_CONST_INIT +#else +#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES +#endif + // `AtomicHook` is a helper class, templatized on a raw function pointer type, // for implementing Abseil customization hooks. It is a callable object that // dispatches to the registered hook. Objects of type `AtomicHook` must have @@ -59,11 +59,11 @@ class AtomicHook; // A default constructed object performs a no-op (and returns a default // constructed object) if no hook has been registered. // -// Hooks can be pre-registered via constant initialization, for example: -// -// ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static AtomicHook<void(*)()> -// my_hook(DefaultAction); -// +// Hooks can be pre-registered via constant initialization, for example: +// +// ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static AtomicHook<void(*)()> +// my_hook(DefaultAction); +// // and then changed at runtime via a call to `Store()`. // // Reads and writes guarantee memory_order_acquire/memory_order_release @@ -82,15 +82,15 @@ class AtomicHook<ReturnType (*)(Args...)> { #if ABSL_HAVE_WORKING_ATOMIC_POINTER && ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT explicit constexpr AtomicHook(FnPtr default_fn) : hook_(default_fn), default_fn_(default_fn) {} -#elif ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT - explicit constexpr AtomicHook(FnPtr default_fn) - : hook_(kUninitialized), default_fn_(default_fn) {} +#elif ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT + explicit constexpr AtomicHook(FnPtr default_fn) + : hook_(kUninitialized), default_fn_(default_fn) {} #else - // As of January 2020, on all known versions of MSVC this constructor runs in - // the global constructor sequence. If `Store()` is called by a dynamic - // initializer, we want to preserve the value, even if this constructor runs - // after the call to `Store()`. If not, `hook_` will be - // zero-initialized by the linker and we have no need to set it. + // As of January 2020, on all known versions of MSVC this constructor runs in + // the global constructor sequence. If `Store()` is called by a dynamic + // initializer, we want to preserve the value, even if this constructor runs + // after the call to `Store()`. If not, `hook_` will be + // zero-initialized by the linker and we have no need to set it. // https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html explicit constexpr AtomicHook(FnPtr default_fn) : /* hook_(deliberately omitted), */ default_fn_(default_fn) { @@ -194,7 +194,7 @@ class AtomicHook<ReturnType (*)(Args...)> { #undef ABSL_HAVE_WORKING_CONSTEXPR_STATIC_INIT } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook_test_helper.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook_test_helper.h index e600d27f4f..6513eca501 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook_test_helper.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/atomic_hook_test_helper.h @@ -18,7 +18,7 @@ #include "y_absl/base/internal/atomic_hook.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace atomic_hook_internal { using VoidF = void (*)(); @@ -28,7 +28,7 @@ void DefaultFunc(); void RegisterFunc(VoidF func); } // namespace atomic_hook_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_ATOMIC_HOOK_TEST_HELPER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.cc index 6b43f7c184..e46b951260 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.cc @@ -28,7 +28,7 @@ #include "y_absl/base/internal/unscaledcycleclock.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { #if ABSL_USE_UNSCALED_CYCLECLOCK @@ -103,5 +103,5 @@ double CycleClock::Frequency() { #endif } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.h index 389c9093e3..46bed6b951 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/cycleclock.h @@ -44,10 +44,10 @@ #include <cstdint> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // ----------------------------------------------------------------------------- @@ -88,7 +88,7 @@ class CycleClockSource { }; } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/direct_mmap.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/direct_mmap.h index 82be9f94ab..aadaccad6e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/direct_mmap.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/direct_mmap.h @@ -66,7 +66,7 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t); #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // Platform specific logic extracted from @@ -137,7 +137,7 @@ inline int DirectMunmap(void* start, size_t length) { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // !__linux__ @@ -146,7 +146,7 @@ ABSL_NAMESPACE_END // actual mmap()/munmap() methods. namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, @@ -159,7 +159,7 @@ inline int DirectMunmap(void* start, size_t length) { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // __linux__ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/endian.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/endian.h index 0f7adb8bf6..65cf71300d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/endian.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/endian.h @@ -32,7 +32,7 @@ #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Use compiler byte-swapping intrinsics if they are available. 32-bit // and 64-bit versions are available in Clang and GCC as of GCC 4.3.0. @@ -321,7 +321,7 @@ inline void Store64(void *p, uint64_t v) { } // namespace big_endian -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_ENDIAN_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/errno_saver.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/errno_saver.h index 94202a4ed6..a44b415223 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/errno_saver.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/errno_saver.h @@ -1,43 +1,43 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ -#define ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ - -#include <cerrno> - -#include "y_absl/base/config.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace base_internal { - -// `ErrnoSaver` captures the value of `errno` upon construction and restores it -// upon deletion. It is used in low-level code and must be super fast. Do not -// add instrumentation, even in debug modes. -class ErrnoSaver { - public: - ErrnoSaver() : saved_errno_(errno) {} - ~ErrnoSaver() { errno = saved_errno_; } - int operator()() const { return saved_errno_; } - - private: - const int saved_errno_; -}; - -} // namespace base_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ +#define ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ + +#include <cerrno> + +#include "y_absl/base/config.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { + +// `ErrnoSaver` captures the value of `errno` upon construction and restores it +// upon deletion. It is used in low-level code and must be super fast. Do not +// add instrumentation, even in debug modes. +class ErrnoSaver { + public: + ErrnoSaver() : saved_errno_(errno) {} + ~ErrnoSaver() { errno = saved_errno_; } + int operator()() const { return saved_errno_; } + + private: + const int saved_errno_; +}; + +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_BASE_INTERNAL_ERRNO_SAVER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/exception_safety_testing.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/exception_safety_testing.h index 3009f17875..b1b9bac53e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/exception_safety_testing.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/exception_safety_testing.h @@ -26,7 +26,7 @@ #include <functional> #include <initializer_list> #include <iosfwd> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <tuple> #include <unordered_map> diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/hide_ptr.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/hide_ptr.h index ccdad25cb7..365bf1d1ef 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/hide_ptr.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/hide_ptr.h @@ -17,10 +17,10 @@ #include <cstdint> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // Arbitrary value with high bits set. Xor'ing with it is unlikely @@ -45,7 +45,7 @@ inline T* UnhidePtr(uintptr_t hidden) { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/identity.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/identity.h index 2360afeed2..22c5defeb4 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/identity.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/identity.h @@ -16,10 +16,10 @@ #ifndef ABSL_BASE_INTERNAL_IDENTITY_H_ #define ABSL_BASE_INTERNAL_IDENTITY_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace internal { template <typename T> @@ -31,7 +31,7 @@ template <typename T> using identity_t = typename identity<T>::type; } // namespace internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_IDENTITY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/inline_variable_testing.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/inline_variable_testing.h index 190e74e643..6aded482a7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/inline_variable_testing.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/inline_variable_testing.h @@ -18,7 +18,7 @@ #include "y_absl/base/internal/inline_variable.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace inline_variable_testing_internal { struct Foo { @@ -40,7 +40,7 @@ const int& get_int_a(); const int& get_int_b(); } // namespace inline_variable_testing_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INLINE_VARIABLE_TESTING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/invoke.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/invoke.h index 928666ff44..9d448c122a 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/invoke.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/invoke.h @@ -45,7 +45,7 @@ // top of this file for the API documentation. namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // The five classes below each implement one of the clauses from the definition @@ -181,7 +181,7 @@ invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) { std::forward<Args>(args)...); } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_INVOKE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.cc index 0c477d1b28..8d14f06bf7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.cc @@ -63,7 +63,7 @@ #endif // __APPLE__ namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // A first-fit allocator with amortized logarithmic free() time. @@ -223,14 +223,14 @@ namespace { // Static storage space for the lazily-constructed, default global arena // instances. We require this space because the whole point of LowLevelAlloc // is to avoid relying on malloc/new. -alignas(LowLevelAlloc::Arena) unsigned char default_arena_storage[sizeof( - LowLevelAlloc::Arena)]; -alignas(LowLevelAlloc::Arena) unsigned char unhooked_arena_storage[sizeof( - LowLevelAlloc::Arena)]; +alignas(LowLevelAlloc::Arena) unsigned char default_arena_storage[sizeof( + LowLevelAlloc::Arena)]; +alignas(LowLevelAlloc::Arena) unsigned char unhooked_arena_storage[sizeof( + LowLevelAlloc::Arena)]; #ifndef ABSL_LOW_LEVEL_ALLOC_ASYNC_SIGNAL_SAFE_MISSING -alignas( - LowLevelAlloc::Arena) unsigned char unhooked_async_sig_safe_arena_storage - [sizeof(LowLevelAlloc::Arena)]; +alignas( + LowLevelAlloc::Arena) unsigned char unhooked_async_sig_safe_arena_storage + [sizeof(LowLevelAlloc::Arena)]; #endif // We must use LowLevelCallOnce here to construct the global arenas, rather than @@ -614,7 +614,7 @@ void *LowLevelAlloc::AllocWithArena(size_t request, Arena *arena) { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_LOW_LEVEL_ALLOC_MISSING diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.h index fa109d53ec..38df41fe80 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc.h @@ -55,7 +55,7 @@ #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { class LowLevelAlloc { @@ -120,7 +120,7 @@ class LowLevelAlloc { }; } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_ALLOC_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc/ya.make index fabba74677..46233b8ae4 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc/ya.make @@ -18,9 +18,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_scheduling.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_scheduling.h index 61eb4ac643..6aa0857def 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_scheduling.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_scheduling.h @@ -29,7 +29,7 @@ extern "C" bool __google_disable_rescheduling(void); extern "C" void __google_enable_rescheduling(bool disable_result); namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class CondVar; class Mutex; @@ -128,7 +128,7 @@ inline SchedulingGuard::ScopedEnable::~ScopedEnable() { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.cc index ea9a48c2c0..51a67591e8 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.cc @@ -37,8 +37,8 @@ // this, consider moving both to config.h instead. #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__Fuchsia__) || defined(__native_client__) || \ - defined(__EMSCRIPTEN__) || defined(__ASYLO__) - + defined(__EMSCRIPTEN__) || defined(__ASYLO__) + #include <unistd.h> #define ABSL_HAVE_POSIX_WRITE 1 @@ -226,8 +226,8 @@ bool RawLoggingFullySupported() { } ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL - y_absl::base_internal::AtomicHook<InternalLogFunction> - internal_log_function(DefaultInternalLog); + y_absl::base_internal::AtomicHook<InternalLogFunction> + internal_log_function(DefaultInternalLog); void RegisterLogPrefixHook(LogPrefixHook func) { log_prefix_hook.Store(func); } @@ -238,5 +238,5 @@ void RegisterInternalLogFunction(InternalLogFunction func) { } } // namespace raw_logging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.h index 4d5c77003f..b3cab648ca 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging.h @@ -19,14 +19,14 @@ #ifndef ABSL_BASE_INTERNAL_RAW_LOGGING_H_ #define ABSL_BASE_INTERNAL_RAW_LOGGING_H_ -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/attributes.h" -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/base/internal/atomic_hook.h" #include "y_absl/base/log_severity.h" #include "y_absl/base/macros.h" -#include "y_absl/base/optimization.h" +#include "y_absl/base/optimization.h" #include "y_absl/base/port.h" // This is similar to LOG(severity) << format..., but @@ -99,7 +99,7 @@ ::y_absl::NormalizeLogSeverity(severity) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace raw_logging_internal { // Helper function to implement ABSL_RAW_LOG @@ -160,7 +160,7 @@ using LogPrefixHook = bool (*)(y_absl::LogSeverity severity, const char* file, // // 'file' and 'line' are the file and line number where the ABSL_RAW_LOG macro // was located. -// The NUL-terminated logged message lives in the buffer between 'buf_start' +// The NUL-terminated logged message lives in the buffer between 'buf_start' // and 'buf_end'. 'prefix_end' points to the first non-prefix character of the // buffer (as written by the LogPrefixHook.) using AbortHook = void (*)(const char* file, int line, const char* buf_start, @@ -175,8 +175,8 @@ using InternalLogFunction = void (*)(y_absl::LogSeverity severity, const TString& message); ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL extern base_internal::AtomicHook< - InternalLogFunction> - internal_log_function; + InternalLogFunction> + internal_log_function; // Registers hooks of the above types. Only a single hook of each type may be // registered. It is an error to call these functions multiple times with @@ -189,7 +189,7 @@ void RegisterAbortHook(AbortHook func); void RegisterInternalLogFunction(InternalLogFunction func); } // namespace raw_logging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_RAW_LOGGING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging/ya.make index e7cfe7d216..fbc5a826ef 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging/ya.make @@ -15,9 +15,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scheduling_mode.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scheduling_mode.h index 0165e7233b..d1f9133434 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scheduling_mode.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scheduling_mode.h @@ -18,10 +18,10 @@ #ifndef ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ #define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // Used to describe how a thread may be scheduled. Typically associated with @@ -52,7 +52,7 @@ enum SchedulingMode { }; } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.cc index e489272b45..35870b2493 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.cc @@ -23,7 +23,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -77,5 +77,5 @@ ScopedSetEnv::~ScopedSetEnv() { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.h index 5641562f1b..57435a21ad 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/scoped_set_env.h @@ -19,10 +19,10 @@ #include <util/generic/string.h> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { class ScopedSetEnv { @@ -39,7 +39,7 @@ class ScopedSetEnv { }; } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_SCOPED_SET_ENV_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.cc index 2ee7cde432..1de45b9558 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.cc @@ -54,11 +54,11 @@ // holder to acquire the lock. There may be outstanding waiter(s). namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { -ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static base_internal::AtomicHook<void (*)( - const void *lock, int64_t wait_cycles)> +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static base_internal::AtomicHook<void (*)( + const void *lock, int64_t wait_cycles)> submit_profile_data; void RegisterSpinLockProfiler(void (*fn)(const void *contendedlock, @@ -225,5 +225,5 @@ uint64_t SpinLock::DecodeWaitCycles(uint32_t lock_value) { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.h index ef88cb52c0..2d456621eb 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock.h @@ -46,7 +46,7 @@ #include "y_absl/base/thread_annotations.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { class ABSL_LOCKABLE SpinLock { @@ -242,7 +242,7 @@ inline uint32_t SpinLock::TryLockInternal(uint32_t lock_value, } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_SPINLOCK_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_linux.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_linux.inc index 5b4480d133..f3a3f2b53c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_linux.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_linux.inc @@ -24,7 +24,7 @@ #include <ctime> #include "y_absl/base/attributes.h" -#include "y_absl/base/internal/errno_saver.h" +#include "y_absl/base/internal/errno_saver.h" // The SpinLock lockword is `std::atomic<uint32_t>`. Here we assert that // `std::atomic<uint32_t>` is bitwise equivalent of the `int` expected @@ -59,7 +59,7 @@ extern "C" { ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)( std::atomic<uint32_t> *w, uint32_t value, int loop, y_absl::base_internal::SchedulingMode) { - y_absl::base_internal::ErrnoSaver errno_saver; + y_absl::base_internal::ErrnoSaver errno_saver; struct timespec tm; tm.tv_sec = 0; tm.tv_nsec = y_absl::base_internal::SpinLockSuggestedDelayNS(loop); diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_posix.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_posix.inc index 12a9b86599..ed21a2cf37 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_posix.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_posix.inc @@ -15,11 +15,11 @@ // This file is a Posix-specific part of spinlock_wait.cc #include <sched.h> - + #include <atomic> #include <ctime> -#include "y_absl/base/internal/errno_saver.h" +#include "y_absl/base/internal/errno_saver.h" #include "y_absl/base/internal/scheduling_mode.h" #include "y_absl/base/port.h" @@ -28,7 +28,7 @@ extern "C" { ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)( std::atomic<uint32_t>* /* lock_word */, uint32_t /* value */, int loop, y_absl::base_internal::SchedulingMode /* mode */) { - y_absl::base_internal::ErrnoSaver errno_saver; + y_absl::base_internal::ErrnoSaver errno_saver; if (loop == 0) { } else if (loop == 1) { sched_yield(); diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.cc index 138cb3c5f0..7ee8f82bf5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.cc @@ -32,7 +32,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // See spinlock_wait.h for spec. @@ -77,5 +77,5 @@ int SpinLockSuggestedDelayNS(int loop) { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.h index 2e34d7026b..cd1daea675 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait.h @@ -24,7 +24,7 @@ #include "y_absl/base/internal/scheduling_mode.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // SpinLockWait() waits until it can perform one of several transitions from @@ -63,7 +63,7 @@ void SpinLockDelay(std::atomic<uint32_t> *w, uint32_t value, int loop, int SpinLockSuggestedDelayNS(int loop); } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // In some build configurations we pass --detect-odr-violations to the diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait/ya.make index 902ffe394f..571ff7a134 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc index 9eb0cf3f8c..8dbe6c3d41 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc @@ -58,7 +58,7 @@ #include "y_absl/base/thread_annotations.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { namespace { @@ -150,23 +150,23 @@ static double GetNominalCPUFrequency() { // API informing about CPU nominal frequency. return 1.0; #else -#pragma comment(lib, "advapi32.lib") // For Reg* functions. - HKEY key; - // Use the Reg* functions rather than the SH functions because shlwapi.dll - // pulls in gdi32.dll which makes process destruction much more costly. - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, - KEY_READ, &key) == ERROR_SUCCESS) { - DWORD type = 0; - DWORD data = 0; - DWORD data_size = sizeof(data); - auto result = RegQueryValueExA(key, "~MHz", 0, &type, - reinterpret_cast<LPBYTE>(&data), &data_size); - RegCloseKey(key); - if (result == ERROR_SUCCESS && type == REG_DWORD && - data_size == sizeof(data)) { - return data * 1e6; // Value is MHz. - } +#pragma comment(lib, "advapi32.lib") // For Reg* functions. + HKEY key; + // Use the Reg* functions rather than the SH functions because shlwapi.dll + // pulls in gdi32.dll which makes process destruction much more costly. + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + KEY_READ, &key) == ERROR_SUCCESS) { + DWORD type = 0; + DWORD data = 0; + DWORD data_size = sizeof(data); + auto result = RegQueryValueExA(key, "~MHz", 0, &type, + reinterpret_cast<LPBYTE>(&data), &data_size); + RegCloseKey(key); + if (result == ERROR_SUCCESS && type == REG_DWORD && + data_size == sizeof(data)) { + return data * 1e6; // Value is MHz. + } } return 1.0; #endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP @@ -340,34 +340,34 @@ static double GetNominalCPUFrequency() { #endif -ABSL_CONST_INIT static once_flag init_num_cpus_once; -ABSL_CONST_INIT static int num_cpus = 0; +ABSL_CONST_INIT static once_flag init_num_cpus_once; +ABSL_CONST_INIT static int num_cpus = 0; -// NumCPUs() may be called before main() and before malloc is properly -// initialized, therefore this must not allocate memory. +// NumCPUs() may be called before main() and before malloc is properly +// initialized, therefore this must not allocate memory. int NumCPUs() { - base_internal::LowLevelCallOnce( - &init_num_cpus_once, []() { num_cpus = GetNumCPUs(); }); + base_internal::LowLevelCallOnce( + &init_num_cpus_once, []() { num_cpus = GetNumCPUs(); }); return num_cpus; } -// A default frequency of 0.0 might be dangerous if it is used in division. -ABSL_CONST_INIT static once_flag init_nominal_cpu_frequency_once; -ABSL_CONST_INIT static double nominal_cpu_frequency = 1.0; - -// NominalCPUFrequency() may be called before main() and before malloc is -// properly initialized, therefore this must not allocate memory. +// A default frequency of 0.0 might be dangerous if it is used in division. +ABSL_CONST_INIT static once_flag init_nominal_cpu_frequency_once; +ABSL_CONST_INIT static double nominal_cpu_frequency = 1.0; + +// NominalCPUFrequency() may be called before main() and before malloc is +// properly initialized, therefore this must not allocate memory. double NominalCPUFrequency() { - base_internal::LowLevelCallOnce( - &init_nominal_cpu_frequency_once, - []() { nominal_cpu_frequency = GetNominalCPUFrequency(); }); + base_internal::LowLevelCallOnce( + &init_nominal_cpu_frequency_once, + []() { nominal_cpu_frequency = GetNominalCPUFrequency(); }); return nominal_cpu_frequency; } #if defined(_WIN32) pid_t GetTID() { - return pid_t{GetCurrentThreadId()}; + return pid_t{GetCurrentThreadId()}; } #elif defined(__linux__) @@ -504,5 +504,5 @@ pid_t GetCachedTID() { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.h index 0fd7207a38..b5e01a601c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.h @@ -28,13 +28,13 @@ #include <sys/types.h> #endif -#include <cstdint> - +#include <cstdint> + #include "y_absl/base/config.h" #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // Nominal core processor cycles per second of each processor. This is _not_ @@ -53,10 +53,10 @@ int NumCPUs(); // On Linux, you may send a signal to the resulting ID with kill(). However, // it is recommended for portability that you use pthread_kill() instead. #ifdef _WIN32 -// On Windows, process id and thread id are of the same type according to the -// return types of GetProcessId() and GetThreadId() are both DWORD, an unsigned -// 32-bit type. -using pid_t = uint32_t; +// On Windows, process id and thread id are of the same type according to the +// return types of GetProcessId() and GetThreadId() are both DWORD, an unsigned +// 32-bit type. +using pid_t = uint32_t; #endif pid_t GetTID(); @@ -68,7 +68,7 @@ pid_t GetTID(); pid_t GetCachedTID(); } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_SYSINFO_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.cc index b5e88ae302..f95c0eb00f 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.cc @@ -29,7 +29,7 @@ #include "y_absl/base/internal/spinlock.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { #if ABSL_THREAD_IDENTITY_MODE != ABSL_THREAD_IDENTITY_MODE_USE_CPP11 @@ -59,12 +59,12 @@ void AllocateThreadIdentityKey(ThreadIdentityReclaimerFunction reclaimer) { #if ABSL_HAVE_ATTRIBUTE(visibility) && !defined(__APPLE__) __attribute__((visibility("protected"))) #endif // ABSL_HAVE_ATTRIBUTE(visibility) && !defined(__APPLE__) -#if ABSL_PER_THREAD_TLS -// Prefer __thread to thread_local as benchmarks indicate it is a bit faster. -ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* thread_identity_ptr = nullptr; -#elif defined(ABSL_HAVE_THREAD_LOCAL) -thread_local ThreadIdentity* thread_identity_ptr = nullptr; -#endif // ABSL_PER_THREAD_TLS +#if ABSL_PER_THREAD_TLS +// Prefer __thread to thread_local as benchmarks indicate it is a bit faster. +ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* thread_identity_ptr = nullptr; +#elif defined(ABSL_HAVE_THREAD_LOCAL) +thread_local ThreadIdentity* thread_identity_ptr = nullptr; +#endif // ABSL_PER_THREAD_TLS #endif // TLS or CPP11 void SetCurrentThreadIdentity( @@ -78,8 +78,8 @@ void SetCurrentThreadIdentity( y_absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey, reclaimer); -#if defined(__EMSCRIPTEN__) || defined(__MINGW32__) - // Emscripten and MinGW pthread implementations does not support signals. +#if defined(__EMSCRIPTEN__) || defined(__MINGW32__) + // Emscripten and MinGW pthread implementations does not support signals. // See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html // for more information. pthread_setspecific(thread_identity_pthread_key, @@ -98,7 +98,7 @@ void SetCurrentThreadIdentity( pthread_setspecific(thread_identity_pthread_key, reinterpret_cast<void*>(identity)); pthread_sigmask(SIG_SETMASK, &curr_signals, nullptr); -#endif // !__EMSCRIPTEN__ && !__MINGW32__ +#endif // !__EMSCRIPTEN__ && !__MINGW32__ #elif ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS // NOTE: Not async-safe. But can be open-coded. @@ -116,18 +116,18 @@ void SetCurrentThreadIdentity( #endif } -#if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ - ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 - -// Please see the comment on `CurrentThreadIdentityIfPresent` in +#if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ + ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 + +// Please see the comment on `CurrentThreadIdentityIfPresent` in // thread_identity.h. When we cannot expose thread_local variables in // headers, we opt for the correct-but-slower option of not inlining this // function. #ifndef ABSL_INTERNAL_INLINE_CURRENT_THREAD_IDENTITY_IF_PRESENT -ThreadIdentity* CurrentThreadIdentityIfPresent() { return thread_identity_ptr; } -#endif -#endif - +ThreadIdentity* CurrentThreadIdentityIfPresent() { return thread_identity_ptr; } +#endif +#endif + void ClearCurrentThreadIdentity() { #if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 @@ -151,5 +151,5 @@ ThreadIdentity* CurrentThreadIdentityIfPresent() { #endif } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.h index 09a6c0bce1..21db0703b2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/thread_identity.h @@ -30,12 +30,12 @@ #include <atomic> #include <cstdint> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/base/internal/per_thread_tls.h" #include "y_absl/base/optimization.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN struct SynchLocksHeld; struct SynchWaitParams; @@ -209,7 +209,7 @@ void ClearCurrentThreadIdentity(); #error ABSL_THREAD_IDENTITY_MODE cannot be directly set #elif defined(ABSL_FORCE_THREAD_IDENTITY_MODE) #define ABSL_THREAD_IDENTITY_MODE ABSL_FORCE_THREAD_IDENTITY_MODE -#elif defined(_WIN32) && !defined(__MINGW32__) +#elif defined(_WIN32) && !defined(__MINGW32__) #define ABSL_THREAD_IDENTITY_MODE ABSL_THREAD_IDENTITY_MODE_USE_CPP11 #elif defined(__APPLE__) && defined(ABSL_HAVE_THREAD_LOCAL) #define ABSL_THREAD_IDENTITY_MODE ABSL_THREAD_IDENTITY_MODE_USE_CPP11 @@ -227,20 +227,20 @@ void ClearCurrentThreadIdentity(); #if ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS || \ ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11 -#if ABSL_PER_THREAD_TLS -ABSL_CONST_INIT extern ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* - thread_identity_ptr; -#elif defined(ABSL_HAVE_THREAD_LOCAL) -ABSL_CONST_INIT extern thread_local ThreadIdentity* thread_identity_ptr; -#else -#error Thread-local storage not detected on this platform -#endif +#if ABSL_PER_THREAD_TLS +ABSL_CONST_INIT extern ABSL_PER_THREAD_TLS_KEYWORD ThreadIdentity* + thread_identity_ptr; +#elif defined(ABSL_HAVE_THREAD_LOCAL) +ABSL_CONST_INIT extern thread_local ThreadIdentity* thread_identity_ptr; +#else +#error Thread-local storage not detected on this platform +#endif // thread_local variables cannot be in headers exposed by DLLs or in certain // build configurations on Apple platforms. However, it is important for // performance reasons in general that `CurrentThreadIdentityIfPresent` be // inlined. In the other cases we opt to have the function not be inlined. Note -// that `CurrentThreadIdentityIfPresent` is declared above so we can exclude +// that `CurrentThreadIdentityIfPresent` is declared above so we can exclude // this entire inline definition. #if !defined(__APPLE__) && !defined(ABSL_BUILD_DLL) && \ !defined(ABSL_CONSUME_DLL) @@ -251,7 +251,7 @@ ABSL_CONST_INIT extern thread_local ThreadIdentity* thread_identity_ptr; inline ThreadIdentity* CurrentThreadIdentityIfPresent() { return thread_identity_ptr; } -#endif +#endif #elif ABSL_THREAD_IDENTITY_MODE != \ ABSL_THREAD_IDENTITY_MODE_USE_POSIX_SETSPECIFIC @@ -259,7 +259,7 @@ inline ThreadIdentity* CurrentThreadIdentityIfPresent() { #endif } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.cc index dcce5aedc3..ec07412b68 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.cc @@ -23,7 +23,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // NOTE: The various STL exception throwing functions are placed within the @@ -208,5 +208,5 @@ void ThrowStdBadAlloc() { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.h index fda03a5db3..facc81c022 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate.h @@ -19,10 +19,10 @@ #include <util/generic/string.h> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // Helper functions that allow throwing exceptions consistently from anywhere. @@ -69,7 +69,7 @@ namespace base_internal { // [[noreturn]] void ThrowStdBadArrayNewLength(); } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate/ya.make index 1b956ad494..01baf424a9 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate/ya.make @@ -16,9 +16,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unaligned_access.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unaligned_access.h index 7dbb23b1de..3bcaeabc62 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unaligned_access.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unaligned_access.h @@ -18,11 +18,11 @@ #define ABSL_BASE_INTERNAL_UNALIGNED_ACCESS_H_ #include <string.h> - + #include <cstdint> #include "y_absl/base/attributes.h" -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" // unaligned APIs @@ -32,7 +32,7 @@ // (namespaces, inline) which are absent or incompatible in C. #if defined(__cplusplus) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { inline uint16_t UnalignedLoad16(const void *p) { @@ -60,7 +60,7 @@ inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); } inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.cc index 072a9852fa..4bbbc2621b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.cc @@ -21,18 +21,18 @@ #endif #if defined(__powerpc__) || defined(__ppc__) -#ifdef __GLIBC__ +#ifdef __GLIBC__ #include <sys/platform/ppc.h> -#elif defined(__FreeBSD__) -#include <sys/sysctl.h> -#include <sys/types.h> -#endif +#elif defined(__FreeBSD__) +#include <sys/sysctl.h> +#include <sys/types.h> #endif +#endif #include "y_absl/base/internal/sysinfo.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { #if defined(__i386__) @@ -62,47 +62,47 @@ double UnscaledCycleClock::Frequency() { #elif defined(__powerpc__) || defined(__ppc__) int64_t UnscaledCycleClock::Now() { -#ifdef __GLIBC__ +#ifdef __GLIBC__ return __ppc_get_timebase(); -#else -#ifdef __powerpc64__ - int64_t tbr; - asm volatile("mfspr %0, 268" : "=r"(tbr)); - return tbr; -#else - int32_t tbu, tbl, tmp; - asm volatile( - "0:\n" - "mftbu %[hi32]\n" - "mftb %[lo32]\n" - "mftbu %[tmp]\n" - "cmpw %[tmp],%[hi32]\n" - "bne 0b\n" - : [ hi32 ] "=r"(tbu), [ lo32 ] "=r"(tbl), [ tmp ] "=r"(tmp)); - return (static_cast<int64_t>(tbu) << 32) | tbl; -#endif -#endif +#else +#ifdef __powerpc64__ + int64_t tbr; + asm volatile("mfspr %0, 268" : "=r"(tbr)); + return tbr; +#else + int32_t tbu, tbl, tmp; + asm volatile( + "0:\n" + "mftbu %[hi32]\n" + "mftb %[lo32]\n" + "mftbu %[tmp]\n" + "cmpw %[tmp],%[hi32]\n" + "bne 0b\n" + : [ hi32 ] "=r"(tbu), [ lo32 ] "=r"(tbl), [ tmp ] "=r"(tmp)); + return (static_cast<int64_t>(tbu) << 32) | tbl; +#endif +#endif } double UnscaledCycleClock::Frequency() { -#ifdef __GLIBC__ +#ifdef __GLIBC__ return __ppc_get_timebase_freq(); #elif defined(_AIX) // This is the same constant value as returned by // __ppc_get_timebase_freq(). return static_cast<double>(512000000); -#elif defined(__FreeBSD__) - static once_flag init_timebase_frequency_once; - static double timebase_frequency = 0.0; - base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() { - size_t length = sizeof(timebase_frequency); - sysctlbyname("kern.timecounter.tc.timebase.frequency", &timebase_frequency, - &length, nullptr, 0); - }); - return timebase_frequency; -#else -#error Must implement UnscaledCycleClock::Frequency() -#endif +#elif defined(__FreeBSD__) + static once_flag init_timebase_frequency_once; + static double timebase_frequency = 0.0; + base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() { + size_t length = sizeof(timebase_frequency); + sysctlbyname("kern.timecounter.tc.timebase.frequency", &timebase_frequency, + &length, nullptr, 0); + }); + return timebase_frequency; +#else +#error Must implement UnscaledCycleClock::Frequency() +#endif } #elif defined(__aarch64__) @@ -148,7 +148,7 @@ double UnscaledCycleClock::Frequency() { #endif } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USE_UNSCALED_CYCLECLOCK diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.h index 618c5c7e73..29f588b92d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/unscaledcycleclock.h @@ -86,7 +86,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { class UnscaledCycleClockWrapperForGetCurrentTime; } // namespace time_internal @@ -116,7 +116,7 @@ class UnscaledCycleClock { }; } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USE_UNSCALED_CYCLECLOCK diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.cc index 2ae8c75aec..bf4bb7fe98 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.cc @@ -17,11 +17,11 @@ #include <ostream> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN std::ostream& operator<<(std::ostream& os, y_absl::LogSeverity s) { if (s == y_absl::NormalizeLogSeverity(s)) return os << y_absl::LogSeverityName(s); return os << "y_absl::LogSeverity(" << static_cast<int>(s) << ")"; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.h index 26f20ad8e1..5af39dbcc5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity.h @@ -19,51 +19,51 @@ #include <ostream> #include "y_absl/base/attributes.h" -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN -// y_absl::LogSeverity -// -// Four severity levels are defined. Logging APIs should terminate the program +// y_absl::LogSeverity +// +// Four severity levels are defined. Logging APIs should terminate the program // when a message is logged at severity `kFatal`; the other levels have no // special semantics. // -// Values other than the four defined levels (e.g. produced by `static_cast`) -// are valid, but their semantics when passed to a function, macro, or flag -// depend on the function, macro, or flag. The usual behavior is to normalize -// such values to a defined severity level, however in some cases values other -// than the defined levels are useful for comparison. +// Values other than the four defined levels (e.g. produced by `static_cast`) +// are valid, but their semantics when passed to a function, macro, or flag +// depend on the function, macro, or flag. The usual behavior is to normalize +// such values to a defined severity level, however in some cases values other +// than the defined levels are useful for comparison. // // Example: // -// // Effectively disables all logging: -// SetMinLogLevel(static_cast<y_absl::LogSeverity>(100)); -// -// Abseil flags may be defined with type `LogSeverity`. Dependency layering -// constraints require that the `AbslParseFlag()` overload be declared and -// defined in the flags library itself rather than here. The `AbslUnparseFlag()` -// overload is defined there as well for consistency. -// -// y_absl::LogSeverity Flag String Representation -// -// An `y_absl::LogSeverity` has a string representation used for parsing -// command-line flags based on the enumerator name (e.g. `kFatal`) or -// its unprefixed name (without the `k`) in any case-insensitive form. (E.g. -// "FATAL", "fatal" or "Fatal" are all valid.) Unparsing such flags produces an -// unprefixed string representation in all caps (e.g. "FATAL") or an integer. -// -// Additionally, the parser accepts arbitrary integers (as if the type were -// `int`). -// -// Examples: -// -// --my_log_level=kInfo -// --my_log_level=INFO -// --my_log_level=info -// --my_log_level=0 -// +// // Effectively disables all logging: +// SetMinLogLevel(static_cast<y_absl::LogSeverity>(100)); +// +// Abseil flags may be defined with type `LogSeverity`. Dependency layering +// constraints require that the `AbslParseFlag()` overload be declared and +// defined in the flags library itself rather than here. The `AbslUnparseFlag()` +// overload is defined there as well for consistency. +// +// y_absl::LogSeverity Flag String Representation +// +// An `y_absl::LogSeverity` has a string representation used for parsing +// command-line flags based on the enumerator name (e.g. `kFatal`) or +// its unprefixed name (without the `k`) in any case-insensitive form. (E.g. +// "FATAL", "fatal" or "Fatal" are all valid.) Unparsing such flags produces an +// unprefixed string representation in all caps (e.g. "FATAL") or an integer. +// +// Additionally, the parser accepts arbitrary integers (as if the type were +// `int`). +// +// Examples: +// +// --my_log_level=kInfo +// --my_log_level=INFO +// --my_log_level=info +// --my_log_level=0 +// // Unparsing a flag produces the same result as `y_absl::LogSeverityName()` for // the standard levels and a base-ten integer otherwise. enum class LogSeverity : int { @@ -73,8 +73,8 @@ enum class LogSeverity : int { kFatal = 3, }; -// LogSeverities() -// +// LogSeverities() +// // Returns an iterable of all standard `y_absl::LogSeverity` values, ordered from // least to most severe. constexpr std::array<y_absl::LogSeverity, 4> LogSeverities() { @@ -82,8 +82,8 @@ constexpr std::array<y_absl::LogSeverity, 4> LogSeverities() { y_absl::LogSeverity::kError, y_absl::LogSeverity::kFatal}}; } -// LogSeverityName() -// +// LogSeverityName() +// // Returns the all-caps string representation (e.g. "INFO") of the specified // severity level if it is one of the standard levels and "UNKNOWN" otherwise. constexpr const char* LogSeverityName(y_absl::LogSeverity s) { @@ -96,8 +96,8 @@ constexpr const char* LogSeverityName(y_absl::LogSeverity s) { : s == y_absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN"; } -// NormalizeLogSeverity() -// +// NormalizeLogSeverity() +// // Values less than `kInfo` normalize to `kInfo`; values greater than `kFatal` // normalize to `kError` (**NOT** `kFatal`). constexpr y_absl::LogSeverity NormalizeLogSeverity(y_absl::LogSeverity s) { @@ -109,13 +109,13 @@ constexpr y_absl::LogSeverity NormalizeLogSeverity(int s) { return y_absl::NormalizeLogSeverity(static_cast<y_absl::LogSeverity>(s)); } -// operator<< -// +// operator<< +// // The exact representation of a streamed `y_absl::LogSeverity` is deliberately // unspecified; do not rely on it. std::ostream& operator<<(std::ostream& os, y_absl::LogSeverity s); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_LOG_SEVERITY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity/ya.make index 3e4b5634c2..02f14c314c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/macros.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/macros.h index b09a81877d..c054ce3969 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/macros.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/macros.h @@ -31,7 +31,7 @@ #include <cassert> #include <cstddef> -#include "y_absl/base/attributes.h" +#include "y_absl/base/attributes.h" #include "y_absl/base/config.h" #include "y_absl/base/optimization.h" #include "y_absl/base/port.h" @@ -45,14 +45,14 @@ (sizeof(::y_absl::macros_internal::ArraySizeHelper(array))) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace macros_internal { // Note: this internal template function declaration is used by ABSL_ARRAYSIZE. // The function doesn't need a definition, as we only use its type. template <typename T, size_t N> auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; } // namespace macros_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // ABSL_BAD_CALL_IF() @@ -60,7 +60,7 @@ ABSL_NAMESPACE_END // Used on a function overload to trap bad calls: any call that matches the // overload will cause a compile-time error. This macro uses a clang-specific // "enable_if" attribute, as described at -// https://clang.llvm.org/docs/AttributeReference.html#enable-if +// https://clang.llvm.org/docs/AttributeReference.html#enable-if // // Overloads which use this macro should be bracketed by // `#ifdef ABSL_BAD_CALL_IF`. @@ -73,9 +73,9 @@ ABSL_NAMESPACE_END // ABSL_BAD_CALL_IF(c <= -1 || c > 255, // "'c' must have the value of an unsigned char or EOF"); // #endif // ABSL_BAD_CALL_IF -#if ABSL_HAVE_ATTRIBUTE(enable_if) -#define ABSL_BAD_CALL_IF(expr, msg) \ - __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) +#if ABSL_HAVE_ATTRIBUTE(enable_if) +#define ABSL_BAD_CALL_IF(expr, msg) \ + __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) #endif // ABSL_ASSERT() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/options.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/options.h index 906310cde0..c6ff1d0884 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/options.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/options.h @@ -63,16 +63,16 @@ // NOTE: the defaults within this file all assume that Abseil can select the // proper Abseil implementation at compile-time, which will not be sufficient // to guarantee ABI stability to package managers. - + #ifndef ABSL_BASE_OPTIONS_H_ #define ABSL_BASE_OPTIONS_H_ -// Include a standard library header to allow configuration based on the -// standard library in use. -#ifdef __cplusplus -#include <ciso646> -#endif - +// Include a standard library header to allow configuration based on the +// standard library in use. +#ifdef __cplusplus +#include <ciso646> +#endif + // ----------------------------------------------------------------------------- // Type Compatibility Options // ----------------------------------------------------------------------------- @@ -182,32 +182,32 @@ #define ABSL_OPTION_USE_STD_VARIANT 2 - -// ABSL_OPTION_USE_INLINE_NAMESPACE -// ABSL_OPTION_INLINE_NAMESPACE_NAME -// -// These options controls whether all entities in the y_absl namespace are -// contained within an inner inline namespace. This does not affect the -// user-visible API of Abseil, but it changes the mangled names of all symbols. -// -// This can be useful as a version tag if you are distributing Abseil in -// precompiled form. This will prevent a binary library build of Abseil with -// one inline namespace being used with headers configured with a different -// inline namespace name. Binary packagers are reminded that Abseil does not -// guarantee any ABI stability in Abseil, so any update of Abseil or -// configuration change in such a binary package should be combined with a -// new, unique value for the inline namespace name. -// -// A value of 0 means not to use inline namespaces. -// -// A value of 1 means to use an inline namespace with the given name inside -// namespace y_absl. If this is set, ABSL_OPTION_INLINE_NAMESPACE_NAME must also -// be changed to a new, unique identifier name. In particular "head" is not -// allowed. - -#define ABSL_OPTION_USE_INLINE_NAMESPACE 1 + +// ABSL_OPTION_USE_INLINE_NAMESPACE +// ABSL_OPTION_INLINE_NAMESPACE_NAME +// +// These options controls whether all entities in the y_absl namespace are +// contained within an inner inline namespace. This does not affect the +// user-visible API of Abseil, but it changes the mangled names of all symbols. +// +// This can be useful as a version tag if you are distributing Abseil in +// precompiled form. This will prevent a binary library build of Abseil with +// one inline namespace being used with headers configured with a different +// inline namespace name. Binary packagers are reminded that Abseil does not +// guarantee any ABI stability in Abseil, so any update of Abseil or +// configuration change in such a binary package should be combined with a +// new, unique value for the inline namespace name. +// +// A value of 0 means not to use inline namespaces. +// +// A value of 1 means to use an inline namespace with the given name inside +// namespace y_absl. If this is set, ABSL_OPTION_INLINE_NAMESPACE_NAME must also +// be changed to a new, unique identifier name. In particular "head" is not +// allowed. + +#define ABSL_OPTION_USE_INLINE_NAMESPACE 1 #define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_y_20211102 - + // ABSL_OPTION_HARDENED // // This option enables a "hardened" build in release mode (in this context, diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/thread_annotations.h b/contrib/restricted/abseil-cpp-tstring/y_absl/base/thread_annotations.h index aba5d58dc3..fe9c81b1cd 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/thread_annotations.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/thread_annotations.h @@ -35,7 +35,7 @@ #define ABSL_BASE_THREAD_ANNOTATIONS_H_ #include "y_absl/base/attributes.h" -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" // TODO(mbonadei): Remove after the backward compatibility period. #include "y_absl/base/internal/thread_annotations.h" // IWYU pragma: export @@ -312,7 +312,7 @@ #define ABSL_TS_UNCHECKED_READ(x) y_absl::base_internal::ts_unchecked_read(x) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace base_internal { // Takes a reference to a guarded data member, and returns an unguarded @@ -329,7 +329,7 @@ inline T& ts_unchecked_read(T& v) ABSL_NO_THREAD_SAFETY_ANALYSIS { } } // namespace base_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_BASE_THREAD_ANNOTATIONS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make index 9e0d53060e..f3a8a933cb 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/ya.make @@ -17,9 +17,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/city/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/city/ya.make index 7fc856d796..843a60b762 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/city/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/city/ya.make @@ -18,9 +18,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h index 3f46c541b8..eb865ed587 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_map.h @@ -51,7 +51,7 @@ #include "y_absl/container/internal/btree_container.h" // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // y_absl::btree_map<> // @@ -226,30 +226,30 @@ class btree_map // Inserts the elements within the initializer list `ilist`. using Base::insert; - // btree_map::insert_or_assign() - // - // Inserts an element of the specified value into the `btree_map` provided - // that a value with the given key does not already exist, or replaces the - // corresponding mapped type with the forwarded `obj` argument if a key for - // that value already exists, returning an iterator pointing to the newly - // inserted element. Overloads are listed below. - // - // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj): - // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj): - // - // Inserts/Assigns (or moves) the element of the specified key into the - // `btree_map`. If the returned bool is true, insertion took place, and if - // it's false, assignment took place. - // - // iterator insert_or_assign(const_iterator hint, - // const key_type& k, M&& obj): - // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj): - // - // Inserts/Assigns (or moves) the element of the specified key into the - // `btree_map` using the position of `hint` as a non-binding suggestion - // for where to begin the insertion search. - using Base::insert_or_assign; - + // btree_map::insert_or_assign() + // + // Inserts an element of the specified value into the `btree_map` provided + // that a value with the given key does not already exist, or replaces the + // corresponding mapped type with the forwarded `obj` argument if a key for + // that value already exists, returning an iterator pointing to the newly + // inserted element. Overloads are listed below. + // + // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj): + // pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj): + // + // Inserts/Assigns (or moves) the element of the specified key into the + // `btree_map`. If the returned bool is true, insertion took place, and if + // it's false, assignment took place. + // + // iterator insert_or_assign(const_iterator hint, + // const key_type& k, M&& obj): + // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj): + // + // Inserts/Assigns (or moves) the element of the specified key into the + // `btree_map` using the position of `hint` as a non-binding suggestion + // for where to begin the insertion search. + using Base::insert_or_assign; + // btree_map::emplace() // // Inserts an element of the specified value by constructing it in-place @@ -464,20 +464,20 @@ void swap(btree_map<K, V, C, A> &x, btree_map<K, V, C, A> &y) { return x.swap(y); } -// y_absl::erase_if(y_absl::btree_map<>, Pred) -// -// Erases all elements that satisfy the predicate pred from the container. -template <typename K, typename V, typename C, typename A, typename Pred> -void erase_if(btree_map<K, V, C, A> &map, Pred pred) { - for (auto it = map.begin(); it != map.end();) { - if (pred(*it)) { - it = map.erase(it); - } else { - ++it; - } - } -} - +// y_absl::erase_if(y_absl::btree_map<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename V, typename C, typename A, typename Pred> +void erase_if(btree_map<K, V, C, A> &map, Pred pred) { + for (auto it = map.begin(); it != map.end();) { + if (pred(*it)) { + it = map.erase(it); + } else { + ++it; + } + } +} + // y_absl::btree_multimap // // An `y_absl::btree_multimap<K, V>` is an ordered associative container of @@ -795,21 +795,21 @@ void swap(btree_multimap<K, V, C, A> &x, btree_multimap<K, V, C, A> &y) { return x.swap(y); } -// y_absl::erase_if(y_absl::btree_multimap<>, Pred) -// -// Erases all elements that satisfy the predicate pred from the container. -template <typename K, typename V, typename C, typename A, typename Pred> -void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) { - for (auto it = map.begin(); it != map.end();) { - if (pred(*it)) { - it = map.erase(it); - } else { - ++it; - } - } -} - -ABSL_NAMESPACE_END +// y_absl::erase_if(y_absl::btree_multimap<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename V, typename C, typename A, typename Pred> +void erase_if(btree_multimap<K, V, C, A> &map, Pred pred) { + for (auto it = map.begin(); it != map.end();) { + if (pred(*it)) { + it = map.erase(it); + } else { + ++it; + } + } +} + +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_BTREE_MAP_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h index 905fb8e964..a9ba1b3d86 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_set.h @@ -51,7 +51,7 @@ #include "y_absl/container/internal/btree_container.h" // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // y_absl::btree_set<> // @@ -382,20 +382,20 @@ void swap(btree_set<K, C, A> &x, btree_set<K, C, A> &y) { return x.swap(y); } -// y_absl::erase_if(y_absl::btree_set<>, Pred) -// -// Erases all elements that satisfy the predicate pred from the container. -template <typename K, typename C, typename A, typename Pred> -void erase_if(btree_set<K, C, A> &set, Pred pred) { - for (auto it = set.begin(); it != set.end();) { - if (pred(*it)) { - it = set.erase(it); - } else { - ++it; - } - } -} - +// y_absl::erase_if(y_absl::btree_set<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename C, typename A, typename Pred> +void erase_if(btree_set<K, C, A> &set, Pred pred) { + for (auto it = set.begin(); it != set.end();) { + if (pred(*it)) { + it = set.erase(it); + } else { + ++it; + } + } +} + // y_absl::btree_multiset<> // // An `y_absl::btree_multiset<K>` is an ordered associative container of @@ -708,21 +708,21 @@ void swap(btree_multiset<K, C, A> &x, btree_multiset<K, C, A> &y) { return x.swap(y); } -// y_absl::erase_if(y_absl::btree_multiset<>, Pred) -// -// Erases all elements that satisfy the predicate pred from the container. -template <typename K, typename C, typename A, typename Pred> -void erase_if(btree_multiset<K, C, A> &set, Pred pred) { - for (auto it = set.begin(); it != set.end();) { - if (pred(*it)) { - it = set.erase(it); - } else { - ++it; - } - } -} - -ABSL_NAMESPACE_END +// y_absl::erase_if(y_absl::btree_multiset<>, Pred) +// +// Erases all elements that satisfy the predicate pred from the container. +template <typename K, typename C, typename A, typename Pred> +void erase_if(btree_multiset<K, C, A> &set, Pred pred) { + for (auto it = set.begin(); it != set.end();) { + if (pred(*it)) { + it = set.erase(it); + } else { + ++it; + } + } +} + +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_BTREE_SET_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h index 97ed054ce8..639e34ea03 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/btree_test.h @@ -18,7 +18,7 @@ #include <algorithm> #include <cassert> #include <random> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <utility> #include <vector> @@ -29,7 +29,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // Like remove_const but propagates the removal through std::pair. @@ -160,7 +160,7 @@ std::vector<V> GenerateValuesWithSeed(int n, int maxval, int seed) { } } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_BTREE_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h index 33b6caf00d..30ff1734dc 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/fixed_array.h @@ -51,7 +51,7 @@ #include "y_absl/memory/memory.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1); @@ -521,7 +521,7 @@ void FixedArray<T, N, A>::NonEmptyInlinedStorage::AnnotateDestruct( #endif // ABSL_HAVE_ADDRESS_SANITIZER static_cast<void>(n); // Mark used when not in asan mode } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_FIXED_ARRAY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h index eb3f09f06d..3493159b50 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_map.h @@ -42,7 +42,7 @@ #include "y_absl/memory/memory.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class K, class V> struct FlatHashMapPolicy; @@ -538,15 +538,15 @@ class flat_hash_map : public y_absl::container_internal::raw_hash_map< using Base::key_eq; }; -// erase_if(flat_hash_map<>, Pred) -// -// Erases all elements that satisfy the predicate `pred` from the container `c`. -template <typename K, typename V, typename H, typename E, typename A, - typename Predicate> -void erase_if(flat_hash_map<K, V, H, E, A>& c, Predicate pred) { - container_internal::EraseIf(pred, &c); -} - +// erase_if(flat_hash_map<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename K, typename V, typename H, typename E, typename A, + typename Predicate> +void erase_if(flat_hash_map<K, V, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class K, class V> @@ -600,7 +600,7 @@ struct IsUnorderedContainer< } // namespace container_algorithm_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_FLAT_HASH_MAP_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h index 23fe02a950..6d1b255cf9 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/flat_hash_set.h @@ -40,7 +40,7 @@ #include "y_absl/memory/memory.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename T> struct FlatHashSetPolicy; @@ -440,14 +440,14 @@ class flat_hash_set using Base::key_eq; }; -// erase_if(flat_hash_set<>, Pred) -// -// Erases all elements that satisfy the predicate `pred` from the container `c`. -template <typename T, typename H, typename E, typename A, typename Predicate> -void erase_if(flat_hash_set<T, H, E, A>& c, Predicate pred) { - container_internal::EraseIf(pred, &c); -} - +// erase_if(flat_hash_set<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename T, typename H, typename E, typename A, typename Predicate> +void erase_if(flat_hash_set<T, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class T> @@ -498,7 +498,7 @@ struct IsUnorderedContainer<y_absl::flat_hash_set<Key, Hash, KeyEqual, Allocator } // namespace container_algorithm_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_FLAT_HASH_SET_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h index 34af121cf7..190b83dc52 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/inlined_vector.h @@ -55,7 +55,7 @@ #include "y_absl/memory/memory.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // InlinedVector // ----------------------------------------------------------------------------- @@ -849,7 +849,7 @@ H AbslHashValue(H h, const y_absl::InlinedVector<T, N, A>& a) { return H::combine(H::combine_contiguous(std::move(h), a.data(), size), size); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INLINED_VECTOR_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h index a249260811..a3a6f6c3d5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree.h @@ -54,7 +54,7 @@ #include <iterator> #include <limits> #include <new> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include <utility> @@ -71,7 +71,7 @@ #include "y_absl/utility/utility.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // A helper class that indicates if the Compare parameter is a key-compare-to @@ -513,9 +513,9 @@ class btree_node { // // TODO(ezb): right now, `start` is always 0. Update insertion/merge // // logic to allow for floating storage within nodes. // field_type start; - // // The index after the last populated value in `values`. Currently, this - // // is the same as the count of values. - // field_type finish; + // // The index after the last populated value in `values`. Currently, this + // // is the same as the count of values. + // field_type finish; // // The maximum number of values the node can hold. This is an integer in // // [1, kNodeSlots] for root leaf nodes, kNodeSlots for non-root leaf // // nodes, and kInternalNodeMaxCount (as a sentinel value) for internal @@ -526,7 +526,7 @@ class btree_node { // // // The array of values. The capacity is `max_count` for leaf nodes and // // kNodeSlots for internal nodes. Only the values in - // // [start, finish) have been initialized and are valid. + // // [start, finish) have been initialized and are valid. // slot_type values[max_count]; // // // The array of child pointers. The keys in children[i] are all less @@ -557,7 +557,7 @@ class btree_node { slot_type, btree_node *>; constexpr static size_type SizeWithNSlots(size_type n) { return layout_type(/*parent*/ 1, - /*position, start, finish, max_count*/ 4, + /*position, start, finish, max_count*/ 4, /*slots*/ n, /*children*/ 0) .AllocSize(); @@ -599,13 +599,13 @@ class btree_node { // Leaves can have less than kNodeSlots values. constexpr static layout_type LeafLayout(const int slot_count = kNodeSlots) { return layout_type(/*parent*/ 1, - /*position, start, finish, max_count*/ 4, + /*position, start, finish, max_count*/ 4, /*slots*/ slot_count, /*children*/ 0); } constexpr static layout_type InternalLayout() { return layout_type(/*parent*/ 1, - /*position, start, finish, max_count*/ 4, + /*position, start, finish, max_count*/ 4, /*slots*/ kNodeSlots, /*children*/ kNodeSlots + 1); } @@ -631,14 +631,14 @@ class btree_node { reinterpret_cast<const char *>(this)); } void set_parent(btree_node *p) { *GetField<0>() = p; } - field_type &mutable_finish() { return GetField<1>()[2]; } + field_type &mutable_finish() { return GetField<1>()[2]; } slot_type *slot(int i) { return &GetField<2>()[i]; } - slot_type *start_slot() { return slot(start()); } - slot_type *finish_slot() { return slot(finish()); } + slot_type *start_slot() { return slot(start()); } + slot_type *finish_slot() { return slot(finish()); } const slot_type *slot(int i) const { return &GetField<2>()[i]; } void set_position(field_type v) { GetField<1>()[0] = v; } void set_start(field_type v) { GetField<1>()[1] = v; } - void set_finish(field_type v) { GetField<1>()[2] = v; } + void set_finish(field_type v) { GetField<1>()[2] = v; } // This method is only called by the node init methods. void set_max_count(field_type v) { GetField<1>()[3] = v; } @@ -651,20 +651,20 @@ class btree_node { field_type position() const { return GetField<1>()[0]; } // Getter for the offset of the first value in the `values` array. - field_type start() const { - // TODO(ezb): when floating storage is implemented, return GetField<1>()[1]; - assert(GetField<1>()[1] == 0); - return 0; - } - - // Getter for the offset after the last value in the `values` array. - field_type finish() const { return GetField<1>()[2]; } - + field_type start() const { + // TODO(ezb): when floating storage is implemented, return GetField<1>()[1]; + assert(GetField<1>()[1] == 0); + return 0; + } + + // Getter for the offset after the last value in the `values` array. + field_type finish() const { return GetField<1>()[2]; } + // Getters for the number of values stored in this node. - field_type count() const { - assert(finish() >= start()); - return finish() - start(); - } + field_type count() const { + assert(finish() >= start()); + return finish() - start(); + } field_type max_count() const { // Internal nodes have max_count==kInternalNodeMaxCount. // Leaf nodes have max_count in [1, kNodeSlots]. @@ -692,7 +692,7 @@ class btree_node { // Getters/setter for the child at position i in the node. btree_node *child(int i) const { return GetField<3>()[i]; } - btree_node *start_child() const { return child(start()); } + btree_node *start_child() const { return child(start()); } btree_node *&mutable_child(int i) { return GetField<3>()[i]; } void clear_child(int i) { y_absl::container_internal::SanitizerPoisonObject(&mutable_child(i)); @@ -725,14 +725,14 @@ class btree_node { template <typename K, typename Compare> SearchResult<int, btree_is_key_compare_to<Compare, key_type>::value> linear_search(const K &k, const Compare &comp) const { - return linear_search_impl(k, start(), finish(), comp, + return linear_search_impl(k, start(), finish(), comp, btree_is_key_compare_to<Compare, key_type>()); } template <typename K, typename Compare> SearchResult<int, btree_is_key_compare_to<Compare, key_type>::value> binary_search(const K &k, const Compare &comp) const { - return binary_search_impl(k, start(), finish(), comp, + return binary_search_impl(k, start(), finish(), comp, btree_is_key_compare_to<Compare, key_type>()); } @@ -968,7 +968,7 @@ struct btree_iterator { using iterator_category = std::bidirectional_iterator_tag; btree_iterator() : node(nullptr), position(-1) {} - explicit btree_iterator(Node *n) : node(n), position(n->start()) {} + explicit btree_iterator(Node *n) : node(n), position(n->start()) {} btree_iterator(Node *n, int p) : node(n), position(p) {} // NOTE: this SFINAE allows for implicit conversions from iterator to @@ -997,7 +997,7 @@ struct btree_iterator { // Increment/decrement the iterator. void increment() { - if (node->leaf() && ++position < node->finish()) { + if (node->leaf() && ++position < node->finish()) { return; } increment_slow(); @@ -1005,7 +1005,7 @@ struct btree_iterator { void increment_slow(); void decrement() { - if (node->leaf() && --position >= node->start()) { + if (node->leaf() && --position >= node->start()) { return; } decrement_slow(); @@ -1035,11 +1035,11 @@ struct btree_iterator { } pointer operator->() const { return &operator*(); } - btree_iterator &operator++() { + btree_iterator &operator++() { increment(); return *this; } - btree_iterator &operator--() { + btree_iterator &operator--() { decrement(); return *this; } @@ -1095,7 +1095,7 @@ class btree { node_type *parent; field_type position = 0; field_type start = 0; - field_type finish = 0; + field_type finish = 0; // max_count must be != kInternalNodeMaxCount (so that this node is regarded // as a leaf node). max_count() is never called when the tree is empty. field_type max_count = node_type::kInternalNodeMaxCount + 1; @@ -1110,7 +1110,7 @@ class btree { static node_type *EmptyNode() { #ifdef _MSC_VER - static EmptyNodeType *empty_node = new EmptyNodeType; + static EmptyNodeType *empty_node = new EmptyNodeType; // This assert fails on some other construction methods. assert(empty_node->parent == empty_node); return empty_node; @@ -1129,7 +1129,7 @@ class btree { struct node_stats { using size_type = typename Params::size_type; - node_stats(size_type l, size_type i) : leaf_nodes(l), internal_nodes(i) {} + node_stats(size_type l, size_type i) : leaf_nodes(l), internal_nodes(i) {} node_stats &operator+=(const node_stats &other) { leaf_nodes += other.leaf_nodes; @@ -1220,17 +1220,17 @@ class btree { btree &operator=(const btree &other); btree &operator=(btree &&other) noexcept; - iterator begin() { return iterator(leftmost()); } - const_iterator begin() const { return const_iterator(leftmost()); } - iterator end() { return iterator(rightmost_, rightmost_->finish()); } + iterator begin() { return iterator(leftmost()); } + const_iterator begin() const { return const_iterator(leftmost()); } + iterator end() { return iterator(rightmost_, rightmost_->finish()); } const_iterator end() const { - return const_iterator(rightmost_, rightmost_->finish()); + return const_iterator(rightmost_, rightmost_->finish()); } - reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } + reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } @@ -1330,7 +1330,7 @@ class btree { // Erases range. Returns the number of keys erased and an iterator pointing // to the element after the last erased element. - std::pair<size_type, iterator> erase_range(iterator begin, iterator end); + std::pair<size_type, iterator> erase_range(iterator begin, iterator end); // Finds an element with key equivalent to `key` or returns `end()` if `key` // is not present. @@ -1387,7 +1387,7 @@ class btree { } // The number of internal, leaf and total nodes used by the btree. - size_type leaf_nodes() const { return internal_stats(root()).leaf_nodes; } + size_type leaf_nodes() const { return internal_stats(root()).leaf_nodes; } size_type internal_nodes() const { return internal_stats(root()).internal_nodes; } @@ -1400,9 +1400,9 @@ class btree { size_type bytes_used() const { node_stats stats = internal_stats(root()); if (stats.leaf_nodes == 1 && stats.internal_nodes == 0) { - return sizeof(*this) + node_type::LeafSize(root()->max_count()); + return sizeof(*this) + node_type::LeafSize(root()->max_count()); } else { - return sizeof(*this) + stats.leaf_nodes * node_type::LeafSize() + + return sizeof(*this) + stats.leaf_nodes * node_type::LeafSize() + stats.internal_nodes * node_type::InternalSize(); } } @@ -1437,7 +1437,7 @@ class btree { } // The allocator used by the btree. - allocator_type get_allocator() const { return allocator(); } + allocator_type get_allocator() const { return allocator(); } private: // Internal accessor routines. @@ -1467,12 +1467,12 @@ class btree { } // Node creation/deletion routines. - node_type *new_internal_node(node_type *parent) { + node_type *new_internal_node(node_type *parent) { node_type *n = allocate(node_type::InternalSize()); n->init_internal(parent); return n; } - node_type *new_leaf_node(node_type *parent) { + node_type *new_leaf_node(node_type *parent) { node_type *n = allocate(node_type::LeafSize()); n->init_leaf(parent, kNodeSlots); return n; @@ -1515,9 +1515,9 @@ class btree { iterator internal_emplace(iterator iter, Args &&... args); // Returns an iterator pointing to the first value >= the value "iter" is - // pointing at. Note that "iter" might be pointing to an invalid location such - // as iter.position == iter.node->finish(). This routine simply moves iter up - // in the tree to a valid location. + // pointing at. Note that "iter" might be pointing to an invalid location such + // as iter.position == iter.node->finish(). This routine simply moves iter up + // in the tree to a valid location. // Requires: iter.node is non-null. template <typename IterType> static IterType internal_last(IterType iter); @@ -1546,8 +1546,8 @@ class btree { iterator internal_find(const K &key) const; // Verifies the tree structure of node. - int internal_verify(const node_type *node, const key_type *lo, - const key_type *hi) const; + int internal_verify(const node_type *node, const key_type *lo, + const key_type *hi) const; node_stats internal_stats(const node_type *node) const { // The root can be a static empty node. @@ -1558,7 +1558,7 @@ class btree { return node_stats(1, 0); } node_stats res(0, 1); - for (int i = node->start(); i <= node->finish(); ++i) { + for (int i = node->start(); i <= node->finish(); ++i) { res += internal_stats(node->child(i)); } return res; @@ -1585,19 +1585,19 @@ template <typename... Args> inline void btree_node<P>::emplace_value(const size_type i, allocator_type *alloc, Args &&... args) { - assert(i >= start()); - assert(i <= finish()); + assert(i >= start()); + assert(i <= finish()); // Shift old values to create space for new value and then construct it in // place. - if (i < finish()) { + if (i < finish()) { transfer_n_backward(finish() - i, /*dest_i=*/i + 1, /*src_i=*/i, this, alloc); } value_init(i, alloc, std::forward<Args>(args)...); - set_finish(finish() + 1); + set_finish(finish() + 1); - if (!leaf() && finish() > i + 1) { - for (int j = finish(); j > i + 1; --j) { + if (!leaf() && finish() > i + 1) { + for (int j = finish(); j > i + 1; --j) { set_child(j, child(j - 1)); } clear_child(i + 1); @@ -1654,18 +1654,18 @@ void btree_node<P>::rebalance_right_to_left(const int to_move, if (!leaf()) { // Move the child pointers from the right to the left node. for (int i = 0; i < to_move; ++i) { - init_child(finish() + i + 1, right->child(i)); + init_child(finish() + i + 1, right->child(i)); } - for (int i = right->start(); i <= right->finish() - to_move; ++i) { + for (int i = right->start(); i <= right->finish() - to_move; ++i) { assert(i + to_move <= right->max_count()); right->init_child(i, right->child(i + to_move)); right->clear_child(i + to_move); } } - // Fixup `finish` on the left and right nodes. - set_finish(finish() + to_move); - right->set_finish(right->finish() - to_move); + // Fixup `finish` on the left and right nodes. + set_finish(finish() + to_move); + right->set_finish(right->finish() - to_move); } template <typename P> @@ -1700,19 +1700,19 @@ void btree_node<P>::rebalance_left_to_right(const int to_move, if (!leaf()) { // Move the child pointers from the left to the right node. - for (int i = right->finish(); i >= right->start(); --i) { + for (int i = right->finish(); i >= right->start(); --i) { right->init_child(i + to_move, right->child(i)); right->clear_child(i); } for (int i = 1; i <= to_move; ++i) { - right->init_child(i - 1, child(finish() - to_move + i)); - clear_child(finish() - to_move + i); + right->init_child(i - 1, child(finish() - to_move + i)); + clear_child(finish() - to_move + i); } } // Fixup the counts on the left and right nodes. - set_finish(finish() - to_move); - right->set_finish(right->finish() + to_move); + set_finish(finish() - to_move); + right->set_finish(right->finish() + to_move); } template <typename P> @@ -1725,31 +1725,31 @@ void btree_node<P>::split(const int insert_position, btree_node *dest, // inserting at the beginning of the left node then bias the split to put // more values on the right node. If we're inserting at the end of the // right node then bias the split to put more values on the left node. - if (insert_position == start()) { - dest->set_finish(dest->start() + finish() - 1); + if (insert_position == start()) { + dest->set_finish(dest->start() + finish() - 1); } else if (insert_position == kNodeSlots) { - dest->set_finish(dest->start()); + dest->set_finish(dest->start()); } else { - dest->set_finish(dest->start() + count() / 2); + dest->set_finish(dest->start() + count() / 2); } - set_finish(finish() - dest->count()); + set_finish(finish() - dest->count()); assert(count() >= 1); // Move values from the left sibling to the right sibling. dest->transfer_n(dest->count(), dest->start(), finish(), this, alloc); // The split key is the largest value in the left sibling. - --mutable_finish(); - parent()->emplace_value(position(), alloc, finish_slot()); - value_destroy(finish(), alloc); + --mutable_finish(); + parent()->emplace_value(position(), alloc, finish_slot()); + value_destroy(finish(), alloc); parent()->init_child(position() + 1, dest); if (!leaf()) { - for (int i = dest->start(), j = finish() + 1; i <= dest->finish(); - ++i, ++j) { - assert(child(j) != nullptr); - dest->init_child(i, child(j)); - clear_child(j); + for (int i = dest->start(), j = finish() + 1; i <= dest->finish(); + ++i, ++j) { + assert(child(j) != nullptr); + dest->init_child(i, child(j)); + clear_child(j); } } } @@ -1760,22 +1760,22 @@ void btree_node<P>::merge(btree_node *src, allocator_type *alloc) { assert(position() + 1 == src->position()); // Move the delimiting value to the left node. - value_init(finish(), alloc, parent()->slot(position())); + value_init(finish(), alloc, parent()->slot(position())); // Move the values from the right to the left node. transfer_n(src->count(), finish() + 1, src->start(), src, alloc); if (!leaf()) { // Move the child pointers from the right to the left node. - for (int i = src->start(), j = finish() + 1; i <= src->finish(); ++i, ++j) { - init_child(j, src->child(i)); + for (int i = src->start(), j = finish() + 1; i <= src->finish(); ++i, ++j) { + init_child(j, src->child(i)); src->clear_child(i); } } - // Fixup `finish` on the src and dest nodes. - set_finish(start() + 1 + count() + src->count()); - src->set_finish(src->start()); + // Fixup `finish` on the src and dest nodes. + set_finish(start() + 1 + count() + src->count()); + src->set_finish(src->start()); // Remove the value on the parent node and delete the src node. parent()->remove_values(position(), /*to_erase=*/1, alloc); @@ -1837,24 +1837,24 @@ void btree_node<P>::clear_and_delete(btree_node *node, allocator_type *alloc) { template <typename N, typename R, typename P> void btree_iterator<N, R, P>::increment_slow() { if (node->leaf()) { - assert(position >= node->finish()); + assert(position >= node->finish()); btree_iterator save(*this); - while (position == node->finish() && !node->is_root()) { + while (position == node->finish() && !node->is_root()) { assert(node->parent()->child(node->position()) == node); position = node->position(); node = node->parent(); } // TODO(ezb): assert we aren't incrementing end() instead of handling. - if (position == node->finish()) { + if (position == node->finish()) { *this = save; } } else { - assert(position < node->finish()); + assert(position < node->finish()); node = node->child(position + 1); while (!node->leaf()) { - node = node->start_child(); + node = node->start_child(); } - position = node->start(); + position = node->start(); } } @@ -1863,22 +1863,22 @@ void btree_iterator<N, R, P>::decrement_slow() { if (node->leaf()) { assert(position <= -1); btree_iterator save(*this); - while (position < node->start() && !node->is_root()) { + while (position < node->start() && !node->is_root()) { assert(node->parent()->child(node->position()) == node); position = node->position() - 1; node = node->parent(); } // TODO(ezb): assert we aren't decrementing begin() instead of handling. - if (position < node->start()) { + if (position < node->start()) { *this = save; } } else { - assert(position >= node->start()); + assert(position >= node->start()); node = node->child(position); while (!node->leaf()) { - node = node->child(node->finish()); + node = node->child(node->finish()); } - position = node->finish() - 1; + position = node->finish() - 1; } } @@ -2011,7 +2011,7 @@ inline auto btree<P>::insert_hint_unique(iterator position, const K &key, -> std::pair<iterator, bool> { if (!empty()) { if (position == end() || compare_keys(key, position.key())) { - if (position == begin() || compare_keys(std::prev(position).key(), key)) { + if (position == begin() || compare_keys(std::prev(position).key(), key)) { // prev.key() < key < position.key() return {internal_emplace(position, std::forward<Args>(args)...), true}; } @@ -2066,16 +2066,16 @@ auto btree<P>::insert_hint_multi(iterator position, ValueType &&v) -> iterator { if (!empty()) { const key_type &key = params_type::key(v); if (position == end() || !compare_keys(position.key(), key)) { - if (position == begin() || - !compare_keys(key, std::prev(position).key())) { + if (position == begin() || + !compare_keys(key, std::prev(position).key())) { // prev.key() <= key <= position.key() return internal_emplace(position, std::forward<ValueType>(v)); } } else { - ++position; - if (position == end() || !compare_keys(position.key(), key)) { - // {original `position`}.key() < key < {current `position`}.key() - return internal_emplace(position, std::forward<ValueType>(v)); + ++position; + if (position == end() || !compare_keys(position.key(), key)) { + // {original `position`}.key() < key < {current `position`}.key() + return internal_emplace(position, std::forward<ValueType>(v)); } } } @@ -2206,8 +2206,8 @@ auto btree<P>::rebalance_after_delete(iterator iter) -> iterator { // Adjust our return value. If we're pointing at the end of a node, advance // the iterator. - if (res.position == res.node->finish()) { - res.position = res.node->finish() - 1; + if (res.position == res.node->finish()) { + res.position = res.node->finish() - 1; ++res; } @@ -2215,7 +2215,7 @@ auto btree<P>::rebalance_after_delete(iterator iter) -> iterator { } template <typename P> -auto btree<P>::erase_range(iterator begin, iterator end) +auto btree<P>::erase_range(iterator begin, iterator end) -> std::pair<size_type, iterator> { difference_type count = std::distance(begin, end); assert(count >= 0); @@ -2241,7 +2241,7 @@ auto btree<P>::erase_range(iterator begin, iterator end) while (size_ > target_size) { if (begin.node->leaf()) { const size_type remaining_to_erase = size_ - target_size; - const size_type remaining_in_node = begin.node->finish() - begin.position; + const size_type remaining_in_node = begin.node->finish() - begin.position; const size_type to_erase = (std::min)(remaining_to_erase, remaining_in_node); begin.node->remove_values(begin.position, to_erase, mutable_allocator()); @@ -2288,7 +2288,7 @@ void btree<P>::verify() const { assert(rightmost_ != nullptr); assert(empty() || size() == internal_verify(root(), nullptr, nullptr)); assert(leftmost() == (++const_iterator(root(), -1)).node); - assert(rightmost_ == (--const_iterator(root(), root()->finish())).node); + assert(rightmost_ == (--const_iterator(root(), root()->finish())).node); assert(leftmost()->leaf()); assert(rightmost_->leaf()); } @@ -2303,7 +2303,7 @@ void btree<P>::rebalance_or_split(iterator *iter) { // First try to make room on the node by rebalancing. node_type *parent = node->parent(); if (node != root()) { - if (node->position() > parent->start()) { + if (node->position() > parent->start()) { // Try rebalancing with our left sibling. node_type *left = parent->child(node->position() - 1); assert(left->max_count() == kNodeSlots); @@ -2315,13 +2315,13 @@ void btree<P>::rebalance_or_split(iterator *iter) { (1 + (insert_position < static_cast<int>(kNodeSlots))); to_move = (std::max)(1, to_move); - if (insert_position - to_move >= node->start() || + if (insert_position - to_move >= node->start() || left->count() + to_move < static_cast<int>(kNodeSlots)) { left->rebalance_right_to_left(to_move, node, mutable_allocator()); assert(node->max_count() - node->count() == to_move); insert_position = insert_position - to_move; - if (insert_position < node->start()) { + if (insert_position < node->start()) { insert_position = insert_position + left->count() + 1; node = left; } @@ -2332,7 +2332,7 @@ void btree<P>::rebalance_or_split(iterator *iter) { } } - if (node->position() < parent->finish()) { + if (node->position() < parent->finish()) { // Try rebalancing with our right sibling. node_type *right = parent->child(node->position() + 1); assert(right->max_count() == kNodeSlots); @@ -2341,14 +2341,14 @@ void btree<P>::rebalance_or_split(iterator *iter) { // inserting at the beginning of the left node then we bias rebalancing // to fill up the right node. int to_move = (static_cast<int>(kNodeSlots) - right->count()) / - (1 + (insert_position > node->start())); + (1 + (insert_position > node->start())); to_move = (std::max)(1, to_move); - if (insert_position <= node->finish() - to_move || + if (insert_position <= node->finish() - to_move || right->count() + to_move < static_cast<int>(kNodeSlots)) { node->rebalance_left_to_right(to_move, right, mutable_allocator()); - if (insert_position > node->finish()) { + if (insert_position > node->finish()) { insert_position = insert_position - node->count() - 1; node = right; } @@ -2371,11 +2371,11 @@ void btree<P>::rebalance_or_split(iterator *iter) { // Create a new root node and set the current root node as the child of the // new root. parent = new_internal_node(parent); - parent->init_child(parent->start(), root()); + parent->init_child(parent->start(), root()); mutable_root() = parent; // If the former root was a leaf node, then it's now the rightmost node. - assert(!parent->start_child()->leaf() || - parent->start_child() == rightmost_); + assert(!parent->start_child()->leaf() || + parent->start_child() == rightmost_); } // Split the node. @@ -2389,7 +2389,7 @@ void btree<P>::rebalance_or_split(iterator *iter) { node->split(insert_position, split_node, mutable_allocator()); } - if (insert_position > node->finish()) { + if (insert_position > node->finish()) { insert_position = insert_position - node->count() - 1; node = split_node; } @@ -2404,7 +2404,7 @@ void btree<P>::merge_nodes(node_type *left, node_type *right) { template <typename P> bool btree<P>::try_merge_or_rebalance(iterator *iter) { node_type *parent = iter->node->parent(); - if (iter->node->position() > parent->start()) { + if (iter->node->position() > parent->start()) { // Try merging with our left sibling. node_type *left = parent->child(iter->node->position() - 1); assert(left->max_count() == kNodeSlots); @@ -2415,7 +2415,7 @@ bool btree<P>::try_merge_or_rebalance(iterator *iter) { return true; } } - if (iter->node->position() < parent->finish()) { + if (iter->node->position() < parent->finish()) { // Try merging with our right sibling. node_type *right = parent->child(iter->node->position() + 1); assert(right->max_count() == kNodeSlots); @@ -2427,22 +2427,22 @@ bool btree<P>::try_merge_or_rebalance(iterator *iter) { // we deleted the first element from iter->node and the node is not // empty. This is a small optimization for the common pattern of deleting // from the front of the tree. - if (right->count() > kMinNodeValues && - (iter->node->count() == 0 || iter->position > iter->node->start())) { + if (right->count() > kMinNodeValues && + (iter->node->count() == 0 || iter->position > iter->node->start())) { int to_move = (right->count() - iter->node->count()) / 2; to_move = (std::min)(to_move, right->count() - 1); iter->node->rebalance_right_to_left(to_move, right, mutable_allocator()); return false; } } - if (iter->node->position() > parent->start()) { + if (iter->node->position() > parent->start()) { // Try rebalancing with our left sibling. We don't perform rebalancing if // we deleted the last element from iter->node and the node is not // empty. This is a small optimization for the common pattern of deleting // from the back of the tree. node_type *left = parent->child(iter->node->position() - 1); - if (left->count() > kMinNodeValues && - (iter->node->count() == 0 || iter->position < iter->node->finish())) { + if (left->count() > kMinNodeValues && + (iter->node->count() == 0 || iter->position < iter->node->finish())) { int to_move = (left->count() - iter->node->count()) / 2; to_move = (std::min)(to_move, left->count() - 1); left->rebalance_left_to_right(to_move, iter->node, mutable_allocator()); @@ -2475,7 +2475,7 @@ template <typename P> template <typename IterType> inline IterType btree<P>::internal_last(IterType iter) { assert(iter.node != nullptr); - while (iter.position == iter.node->finish()) { + while (iter.position == iter.node->finish()) { iter.position = iter.node->position(); iter.node = iter.node->parent(); if (iter.node->leaf()) { @@ -2528,7 +2528,7 @@ template <typename P> template <typename K> inline auto btree<P>::internal_locate(const K &key) const -> SearchResult<iterator, is_key_compare_to::value> { - iterator iter(const_cast<node_type *>(root())); + iterator iter(const_cast<node_type *>(root())); for (;;) { SearchResult<int, is_key_compare_to::value> res = iter.node->lower_bound(key, key_comp()); @@ -2559,7 +2559,7 @@ auto btree<P>::internal_lower_bound(const K &key) const ret.value = internal_last(ret.value); return ret; } - iterator iter(const_cast<node_type *>(root())); + iterator iter(const_cast<node_type *>(root())); SearchResult<int, is_key_compare_to::value> res; bool seen_eq = false; for (;;) { @@ -2578,7 +2578,7 @@ auto btree<P>::internal_lower_bound(const K &key) const template <typename P> template <typename K> auto btree<P>::internal_upper_bound(const K &key) const -> iterator { - iterator iter(const_cast<node_type *>(root())); + iterator iter(const_cast<node_type *>(root())); for (;;) { iter.position = iter.node->upper_bound(key, key_comp()); if (iter.node->leaf()) { @@ -2607,35 +2607,35 @@ auto btree<P>::internal_find(const K &key) const -> iterator { } template <typename P> -int btree<P>::internal_verify(const node_type *node, const key_type *lo, - const key_type *hi) const { +int btree<P>::internal_verify(const node_type *node, const key_type *lo, + const key_type *hi) const { assert(node->count() > 0); assert(node->count() <= node->max_count()); if (lo) { - assert(!compare_keys(node->key(node->start()), *lo)); + assert(!compare_keys(node->key(node->start()), *lo)); } if (hi) { - assert(!compare_keys(*hi, node->key(node->finish() - 1))); + assert(!compare_keys(*hi, node->key(node->finish() - 1))); } - for (int i = node->start() + 1; i < node->finish(); ++i) { + for (int i = node->start() + 1; i < node->finish(); ++i) { assert(!compare_keys(node->key(i), node->key(i - 1))); } int count = node->count(); if (!node->leaf()) { - for (int i = node->start(); i <= node->finish(); ++i) { + for (int i = node->start(); i <= node->finish(); ++i) { assert(node->child(i) != nullptr); assert(node->child(i)->parent() == node); assert(node->child(i)->position() == i); - count += internal_verify(node->child(i), - i == node->start() ? lo : &node->key(i - 1), - i == node->finish() ? hi : &node->key(i)); + count += internal_verify(node->child(i), + i == node->start() ? lo : &node->key(i - 1), + i == node->finish() ? hi : &node->key(i)); } } return count; } } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_BTREE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h index d23feff31b..705b7c0994 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/btree_container.h @@ -28,7 +28,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // A common base class for btree_set, btree_map, btree_multiset, and @@ -156,7 +156,7 @@ class btree_container { iterator erase(const_iterator iter) { return tree_.erase(iterator(iter)); } iterator erase(iterator iter) { return tree_.erase(iter); } iterator erase(const_iterator first, const_iterator last) { - return tree_.erase_range(iterator(first), iterator(last)).second; + return tree_.erase_range(iterator(first), iterator(last)).second; } template <typename K = key_type> size_type erase(const key_arg<K> &key) { @@ -320,10 +320,10 @@ class btree_set_container : public btree_container<Tree> { insert_return_type insert(node_type &&node) { if (!node) return {this->end(), false, node_type()}; std::pair<iterator, bool> res = - this->tree_.insert_unique(params_type::key(CommonAccess::GetSlot(node)), - CommonAccess::GetSlot(node)); + this->tree_.insert_unique(params_type::key(CommonAccess::GetSlot(node)), + CommonAccess::GetSlot(node)); if (res.second) { - CommonAccess::Destroy(&node); + CommonAccess::Destroy(&node); return {res.first, true, node_type()}; } else { return {res.first, false, std::move(node)}; @@ -333,8 +333,8 @@ class btree_set_container : public btree_container<Tree> { if (!node) return this->end(); std::pair<iterator, bool> res = this->tree_.insert_hint_unique( iterator(hint), params_type::key(CommonAccess::GetSlot(node)), - CommonAccess::GetSlot(node)); - if (res.second) CommonAccess::Destroy(&node); + CommonAccess::GetSlot(node)); + if (res.second) CommonAccess::Destroy(&node); return res.first; } @@ -391,7 +391,7 @@ class btree_map_container : public btree_set_container<Tree> { using params_type = typename Tree::params_type; friend class BtreeNodePeer; - private: + private: template <class K> using key_arg = typename super_type::template key_arg<K>; @@ -409,43 +409,43 @@ class btree_map_container : public btree_set_container<Tree> { btree_map_container() {} // Insertion routines. - // Note: the nullptr template arguments and extra `const M&` overloads allow - // for supporting bitfield arguments. + // Note: the nullptr template arguments and extra `const M&` overloads allow + // for supporting bitfield arguments. template <typename K = key_type, class M> std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k, const M &obj) { return insert_or_assign_impl(k, obj); - } + } template <typename K = key_type, class M, K * = nullptr> std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, const M &obj) { return insert_or_assign_impl(std::forward<K>(k), obj); - } + } template <typename K = key_type, class M, M * = nullptr> std::pair<iterator, bool> insert_or_assign(const key_arg<K> &k, M &&obj) { return insert_or_assign_impl(k, std::forward<M>(obj)); - } + } template <typename K = key_type, class M, K * = nullptr, M * = nullptr> std::pair<iterator, bool> insert_or_assign(key_arg<K> &&k, M &&obj) { return insert_or_assign_impl(std::forward<K>(k), std::forward<M>(obj)); - } + } template <typename K = key_type, class M> iterator insert_or_assign(const_iterator hint, const key_arg<K> &k, - const M &obj) { + const M &obj) { return insert_or_assign_hint_impl(hint, k, obj); - } + } template <typename K = key_type, class M, K * = nullptr> iterator insert_or_assign(const_iterator hint, key_arg<K> &&k, const M &obj) { return insert_or_assign_hint_impl(hint, std::forward<K>(k), obj); - } + } template <typename K = key_type, class M, M * = nullptr> iterator insert_or_assign(const_iterator hint, const key_arg<K> &k, M &&obj) { return insert_or_assign_hint_impl(hint, k, std::forward<M>(obj)); - } + } template <typename K = key_type, class M, K * = nullptr, M * = nullptr> iterator insert_or_assign(const_iterator hint, key_arg<K> &&k, M &&obj) { return insert_or_assign_hint_impl(hint, std::forward<K>(k), std::forward<M>(obj)); - } + } template <typename K = key_type, typename... Args, typename y_absl::enable_if_t< @@ -603,21 +603,21 @@ class btree_multiset_container : public btree_container<Tree> { return this->tree_.insert_hint_multi( iterator(hint), init_type(std::forward<Args>(args)...)); } - iterator insert(node_type &&node) { + iterator insert(node_type &&node) { if (!node) return this->end(); iterator res = - this->tree_.insert_multi(params_type::key(CommonAccess::GetSlot(node)), - CommonAccess::GetSlot(node)); - CommonAccess::Destroy(&node); + this->tree_.insert_multi(params_type::key(CommonAccess::GetSlot(node)), + CommonAccess::GetSlot(node)); + CommonAccess::Destroy(&node); return res; } iterator insert(const_iterator hint, node_type &&node) { - if (!node) return this->end(); - iterator res = this->tree_.insert_hint_multi( - iterator(hint), - std::move(params_type::element(CommonAccess::GetSlot(node)))); - CommonAccess::Destroy(&node); - return res; + if (!node) return this->end(); + iterator res = this->tree_.insert_hint_multi( + iterator(hint), + std::move(params_type::element(CommonAccess::GetSlot(node)))); + CommonAccess::Destroy(&node); + return res; } // Node extraction routines. @@ -677,7 +677,7 @@ class btree_multimap_container : public btree_multiset_container<Tree> { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_BTREE_CONTAINER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h index ec84f975e5..0a40bd573d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/common.h @@ -22,7 +22,7 @@ #include "y_absl/types/optional.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class, class = void> @@ -56,7 +56,7 @@ class node_handle_base { public: using allocator_type = Alloc; - constexpr node_handle_base() = default; + constexpr node_handle_base() = default; node_handle_base(node_handle_base&& other) noexcept { *this = std::move(other); } @@ -109,8 +109,8 @@ class node_handle_base { allocator_type* alloc() { return std::addressof(*alloc_); } private: - y_absl::optional<allocator_type> alloc_ = {}; - alignas(slot_type) mutable unsigned char slot_space_[sizeof(slot_type)] = {}; + y_absl::optional<allocator_type> alloc_ = {}; + alignas(slot_type) mutable unsigned char slot_space_[sizeof(slot_type)] = {}; }; // For sets. @@ -171,11 +171,11 @@ struct CommonAccess { } template <typename Node> - static void Destroy(Node* node) { - node->destroy(); - } - - template <typename Node> + static void Destroy(Node* node) { + node->destroy(); + } + + template <typename Node> static void Reset(Node* node) { node->reset(); } @@ -200,7 +200,7 @@ struct InsertReturnType { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_CONTAINER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h index 735b738a9b..241a6c3453 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/compressed_tuple.h @@ -48,7 +48,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename... Ts> @@ -282,7 +282,7 @@ template <> class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple<> {}; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #undef ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h index 348bc8c0d0..bc2a133800 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/container_memory.h @@ -37,7 +37,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <size_t Alignment> @@ -454,7 +454,7 @@ struct map_slot_policy { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h index c8975dbd90..72a5a598ef 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/counting_allocator.h @@ -18,10 +18,10 @@ #include <cstdint> #include <memory> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // This is a stateful allocator, but the state lives outside of the @@ -108,7 +108,7 @@ class CountingAllocator { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_COUNTING_ALLOCATOR_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h index 68a18058d1..231fc20073 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_function_defaults.h @@ -48,7 +48,7 @@ #include <stdint.h> #include <cstddef> #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include "y_absl/base/config.h" @@ -57,7 +57,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // The hash of an object of type T is computed by using y_absl::Hash. @@ -157,7 +157,7 @@ template <class T> using hash_default_eq = typename container_internal::HashEq<T>::Eq; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_HASH_FUNCTION_DEFAULTS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_generator_testing.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_generator_testing.h index 79b215465e..93aa1b8b7e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_generator_testing.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_generator_testing.h @@ -35,7 +35,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hash_internal { namespace generator_internal { @@ -176,7 +176,7 @@ struct UniqueGenerator { } // namespace hash_internal } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_HASH_GENERATOR_TESTING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_testing.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_testing.h index baa367eee6..4c2a64d41e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_testing.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_testing.h @@ -30,7 +30,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hash_testing_internal { @@ -163,7 +163,7 @@ auto keys(const Set& s) } } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // ABSL_UNORDERED_SUPPORTS_ALLOC_CTORS is false for glibcxx versions diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h index 33f704fc4b..322bb0658d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hash_policy_traits.h @@ -24,7 +24,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // Defines how slots are initialized/destroyed/moved. @@ -202,7 +202,7 @@ struct hash_policy_traits { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_HASH_POLICY_TRAITS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug.h index 2be9db2297..cfdeda28d1 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug.h @@ -38,7 +38,7 @@ #include "y_absl/container/internal/hashtable_debug_hooks.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // Returns the number of probes required to lookup `key`. Returns 0 for a @@ -104,7 +104,7 @@ size_t LowerBoundAllocatedByteSize(size_t num_elements) { } } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug_hooks.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug_hooks.h index ec8c0fd29d..522ac114d5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug_hooks.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtable_debug_hooks.h @@ -23,10 +23,10 @@ #include <type_traits> #include <vector> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { namespace hashtable_debug_internal { @@ -79,7 +79,7 @@ struct HashtableDebugAccess { } // namespace hashtable_debug_internal } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_HOOKS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc index 6017ac9bb0..0099dfee53 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.cc @@ -29,7 +29,7 @@ #include "y_absl/synchronization/mutex.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { constexpr int HashtablezInfo::kMaxStackDepth; @@ -39,16 +39,16 @@ ABSL_CONST_INIT std::atomic<bool> g_hashtablez_enabled{ }; ABSL_CONST_INIT std::atomic<int32_t> g_hashtablez_sample_parameter{1 << 10}; -#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) ABSL_PER_THREAD_TLS_KEYWORD y_absl::profiling_internal::ExponentialBiased g_exponential_biased_generator; #endif } // namespace -#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample = 0; -#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) HashtablezSampler& GlobalHashtablezSampler() { static auto* sampler = new HashtablezSampler(); @@ -109,15 +109,15 @@ HashtablezInfo* SampleSlow(int64_t* next_sample, size_t inline_element_size) { return result; } -#if !defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#if !defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) *next_sample = std::numeric_limits<int64_t>::max(); return nullptr; #else bool first = *next_sample < 0; - *next_sample = g_exponential_biased_generator.GetStride( + *next_sample = g_exponential_biased_generator.GetStride( g_hashtablez_sample_parameter.load(std::memory_order_relaxed)); // Small values of interval are equivalent to just sampling next time. - ABSL_ASSERT(*next_sample >= 1); + ABSL_ASSERT(*next_sample >= 1); // g_hashtablez_enabled can be dynamically flipped, we need to set a threshold // low enough that we will start sampling in a reasonable time, so we just use @@ -186,5 +186,5 @@ void SetHashtablezMaxSamples(int32_t max) { } } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h index 8521ee754a..45fafc7b39 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler.h @@ -52,7 +52,7 @@ #include "y_absl/utility/utility.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // Stores information about a sampled hashtable. All mutations to this *must* @@ -231,9 +231,9 @@ class HashtablezInfoHandle { friend inline void swap(HashtablezInfoHandle& /*lhs*/, HashtablezInfoHandle& /*rhs*/) {} }; -#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) - -#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) + +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) extern ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample; #endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) @@ -241,7 +241,7 @@ extern ABSL_PER_THREAD_TLS_KEYWORD int64_t global_next_sample; // with the global sampler. inline HashtablezInfoHandle Sample( size_t inline_element_size ABSL_ATTRIBUTE_UNUSED) { -#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) +#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) if (ABSL_PREDICT_TRUE(--global_next_sample > 0)) { return HashtablezInfoHandle(nullptr); } @@ -275,7 +275,7 @@ void SetHashtablezMaxSamples(int32_t max); extern "C" bool ABSL_INTERNAL_C_SYMBOL(AbslContainerInternalSampleEverything)(); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_HASHTABLEZ_SAMPLER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc index 79a3122981..07e5205b55 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc @@ -17,7 +17,7 @@ #include "y_absl/base/attributes.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // See hashtablez_sampler.h for details. @@ -27,5 +27,5 @@ extern "C" ABSL_ATTRIBUTE_WEAK bool ABSL_INTERNAL_C_SYMBOL( } } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h index e6488e843e..c08cf9591e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/inlined_vector.h @@ -33,7 +33,7 @@ #include "y_absl/types/span.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace inlined_vector_internal { // GCC does not deal very well with the below code @@ -926,7 +926,7 @@ auto Storage<T, N, A>::Swap(Storage* other_storage_ptr) -> void { #endif } // namespace inlined_vector_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_INLINED_VECTOR_INTERNAL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h index 4c3f668943..648ef26834 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/layout.h @@ -165,7 +165,7 @@ #include <stdint.h> #include <ostream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <tuple> #include <type_traits> #include <typeinfo> @@ -190,7 +190,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // A type wrapper that instructs `Layout` to use the specific alignment for the @@ -737,7 +737,7 @@ class Layout : public internal_layout::LayoutType<sizeof...(Ts), Ts...> { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_LAYOUT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/node_hash_policy.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/node_hash_policy.h index 24d0eaf5ee..6abf3132c6 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/node_hash_policy.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/node_hash_policy.h @@ -39,10 +39,10 @@ #include <type_traits> #include <utility> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class Reference, class Policy> @@ -86,7 +86,7 @@ struct node_hash_policy { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_NODE_HASH_POLICY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_map.h index 8a0591f581..21470c4551 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_map.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_map.h @@ -24,7 +24,7 @@ #include "y_absl/container/internal/raw_hash_set.h" // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class Policy, class Hash, class Eq, class Alloc> @@ -192,7 +192,7 @@ class raw_hash_map : public raw_hash_set<Policy, Hash, Eq, Alloc> { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_RAW_HASH_MAP_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc index bf2a15a678..08ef1df039 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.cc @@ -20,7 +20,7 @@ #include "y_absl/base/config.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { alignas(16) ABSL_CONST_INIT ABSL_DLL const ctrl_t kEmptyGroup[16] = { @@ -63,5 +63,5 @@ void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity) { template FindInfo find_first_non_full(const ctrl_t*, size_t, size_t); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h index 8f45559b31..0122c31dad 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set.h @@ -129,7 +129,7 @@ #include "y_absl/utility/utility.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename AllocType> @@ -1220,7 +1220,7 @@ class raw_hash_set { template <class... Args, typename std::enable_if< !IsDecomposable<Args...>::value, int>::type = 0> std::pair<iterator, bool> emplace(Args&&... args) { - alignas(slot_type) unsigned char raw[sizeof(slot_type)]; + alignas(slot_type) unsigned char raw[sizeof(slot_type)]; slot_type* slot = reinterpret_cast<slot_type*>(&raw); PolicyTraits::construct(&alloc_ref(), slot, std::forward<Args>(args)...); @@ -1236,16 +1236,16 @@ class raw_hash_set { // Extension API: support for lazy emplace. // // Looks up key in the table. If found, returns the iterator to the element. - // Otherwise calls `f` with one argument of type `raw_hash_set::constructor`. - // - // `f` must abide by several restrictions: - // - it MUST call `raw_hash_set::constructor` with arguments as if a - // `raw_hash_set::value_type` is constructed, - // - it MUST NOT access the container before the call to - // `raw_hash_set::constructor`, and - // - it MUST NOT erase the lazily emplaced element. - // Doing any of these is undefined behavior. + // Otherwise calls `f` with one argument of type `raw_hash_set::constructor`. // + // `f` must abide by several restrictions: + // - it MUST call `raw_hash_set::constructor` with arguments as if a + // `raw_hash_set::value_type` is constructed, + // - it MUST NOT access the container before the call to + // `raw_hash_set::constructor`, and + // - it MUST NOT erase the lazily emplaced element. + // Doing any of these is undefined behavior. + // // For example: // // std::unordered_set<ArenaString> s; @@ -1727,7 +1727,7 @@ class raw_hash_set { // mark target as FULL // repeat procedure for current slot with moved from element (target) ConvertDeletedToEmptyAndFullToDeleted(ctrl_, capacity_); - alignas(slot_type) unsigned char raw[sizeof(slot_type)]; + alignas(slot_type) unsigned char raw[sizeof(slot_type)]; size_t total_probe_length = 0; slot_type* slot = reinterpret_cast<slot_type*>(&raw); for (size_t i = 0; i != capacity_; ++i) { @@ -1956,18 +1956,18 @@ class raw_hash_set { allocator_type{}}; }; -// Erases all elements that satisfy the predicate `pred` from the container `c`. -template <typename P, typename H, typename E, typename A, typename Predicate> +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename P, typename H, typename E, typename A, typename Predicate> void EraseIf(Predicate& pred, raw_hash_set<P, H, E, A>* c) { - for (auto it = c->begin(), last = c->end(); it != last;) { + for (auto it = c->begin(), last = c->end(); it != last;) { if (pred(*it)) { c->erase(it++); } else { ++it; - } - } -} - + } + } +} + namespace hashtable_debug_internal { template <typename Set> struct HashtableDebugAccess<Set, y_absl::void_t<typename Set::raw_hash_set>> { @@ -2028,7 +2028,7 @@ struct HashtableDebugAccess<Set, y_absl::void_t<typename Set::raw_hash_set>> { } // namespace hashtable_debug_internal } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_RAW_HASH_SET_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make index d636929b87..ebb8b79a7d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/raw_hash_set/ya.make @@ -37,9 +37,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/types ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/test_instance_tracker.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/test_instance_tracker.h index 49dcaf5d21..cdd5c24d51 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/test_instance_tracker.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/test_instance_tracker.h @@ -21,7 +21,7 @@ #include "y_absl/types/compare.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace test_internal { // A type that counts number of occurrences of the type, the live occurrences of @@ -268,7 +268,7 @@ class MovableOnlyInstance : public BaseCountedInstance { }; } // namespace test_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_TEST_INSTANCE_TRACKER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/tracked.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/tracked.h index 8765ee5ea6..62db47fe0b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/tracked.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/tracked.h @@ -16,14 +16,14 @@ #define ABSL_CONTAINER_INTERNAL_TRACKED_H_ #include <stddef.h> - + #include <memory> #include <utility> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { // A class that tracks its copies and moves so that it can be queried in tests. @@ -77,7 +77,7 @@ class Tracked { }; } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_TRACKED_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h index f55d6293ae..fbc2439e81 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_constructor_test.h @@ -25,7 +25,7 @@ #include "y_absl/container/internal/hash_policy_testing.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -488,7 +488,7 @@ REGISTER_TYPED_TEST_CASE_P( AssignmentFromInitializerListOverwritesExisting, AssignmentOnSelf); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_CONSTRUCTOR_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_lookup_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_lookup_test.h index 251f49aea2..5ec33318c2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_lookup_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_lookup_test.h @@ -21,7 +21,7 @@ #include "y_absl/container/internal/hash_policy_testing.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -111,7 +111,7 @@ REGISTER_TYPED_TEST_CASE_P(LookupTest, At, OperatorBracket, Count, Find, EqualRange); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_members_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_members_test.h index 1c9dc8c6be..68b12d7302 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_members_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_members_test.h @@ -21,7 +21,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -81,7 +81,7 @@ TYPED_TEST_P(MembersTest, BeginEnd) { REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h index 725cfdc345..e6cce711ba 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_map_modifiers_test.h @@ -23,7 +23,7 @@ #include "y_absl/container/internal/hash_policy_testing.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -345,7 +345,7 @@ TYPED_TEST_P(UniquePtrModifiersTest, TryEmplace) { REGISTER_TYPED_TEST_SUITE_P(UniquePtrModifiersTest, TryEmplace); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MODIFIERS_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_constructor_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_constructor_test.h index 1404f44916..185b6efd6e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_constructor_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_constructor_test.h @@ -26,7 +26,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordMap> @@ -490,7 +490,7 @@ REGISTER_TYPED_TEST_CASE_P( AssignmentFromInitializerListOverwritesExisting, AssignmentOnSelf); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_CONSTRUCTOR_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_lookup_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_lookup_test.h index 05579173d1..42319a2cb2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_lookup_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_lookup_test.h @@ -21,7 +21,7 @@ #include "y_absl/container/internal/hash_policy_testing.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordSet> @@ -85,7 +85,7 @@ TYPED_TEST_P(LookupTest, EqualRange) { REGISTER_TYPED_TEST_CASE_P(LookupTest, Count, Find, EqualRange); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_LOOKUP_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_members_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_members_test.h index ad1c88d8b2..c64414b33e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_members_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_members_test.h @@ -21,7 +21,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordSet> @@ -80,7 +80,7 @@ TYPED_TEST_P(MembersTest, BeginEnd) { REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_modifiers_test.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_modifiers_test.h index 2f96a0197b..aead336049 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_modifiers_test.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/internal/unordered_set_modifiers_test.h @@ -21,7 +21,7 @@ #include "y_absl/container/internal/hash_policy_testing.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class UnordSet> @@ -215,7 +215,7 @@ REGISTER_TYPED_TEST_CASE_P(ModifiersTest, Clear, Insert, InsertHint, Erase, EraseRange, EraseKey, Swap); } // namespace container_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MODIFIERS_TEST_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h index 07e26def79..70ba43215b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_map.h @@ -48,7 +48,7 @@ #include "y_absl/memory/memory.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <class Key, class Value> class NodeHashMapPolicy; @@ -522,15 +522,15 @@ class node_hash_map using Base::key_eq; }; -// erase_if(node_hash_map<>, Pred) -// -// Erases all elements that satisfy the predicate `pred` from the container `c`. -template <typename K, typename V, typename H, typename E, typename A, - typename Predicate> -void erase_if(node_hash_map<K, V, H, E, A>& c, Predicate pred) { - container_internal::EraseIf(pred, &c); -} - +// erase_if(node_hash_map<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename K, typename V, typename H, typename E, typename A, + typename Predicate> +void erase_if(node_hash_map<K, V, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class Key, class Value> @@ -591,7 +591,7 @@ struct IsUnorderedContainer< } // namespace container_algorithm_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_NODE_HASH_MAP_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h index aa98bb29b8..733dd08bb3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/container/node_hash_set.h @@ -44,7 +44,7 @@ #include "y_absl/memory/memory.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace container_internal { template <typename T> struct NodeHashSetPolicy; @@ -77,7 +77,7 @@ struct NodeHashSetPolicy; // // // Create a node hash set of three strings // y_absl::node_hash_set<TString> ducks = -// {"huey", "dewey", "louie"}; +// {"huey", "dewey", "louie"}; // // // Insert a new element into the node hash set // ducks.insert("donald"); @@ -111,7 +111,7 @@ class node_hash_set // * Initializer List constructor // // y_absl::node_hash_set<TString> set2 = - // {{"huey"}, {"dewey"}, {"louie"}}; + // {{"huey"}, {"dewey"}, {"louie"}}; // // * Copy constructor // @@ -430,14 +430,14 @@ class node_hash_set using Base::key_eq; }; -// erase_if(node_hash_set<>, Pred) -// -// Erases all elements that satisfy the predicate `pred` from the container `c`. -template <typename T, typename H, typename E, typename A, typename Predicate> -void erase_if(node_hash_set<T, H, E, A>& c, Predicate pred) { - container_internal::EraseIf(pred, &c); -} - +// erase_if(node_hash_set<>, Pred) +// +// Erases all elements that satisfy the predicate `pred` from the container `c`. +template <typename T, typename H, typename E, typename A, typename Predicate> +void erase_if(node_hash_set<T, H, E, A>& c, Predicate pred) { + container_internal::EraseIf(pred, &c); +} + namespace container_internal { template <class T> @@ -487,7 +487,7 @@ struct IsUnorderedContainer<y_absl::node_hash_set<Key, Hash, KeyEqual, Allocator : std::true_type {}; } // namespace container_algorithm_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_CONTAINER_NODE_HASH_SET_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.cc index fa6e30f935..90cc7b4575 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.cc @@ -25,10 +25,10 @@ #include <unistd.h> #endif -#ifdef __APPLE__ -#include <TargetConditionals.h> -#endif - +#ifdef __APPLE__ +#include <TargetConditionals.h> +#endif + #ifdef ABSL_HAVE_MMAP #include <sys/mman.h> #endif @@ -42,7 +42,7 @@ #include <ctime> #include "y_absl/base/attributes.h" -#include "y_absl/base/internal/errno_saver.h" +#include "y_absl/base/internal/errno_saver.h" #include "y_absl/base/internal/raw_logging.h" #include "y_absl/base/internal/sysinfo.h" #include "y_absl/debugging/internal/examine_stack.h" @@ -50,15 +50,15 @@ #ifndef _WIN32 #define ABSL_HAVE_SIGACTION -// Apple WatchOS and TVOS don't allow sigaltstack -#if !(defined(TARGET_OS_WATCH) && TARGET_OS_WATCH) && \ - !(defined(TARGET_OS_TV) && TARGET_OS_TV) -#define ABSL_HAVE_SIGALTSTACK -#endif +// Apple WatchOS and TVOS don't allow sigaltstack +#if !(defined(TARGET_OS_WATCH) && TARGET_OS_WATCH) && \ + !(defined(TARGET_OS_TV) && TARGET_OS_TV) +#define ABSL_HAVE_SIGALTSTACK #endif +#endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN ABSL_CONST_INIT static FailureSignalHandlerOptions fsh_options; @@ -128,7 +128,7 @@ const char* FailureSignalToString(int signo) { } // namespace debugging_internal -#ifdef ABSL_HAVE_SIGALTSTACK +#ifdef ABSL_HAVE_SIGALTSTACK static bool SetupAlternateStackOnce() { #if defined(__wasm__) || defined (__asjms__) @@ -181,7 +181,7 @@ static bool SetupAlternateStackOnce() { // Returns the appropriate flag for sig_action.sa_flags // if the system supports using an alternate stack. static int MaybeSetupAlternateStack() { -#ifdef ABSL_HAVE_SIGALTSTACK +#ifdef ABSL_HAVE_SIGALTSTACK ABSL_ATTRIBUTE_UNUSED static const bool kOnce = SetupAlternateStackOnce(); return SA_ONSTACK; #else @@ -217,7 +217,7 @@ static void InstallOneFailureHandler(FailureSignalData* data, #endif static void WriteToStderr(const char* data) { - y_absl::base_internal::ErrnoSaver errno_saver; + y_absl::base_internal::ErrnoSaver errno_saver; y_absl::raw_logging_internal::SafeWriteToStderr(data, strlen(data)); } @@ -384,5 +384,5 @@ void InstallFailureSignalHandler(const FailureSignalHandlerOptions& options) { } } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.h index 879df3c434..1b0ce953f2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler.h @@ -44,10 +44,10 @@ #ifndef ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ #define ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // FailureSignalHandlerOptions // @@ -115,7 +115,7 @@ namespace debugging_internal { const char* FailureSignalToString(int signo); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.cc index df217335ea..2481f10226 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.cc @@ -20,14 +20,14 @@ #if !defined(__linux__) || defined(__ANDROID__) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // On platforms other than Linux, just return true. bool AddressIsReadable(const void* /* addr */) { return true; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else @@ -35,16 +35,16 @@ ABSL_NAMESPACE_END #include <fcntl.h> #include <sys/syscall.h> #include <unistd.h> - + #include <atomic> #include <cerrno> #include <cstdint> -#include "y_absl/base/internal/errno_saver.h" +#include "y_absl/base/internal/errno_saver.h" #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Pack a pid and two file descriptors into a 64-bit word, @@ -70,7 +70,7 @@ static void Unpack(uint64_t x, int *pid, int *read_fd, int *write_fd) { static std::atomic<uint64_t> pid_and_fds; // initially 0, an invalid pid. bool AddressIsReadable(const void *addr) { - y_absl::base_internal::ErrnoSaver errno_saver; + y_absl::base_internal::ErrnoSaver errno_saver; // We test whether a byte is readable by using write(). Normally, this would // be done via a cached file descriptor to /dev/null, but linux fails to // check whether the byte is readable when the destination is /dev/null, so @@ -133,7 +133,7 @@ bool AddressIsReadable(const void *addr) { } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.h index 279dcc640b..1c30b0e95d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/address_is_readable.h @@ -15,10 +15,10 @@ #ifndef ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ #define ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Return whether the byte at *addr is readable, without faulting. @@ -26,7 +26,7 @@ namespace debugging_internal { bool AddressIsReadable(const void *addr); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.cc index 0a4daa2f5c..9ca0d2a293 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.cc @@ -24,7 +24,7 @@ #include <limits> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { typedef struct { @@ -1955,5 +1955,5 @@ bool Demangle(const char *mangled, char *out, int out_size) { } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.h index a9b42edb45..60e7ff715d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/demangle.h @@ -53,10 +53,10 @@ #ifndef ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Demangle `mangled`. On success, return true and write the @@ -65,7 +65,7 @@ namespace debugging_internal { bool Demangle(const char *mangled, char *out, int out_size); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.cc index ba4bbc3855..8d70b5ad7b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.cc @@ -39,7 +39,7 @@ #define VERSYM_VERSION 0x7fff namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { namespace { @@ -377,7 +377,7 @@ void ElfMemImage::SymbolIterator::Update(int increment) { } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HAVE_ELF_MEM_IMAGE diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.h index 13a6b2e664..73a25707cd 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/elf_mem_image.h @@ -23,8 +23,8 @@ // used. #include <climits> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + // Maybe one day we can rewrite this file not to require the elf // symbol extensions in glibc, but for right now we need them. #ifdef ABSL_HAVE_ELF_MEM_IMAGE @@ -45,7 +45,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // An in-memory ELF image (may not exist on disk). @@ -130,7 +130,7 @@ class ElfMemImage { }; } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HAVE_ELF_MEM_IMAGE diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.cc index c59d92b6a3..7d910c8b36 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.cc @@ -34,7 +34,7 @@ #include "y_absl/debugging/symbolize.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Returns the program counter from signal context, nullptr if @@ -65,8 +65,8 @@ void* GetProgramCounter(void* vuc) { return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]); #elif defined(__powerpc__) return reinterpret_cast<void*>(context->uc_mcontext.uc_regs->gregs[32]); -#elif defined(__riscv) - return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]); +#elif defined(__riscv) + return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]); #elif defined(__s390__) && !defined(__s390x__) return reinterpret_cast<void*>(context->uc_mcontext.psw.addr & 0x7fffffff); #elif defined(__s390__) && defined(__s390x__) @@ -199,5 +199,5 @@ void DumpPCAndFrameSizesAndStackTrace( } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.h index 32892a1150..7d31fa1644 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/examine_stack.h @@ -17,10 +17,10 @@ #ifndef ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ #define ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Returns the program counter from signal context, or nullptr if @@ -36,7 +36,7 @@ void DumpPCAndFrameSizesAndStackTrace( void (*writerfn)(const char*, void*), void* writerfn_arg); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stack_consumption.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stack_consumption.h index 80137ad0eb..56078487db 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stack_consumption.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stack_consumption.h @@ -18,8 +18,8 @@ #ifndef ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ #define ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + // The code in this module is not portable. // Use this feature test macro to detect its availability. #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION @@ -30,7 +30,7 @@ #define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1 namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Returns the stack consumption in bytes for the code exercised by @@ -42,7 +42,7 @@ namespace debugging_internal { int GetSignalHandlerStackConsumption(void (*signal_handler)(int)); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_aarch64-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_aarch64-inl.inc index 700f607488..24d668681d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_aarch64-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_aarch64-inl.inc @@ -187,13 +187,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_AARCH64_INL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_arm-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_arm-inl.inc index b73307120e..fbef773be9 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_arm-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_arm-inl.inc @@ -122,13 +122,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return false; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_ARM_INL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_generic-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_generic-inl.inc index fa623aa954..f73f9a6a56 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_generic-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_generic-inl.inc @@ -96,13 +96,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_GENERIC_INL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_powerpc-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_powerpc-inl.inc index 1e41c4ebf2..a4a3601e3c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_powerpc-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_powerpc-inl.inc @@ -241,13 +241,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_POWERPC_INL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_unimplemented-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_unimplemented-inl.inc index 54dccaeae9..c3a753043b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_unimplemented-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_unimplemented-inl.inc @@ -12,13 +12,13 @@ static int UnwindImpl(void** /* result */, int* /* sizes */, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return false; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_UNIMPLEMENTED_INL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_win32-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_win32-inl.inc index 69bd7e3f2f..8d8f1cacaa 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_win32-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_win32-inl.inc @@ -81,13 +81,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return false; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_WIN32_INL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_x86-inl.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_x86-inl.inc index 8936f8ca70..65f65eccde 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_x86-inl.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/stacktrace_x86-inl.inc @@ -174,7 +174,7 @@ static void **NextStackFrame(void **old_fp, const void *uc, static const unsigned char *kernel_rt_sigreturn_address = nullptr; static const unsigned char *kernel_vsyscall_address = nullptr; if (num_push_instructions == -1) { -#ifdef ABSL_HAVE_VDSO_SUPPORT +#ifdef ABSL_HAVE_VDSO_SUPPORT y_absl::debugging_internal::VDSOSupport vdso; if (vdso.IsPresent()) { y_absl::debugging_internal::VDSOSupport::SymbolInfo @@ -203,9 +203,9 @@ static void **NextStackFrame(void **old_fp, const void *uc, } else { num_push_instructions = 0; } -#else // ABSL_HAVE_VDSO_SUPPORT - num_push_instructions = 0; -#endif // ABSL_HAVE_VDSO_SUPPORT +#else // ABSL_HAVE_VDSO_SUPPORT + num_push_instructions = 0; +#endif // ABSL_HAVE_VDSO_SUPPORT } if (num_push_instructions != 0 && kernel_rt_sigreturn_address != nullptr && old_fp[1] == kernel_rt_sigreturn_address) { @@ -352,13 +352,13 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count, } namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { bool StackTraceWorksForTest() { return true; } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_X86_INL_INC_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/symbolize.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/symbolize.h index e6e2b0724a..e027e6db84 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/symbolize.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/symbolize.h @@ -23,9 +23,9 @@ #include <cstddef> #include <cstdint> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/strings/string_view.h" - + #ifdef ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE #error ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE cannot be directly set #elif defined(__ELF__) && defined(__GLIBC__) && !defined(__native_client__) \ @@ -38,7 +38,7 @@ #include <util/generic/string.h> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // Iterates over all sections, invoking callback on each with the section name @@ -57,7 +57,7 @@ bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, ElfW(Shdr) *out); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE @@ -75,7 +75,7 @@ ABSL_NAMESPACE_END #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { struct SymbolDecoratorArgs { @@ -135,7 +135,7 @@ bool GetFileMappingHint(const void** start, const void** end, uint64_t* offset, const char** filename); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // __cplusplus diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.cc index 7905eba32f..383d2eca56 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.cc @@ -56,7 +56,7 @@ using Elf32_auxv_t = Elf32_Auxinfo; #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { ABSL_CONST_INIT @@ -185,7 +185,7 @@ int GetCPU() { } } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HAVE_VDSO_SUPPORT diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.h index c0064b9fe1..9f03061742 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/internal/vdso_support.h @@ -53,7 +53,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { // NOTE: this class may be used from within tcmalloc, and can not @@ -150,7 +150,7 @@ class VDSOSupport { int GetCPU(); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HAVE_ELF_MEM_IMAGE diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.cc index ae5cf79fe2..ee38bd5d4c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.cc @@ -22,7 +22,7 @@ #ifndef LEAK_SANITIZER namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN bool HaveLeakSanitizer() { return false; } bool LeakCheckerIsActive() { return false; } void DoIgnoreLeak(const void*) { } @@ -30,7 +30,7 @@ void RegisterLivePointers(const void*, size_t) { } void UnRegisterLivePointers(const void*, size_t) { } LeakCheckDisabler::LeakCheckDisabler() { } LeakCheckDisabler::~LeakCheckDisabler() { } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else @@ -42,7 +42,7 @@ extern "C" ABSL_ATTRIBUTE_WEAK int __lsan_is_turned_off(); #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN bool HaveLeakSanitizer() { return true; } #if ABSL_HAVE_ATTRIBUTE_WEAK @@ -63,7 +63,7 @@ void UnRegisterLivePointers(const void* ptr, size_t size) { } LeakCheckDisabler::LeakCheckDisabler() { __lsan_disable(); } LeakCheckDisabler::~LeakCheckDisabler() { __lsan_enable(); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // LEAK_SANITIZER diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.h index d69f08f248..bf46b5afa0 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check.h @@ -32,10 +32,10 @@ #include <cstddef> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // HaveLeakSanitizer() // @@ -127,7 +127,7 @@ void RegisterLivePointers(const void* ptr, size_t size); // `RegisterLivePointers()`, enabling leak checking of those pointers. void UnRegisterLivePointers(const void* ptr, size_t size); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_LEAK_CHECK_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check/ya.make index f22152ef8a..932662c71c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check_disable/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check_disable/ya.make index 41792f1bc6..d88d6d2846 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check_disable/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/leak_check_disable/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.cc index 9263d6a2a8..3046430f17 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.cc @@ -59,7 +59,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { typedef int (*Unwinder)(void**, int*, int, int, const void*, int*); @@ -138,5 +138,5 @@ int DefaultStackUnwinder(void** pcs, int* sizes, int depth, int skip, return n; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.h index cbd48b986b..6246c1e1f2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace.h @@ -31,10 +31,10 @@ #ifndef ABSL_DEBUGGING_STACKTRACE_H_ #define ABSL_DEBUGGING_STACKTRACE_H_ -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // GetStackFrames() // @@ -225,7 +225,7 @@ namespace debugging_internal { // working. extern bool StackTraceWorksForTest(); } // namespace debugging_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_STACKTRACE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace/ya.make index a56bdc8a4c..133d30fd3e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace/ya.make @@ -17,9 +17,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/debugging ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize.h b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize.h index 2a99f65c83..b6c32ad7db 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize.h @@ -55,7 +55,7 @@ #include "y_absl/debugging/internal/symbolize.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // InitializeSymbolizer() // @@ -71,7 +71,7 @@ ABSL_NAMESPACE_BEGIN // // Now you can use the symbolizer // } void InitializeSymbolizer(const char* argv0); -// +// // Symbolize() // // Symbolizes a program counter (instruction pointer value) `pc` and, on @@ -89,11 +89,11 @@ void InitializeSymbolizer(const char* argv0); // if (y_absl::Symbolize(pc, tmp, sizeof(tmp))) { // symbol = tmp; // } -// y_absl::PrintF("%p %s\n", pc, symbol); +// y_absl::PrintF("%p %s\n", pc, symbol); // } bool Symbolize(const void *pc, char *out, int out_size); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_DEBUGGING_SYMBOLIZE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize/ya.make index 58f9d70682..f939ba93b3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize/ya.make @@ -25,9 +25,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_elf.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_elf.inc index 18297405e3..664397e1c0 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_elf.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_elf.inc @@ -82,7 +82,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Value of argv[0]. Used by MaybeInitializeObjFile(). static char *argv0_value = nullptr; @@ -1563,7 +1563,7 @@ bool Symbolize(const void *pc, char *out, int out_size) { return ok; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl extern "C" bool YAbslInternalGetFileMappingHint(const void **start, diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_unimplemented.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_unimplemented.inc index 4e55ed122f..db00d551cf 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_unimplemented.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_unimplemented.inc @@ -17,7 +17,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace debugging_internal { @@ -36,5 +36,5 @@ bool GetFileMappingHint(const void **, const void **, uint64_t *, const char **) void InitializeSymbolizer(const char*) {} bool Symbolize(const void *, char *, int) { return false; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_win32.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_win32.inc index 81e0473f88..03b7780ce8 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_win32.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize_win32.inc @@ -31,7 +31,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN static HANDLE process = NULL; @@ -77,5 +77,5 @@ bool Symbolize(const void* pc, char* out, int out_size) { return true; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make index d768f195c2..2c096aaa5d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/debugging/ya.make @@ -16,9 +16,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/demangle/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/demangle/ya.make index a1abc9f615..ff336db348 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/demangle/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/demangle/ya.make @@ -18,9 +18,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/bind_front.h b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/bind_front.h index 457b1fa734..ef636e99a0 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/bind_front.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/bind_front.h @@ -1,184 +1,184 @@ -// Copyright 2018 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: bind_front.h -// ----------------------------------------------------------------------------- -// -// `y_absl::bind_front()` returns a functor by binding a number of arguments to -// the front of a provided (usually more generic) functor. Unlike `std::bind`, -// it does not require the use of argument placeholders. The simpler syntax of -// `y_absl::bind_front()` allows you to avoid known misuses with `std::bind()`. -// -// `y_absl::bind_front()` is meant as a drop-in replacement for C++20's upcoming -// `std::bind_front()`, which similarly resolves these issues with -// `std::bind()`. Both `bind_front()` alternatives, unlike `std::bind()`, allow -// partial function application. (See -// https://en.wikipedia.org/wiki/Partial_application). - -#ifndef ABSL_FUNCTIONAL_BIND_FRONT_H_ -#define ABSL_FUNCTIONAL_BIND_FRONT_H_ - -#include "y_absl/functional/internal/front_binder.h" -#include "y_absl/utility/utility.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN - -// bind_front() -// -// Binds the first N arguments of an invocable object and stores them by value. -// -// Like `std::bind()`, `y_absl::bind_front()` is implicitly convertible to -// `std::function`. In particular, it may be used as a simpler replacement for -// `std::bind()` in most cases, as it does not require placeholders to be -// specified. More importantly, it provides more reliable correctness guarantees -// than `std::bind()`; while `std::bind()` will silently ignore passing more -// parameters than expected, for example, `y_absl::bind_front()` will report such -// mis-uses as errors. -// -// y_absl::bind_front(a...) can be seen as storing the results of -// std::make_tuple(a...). -// -// Example: Binding a free function. -// -// int Minus(int a, int b) { return a - b; } -// -// assert(y_absl::bind_front(Minus)(3, 2) == 3 - 2); -// assert(y_absl::bind_front(Minus, 3)(2) == 3 - 2); -// assert(y_absl::bind_front(Minus, 3, 2)() == 3 - 2); -// -// Example: Binding a member function. -// -// struct Math { -// int Double(int a) const { return 2 * a; } -// }; -// -// Math math; -// -// assert(y_absl::bind_front(&Math::Double)(&math, 3) == 2 * 3); -// // Stores a pointer to math inside the functor. -// assert(y_absl::bind_front(&Math::Double, &math)(3) == 2 * 3); -// // Stores a copy of math inside the functor. -// assert(y_absl::bind_front(&Math::Double, math)(3) == 2 * 3); -// // Stores std::unique_ptr<Math> inside the functor. -// assert(y_absl::bind_front(&Math::Double, -// std::unique_ptr<Math>(new Math))(3) == 2 * 3); -// -// Example: Using `y_absl::bind_front()`, instead of `std::bind()`, with -// `std::function`. -// -// class FileReader { -// public: -// void ReadFileAsync(const TString& filename, TString* content, -// const std::function<void()>& done) { -// // Calls Executor::Schedule(std::function<void()>). -// Executor::DefaultExecutor()->Schedule( -// y_absl::bind_front(&FileReader::BlockingRead, this, -// filename, content, done)); -// } -// -// private: -// void BlockingRead(const TString& filename, TString* content, -// const std::function<void()>& done) { -// CHECK_OK(file::GetContents(filename, content, {})); -// done(); -// } -// }; -// -// `y_absl::bind_front()` stores bound arguments explicitly using the type passed -// rather than implicitly based on the type accepted by its functor. -// -// Example: Binding arguments explicitly. -// -// void LogStringView(y_absl::string_view sv) { -// LOG(INFO) << sv; -// } -// -// Executor* e = Executor::DefaultExecutor(); -// TString s = "hello"; -// y_absl::string_view sv = s; -// -// // y_absl::bind_front(LogStringView, arg) makes a copy of arg and stores it. -// e->Schedule(y_absl::bind_front(LogStringView, sv)); // ERROR: dangling -// // string_view. -// -// e->Schedule(y_absl::bind_front(LogStringView, s)); // OK: stores a copy of -// // s. -// -// To store some of the arguments passed to `y_absl::bind_front()` by reference, -// use std::ref()` and `std::cref()`. -// -// Example: Storing some of the bound arguments by reference. -// -// class Service { -// public: -// void Serve(const Request& req, std::function<void()>* done) { -// // The request protocol buffer won't be deleted until done is called. -// // It's safe to store a reference to it inside the functor. -// Executor::DefaultExecutor()->Schedule( -// y_absl::bind_front(&Service::BlockingServe, this, std::cref(req), -// done)); -// } -// -// private: -// void BlockingServe(const Request& req, std::function<void()>* done); -// }; -// -// Example: Storing bound arguments by reference. -// -// void Print(const TString& a, const TString& b) { -// std::cerr << a << b; -// } -// -// TString hi = "Hello, "; -// std::vector<TString> names = {"Chuk", "Gek"}; -// // Doesn't copy hi. -// for_each(names.begin(), names.end(), -// y_absl::bind_front(Print, std::ref(hi))); -// -// // DO NOT DO THIS: the functor may outlive "hi", resulting in -// // dangling references. -// foo->DoInFuture(y_absl::bind_front(Print, std::ref(hi), "Guest")); // BAD! -// auto f = y_absl::bind_front(Print, std::ref(hi), "Guest"); // BAD! -// -// Example: Storing reference-like types. -// -// void Print(y_absl::string_view a, const TString& b) { -// std::cerr << a << b; -// } -// -// TString hi = "Hello, "; -// // Copies "hi". -// y_absl::bind_front(Print, hi)("Chuk"); -// -// // Compile error: std::reference_wrapper<const string> is not implicitly -// // convertible to string_view. -// // y_absl::bind_front(Print, std::cref(hi))("Chuk"); -// -// // Doesn't copy "hi". -// y_absl::bind_front(Print, y_absl::string_view(hi))("Chuk"); -// -template <class F, class... BoundArgs> -constexpr functional_internal::bind_front_t<F, BoundArgs...> bind_front( - F&& func, BoundArgs&&... args) { - return functional_internal::bind_front_t<F, BoundArgs...>( - y_absl::in_place, y_absl::forward<F>(func), - y_absl::forward<BoundArgs>(args)...); -} - -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_FUNCTIONAL_BIND_FRONT_H_ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// File: bind_front.h +// ----------------------------------------------------------------------------- +// +// `y_absl::bind_front()` returns a functor by binding a number of arguments to +// the front of a provided (usually more generic) functor. Unlike `std::bind`, +// it does not require the use of argument placeholders. The simpler syntax of +// `y_absl::bind_front()` allows you to avoid known misuses with `std::bind()`. +// +// `y_absl::bind_front()` is meant as a drop-in replacement for C++20's upcoming +// `std::bind_front()`, which similarly resolves these issues with +// `std::bind()`. Both `bind_front()` alternatives, unlike `std::bind()`, allow +// partial function application. (See +// https://en.wikipedia.org/wiki/Partial_application). + +#ifndef ABSL_FUNCTIONAL_BIND_FRONT_H_ +#define ABSL_FUNCTIONAL_BIND_FRONT_H_ + +#include "y_absl/functional/internal/front_binder.h" +#include "y_absl/utility/utility.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN + +// bind_front() +// +// Binds the first N arguments of an invocable object and stores them by value. +// +// Like `std::bind()`, `y_absl::bind_front()` is implicitly convertible to +// `std::function`. In particular, it may be used as a simpler replacement for +// `std::bind()` in most cases, as it does not require placeholders to be +// specified. More importantly, it provides more reliable correctness guarantees +// than `std::bind()`; while `std::bind()` will silently ignore passing more +// parameters than expected, for example, `y_absl::bind_front()` will report such +// mis-uses as errors. +// +// y_absl::bind_front(a...) can be seen as storing the results of +// std::make_tuple(a...). +// +// Example: Binding a free function. +// +// int Minus(int a, int b) { return a - b; } +// +// assert(y_absl::bind_front(Minus)(3, 2) == 3 - 2); +// assert(y_absl::bind_front(Minus, 3)(2) == 3 - 2); +// assert(y_absl::bind_front(Minus, 3, 2)() == 3 - 2); +// +// Example: Binding a member function. +// +// struct Math { +// int Double(int a) const { return 2 * a; } +// }; +// +// Math math; +// +// assert(y_absl::bind_front(&Math::Double)(&math, 3) == 2 * 3); +// // Stores a pointer to math inside the functor. +// assert(y_absl::bind_front(&Math::Double, &math)(3) == 2 * 3); +// // Stores a copy of math inside the functor. +// assert(y_absl::bind_front(&Math::Double, math)(3) == 2 * 3); +// // Stores std::unique_ptr<Math> inside the functor. +// assert(y_absl::bind_front(&Math::Double, +// std::unique_ptr<Math>(new Math))(3) == 2 * 3); +// +// Example: Using `y_absl::bind_front()`, instead of `std::bind()`, with +// `std::function`. +// +// class FileReader { +// public: +// void ReadFileAsync(const TString& filename, TString* content, +// const std::function<void()>& done) { +// // Calls Executor::Schedule(std::function<void()>). +// Executor::DefaultExecutor()->Schedule( +// y_absl::bind_front(&FileReader::BlockingRead, this, +// filename, content, done)); +// } +// +// private: +// void BlockingRead(const TString& filename, TString* content, +// const std::function<void()>& done) { +// CHECK_OK(file::GetContents(filename, content, {})); +// done(); +// } +// }; +// +// `y_absl::bind_front()` stores bound arguments explicitly using the type passed +// rather than implicitly based on the type accepted by its functor. +// +// Example: Binding arguments explicitly. +// +// void LogStringView(y_absl::string_view sv) { +// LOG(INFO) << sv; +// } +// +// Executor* e = Executor::DefaultExecutor(); +// TString s = "hello"; +// y_absl::string_view sv = s; +// +// // y_absl::bind_front(LogStringView, arg) makes a copy of arg and stores it. +// e->Schedule(y_absl::bind_front(LogStringView, sv)); // ERROR: dangling +// // string_view. +// +// e->Schedule(y_absl::bind_front(LogStringView, s)); // OK: stores a copy of +// // s. +// +// To store some of the arguments passed to `y_absl::bind_front()` by reference, +// use std::ref()` and `std::cref()`. +// +// Example: Storing some of the bound arguments by reference. +// +// class Service { +// public: +// void Serve(const Request& req, std::function<void()>* done) { +// // The request protocol buffer won't be deleted until done is called. +// // It's safe to store a reference to it inside the functor. +// Executor::DefaultExecutor()->Schedule( +// y_absl::bind_front(&Service::BlockingServe, this, std::cref(req), +// done)); +// } +// +// private: +// void BlockingServe(const Request& req, std::function<void()>* done); +// }; +// +// Example: Storing bound arguments by reference. +// +// void Print(const TString& a, const TString& b) { +// std::cerr << a << b; +// } +// +// TString hi = "Hello, "; +// std::vector<TString> names = {"Chuk", "Gek"}; +// // Doesn't copy hi. +// for_each(names.begin(), names.end(), +// y_absl::bind_front(Print, std::ref(hi))); +// +// // DO NOT DO THIS: the functor may outlive "hi", resulting in +// // dangling references. +// foo->DoInFuture(y_absl::bind_front(Print, std::ref(hi), "Guest")); // BAD! +// auto f = y_absl::bind_front(Print, std::ref(hi), "Guest"); // BAD! +// +// Example: Storing reference-like types. +// +// void Print(y_absl::string_view a, const TString& b) { +// std::cerr << a << b; +// } +// +// TString hi = "Hello, "; +// // Copies "hi". +// y_absl::bind_front(Print, hi)("Chuk"); +// +// // Compile error: std::reference_wrapper<const string> is not implicitly +// // convertible to string_view. +// // y_absl::bind_front(Print, std::cref(hi))("Chuk"); +// +// // Doesn't copy "hi". +// y_absl::bind_front(Print, y_absl::string_view(hi))("Chuk"); +// +template <class F, class... BoundArgs> +constexpr functional_internal::bind_front_t<F, BoundArgs...> bind_front( + F&& func, BoundArgs&&... args) { + return functional_internal::bind_front_t<F, BoundArgs...>( + y_absl::in_place, y_absl::forward<F>(func), + y_absl::forward<BoundArgs>(args)...); +} + +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_FUNCTIONAL_BIND_FRONT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/function_ref.h b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/function_ref.h index 6ae4c63c9e..0d01e55969 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/function_ref.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/function_ref.h @@ -55,7 +55,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // FunctionRef // @@ -136,7 +136,7 @@ class FunctionRef<R(Args...)> { y_absl::functional_internal::Invoker<R, Args...> invoker_; }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_FUNCTIONAL_FUNCTION_REF_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/front_binder.h b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/front_binder.h index b2fff44274..820be681a2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/front_binder.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/front_binder.h @@ -1,95 +1,95 @@ -// Copyright 2018 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Implementation details for `y_absl::bind_front()`. - -#ifndef ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ -#define ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ - -#include <cstddef> -#include <type_traits> -#include <utility> - -#include "y_absl/base/internal/invoke.h" -#include "y_absl/container/internal/compressed_tuple.h" -#include "y_absl/meta/type_traits.h" -#include "y_absl/utility/utility.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace functional_internal { - -// Invoke the method, expanding the tuple of bound arguments. -template <class R, class Tuple, size_t... Idx, class... Args> -R Apply(Tuple&& bound, y_absl::index_sequence<Idx...>, Args&&... free) { +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Implementation details for `y_absl::bind_front()`. + +#ifndef ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ +#define ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ + +#include <cstddef> +#include <type_traits> +#include <utility> + +#include "y_absl/base/internal/invoke.h" +#include "y_absl/container/internal/compressed_tuple.h" +#include "y_absl/meta/type_traits.h" +#include "y_absl/utility/utility.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace functional_internal { + +// Invoke the method, expanding the tuple of bound arguments. +template <class R, class Tuple, size_t... Idx, class... Args> +R Apply(Tuple&& bound, y_absl::index_sequence<Idx...>, Args&&... free) { return base_internal::invoke( - y_absl::forward<Tuple>(bound).template get<Idx>()..., - y_absl::forward<Args>(free)...); -} - -template <class F, class... BoundArgs> -class FrontBinder { - using BoundArgsT = y_absl::container_internal::CompressedTuple<F, BoundArgs...>; - using Idx = y_absl::make_index_sequence<sizeof...(BoundArgs) + 1>; - - BoundArgsT bound_args_; - - public: - template <class... Ts> - constexpr explicit FrontBinder(y_absl::in_place_t, Ts&&... ts) - : bound_args_(y_absl::forward<Ts>(ts)...) {} - + y_absl::forward<Tuple>(bound).template get<Idx>()..., + y_absl::forward<Args>(free)...); +} + +template <class F, class... BoundArgs> +class FrontBinder { + using BoundArgsT = y_absl::container_internal::CompressedTuple<F, BoundArgs...>; + using Idx = y_absl::make_index_sequence<sizeof...(BoundArgs) + 1>; + + BoundArgsT bound_args_; + + public: + template <class... Ts> + constexpr explicit FrontBinder(y_absl::in_place_t, Ts&&... ts) + : bound_args_(y_absl::forward<Ts>(ts)...) {} + template <class... FreeArgs, class R = base_internal::invoke_result_t< F&, BoundArgs&..., FreeArgs&&...>> - R operator()(FreeArgs&&... free_args) & { - return functional_internal::Apply<R>(bound_args_, Idx(), - y_absl::forward<FreeArgs>(free_args)...); - } - - template <class... FreeArgs, + R operator()(FreeArgs&&... free_args) & { + return functional_internal::Apply<R>(bound_args_, Idx(), + y_absl::forward<FreeArgs>(free_args)...); + } + + template <class... FreeArgs, class R = base_internal::invoke_result_t< const F&, const BoundArgs&..., FreeArgs&&...>> - R operator()(FreeArgs&&... free_args) const& { - return functional_internal::Apply<R>(bound_args_, Idx(), - y_absl::forward<FreeArgs>(free_args)...); - } - + R operator()(FreeArgs&&... free_args) const& { + return functional_internal::Apply<R>(bound_args_, Idx(), + y_absl::forward<FreeArgs>(free_args)...); + } + template <class... FreeArgs, class R = base_internal::invoke_result_t< - F&&, BoundArgs&&..., FreeArgs&&...>> - R operator()(FreeArgs&&... free_args) && { - // This overload is called when *this is an rvalue. If some of the bound - // arguments are stored by value or rvalue reference, we move them. - return functional_internal::Apply<R>(y_absl::move(bound_args_), Idx(), - y_absl::forward<FreeArgs>(free_args)...); - } - - template <class... FreeArgs, + F&&, BoundArgs&&..., FreeArgs&&...>> + R operator()(FreeArgs&&... free_args) && { + // This overload is called when *this is an rvalue. If some of the bound + // arguments are stored by value or rvalue reference, we move them. + return functional_internal::Apply<R>(y_absl::move(bound_args_), Idx(), + y_absl::forward<FreeArgs>(free_args)...); + } + + template <class... FreeArgs, class R = base_internal::invoke_result_t< const F&&, const BoundArgs&&..., FreeArgs&&...>> - R operator()(FreeArgs&&... free_args) const&& { - // This overload is called when *this is an rvalue. If some of the bound - // arguments are stored by value or rvalue reference, we move them. - return functional_internal::Apply<R>(y_absl::move(bound_args_), Idx(), - y_absl::forward<FreeArgs>(free_args)...); - } -}; - -template <class F, class... BoundArgs> -using bind_front_t = FrontBinder<decay_t<F>, y_absl::decay_t<BoundArgs>...>; - -} // namespace functional_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ + R operator()(FreeArgs&&... free_args) const&& { + // This overload is called when *this is an rvalue. If some of the bound + // arguments are stored by value or rvalue reference, we move them. + return functional_internal::Apply<R>(y_absl::move(bound_args_), Idx(), + y_absl::forward<FreeArgs>(free_args)...); + } +}; + +template <class F, class... BoundArgs> +using bind_front_t = FrontBinder<decay_t<F>, y_absl::decay_t<BoundArgs>...>; + +} // namespace functional_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_FUNCTIONAL_INTERNAL_FRONT_BINDER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/function_ref.h b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/function_ref.h index 1ba81ee96a..0af5c62e92 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/function_ref.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/functional/internal/function_ref.h @@ -23,7 +23,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace functional_internal { // Like a void* that can handle function pointers as well. The standard does not @@ -100,7 +100,7 @@ template <bool C> using EnableIf = typename ::std::enable_if<C, int>::type; } // namespace functional_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_FUNCTIONAL_INTERNAL_FUNCTION_REF_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash.h b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash.h index 1e93ee96d9..3fd5661858 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash.h @@ -78,7 +78,7 @@ #include "y_absl/hash/internal/hash.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // `y_absl::Hash` @@ -341,7 +341,7 @@ class HashState : public hash_internal::HashStateBase<HashState> { void (*combine_contiguous_)(void*, const unsigned char*, size_t); }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HASH_HASH_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash_testing.h b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash_testing.h index 2f22d37039..0eaa98be97 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash_testing.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/hash_testing.h @@ -28,7 +28,7 @@ #include "y_absl/types/variant.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Run the y_absl::Hash algorithm over all the elements passed in and verify that // their hash expansion is congruent with their `==` operator. @@ -372,7 +372,7 @@ VerifyTypeImplementsAbslHashCorrectly(std::initializer_list<T> values, equals); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HASH_HASH_TESTING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.cc index 5f1b655e7e..d0f7dcdc8c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.cc @@ -30,7 +30,7 @@ #include "y_absl/base/optimization.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace hash_internal { #ifdef ABSL_IS_BIG_ENDIAN @@ -345,5 +345,5 @@ uint64_t CityHash64WithSeeds(const char *s, size_t len, uint64_t seed0, } } // namespace hash_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.h b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.h index d2b32f0068..0c18ba7fe7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/city.h @@ -47,13 +47,13 @@ #include <stdint.h> #include <stdlib.h> // for size_t. - + #include <utility> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace hash_internal { // Hash function for a byte array. @@ -72,7 +72,7 @@ uint64_t CityHash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint32_t CityHash32(const char *s, size_t len); } // namespace hash_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HASH_INTERNAL_CITY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.cc index fe075de43a..dd0cf8aad3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.cc @@ -15,7 +15,7 @@ #include "y_absl/hash/internal/hash.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace hash_internal { uint64_t MixingHashState::CombineLargeContiguousImpl32( @@ -65,5 +65,5 @@ uint64_t MixingHashState::LowLevelHashImpl(const unsigned char* data, } } // namespace hash_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.h b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.h index fcbe43accd..f24afd7725 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/hash.h @@ -33,7 +33,7 @@ #include <map> #include <memory> #include <set> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <tuple> #include <type_traits> #include <utility> @@ -53,12 +53,12 @@ #include "y_absl/utility/utility.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace hash_internal { // Internal detail: Large buffers are hashed in smaller chunks. This function // returns the size of these chunks. -constexpr size_t PiecewiseChunkSize() { return 1024; } +constexpr size_t PiecewiseChunkSize() { return 1024; } // PiecewiseCombiner // @@ -1057,7 +1057,7 @@ H PiecewiseCombiner::add_buffer(H state, const unsigned char* data, // This partial chunk does not fill our existing buffer memcpy(buf_ + position_, data, size); position_ += size; - return state; + return state; } // If the buffer is partially filled we need to complete the buffer @@ -1079,7 +1079,7 @@ H PiecewiseCombiner::add_buffer(H state, const unsigned char* data, // Fill the buffer with the remainder memcpy(buf_, data, size); position_ = size; - return state; + return state; } // HashStateBase::PiecewiseCombiner::finalize() @@ -1090,7 +1090,7 @@ H PiecewiseCombiner::finalize(H state) { } } // namespace hash_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HASH_INTERNAL_HASH_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/spy_hash_state.h b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/spy_hash_state.h index 520cbf904f..f92c7a874c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/spy_hash_state.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/hash/internal/spy_hash_state.h @@ -16,7 +16,7 @@ #define ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_ #include <ostream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> #include "y_absl/hash/hash.h" @@ -25,7 +25,7 @@ #include "y_absl/strings/str_join.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace hash_internal { // SpyHashState is an implementation of the HashState API that simply @@ -225,7 +225,7 @@ void AbslHashValue(SpyHashStateImpl<T>, const U&); using SpyHashState = SpyHashStateImpl<void>; } // namespace hash_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/memory/memory.h b/contrib/restricted/abseil-cpp-tstring/y_absl/memory/memory.h index 134a614b33..f3059dc241 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/memory/memory.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/memory/memory.h @@ -34,7 +34,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // Function Template: WrapUnique() @@ -692,7 +692,7 @@ void CopyRange(Allocator& alloc, Iterator destination, InputIterator first, } } } // namespace memory_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_MEMORY_MEMORY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/meta/type_traits.h b/contrib/restricted/abseil-cpp-tstring/y_absl/meta/type_traits.h index eb9649060b..6714572bd1 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/meta/type_traits.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/meta/type_traits.h @@ -41,12 +41,12 @@ #include "y_absl/base/config.h" -// MSVC constructibility traits do not detect destructor properties and so our -// implementations should not use them as a source-of-truth. -#if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) -#define ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 -#endif - +// MSVC constructibility traits do not detect destructor properties and so our +// implementations should not use them as a source-of-truth. +#if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) +#define ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 +#endif + // Defines the default alignment. `__STDCPP_DEFAULT_NEW_ALIGNMENT__` is a C++17 // feature. #if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) @@ -56,14 +56,14 @@ #endif // defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) namespace y_absl { -ABSL_NAMESPACE_BEGIN - -// Defined and documented later on in this file. -template <typename T> -struct is_trivially_destructible; +ABSL_NAMESPACE_BEGIN // Defined and documented later on in this file. template <typename T> +struct is_trivially_destructible; + +// Defined and documented later on in this file. +template <typename T> struct is_trivially_move_assignable; namespace type_traits_internal { @@ -85,20 +85,20 @@ union SingleMemberUnion { #endif // defined(_MSC_VER) && !defined(__GNUC__) template <class T> -struct IsTriviallyMoveConstructibleObject - : std::integral_constant< - bool, std::is_move_constructible< - type_traits_internal::SingleMemberUnion<T>>::value && - y_absl::is_trivially_destructible<T>::value> {}; - -template <class T> -struct IsTriviallyCopyConstructibleObject - : std::integral_constant< - bool, std::is_copy_constructible< - type_traits_internal::SingleMemberUnion<T>>::value && - y_absl::is_trivially_destructible<T>::value> {}; - -template <class T> +struct IsTriviallyMoveConstructibleObject + : std::integral_constant< + bool, std::is_move_constructible< + type_traits_internal::SingleMemberUnion<T>>::value && + y_absl::is_trivially_destructible<T>::value> {}; + +template <class T> +struct IsTriviallyCopyConstructibleObject + : std::integral_constant< + bool, std::is_copy_constructible< + type_traits_internal::SingleMemberUnion<T>>::value && + y_absl::is_trivially_destructible<T>::value> {}; + +template <class T> struct IsTriviallyMoveAssignableReference : std::false_type {}; template <class T> @@ -350,9 +350,9 @@ struct is_trivially_default_constructible : std::integral_constant<bool, __has_trivial_constructor(T) && std::is_default_constructible<T>::value && is_trivially_destructible<T>::value> { -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ - !defined( \ - ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) +#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ + !defined( \ + ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_default_constructible<T>::value == @@ -383,11 +383,11 @@ template <typename T> struct is_trivially_move_constructible : std::conditional< std::is_object<T>::value && !std::is_array<T>::value, - type_traits_internal::IsTriviallyMoveConstructibleObject<T>, + type_traits_internal::IsTriviallyMoveConstructibleObject<T>, std::is_reference<T>>::type::type { -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ - !defined( \ - ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) +#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ + !defined( \ + ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_move_constructible<T>::value == @@ -418,11 +418,11 @@ template <typename T> struct is_trivially_copy_constructible : std::conditional< std::is_object<T>::value && !std::is_array<T>::value, - type_traits_internal::IsTriviallyCopyConstructibleObject<T>, + type_traits_internal::IsTriviallyCopyConstructibleObject<T>, std::is_lvalue_reference<T>>::type::type { -#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ - !defined( \ - ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) +#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \ + !defined( \ + ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION) private: static constexpr bool compliant = std::is_trivially_copy_constructible<T>::value == @@ -454,8 +454,8 @@ struct is_trivially_copy_constructible template <typename T> struct is_trivially_move_assignable : std::conditional< - std::is_object<T>::value && !std::is_array<T>::value && - std::is_move_assignable<T>::value, + std::is_object<T>::value && !std::is_array<T>::value && + std::is_move_assignable<T>::value, std::is_move_assignable<type_traits_internal::SingleMemberUnion<T>>, type_traits_internal::IsTriviallyMoveAssignableReference<T>>::type:: type { @@ -791,7 +791,7 @@ using swap_internal::Swap; using swap_internal::StdSwapIsUnconstrained; } // namespace type_traits_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_META_TYPE_TRAITS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.cc index 6172372d75..20e4bbd66c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.cc @@ -20,17 +20,17 @@ #include <iomanip> #include <ostream> // NOLINT(readability/streams) #include <sstream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include "y_absl/base/optimization.h" #include "y_absl/numeric/bits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN -ABSL_DLL const uint128 kuint128max = MakeUint128( - std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max()); +ABSL_DLL const uint128 kuint128max = MakeUint128( + std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max()); namespace { @@ -197,7 +197,7 @@ TString Uint128ToFormattedString(uint128 v, std::ios_base::fmtflags flags) { os << std::noshowbase << std::setfill('0') << std::setw(div_base_log); } os << Uint128Low64(low); - return TString(os.str()); + return TString(os.str()); } } // namespace @@ -329,7 +329,7 @@ std::ostream& operator<<(std::ostream& os, int128 v) { return os << rep; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl namespace std { diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.h b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.h index b54d614ce9..16db1e670e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/int128.h @@ -53,7 +53,7 @@ #endif // defined(_MSC_VER) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class int128; @@ -238,7 +238,7 @@ class // Prefer to use the constexpr `Uint128Max()`. // // TODO(y_absl-team) deprecate kuint128max once migration tool is released. -ABSL_DLL extern const uint128 kuint128max; +ABSL_DLL extern const uint128 kuint128max; // allow uint128 to be logged std::ostream& operator<<(std::ostream& os, uint128 v); @@ -250,7 +250,7 @@ constexpr uint128 Uint128Max() { (std::numeric_limits<uint64_t>::max)()); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // Specialized numeric_limits for uint128. @@ -299,7 +299,7 @@ class numeric_limits<y_absl::uint128> { } // namespace std namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // int128 // @@ -485,7 +485,7 @@ constexpr int128 Int128Min() { return int128((std::numeric_limits<int64_t>::min)(), 0); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // Specialized numeric_limits for int128. @@ -537,7 +537,7 @@ class numeric_limits<y_absl::int128> { // Implementation details follow // -------------------------------------------------------------------------- namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN constexpr uint128 MakeUint128(uint64_t high, uint64_t low) { return uint128(high, low); @@ -1157,7 +1157,7 @@ constexpr int64_t BitCastToSigned(uint64_t v) { #include "y_absl/numeric/int128_no_intrinsic.inc" // IWYU pragma: export #endif // ABSL_HAVE_INTRINSIC_INT128 -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #undef ABSL_INTERNAL_WCHAR_T diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make index 9f3280c39d..7fde3b058e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/numeric/ya.make @@ -11,9 +11,9 @@ LICENSE(Apache-2.0) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.cc index 02f5dfd9da..96596b8245 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.cc @@ -16,7 +16,7 @@ #include <stdint.h> -#include <algorithm> +#include <algorithm> #include <atomic> #include <cmath> #include <limits> @@ -25,7 +25,7 @@ #include "y_absl/base/optimization.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace profiling_internal { // The algorithm generates a random number between 0 and 1 and applies the @@ -38,7 +38,7 @@ namespace profiling_internal { // -log_e(q)/m = x // log_2(q) * (-log_e(2) * 1/m) = x // In the code, q is actually in the range 1 to 2**26, hence the -26 below -int64_t ExponentialBiased::GetSkipCount(int64_t mean) { +int64_t ExponentialBiased::GetSkipCount(int64_t mean) { if (ABSL_PREDICT_FALSE(!initialized_)) { Initialize(); } @@ -53,24 +53,24 @@ int64_t ExponentialBiased::GetSkipCount(int64_t mean) { // under piii debug for some binaries. double q = static_cast<uint32_t>(rng >> (kPrngNumBits - 26)) + 1.0; // Put the computed p-value through the CDF of a geometric. - double interval = bias_ + (std::log2(q) - 26) * (-std::log(2.0) * mean); - // Very large values of interval overflow int64_t. To avoid that, we will - // cheat and clamp any huge values to (int64_t max)/2. This is a potential - // source of bias, but the mean would need to be such a large value that it's - // not likely to come up. For example, with a mean of 1e18, the probability of - // hitting this condition is about 1/1000. For a mean of 1e17, standard - // calculators claim that this event won't happen. + double interval = bias_ + (std::log2(q) - 26) * (-std::log(2.0) * mean); + // Very large values of interval overflow int64_t. To avoid that, we will + // cheat and clamp any huge values to (int64_t max)/2. This is a potential + // source of bias, but the mean would need to be such a large value that it's + // not likely to come up. For example, with a mean of 1e18, the probability of + // hitting this condition is about 1/1000. For a mean of 1e17, standard + // calculators claim that this event won't happen. if (interval > static_cast<double>(std::numeric_limits<int64_t>::max() / 2)) { - // Assume huge values are bias neutral, retain bias for next call. + // Assume huge values are bias neutral, retain bias for next call. return std::numeric_limits<int64_t>::max() / 2; } double value = std::rint(interval); - bias_ = interval - value; - return value; -} + bias_ = interval - value; + return value; +} -int64_t ExponentialBiased::GetStride(int64_t mean) { - return GetSkipCount(mean - 1) + 1; +int64_t ExponentialBiased::GetStride(int64_t mean) { + return GetSkipCount(mean - 1) + 1; } void ExponentialBiased::Initialize() { @@ -89,5 +89,5 @@ void ExponentialBiased::Initialize() { } } // namespace profiling_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.h b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.h index ee7954a535..f1de3258dd 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased.h @@ -17,87 +17,87 @@ #include <stdint.h> -#include "y_absl/base/config.h" -#include "y_absl/base/macros.h" - +#include "y_absl/base/config.h" +#include "y_absl/base/macros.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace profiling_internal { // ExponentialBiased provides a small and fast random number generator for a -// rounded exponential distribution. This generator manages very little state, -// and imposes no synchronization overhead. This makes it useful in specialized -// scenarios requiring minimum overhead, such as stride based periodic sampling. -// -// ExponentialBiased provides two closely related functions, GetSkipCount() and -// GetStride(), both returning a rounded integer defining a number of events -// required before some event with a given mean probability occurs. -// -// The distribution is useful to generate a random wait time or some periodic -// event with a given mean probability. For example, if an action is supposed to -// happen on average once every 'N' events, then we can get a random 'stride' -// counting down how long before the event to happen. For example, if we'd want -// to sample one in every 1000 'Frobber' calls, our code could look like this: -// -// Frobber::Frobber() { -// stride_ = exponential_biased_.GetStride(1000); -// } -// -// void Frobber::Frob(int arg) { -// if (--stride == 0) { -// SampleFrob(arg); -// stride_ = exponential_biased_.GetStride(1000); -// } -// ... -// } +// rounded exponential distribution. This generator manages very little state, +// and imposes no synchronization overhead. This makes it useful in specialized +// scenarios requiring minimum overhead, such as stride based periodic sampling. // -// The rounding of the return value creates a bias, especially for smaller means -// where the distribution of the fraction is not evenly distributed. We correct -// this bias by tracking the fraction we rounded up or down on each iteration, -// effectively tracking the distance between the cumulative value, and the -// rounded cumulative value. For example, given a mean of 2: +// ExponentialBiased provides two closely related functions, GetSkipCount() and +// GetStride(), both returning a rounded integer defining a number of events +// required before some event with a given mean probability occurs. // -// raw = 1.63076, cumulative = 1.63076, rounded = 2, bias = -0.36923 -// raw = 0.14624, cumulative = 1.77701, rounded = 2, bias = 0.14624 -// raw = 4.93194, cumulative = 6.70895, rounded = 7, bias = -0.06805 -// raw = 0.24206, cumulative = 6.95101, rounded = 7, bias = 0.24206 -// etc... +// The distribution is useful to generate a random wait time or some periodic +// event with a given mean probability. For example, if an action is supposed to +// happen on average once every 'N' events, then we can get a random 'stride' +// counting down how long before the event to happen. For example, if we'd want +// to sample one in every 1000 'Frobber' calls, our code could look like this: // -// Adjusting with rounding bias is relatively trivial: -// -// double value = bias_ + exponential_distribution(mean)(); +// Frobber::Frobber() { +// stride_ = exponential_biased_.GetStride(1000); +// } +// +// void Frobber::Frob(int arg) { +// if (--stride == 0) { +// SampleFrob(arg); +// stride_ = exponential_biased_.GetStride(1000); +// } +// ... +// } +// +// The rounding of the return value creates a bias, especially for smaller means +// where the distribution of the fraction is not evenly distributed. We correct +// this bias by tracking the fraction we rounded up or down on each iteration, +// effectively tracking the distance between the cumulative value, and the +// rounded cumulative value. For example, given a mean of 2: +// +// raw = 1.63076, cumulative = 1.63076, rounded = 2, bias = -0.36923 +// raw = 0.14624, cumulative = 1.77701, rounded = 2, bias = 0.14624 +// raw = 4.93194, cumulative = 6.70895, rounded = 7, bias = -0.06805 +// raw = 0.24206, cumulative = 6.95101, rounded = 7, bias = 0.24206 +// etc... +// +// Adjusting with rounding bias is relatively trivial: +// +// double value = bias_ + exponential_distribution(mean)(); // double rounded_value = std::rint(value); -// bias_ = value - rounded_value; -// return rounded_value; -// +// bias_ = value - rounded_value; +// return rounded_value; +// // This class is thread-compatible. class ExponentialBiased { public: // The number of bits set by NextRandom. static constexpr int kPrngNumBits = 48; - // `GetSkipCount()` returns the number of events to skip before some chosen - // event happens. For example, randomly tossing a coin, we will on average - // throw heads once before we get tails. We can simulate random coin tosses - // using GetSkipCount() as: - // - // ExponentialBiased eb; - // for (...) { - // int number_of_heads_before_tail = eb.GetSkipCount(1); - // for (int flips = 0; flips < number_of_heads_before_tail; ++flips) { - // printf("head..."); - // } - // printf("tail\n"); - // } - // - int64_t GetSkipCount(int64_t mean); - - // GetStride() returns the number of events required for a specific event to - // happen. See the class comments for a usage example. `GetStride()` is - // equivalent to `GetSkipCount(mean - 1) + 1`. When to use `GetStride()` or - // `GetSkipCount()` depends mostly on what best fits the use case. - int64_t GetStride(int64_t mean); + // `GetSkipCount()` returns the number of events to skip before some chosen + // event happens. For example, randomly tossing a coin, we will on average + // throw heads once before we get tails. We can simulate random coin tosses + // using GetSkipCount() as: + // + // ExponentialBiased eb; + // for (...) { + // int number_of_heads_before_tail = eb.GetSkipCount(1); + // for (int flips = 0; flips < number_of_heads_before_tail; ++flips) { + // printf("head..."); + // } + // printf("tail\n"); + // } + // + int64_t GetSkipCount(int64_t mean); + // GetStride() returns the number of events required for a specific event to + // happen. See the class comments for a usage example. `GetStride()` is + // equivalent to `GetSkipCount(mean - 1) + 1`. When to use `GetStride()` or + // `GetSkipCount()` depends mostly on what best fits the use case. + int64_t GetStride(int64_t mean); + // Computes a random number in the range [0, 1<<(kPrngNumBits+1) - 1] // // This is public to enable testing. @@ -107,7 +107,7 @@ class ExponentialBiased { void Initialize(); uint64_t rng_{0}; - double bias_{0}; + double bias_{0}; bool initialized_{false}; }; @@ -124,7 +124,7 @@ inline uint64_t ExponentialBiased::NextRandom(uint64_t rnd) { } } // namespace profiling_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_PROFILING_INTERNAL_EXPONENTIAL_BIASED_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased/ya.make index ddfe147041..88508c4064 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.cc index 39fb3660f0..d9786ed02e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.cc @@ -19,11 +19,11 @@ #include "y_absl/profiling/internal/exponential_biased.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace profiling_internal { int64_t PeriodicSamplerBase::GetExponentialBiased(int period) noexcept { - return rng_.GetStride(period); + return rng_.GetStride(period); } bool PeriodicSamplerBase::SubtleConfirmSample() noexcept { @@ -37,17 +37,17 @@ bool PeriodicSamplerBase::SubtleConfirmSample() noexcept { // Check if this is the first call to Sample() if (ABSL_PREDICT_FALSE(stride_ == 1)) { - stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period)); + stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period)); if (static_cast<int64_t>(stride_) < -1) { ++stride_; return false; } } - - stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period)); + + stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period)); return true; } } // namespace profiling_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.h b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.h index 37796a9e00..4493246fd2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/periodic_sampler.h @@ -23,7 +23,7 @@ #include "y_absl/profiling/internal/exponential_biased.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace profiling_internal { // PeriodicSamplerBase provides the basic period sampler implementation. @@ -205,7 +205,7 @@ template <typename Tag, int default_period> std::atomic<int> PeriodicSampler<Tag, default_period>::period_(default_period); } // namespace profiling_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_PROFILING_INTERNAL_PERIODIC_SAMPLER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.cc index 3b7fe28e08..9884ab8060 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.cc @@ -1,292 +1,292 @@ -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "y_absl/status/status.h" - -#include <cassert> - -#include "y_absl/base/internal/raw_logging.h" -#include "y_absl/debugging/stacktrace.h" -#include "y_absl/debugging/symbolize.h" -#include "y_absl/status/status_payload_printer.h" -#include "y_absl/strings/escaping.h" -#include "y_absl/strings/str_cat.h" -#include "y_absl/strings/str_format.h" -#include "y_absl/strings/str_split.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN - -TString StatusCodeToString(StatusCode code) { - switch (code) { - case StatusCode::kOk: - return "OK"; - case StatusCode::kCancelled: - return "CANCELLED"; - case StatusCode::kUnknown: - return "UNKNOWN"; - case StatusCode::kInvalidArgument: - return "INVALID_ARGUMENT"; - case StatusCode::kDeadlineExceeded: - return "DEADLINE_EXCEEDED"; - case StatusCode::kNotFound: - return "NOT_FOUND"; - case StatusCode::kAlreadyExists: - return "ALREADY_EXISTS"; - case StatusCode::kPermissionDenied: - return "PERMISSION_DENIED"; - case StatusCode::kUnauthenticated: - return "UNAUTHENTICATED"; - case StatusCode::kResourceExhausted: - return "RESOURCE_EXHAUSTED"; - case StatusCode::kFailedPrecondition: - return "FAILED_PRECONDITION"; - case StatusCode::kAborted: - return "ABORTED"; - case StatusCode::kOutOfRange: - return "OUT_OF_RANGE"; - case StatusCode::kUnimplemented: - return "UNIMPLEMENTED"; - case StatusCode::kInternal: - return "INTERNAL"; - case StatusCode::kUnavailable: - return "UNAVAILABLE"; - case StatusCode::kDataLoss: - return "DATA_LOSS"; - default: - return ""; - } -} - -std::ostream& operator<<(std::ostream& os, StatusCode code) { - return os << StatusCodeToString(code); -} - -namespace status_internal { - -static int FindPayloadIndexByUrl(const Payloads* payloads, - y_absl::string_view type_url) { - if (payloads == nullptr) return -1; - +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "y_absl/status/status.h" + +#include <cassert> + +#include "y_absl/base/internal/raw_logging.h" +#include "y_absl/debugging/stacktrace.h" +#include "y_absl/debugging/symbolize.h" +#include "y_absl/status/status_payload_printer.h" +#include "y_absl/strings/escaping.h" +#include "y_absl/strings/str_cat.h" +#include "y_absl/strings/str_format.h" +#include "y_absl/strings/str_split.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN + +TString StatusCodeToString(StatusCode code) { + switch (code) { + case StatusCode::kOk: + return "OK"; + case StatusCode::kCancelled: + return "CANCELLED"; + case StatusCode::kUnknown: + return "UNKNOWN"; + case StatusCode::kInvalidArgument: + return "INVALID_ARGUMENT"; + case StatusCode::kDeadlineExceeded: + return "DEADLINE_EXCEEDED"; + case StatusCode::kNotFound: + return "NOT_FOUND"; + case StatusCode::kAlreadyExists: + return "ALREADY_EXISTS"; + case StatusCode::kPermissionDenied: + return "PERMISSION_DENIED"; + case StatusCode::kUnauthenticated: + return "UNAUTHENTICATED"; + case StatusCode::kResourceExhausted: + return "RESOURCE_EXHAUSTED"; + case StatusCode::kFailedPrecondition: + return "FAILED_PRECONDITION"; + case StatusCode::kAborted: + return "ABORTED"; + case StatusCode::kOutOfRange: + return "OUT_OF_RANGE"; + case StatusCode::kUnimplemented: + return "UNIMPLEMENTED"; + case StatusCode::kInternal: + return "INTERNAL"; + case StatusCode::kUnavailable: + return "UNAVAILABLE"; + case StatusCode::kDataLoss: + return "DATA_LOSS"; + default: + return ""; + } +} + +std::ostream& operator<<(std::ostream& os, StatusCode code) { + return os << StatusCodeToString(code); +} + +namespace status_internal { + +static int FindPayloadIndexByUrl(const Payloads* payloads, + y_absl::string_view type_url) { + if (payloads == nullptr) return -1; + for (size_t i = 0; i < payloads->size(); ++i) { - if ((*payloads)[i].type_url == type_url) return i; - } - - return -1; -} - -// Convert canonical code to a value known to this binary. -y_absl::StatusCode MapToLocalCode(int value) { - y_absl::StatusCode code = static_cast<y_absl::StatusCode>(value); - switch (code) { - case y_absl::StatusCode::kOk: - case y_absl::StatusCode::kCancelled: - case y_absl::StatusCode::kUnknown: - case y_absl::StatusCode::kInvalidArgument: - case y_absl::StatusCode::kDeadlineExceeded: - case y_absl::StatusCode::kNotFound: - case y_absl::StatusCode::kAlreadyExists: - case y_absl::StatusCode::kPermissionDenied: - case y_absl::StatusCode::kResourceExhausted: - case y_absl::StatusCode::kFailedPrecondition: - case y_absl::StatusCode::kAborted: - case y_absl::StatusCode::kOutOfRange: - case y_absl::StatusCode::kUnimplemented: - case y_absl::StatusCode::kInternal: - case y_absl::StatusCode::kUnavailable: - case y_absl::StatusCode::kDataLoss: - case y_absl::StatusCode::kUnauthenticated: - return code; - default: - return y_absl::StatusCode::kUnknown; - } -} -} // namespace status_internal - -y_absl::optional<y_absl::Cord> Status::GetPayload( - y_absl::string_view type_url) const { - const auto* payloads = GetPayloads(); - int index = status_internal::FindPayloadIndexByUrl(payloads, type_url); - if (index != -1) return (*payloads)[index].payload; - - return y_absl::nullopt; -} - -void Status::SetPayload(y_absl::string_view type_url, y_absl::Cord payload) { - if (ok()) return; - - PrepareToModify(); - - status_internal::StatusRep* rep = RepToPointer(rep_); - if (!rep->payloads) { - rep->payloads = y_absl::make_unique<status_internal::Payloads>(); - } - - int index = - status_internal::FindPayloadIndexByUrl(rep->payloads.get(), type_url); - if (index != -1) { - (*rep->payloads)[index].payload = std::move(payload); - return; - } - - rep->payloads->push_back({TString(type_url), std::move(payload)}); -} - -bool Status::ErasePayload(y_absl::string_view type_url) { - int index = status_internal::FindPayloadIndexByUrl(GetPayloads(), type_url); - if (index != -1) { - PrepareToModify(); - GetPayloads()->erase(GetPayloads()->begin() + index); - if (GetPayloads()->empty() && message().empty()) { - // Special case: If this can be represented inlined, it MUST be - // inlined (EqualsSlow depends on this behavior). - StatusCode c = static_cast<StatusCode>(raw_code()); - Unref(rep_); - rep_ = CodeToInlinedRep(c); - } - return true; - } - - return false; -} - -void Status::ForEachPayload( + if ((*payloads)[i].type_url == type_url) return i; + } + + return -1; +} + +// Convert canonical code to a value known to this binary. +y_absl::StatusCode MapToLocalCode(int value) { + y_absl::StatusCode code = static_cast<y_absl::StatusCode>(value); + switch (code) { + case y_absl::StatusCode::kOk: + case y_absl::StatusCode::kCancelled: + case y_absl::StatusCode::kUnknown: + case y_absl::StatusCode::kInvalidArgument: + case y_absl::StatusCode::kDeadlineExceeded: + case y_absl::StatusCode::kNotFound: + case y_absl::StatusCode::kAlreadyExists: + case y_absl::StatusCode::kPermissionDenied: + case y_absl::StatusCode::kResourceExhausted: + case y_absl::StatusCode::kFailedPrecondition: + case y_absl::StatusCode::kAborted: + case y_absl::StatusCode::kOutOfRange: + case y_absl::StatusCode::kUnimplemented: + case y_absl::StatusCode::kInternal: + case y_absl::StatusCode::kUnavailable: + case y_absl::StatusCode::kDataLoss: + case y_absl::StatusCode::kUnauthenticated: + return code; + default: + return y_absl::StatusCode::kUnknown; + } +} +} // namespace status_internal + +y_absl::optional<y_absl::Cord> Status::GetPayload( + y_absl::string_view type_url) const { + const auto* payloads = GetPayloads(); + int index = status_internal::FindPayloadIndexByUrl(payloads, type_url); + if (index != -1) return (*payloads)[index].payload; + + return y_absl::nullopt; +} + +void Status::SetPayload(y_absl::string_view type_url, y_absl::Cord payload) { + if (ok()) return; + + PrepareToModify(); + + status_internal::StatusRep* rep = RepToPointer(rep_); + if (!rep->payloads) { + rep->payloads = y_absl::make_unique<status_internal::Payloads>(); + } + + int index = + status_internal::FindPayloadIndexByUrl(rep->payloads.get(), type_url); + if (index != -1) { + (*rep->payloads)[index].payload = std::move(payload); + return; + } + + rep->payloads->push_back({TString(type_url), std::move(payload)}); +} + +bool Status::ErasePayload(y_absl::string_view type_url) { + int index = status_internal::FindPayloadIndexByUrl(GetPayloads(), type_url); + if (index != -1) { + PrepareToModify(); + GetPayloads()->erase(GetPayloads()->begin() + index); + if (GetPayloads()->empty() && message().empty()) { + // Special case: If this can be represented inlined, it MUST be + // inlined (EqualsSlow depends on this behavior). + StatusCode c = static_cast<StatusCode>(raw_code()); + Unref(rep_); + rep_ = CodeToInlinedRep(c); + } + return true; + } + + return false; +} + +void Status::ForEachPayload( y_absl::FunctionRef<void(y_absl::string_view, const y_absl::Cord&)> visitor) - const { - if (auto* payloads = GetPayloads()) { - bool in_reverse = - payloads->size() > 1 && reinterpret_cast<uintptr_t>(payloads) % 13 > 6; - + const { + if (auto* payloads = GetPayloads()) { + bool in_reverse = + payloads->size() > 1 && reinterpret_cast<uintptr_t>(payloads) % 13 > 6; + for (size_t index = 0; index < payloads->size(); ++index) { - const auto& elem = - (*payloads)[in_reverse ? payloads->size() - 1 - index : index]; - -#ifdef NDEBUG - visitor(elem.type_url, elem.payload); -#else + const auto& elem = + (*payloads)[in_reverse ? payloads->size() - 1 - index : index]; + +#ifdef NDEBUG + visitor(elem.type_url, elem.payload); +#else // In debug mode invalidate the type url to prevent users from relying on // this string lifetime. - - // NOLINTNEXTLINE intentional extra conversion to force temporary. - visitor(TString(elem.type_url), elem.payload); -#endif // NDEBUG - } - } -} - -const TString* Status::EmptyString() { - static TString* empty_string = new TString(); - return empty_string; -} - -constexpr const char Status::kMovedFromString[]; - -const TString* Status::MovedFromString() { - static TString* moved_from_string = new TString(kMovedFromString); - return moved_from_string; -} - -void Status::UnrefNonInlined(uintptr_t rep) { - status_internal::StatusRep* r = RepToPointer(rep); - // Fast path: if ref==1, there is no need for a RefCountDec (since - // this is the only reference and therefore no other thread is - // allowed to be mucking with r). - if (r->ref.load(std::memory_order_acquire) == 1 || - r->ref.fetch_sub(1, std::memory_order_acq_rel) - 1 == 0) { - delete r; - } -} - -Status::Status(y_absl::StatusCode code, y_absl::string_view msg) - : rep_(CodeToInlinedRep(code)) { - if (code != y_absl::StatusCode::kOk && !msg.empty()) { + + // NOLINTNEXTLINE intentional extra conversion to force temporary. + visitor(TString(elem.type_url), elem.payload); +#endif // NDEBUG + } + } +} + +const TString* Status::EmptyString() { + static TString* empty_string = new TString(); + return empty_string; +} + +constexpr const char Status::kMovedFromString[]; + +const TString* Status::MovedFromString() { + static TString* moved_from_string = new TString(kMovedFromString); + return moved_from_string; +} + +void Status::UnrefNonInlined(uintptr_t rep) { + status_internal::StatusRep* r = RepToPointer(rep); + // Fast path: if ref==1, there is no need for a RefCountDec (since + // this is the only reference and therefore no other thread is + // allowed to be mucking with r). + if (r->ref.load(std::memory_order_acquire) == 1 || + r->ref.fetch_sub(1, std::memory_order_acq_rel) - 1 == 0) { + delete r; + } +} + +Status::Status(y_absl::StatusCode code, y_absl::string_view msg) + : rep_(CodeToInlinedRep(code)) { + if (code != y_absl::StatusCode::kOk && !msg.empty()) { rep_ = PointerToRep(new status_internal::StatusRep(code, msg, nullptr)); - } -} - -int Status::raw_code() const { - if (IsInlined(rep_)) { - return static_cast<int>(InlinedRepToCode(rep_)); - } - status_internal::StatusRep* rep = RepToPointer(rep_); - return static_cast<int>(rep->code); -} - -y_absl::StatusCode Status::code() const { - return status_internal::MapToLocalCode(raw_code()); -} - -void Status::PrepareToModify() { - ABSL_RAW_CHECK(!ok(), "PrepareToModify shouldn't be called on OK status."); - if (IsInlined(rep_)) { + } +} + +int Status::raw_code() const { + if (IsInlined(rep_)) { + return static_cast<int>(InlinedRepToCode(rep_)); + } + status_internal::StatusRep* rep = RepToPointer(rep_); + return static_cast<int>(rep->code); +} + +y_absl::StatusCode Status::code() const { + return status_internal::MapToLocalCode(raw_code()); +} + +void Status::PrepareToModify() { + ABSL_RAW_CHECK(!ok(), "PrepareToModify shouldn't be called on OK status."); + if (IsInlined(rep_)) { rep_ = PointerToRep(new status_internal::StatusRep( static_cast<y_absl::StatusCode>(raw_code()), y_absl::string_view(), nullptr)); - return; - } - - uintptr_t rep_i = rep_; - status_internal::StatusRep* rep = RepToPointer(rep_); - if (rep->ref.load(std::memory_order_acquire) != 1) { - std::unique_ptr<status_internal::Payloads> payloads; - if (rep->payloads) { - payloads = y_absl::make_unique<status_internal::Payloads>(*rep->payloads); - } + return; + } + + uintptr_t rep_i = rep_; + status_internal::StatusRep* rep = RepToPointer(rep_); + if (rep->ref.load(std::memory_order_acquire) != 1) { + std::unique_ptr<status_internal::Payloads> payloads; + if (rep->payloads) { + payloads = y_absl::make_unique<status_internal::Payloads>(*rep->payloads); + } status_internal::StatusRep* const new_rep = new status_internal::StatusRep( rep->code, message(), std::move(payloads)); rep_ = PointerToRep(new_rep); - UnrefNonInlined(rep_i); - } -} - -bool Status::EqualsSlow(const y_absl::Status& a, const y_absl::Status& b) { - if (IsInlined(a.rep_) != IsInlined(b.rep_)) return false; - if (a.message() != b.message()) return false; - if (a.raw_code() != b.raw_code()) return false; - if (a.GetPayloads() == b.GetPayloads()) return true; - - const status_internal::Payloads no_payloads; - const status_internal::Payloads* larger_payloads = - a.GetPayloads() ? a.GetPayloads() : &no_payloads; - const status_internal::Payloads* smaller_payloads = - b.GetPayloads() ? b.GetPayloads() : &no_payloads; - if (larger_payloads->size() < smaller_payloads->size()) { - std::swap(larger_payloads, smaller_payloads); - } - if ((larger_payloads->size() - smaller_payloads->size()) > 1) return false; - // Payloads can be ordered differently, so we can't just compare payload - // vectors. - for (const auto& payload : *larger_payloads) { - - bool found = false; - for (const auto& other_payload : *smaller_payloads) { - if (payload.type_url == other_payload.type_url) { - if (payload.payload != other_payload.payload) { - return false; - } - found = true; - break; - } - } - if (!found) return false; - } - return true; -} - + UnrefNonInlined(rep_i); + } +} + +bool Status::EqualsSlow(const y_absl::Status& a, const y_absl::Status& b) { + if (IsInlined(a.rep_) != IsInlined(b.rep_)) return false; + if (a.message() != b.message()) return false; + if (a.raw_code() != b.raw_code()) return false; + if (a.GetPayloads() == b.GetPayloads()) return true; + + const status_internal::Payloads no_payloads; + const status_internal::Payloads* larger_payloads = + a.GetPayloads() ? a.GetPayloads() : &no_payloads; + const status_internal::Payloads* smaller_payloads = + b.GetPayloads() ? b.GetPayloads() : &no_payloads; + if (larger_payloads->size() < smaller_payloads->size()) { + std::swap(larger_payloads, smaller_payloads); + } + if ((larger_payloads->size() - smaller_payloads->size()) > 1) return false; + // Payloads can be ordered differently, so we can't just compare payload + // vectors. + for (const auto& payload : *larger_payloads) { + + bool found = false; + for (const auto& other_payload : *smaller_payloads) { + if (payload.type_url == other_payload.type_url) { + if (payload.payload != other_payload.payload) { + return false; + } + found = true; + break; + } + } + if (!found) return false; + } + return true; +} + TString Status::ToStringSlow(StatusToStringMode mode) const { - TString text; - y_absl::StrAppend(&text, y_absl::StatusCodeToString(code()), ": ", message()); - + TString text; + y_absl::StrAppend(&text, y_absl::StatusCodeToString(code()), ": ", message()); + const bool with_payload = (mode & StatusToStringMode::kWithPayload) == StatusToStringMode::kWithPayload; @@ -304,141 +304,141 @@ TString Status::ToStringSlow(StatusToStringMode mode) const { }); } - return text; -} - -std::ostream& operator<<(std::ostream& os, const Status& x) { + return text; +} + +std::ostream& operator<<(std::ostream& os, const Status& x) { os << x.ToString(StatusToStringMode::kWithEverything); - return os; -} - -Status AbortedError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kAborted, message); -} - -Status AlreadyExistsError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kAlreadyExists, message); -} - -Status CancelledError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kCancelled, message); -} - -Status DataLossError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kDataLoss, message); -} - -Status DeadlineExceededError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kDeadlineExceeded, message); -} - -Status FailedPreconditionError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kFailedPrecondition, message); -} - -Status InternalError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kInternal, message); -} - -Status InvalidArgumentError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kInvalidArgument, message); -} - -Status NotFoundError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kNotFound, message); -} - -Status OutOfRangeError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kOutOfRange, message); -} - -Status PermissionDeniedError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kPermissionDenied, message); -} - -Status ResourceExhaustedError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kResourceExhausted, message); -} - -Status UnauthenticatedError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kUnauthenticated, message); -} - -Status UnavailableError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kUnavailable, message); -} - -Status UnimplementedError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kUnimplemented, message); -} - -Status UnknownError(y_absl::string_view message) { - return Status(y_absl::StatusCode::kUnknown, message); -} - -bool IsAborted(const Status& status) { - return status.code() == y_absl::StatusCode::kAborted; -} - -bool IsAlreadyExists(const Status& status) { - return status.code() == y_absl::StatusCode::kAlreadyExists; -} - -bool IsCancelled(const Status& status) { - return status.code() == y_absl::StatusCode::kCancelled; -} - -bool IsDataLoss(const Status& status) { - return status.code() == y_absl::StatusCode::kDataLoss; -} - -bool IsDeadlineExceeded(const Status& status) { - return status.code() == y_absl::StatusCode::kDeadlineExceeded; -} - -bool IsFailedPrecondition(const Status& status) { - return status.code() == y_absl::StatusCode::kFailedPrecondition; -} - -bool IsInternal(const Status& status) { - return status.code() == y_absl::StatusCode::kInternal; -} - -bool IsInvalidArgument(const Status& status) { - return status.code() == y_absl::StatusCode::kInvalidArgument; -} - -bool IsNotFound(const Status& status) { - return status.code() == y_absl::StatusCode::kNotFound; -} - -bool IsOutOfRange(const Status& status) { - return status.code() == y_absl::StatusCode::kOutOfRange; -} - -bool IsPermissionDenied(const Status& status) { - return status.code() == y_absl::StatusCode::kPermissionDenied; -} - -bool IsResourceExhausted(const Status& status) { - return status.code() == y_absl::StatusCode::kResourceExhausted; -} - -bool IsUnauthenticated(const Status& status) { - return status.code() == y_absl::StatusCode::kUnauthenticated; -} - -bool IsUnavailable(const Status& status) { - return status.code() == y_absl::StatusCode::kUnavailable; -} - -bool IsUnimplemented(const Status& status) { - return status.code() == y_absl::StatusCode::kUnimplemented; -} - -bool IsUnknown(const Status& status) { - return status.code() == y_absl::StatusCode::kUnknown; -} - -ABSL_NAMESPACE_END -} // namespace y_absl + return os; +} + +Status AbortedError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kAborted, message); +} + +Status AlreadyExistsError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kAlreadyExists, message); +} + +Status CancelledError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kCancelled, message); +} + +Status DataLossError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kDataLoss, message); +} + +Status DeadlineExceededError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kDeadlineExceeded, message); +} + +Status FailedPreconditionError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kFailedPrecondition, message); +} + +Status InternalError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kInternal, message); +} + +Status InvalidArgumentError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kInvalidArgument, message); +} + +Status NotFoundError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kNotFound, message); +} + +Status OutOfRangeError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kOutOfRange, message); +} + +Status PermissionDeniedError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kPermissionDenied, message); +} + +Status ResourceExhaustedError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kResourceExhausted, message); +} + +Status UnauthenticatedError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kUnauthenticated, message); +} + +Status UnavailableError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kUnavailable, message); +} + +Status UnimplementedError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kUnimplemented, message); +} + +Status UnknownError(y_absl::string_view message) { + return Status(y_absl::StatusCode::kUnknown, message); +} + +bool IsAborted(const Status& status) { + return status.code() == y_absl::StatusCode::kAborted; +} + +bool IsAlreadyExists(const Status& status) { + return status.code() == y_absl::StatusCode::kAlreadyExists; +} + +bool IsCancelled(const Status& status) { + return status.code() == y_absl::StatusCode::kCancelled; +} + +bool IsDataLoss(const Status& status) { + return status.code() == y_absl::StatusCode::kDataLoss; +} + +bool IsDeadlineExceeded(const Status& status) { + return status.code() == y_absl::StatusCode::kDeadlineExceeded; +} + +bool IsFailedPrecondition(const Status& status) { + return status.code() == y_absl::StatusCode::kFailedPrecondition; +} + +bool IsInternal(const Status& status) { + return status.code() == y_absl::StatusCode::kInternal; +} + +bool IsInvalidArgument(const Status& status) { + return status.code() == y_absl::StatusCode::kInvalidArgument; +} + +bool IsNotFound(const Status& status) { + return status.code() == y_absl::StatusCode::kNotFound; +} + +bool IsOutOfRange(const Status& status) { + return status.code() == y_absl::StatusCode::kOutOfRange; +} + +bool IsPermissionDenied(const Status& status) { + return status.code() == y_absl::StatusCode::kPermissionDenied; +} + +bool IsResourceExhausted(const Status& status) { + return status.code() == y_absl::StatusCode::kResourceExhausted; +} + +bool IsUnauthenticated(const Status& status) { + return status.code() == y_absl::StatusCode::kUnauthenticated; +} + +bool IsUnavailable(const Status& status) { + return status.code() == y_absl::StatusCode::kUnavailable; +} + +bool IsUnimplemented(const Status& status) { + return status.code() == y_absl::StatusCode::kUnimplemented; +} + +bool IsUnknown(const Status& status) { + return status.code() == y_absl::StatusCode::kUnknown; +} + +ABSL_NAMESPACE_END +} // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.h b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.h index fa461e9f76..43d7336ee5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status.h @@ -1,16 +1,16 @@ -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. // // ----------------------------------------------------------------------------- // File: status.h @@ -48,22 +48,22 @@ // error codes (of type `y_absl::StatusCode`) enumerated in this header file. // These canonical codes are understood across the codebase and will be // accepted across all API and RPC boundaries. -#ifndef ABSL_STATUS_STATUS_H_ -#define ABSL_STATUS_STATUS_H_ - -#include <iostream> -#include <util/generic/string.h> - -#include "y_absl/container/inlined_vector.h" +#ifndef ABSL_STATUS_STATUS_H_ +#define ABSL_STATUS_STATUS_H_ + +#include <iostream> +#include <util/generic/string.h> + +#include "y_absl/container/inlined_vector.h" #include "y_absl/functional/function_ref.h" #include "y_absl/status/internal/status_internal.h" -#include "y_absl/strings/cord.h" +#include "y_absl/strings/cord.h" #include "y_absl/strings/string_view.h" -#include "y_absl/types/optional.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN - +#include "y_absl/types/optional.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN + // y_absl::StatusCode // // An `y_absl::StatusCode` is an enumerated type indicating either no error ("OK") @@ -89,20 +89,20 @@ ABSL_NAMESPACE_BEGIN // If your error handling code requires more context, you can attach payloads // to your status. See `y_absl::Status::SetPayload()` and // `y_absl::Status::GetPayload()` below. -enum class StatusCode : int { +enum class StatusCode : int { // StatusCode::kOk // // kOK (gRPC code "OK") does not indicate an error; this value is returned on // success. It is typical to check for this value before proceeding on any // given call across an API or RPC boundary. To check this value, use the // `y_absl::Status::ok()` member function rather than inspecting the raw code. - kOk = 0, + kOk = 0, // StatusCode::kCancelled // // kCancelled (gRPC code "CANCELLED") indicates the operation was cancelled, // typically by the caller. - kCancelled = 1, + kCancelled = 1, // StatusCode::kUnknown // @@ -110,7 +110,7 @@ enum class StatusCode : int { // general, more specific errors should be raised, if possible. Errors raised // by APIs that do not return enough error information may be converted to // this error. - kUnknown = 2, + kUnknown = 2, // StatusCode::kInvalidArgument // @@ -120,7 +120,7 @@ enum class StatusCode : int { // the arguments themselves. Errors with validly formed arguments that may // cause errors with the state of the receiving system should be denoted with // `kFailedPrecondition` instead. - kInvalidArgument = 3, + kInvalidArgument = 3, // StatusCode::kDeadlineExceeded // @@ -129,7 +129,7 @@ enum class StatusCode : int { // state within a system, this error may be returned even if the operation has // completed successfully. For example, a successful response from a server // could have been delayed long enough for the deadline to expire. - kDeadlineExceeded = 4, + kDeadlineExceeded = 4, // StatusCode::kNotFound // @@ -140,14 +140,14 @@ enum class StatusCode : int { // users, such as during a gradual feature rollout or undocumented allow list. // If a request should be denied for specific sets of users, such as through // user-based access control, use `kPermissionDenied` instead. - kNotFound = 5, + kNotFound = 5, // StatusCode::kAlreadyExists // // kAlreadyExists (gRPC code "ALREADY_EXISTS") indicates that the entity a // caller attempted to create (such as a file or directory) is already // present. - kAlreadyExists = 6, + kAlreadyExists = 6, // StatusCode::kPermissionDenied // @@ -161,14 +161,14 @@ enum class StatusCode : int { // some resource. Instead, use `kResourceExhausted` for those errors. // `kPermissionDenied` must not be used if the caller cannot be identified. // Instead, use `kUnauthenticated` for those errors. - kPermissionDenied = 7, + kPermissionDenied = 7, // StatusCode::kResourceExhausted // // kResourceExhausted (gRPC code "RESOURCE_EXHAUSTED") indicates some resource // has been exhausted, perhaps a per-user quota, or perhaps the entire file // system is out of space. - kResourceExhausted = 8, + kResourceExhausted = 8, // StatusCode::kFailedPrecondition // @@ -189,7 +189,7 @@ enum class StatusCode : int { // fails because the directory is non-empty, `kFailedPrecondition` // should be returned since the client should not retry unless // the files are deleted from the directory. - kFailedPrecondition = 9, + kFailedPrecondition = 9, // StatusCode::kAborted // @@ -199,7 +199,7 @@ enum class StatusCode : int { // // See the guidelines above for deciding between `kFailedPrecondition`, // `kAborted`, and `kUnavailable`. - kAborted = 10, + kAborted = 10, // StatusCode::kOutOfRange // @@ -219,21 +219,21 @@ enum class StatusCode : int { // error) when it applies so that callers who are iterating through // a space can easily look for an `kOutOfRange` error to detect when // they are done. - kOutOfRange = 11, + kOutOfRange = 11, // StatusCode::kUnimplemented // // kUnimplemented (gRPC code "UNIMPLEMENTED") indicates the operation is not // implemented or supported in this service. In this case, the operation // should not be re-attempted. - kUnimplemented = 12, + kUnimplemented = 12, // StatusCode::kInternal // // kInternal (gRPC code "INTERNAL") indicates an internal error has occurred // and some invariants expected by the underlying system have not been // satisfied. This error code is reserved for serious errors. - kInternal = 13, + kInternal = 13, // StatusCode::kUnavailable // @@ -244,21 +244,21 @@ enum class StatusCode : int { // // See the guidelines above for deciding between `kFailedPrecondition`, // `kAborted`, and `kUnavailable`. - kUnavailable = 14, + kUnavailable = 14, // StatusCode::kDataLoss // // kDataLoss (gRPC code "DATA_LOSS") indicates that unrecoverable data loss or // corruption has occurred. As this error is serious, proper alerting should // be attached to errors such as this. - kDataLoss = 15, + kDataLoss = 15, // StatusCode::kUnauthenticated // // kUnauthenticated (gRPC code "UNAUTHENTICATED") indicates that the request // does not have valid authentication credentials for the operation. Correct // the authentication and try again. - kUnauthenticated = 16, + kUnauthenticated = 16, // StatusCode::DoNotUseReservedForFutureExpansionUseDefaultInSwitchInstead_ // @@ -269,19 +269,19 @@ enum class StatusCode : int { // codes with `switch()` statements to *not* simply enumerate all possible // values, but instead provide a "default:" case. Providing such a default // case ensures that code will compile when new codes are added. - kDoNotUseReservedForFutureExpansionUseDefaultInSwitchInstead_ = 20 -}; - + kDoNotUseReservedForFutureExpansionUseDefaultInSwitchInstead_ = 20 +}; + // StatusCodeToString() // -// Returns the name for the status code, or "" if it is an unknown value. -TString StatusCodeToString(StatusCode code); - +// Returns the name for the status code, or "" if it is an unknown value. +TString StatusCodeToString(StatusCode code); + // operator<< // -// Streams StatusCodeToString(code) to `os`. -std::ostream& operator<<(std::ostream& os, StatusCode code); - +// Streams StatusCodeToString(code) to `os`. +std::ostream& operator<<(std::ostream& os, StatusCode code); + // y_absl::StatusToStringMode // // An `y_absl::StatusToStringMode` is an enumerated type indicating how @@ -297,8 +297,8 @@ enum class StatusToStringMode : int { kWithEverything = ~kWithNoExtraData, // Default mode used by ToString. Its exact value might change in the future. kDefault = kWithPayload, -}; - +}; + // y_absl::StatusToStringMode is specified as a bitmask type, which means the // following operations must be provided: inline constexpr StatusToStringMode operator&(StatusToStringMode lhs, @@ -334,7 +334,7 @@ inline StatusToStringMode& operator^=(StatusToStringMode& lhs, lhs = lhs ^ rhs; return lhs; } - + // y_absl::Status // // The `y_absl::Status` class is generally used to gracefully handle errors @@ -424,33 +424,33 @@ inline StatusToStringMode& operator^=(StatusToStringMode& lhs, class Status final { public: // Constructors - + // This default constructor creates an OK status with no message or payload. // Avoid this constructor and prefer explicit construction of an OK status // with `y_absl::OkStatus()`. - Status(); - + Status(); + // Creates a status in the canonical error space with the specified // `y_absl::StatusCode` and error message. If `code == y_absl::StatusCode::kOk`, // NOLINT // `msg` is ignored and an object identical to an OK status is constructed. - // + // // The `msg` string must be in UTF-8. The implementation may complain (e.g., // NOLINT - // by printing a warning) if it is not. - Status(y_absl::StatusCode code, y_absl::string_view msg); - - Status(const Status&); - Status& operator=(const Status& x); - + // by printing a warning) if it is not. + Status(y_absl::StatusCode code, y_absl::string_view msg); + + Status(const Status&); + Status& operator=(const Status& x); + // Move operators - // The moved-from state is valid but unspecified. - Status(Status&&) noexcept; - Status& operator=(Status&&); - - ~Status(); - + // The moved-from state is valid but unspecified. + Status(Status&&) noexcept; + Status& operator=(Status&&); + + ~Status(); + // Status::Update() - // + // // Updates the existing status with `new_status` provided that `this->ok()`. // If the existing status already contains a non-OK error, this update has no // effect and preserves the current data. Note that this behavior may change @@ -462,22 +462,22 @@ class Status final { // // Example: // // Instead of "if (overall_status.ok()) overall_status = new_status" - // overall_status.Update(new_status); - // - void Update(const Status& new_status); - void Update(Status&& new_status); - + // overall_status.Update(new_status); + // + void Update(const Status& new_status); + void Update(Status&& new_status); + // Status::ok() // // Returns `true` if `this->ok()`. Prefer checking for an OK status using this // member function. - ABSL_MUST_USE_RESULT bool ok() const; - + ABSL_MUST_USE_RESULT bool ok() const; + // Status::code() // // Returns the canonical error code of type `y_absl::StatusCode` of this status. - y_absl::StatusCode code() const; - + y_absl::StatusCode code() const; + // Status::raw_code() // // Returns a raw (canonical) error code corresponding to the enum value of @@ -488,19 +488,19 @@ class Status final { // // NOTE: This function should only be called when converting to an associated // wire format. Use `Status::code()` for error handling. - int raw_code() const; - + int raw_code() const; + // Status::message() // // Returns the error message associated with this error code, if available. // Note that this message rarely describes the error code. It is not unusual // for the error message to be the empty string. As a result, prefer // `operator<<` or `Status::ToString()` for debug logging. - y_absl::string_view message() const; - - friend bool operator==(const Status&, const Status&); - friend bool operator!=(const Status&, const Status&); - + y_absl::string_view message() const; + + friend bool operator==(const Status&, const Status&); + friend bool operator!=(const Status&, const Status&); + // Status::ToString() // // Returns a string based on the `mode`. By default, it returns combination of @@ -514,23 +514,23 @@ class Status final { // mechanism (which is internal). TString ToString( StatusToStringMode mode = StatusToStringMode::kDefault) const; - + // Status::IgnoreError() // - // Ignores any errors. This method does nothing except potentially suppress - // complaints from any tools that are checking that errors are not dropped on - // the floor. - void IgnoreError() const; - + // Ignores any errors. This method does nothing except potentially suppress + // complaints from any tools that are checking that errors are not dropped on + // the floor. + void IgnoreError() const; + // swap() // // Swap the contents of one status with another. - friend void swap(Status& a, Status& b); - + friend void swap(Status& a, Status& b); + //---------------------------------------------------------------------------- // Payload Management APIs //---------------------------------------------------------------------------- - + // A payload may be attached to a status to provide additional context to an // error that may not be satisifed by an existing `y_absl::StatusCode`. // Typically, this payload serves one of several purposes: @@ -552,7 +552,7 @@ class Status final { // should define the format of type URL in a similar practice so as to // minimize the chance of conflict between type URLs. // Users should ensure that the type URL can be mapped to a concrete - // C++ type if they want to deserialize the payload and read it effectively. + // C++ type if they want to deserialize the payload and read it effectively. // // To attach a payload to a status object, call `Status::SetPayload()`, // passing it the type URL and an `y_absl::Cord` of associated data. Similarly, @@ -560,114 +560,114 @@ class Status final { // may attach multiple payloads (with differing type URLs) to any given // status object, provided that the status is currently exhibiting an error // code (i.e. is not OK). - + // Status::GetPayload() // // Gets the payload of a status given its unique `type_url` key, if present. - y_absl::optional<y_absl::Cord> GetPayload(y_absl::string_view type_url) const; - + y_absl::optional<y_absl::Cord> GetPayload(y_absl::string_view type_url) const; + // Status::SetPayload() - // + // // Sets the payload for a non-ok status using a `type_url` key, overwriting // any existing payload for that `type_url`. // // NOTE: This function does nothing if the Status is ok. - void SetPayload(y_absl::string_view type_url, y_absl::Cord payload); - + void SetPayload(y_absl::string_view type_url, y_absl::Cord payload); + // Status::ErasePayload() // // Erases the payload corresponding to the `type_url` key. Returns `true` if - // the payload was present. - bool ErasePayload(y_absl::string_view type_url); - + // the payload was present. + bool ErasePayload(y_absl::string_view type_url); + // Status::ForEachPayload() - // + // // Iterates over the stored payloads and calls the // `visitor(type_key, payload)` callable for each one. // // NOTE: The order of calls to `visitor()` is not specified and may change at - // any time. - // + // any time. + // // NOTE: Any mutation on the same 'y_absl::Status' object during visitation is - // forbidden and could result in undefined behavior. - void ForEachPayload( + // forbidden and could result in undefined behavior. + void ForEachPayload( y_absl::FunctionRef<void(y_absl::string_view, const y_absl::Cord&)> visitor) - const; - - private: - friend Status CancelledError(); - - // Creates a status in the canonical error space with the specified - // code, and an empty error message. - explicit Status(y_absl::StatusCode code); - - static void UnrefNonInlined(uintptr_t rep); - static void Ref(uintptr_t rep); - static void Unref(uintptr_t rep); - - // REQUIRES: !ok() - // Ensures rep_ is not shared with any other Status. - void PrepareToModify(); - - const status_internal::Payloads* GetPayloads() const; - status_internal::Payloads* GetPayloads(); - - // Takes ownership of payload. + const; + + private: + friend Status CancelledError(); + + // Creates a status in the canonical error space with the specified + // code, and an empty error message. + explicit Status(y_absl::StatusCode code); + + static void UnrefNonInlined(uintptr_t rep); + static void Ref(uintptr_t rep); + static void Unref(uintptr_t rep); + + // REQUIRES: !ok() + // Ensures rep_ is not shared with any other Status. + void PrepareToModify(); + + const status_internal::Payloads* GetPayloads() const; + status_internal::Payloads* GetPayloads(); + + // Takes ownership of payload. static uintptr_t NewRep( y_absl::StatusCode code, y_absl::string_view msg, std::unique_ptr<status_internal::Payloads> payload); - static bool EqualsSlow(const y_absl::Status& a, const y_absl::Status& b); - - // MSVC 14.0 limitation requires the const. - static constexpr const char kMovedFromString[] = - "Status accessed after move."; - - static const TString* EmptyString(); - static const TString* MovedFromString(); - - // Returns whether rep contains an inlined representation. - // See rep_ for details. - static bool IsInlined(uintptr_t rep); - - // Indicates whether this Status was the rhs of a move operation. See rep_ - // for details. - static bool IsMovedFrom(uintptr_t rep); - static uintptr_t MovedFromRep(); - - // Convert between error::Code and the inlined uintptr_t representation used - // by rep_. See rep_ for details. - static uintptr_t CodeToInlinedRep(y_absl::StatusCode code); - static y_absl::StatusCode InlinedRepToCode(uintptr_t rep); - - // Converts between StatusRep* and the external uintptr_t representation used - // by rep_. See rep_ for details. - static uintptr_t PointerToRep(status_internal::StatusRep* r); - static status_internal::StatusRep* RepToPointer(uintptr_t r); - + static bool EqualsSlow(const y_absl::Status& a, const y_absl::Status& b); + + // MSVC 14.0 limitation requires the const. + static constexpr const char kMovedFromString[] = + "Status accessed after move."; + + static const TString* EmptyString(); + static const TString* MovedFromString(); + + // Returns whether rep contains an inlined representation. + // See rep_ for details. + static bool IsInlined(uintptr_t rep); + + // Indicates whether this Status was the rhs of a move operation. See rep_ + // for details. + static bool IsMovedFrom(uintptr_t rep); + static uintptr_t MovedFromRep(); + + // Convert between error::Code and the inlined uintptr_t representation used + // by rep_. See rep_ for details. + static uintptr_t CodeToInlinedRep(y_absl::StatusCode code); + static y_absl::StatusCode InlinedRepToCode(uintptr_t rep); + + // Converts between StatusRep* and the external uintptr_t representation used + // by rep_. See rep_ for details. + static uintptr_t PointerToRep(status_internal::StatusRep* r); + static status_internal::StatusRep* RepToPointer(uintptr_t r); + TString ToStringSlow(StatusToStringMode mode) const; - - // Status supports two different representations. - // - When the low bit is off it is an inlined representation. - // It uses the canonical error space, no message or payload. - // The error code is (rep_ >> 2). - // The (rep_ & 2) bit is the "moved from" indicator, used in IsMovedFrom(). - // - When the low bit is on it is an external representation. - // In this case all the data comes from a heap allocated Rep object. - // (rep_ - 1) is a status_internal::StatusRep* pointer to that structure. - uintptr_t rep_; -}; - + + // Status supports two different representations. + // - When the low bit is off it is an inlined representation. + // It uses the canonical error space, no message or payload. + // The error code is (rep_ >> 2). + // The (rep_ & 2) bit is the "moved from" indicator, used in IsMovedFrom(). + // - When the low bit is on it is an external representation. + // In this case all the data comes from a heap allocated Rep object. + // (rep_ - 1) is a status_internal::StatusRep* pointer to that structure. + uintptr_t rep_; +}; + // OkStatus() // // Returns an OK status, equivalent to a default constructed instance. Prefer // usage of `y_absl::OkStatus()` when constructing such an OK status. -Status OkStatus(); - +Status OkStatus(); + // operator<<() // -// Prints a human-readable representation of `x` to `os`. -std::ostream& operator<<(std::ostream& os, const Status& x); - +// Prints a human-readable representation of `x` to `os`. +std::ostream& operator<<(std::ostream& os, const Status& x); + // IsAborted() // IsAlreadyExists() // IsCancelled() @@ -742,141 +742,141 @@ Status UnimplementedError(y_absl::string_view message); Status UnknownError(y_absl::string_view message); //------------------------------------------------------------------------------ -// Implementation details follow +// Implementation details follow //------------------------------------------------------------------------------ - -inline Status::Status() : rep_(CodeToInlinedRep(y_absl::StatusCode::kOk)) {} - -inline Status::Status(y_absl::StatusCode code) : rep_(CodeToInlinedRep(code)) {} - -inline Status::Status(const Status& x) : rep_(x.rep_) { Ref(rep_); } - -inline Status& Status::operator=(const Status& x) { - uintptr_t old_rep = rep_; - if (x.rep_ != old_rep) { - Ref(x.rep_); - rep_ = x.rep_; - Unref(old_rep); - } - return *this; -} - -inline Status::Status(Status&& x) noexcept : rep_(x.rep_) { - x.rep_ = MovedFromRep(); -} - -inline Status& Status::operator=(Status&& x) { - uintptr_t old_rep = rep_; + +inline Status::Status() : rep_(CodeToInlinedRep(y_absl::StatusCode::kOk)) {} + +inline Status::Status(y_absl::StatusCode code) : rep_(CodeToInlinedRep(code)) {} + +inline Status::Status(const Status& x) : rep_(x.rep_) { Ref(rep_); } + +inline Status& Status::operator=(const Status& x) { + uintptr_t old_rep = rep_; + if (x.rep_ != old_rep) { + Ref(x.rep_); + rep_ = x.rep_; + Unref(old_rep); + } + return *this; +} + +inline Status::Status(Status&& x) noexcept : rep_(x.rep_) { + x.rep_ = MovedFromRep(); +} + +inline Status& Status::operator=(Status&& x) { + uintptr_t old_rep = rep_; if (x.rep_ != old_rep) { rep_ = x.rep_; x.rep_ = MovedFromRep(); Unref(old_rep); } - return *this; -} - -inline void Status::Update(const Status& new_status) { - if (ok()) { - *this = new_status; - } -} - -inline void Status::Update(Status&& new_status) { - if (ok()) { - *this = std::move(new_status); - } -} - -inline Status::~Status() { Unref(rep_); } - -inline bool Status::ok() const { - return rep_ == CodeToInlinedRep(y_absl::StatusCode::kOk); -} - -inline y_absl::string_view Status::message() const { - return !IsInlined(rep_) - ? RepToPointer(rep_)->message - : (IsMovedFrom(rep_) ? y_absl::string_view(kMovedFromString) - : y_absl::string_view()); -} - -inline bool operator==(const Status& lhs, const Status& rhs) { - return lhs.rep_ == rhs.rep_ || Status::EqualsSlow(lhs, rhs); -} - -inline bool operator!=(const Status& lhs, const Status& rhs) { - return !(lhs == rhs); -} - + return *this; +} + +inline void Status::Update(const Status& new_status) { + if (ok()) { + *this = new_status; + } +} + +inline void Status::Update(Status&& new_status) { + if (ok()) { + *this = std::move(new_status); + } +} + +inline Status::~Status() { Unref(rep_); } + +inline bool Status::ok() const { + return rep_ == CodeToInlinedRep(y_absl::StatusCode::kOk); +} + +inline y_absl::string_view Status::message() const { + return !IsInlined(rep_) + ? RepToPointer(rep_)->message + : (IsMovedFrom(rep_) ? y_absl::string_view(kMovedFromString) + : y_absl::string_view()); +} + +inline bool operator==(const Status& lhs, const Status& rhs) { + return lhs.rep_ == rhs.rep_ || Status::EqualsSlow(lhs, rhs); +} + +inline bool operator!=(const Status& lhs, const Status& rhs) { + return !(lhs == rhs); +} + inline TString Status::ToString(StatusToStringMode mode) const { return ok() ? "OK" : ToStringSlow(mode); -} - -inline void Status::IgnoreError() const { - // no-op -} - -inline void swap(y_absl::Status& a, y_absl::Status& b) { - using std::swap; - swap(a.rep_, b.rep_); -} - -inline const status_internal::Payloads* Status::GetPayloads() const { - return IsInlined(rep_) ? nullptr : RepToPointer(rep_)->payloads.get(); -} - -inline status_internal::Payloads* Status::GetPayloads() { - return IsInlined(rep_) ? nullptr : RepToPointer(rep_)->payloads.get(); -} - -inline bool Status::IsInlined(uintptr_t rep) { return (rep & 1) == 0; } - -inline bool Status::IsMovedFrom(uintptr_t rep) { - return IsInlined(rep) && (rep & 2) != 0; -} - -inline uintptr_t Status::MovedFromRep() { - return CodeToInlinedRep(y_absl::StatusCode::kInternal) | 2; -} - -inline uintptr_t Status::CodeToInlinedRep(y_absl::StatusCode code) { - return static_cast<uintptr_t>(code) << 2; -} - -inline y_absl::StatusCode Status::InlinedRepToCode(uintptr_t rep) { - assert(IsInlined(rep)); - return static_cast<y_absl::StatusCode>(rep >> 2); -} - -inline status_internal::StatusRep* Status::RepToPointer(uintptr_t rep) { - assert(!IsInlined(rep)); - return reinterpret_cast<status_internal::StatusRep*>(rep - 1); -} - -inline uintptr_t Status::PointerToRep(status_internal::StatusRep* rep) { - return reinterpret_cast<uintptr_t>(rep) + 1; -} - -inline void Status::Ref(uintptr_t rep) { - if (!IsInlined(rep)) { - RepToPointer(rep)->ref.fetch_add(1, std::memory_order_relaxed); - } -} - -inline void Status::Unref(uintptr_t rep) { - if (!IsInlined(rep)) { - UnrefNonInlined(rep); - } -} - -inline Status OkStatus() { return Status(); } - -// Creates a `Status` object with the `y_absl::StatusCode::kCancelled` error code -// and an empty message. It is provided only for efficiency, given that -// message-less kCancelled errors are common in the infrastructure. -inline Status CancelledError() { return Status(y_absl::StatusCode::kCancelled); } - -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_STATUS_STATUS_H_ +} + +inline void Status::IgnoreError() const { + // no-op +} + +inline void swap(y_absl::Status& a, y_absl::Status& b) { + using std::swap; + swap(a.rep_, b.rep_); +} + +inline const status_internal::Payloads* Status::GetPayloads() const { + return IsInlined(rep_) ? nullptr : RepToPointer(rep_)->payloads.get(); +} + +inline status_internal::Payloads* Status::GetPayloads() { + return IsInlined(rep_) ? nullptr : RepToPointer(rep_)->payloads.get(); +} + +inline bool Status::IsInlined(uintptr_t rep) { return (rep & 1) == 0; } + +inline bool Status::IsMovedFrom(uintptr_t rep) { + return IsInlined(rep) && (rep & 2) != 0; +} + +inline uintptr_t Status::MovedFromRep() { + return CodeToInlinedRep(y_absl::StatusCode::kInternal) | 2; +} + +inline uintptr_t Status::CodeToInlinedRep(y_absl::StatusCode code) { + return static_cast<uintptr_t>(code) << 2; +} + +inline y_absl::StatusCode Status::InlinedRepToCode(uintptr_t rep) { + assert(IsInlined(rep)); + return static_cast<y_absl::StatusCode>(rep >> 2); +} + +inline status_internal::StatusRep* Status::RepToPointer(uintptr_t rep) { + assert(!IsInlined(rep)); + return reinterpret_cast<status_internal::StatusRep*>(rep - 1); +} + +inline uintptr_t Status::PointerToRep(status_internal::StatusRep* rep) { + return reinterpret_cast<uintptr_t>(rep) + 1; +} + +inline void Status::Ref(uintptr_t rep) { + if (!IsInlined(rep)) { + RepToPointer(rep)->ref.fetch_add(1, std::memory_order_relaxed); + } +} + +inline void Status::Unref(uintptr_t rep) { + if (!IsInlined(rep)) { + UnrefNonInlined(rep); + } +} + +inline Status OkStatus() { return Status(); } + +// Creates a `Status` object with the `y_absl::StatusCode::kCancelled` error code +// and an empty message. It is provided only for efficiency, given that +// message-less kCancelled errors are common in the infrastructure. +inline Status CancelledError() { return Status(y_absl::StatusCode::kCancelled); } + +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_STATUS_STATUS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.cc index 6990ff6e8d..35d8d593c8 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.cc @@ -1,38 +1,38 @@ -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "y_absl/status/status_payload_printer.h" - -#include <atomic> - -#include "y_absl/base/attributes.h" +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "y_absl/status/status_payload_printer.h" + +#include <atomic> + +#include "y_absl/base/attributes.h" #include "y_absl/base/internal/atomic_hook.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace status_internal { - + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace status_internal { + ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static y_absl::base_internal::AtomicHook<StatusPayloadPrinter> storage; - -void SetStatusPayloadPrinter(StatusPayloadPrinter printer) { + +void SetStatusPayloadPrinter(StatusPayloadPrinter printer) { storage.Store(printer); -} - -StatusPayloadPrinter GetStatusPayloadPrinter() { +} + +StatusPayloadPrinter GetStatusPayloadPrinter() { return storage.Load(); -} - -} // namespace status_internal -ABSL_NAMESPACE_END -} // namespace y_absl +} + +} // namespace status_internal +ABSL_NAMESPACE_END +} // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.h b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.h index 6968e0f40b..c8d0a27577 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/status_payload_printer.h @@ -1,51 +1,51 @@ -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ -#define ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ - -#include <util/generic/string.h> - -#include "y_absl/strings/cord.h" -#include "y_absl/strings/string_view.h" -#include "y_absl/types/optional.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace status_internal { - -// By default, `Status::ToString` and `operator<<(Status)` print a payload by -// dumping the type URL and the raw bytes. To help debugging, we provide an -// extension point, which is a global printer function that can be set by users -// to specify how to print payloads. The function takes the type URL and the -// payload as input, and should return a valid human-readable string on success -// or `y_absl::nullopt` on failure (in which case it falls back to the default -// approach of printing the raw bytes). -// NOTE: This is an internal API and the design is subject to change in the -// future in a non-backward-compatible way. Since it's only meant for debugging -// purpose, you should not rely on it in any critical logic. -using StatusPayloadPrinter = y_absl::optional<TString> (*)(y_absl::string_view, - const y_absl::Cord&); - -// Sets the global payload printer. Only one printer should be set per process. -// If multiple printers are set, it's undefined which one will be used. -void SetStatusPayloadPrinter(StatusPayloadPrinter); - -// Returns the global payload printer if previously set, otherwise `nullptr`. -StatusPayloadPrinter GetStatusPayloadPrinter(); - -} // namespace status_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ +#define ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ + +#include <util/generic/string.h> + +#include "y_absl/strings/cord.h" +#include "y_absl/strings/string_view.h" +#include "y_absl/types/optional.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace status_internal { + +// By default, `Status::ToString` and `operator<<(Status)` print a payload by +// dumping the type URL and the raw bytes. To help debugging, we provide an +// extension point, which is a global printer function that can be set by users +// to specify how to print payloads. The function takes the type URL and the +// payload as input, and should return a valid human-readable string on success +// or `y_absl::nullopt` on failure (in which case it falls back to the default +// approach of printing the raw bytes). +// NOTE: This is an internal API and the design is subject to change in the +// future in a non-backward-compatible way. Since it's only meant for debugging +// purpose, you should not rely on it in any critical logic. +using StatusPayloadPrinter = y_absl::optional<TString> (*)(y_absl::string_view, + const y_absl::Cord&); + +// Sets the global payload printer. Only one printer should be set per process. +// If multiple printers are set, it's undefined which one will be used. +void SetStatusPayloadPrinter(StatusPayloadPrinter); + +// Returns the global payload printer if previously set, otherwise `nullptr`. +StatusPayloadPrinter GetStatusPayloadPrinter(); + +} // namespace status_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make index 9414dfc26b..b0f2168aa1 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/status/ya.make @@ -1,54 +1,54 @@ -# Generated by devtools/yamaker. - -LIBRARY() - +# Generated by devtools/yamaker. + +LIBRARY() + OWNER( somov g:cpp-contrib ) - -LICENSE(Apache-2.0) - + +LICENSE(Apache-2.0) + LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -PEERDIR( - contrib/restricted/abseil-cpp-tstring/y_absl/base - contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc - contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging - contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait - contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate - contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity - contrib/restricted/abseil-cpp-tstring/y_absl/debugging - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace - contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize - contrib/restricted/abseil-cpp-tstring/y_absl/demangle - contrib/restricted/abseil-cpp-tstring/y_absl/numeric +PEERDIR( + contrib/restricted/abseil-cpp-tstring/y_absl/base + contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/low_level_alloc + contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging + contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait + contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/throw_delegate + contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity + contrib/restricted/abseil-cpp-tstring/y_absl/debugging + contrib/restricted/abseil-cpp-tstring/y_absl/debugging/stacktrace + contrib/restricted/abseil-cpp-tstring/y_absl/debugging/symbolize + contrib/restricted/abseil-cpp-tstring/y_absl/demangle + contrib/restricted/abseil-cpp-tstring/y_absl/numeric contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased - contrib/restricted/abseil-cpp-tstring/y_absl/strings + contrib/restricted/abseil-cpp-tstring/y_absl/strings contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_cord_internal contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_functions contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_handle contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_info - contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format + contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format contrib/restricted/abseil-cpp-tstring/y_absl/synchronization contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal contrib/restricted/abseil-cpp-tstring/y_absl/time contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone - contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access -) - -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) - -NO_COMPILER_WARNINGS() - -SRCS( - status.cc - status_payload_printer.cc -) - -END() + contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) + +NO_COMPILER_WARNINGS() + +SRCS( + status.cc + status_payload_printer.cc +) + +END() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.cc index 959d6c27ff..0d977146ab 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.cc @@ -15,7 +15,7 @@ #include "y_absl/strings/ascii.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace ascii_internal { // # Table generated by this Python code (bit 0x02 is currently unused): @@ -57,7 +57,7 @@ namespace ascii_internal { // of these bits is tightly coupled to this implementation, the individual bits // are not named. Note that bitfields for all characters above ASCII 127 are // zero-initialized. -ABSL_DLL const unsigned char kPropertyBits[256] = { +ABSL_DLL const unsigned char kPropertyBits[256] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x00 0x40, 0x68, 0x48, 0x48, 0x48, 0x48, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x10 @@ -79,7 +79,7 @@ ABSL_DLL const unsigned char kPropertyBits[256] = { // Array of characters for the ascii_tolower() function. For values 'A' // through 'Z', return the lower-case character; otherwise, return the // identity of the passed character. -ABSL_DLL const char kToLower[256] = { +ABSL_DLL const char kToLower[256] = { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', @@ -117,7 +117,7 @@ ABSL_DLL const char kToLower[256] = { // Array of characters for the ascii_toupper() function. For values 'a' // through 'z', return the upper-case character; otherwise, return the // identity of the passed character. -ABSL_DLL const char kToUpper[256] = { +ABSL_DLL const char kToUpper[256] = { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', @@ -196,5 +196,5 @@ void RemoveExtraAsciiWhitespace(TString* str) { str->erase(output_it - &(*str)[0]); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.h index bc04710d8c..2b64d8dbc2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ascii.h @@ -53,24 +53,24 @@ #define ABSL_STRINGS_ASCII_H_ #include <algorithm> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/attributes.h" -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace ascii_internal { // Declaration for an array of bitfields holding character information. -ABSL_DLL extern const unsigned char kPropertyBits[256]; +ABSL_DLL extern const unsigned char kPropertyBits[256]; // Declaration for the array of characters to upper-case characters. -ABSL_DLL extern const char kToUpper[256]; +ABSL_DLL extern const char kToUpper[256]; // Declaration for the array of characters to lower-case characters. -ABSL_DLL extern const char kToLower[256]; +ABSL_DLL extern const char kToLower[256]; } // namespace ascii_internal @@ -236,7 +236,7 @@ inline void StripAsciiWhitespace(TString* str) { // Removes leading, trailing, and consecutive internal whitespace. void RemoveExtraAsciiWhitespace(TString*); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_ASCII_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.cc index 9515ca24dd..0fb2b4b0a5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.cc @@ -57,7 +57,7 @@ // narrower mantissas. namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { template <typename FloatType> @@ -980,5 +980,5 @@ const int16_t kPower10ExponentTable[] = { }; } // namespace -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.h index 1a115aa251..c87da48d06 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/charconv.h @@ -17,10 +17,10 @@ #include <system_error> // NOLINT(build/c++11) -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Workalike compatibilty version of std::chars_format from C++17. // @@ -114,7 +114,7 @@ inline chars_format& operator^=(chars_format& lhs, chars_format rhs) { return lhs; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_CHARCONV_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.cc index 0de4ea1b3c..7c3f0df49b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.cc @@ -1,82 +1,82 @@ -// Copyright 2020 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "y_absl/strings/cord.h" - -#include <algorithm> +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "y_absl/strings/cord.h" + +#include <algorithm> #include <atomic> -#include <cstddef> -#include <cstdio> -#include <cstdlib> -#include <iomanip> +#include <cstddef> +#include <cstdio> +#include <cstdlib> +#include <iomanip> #include <iostream> -#include <limits> -#include <ostream> -#include <sstream> -#include <type_traits> -#include <unordered_set> -#include <vector> - -#include "y_absl/base/casts.h" -#include "y_absl/base/internal/raw_logging.h" +#include <limits> +#include <ostream> +#include <sstream> +#include <type_traits> +#include <unordered_set> +#include <vector> + +#include "y_absl/base/casts.h" +#include "y_absl/base/internal/raw_logging.h" #include "y_absl/base/macros.h" -#include "y_absl/base/port.h" -#include "y_absl/container/fixed_array.h" -#include "y_absl/container/inlined_vector.h" -#include "y_absl/strings/escaping.h" -#include "y_absl/strings/internal/cord_internal.h" +#include "y_absl/base/port.h" +#include "y_absl/container/fixed_array.h" +#include "y_absl/container/inlined_vector.h" +#include "y_absl/strings/escaping.h" +#include "y_absl/strings/internal/cord_internal.h" #include "y_absl/strings/internal/cord_rep_btree.h" #include "y_absl/strings/internal/cord_rep_flat.h" #include "y_absl/strings/internal/cordz_statistics.h" #include "y_absl/strings/internal/cordz_update_scope.h" #include "y_absl/strings/internal/cordz_update_tracker.h" -#include "y_absl/strings/internal/resize_uninitialized.h" -#include "y_absl/strings/str_cat.h" -#include "y_absl/strings/str_format.h" -#include "y_absl/strings/str_join.h" -#include "y_absl/strings/string_view.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN - -using ::y_absl::cord_internal::CordRep; +#include "y_absl/strings/internal/resize_uninitialized.h" +#include "y_absl/strings/str_cat.h" +#include "y_absl/strings/str_format.h" +#include "y_absl/strings/str_join.h" +#include "y_absl/strings/string_view.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN + +using ::y_absl::cord_internal::CordRep; using ::y_absl::cord_internal::CordRepBtree; -using ::y_absl::cord_internal::CordRepConcat; -using ::y_absl::cord_internal::CordRepExternal; +using ::y_absl::cord_internal::CordRepConcat; +using ::y_absl::cord_internal::CordRepExternal; using ::y_absl::cord_internal::CordRepFlat; -using ::y_absl::cord_internal::CordRepSubstring; +using ::y_absl::cord_internal::CordRepSubstring; using ::y_absl::cord_internal::CordzUpdateTracker; using ::y_absl::cord_internal::InlineData; using ::y_absl::cord_internal::kMaxFlatLength; using ::y_absl::cord_internal::kMinFlatLength; - + using ::y_absl::cord_internal::kInlinedVectorSize; using ::y_absl::cord_internal::kMaxBytesToCopy; - -constexpr uint64_t Fibonacci(unsigned char n, uint64_t a = 0, uint64_t b = 1) { - return n == 0 ? a : Fibonacci(n - 1, b, a + b); -} - -static_assert(Fibonacci(63) == 6557470319842, - "Fibonacci values computed incorrectly"); - -// Minimum length required for a given depth tree -- a tree is considered -// balanced if -// length(t) >= min_length[depth(t)] -// The root node depth is allowed to become twice as large to reduce rebalancing -// for larger strings (see IsRootBalanced). -static constexpr uint64_t min_length[] = { + +constexpr uint64_t Fibonacci(unsigned char n, uint64_t a = 0, uint64_t b = 1) { + return n == 0 ? a : Fibonacci(n - 1, b, a + b); +} + +static_assert(Fibonacci(63) == 6557470319842, + "Fibonacci values computed incorrectly"); + +// Minimum length required for a given depth tree -- a tree is considered +// balanced if +// length(t) >= min_length[depth(t)] +// The root node depth is allowed to become twice as large to reduce rebalancing +// for larger strings (see IsRootBalanced). +static constexpr uint64_t min_length[] = { Fibonacci(2), Fibonacci(3), Fibonacci(4), Fibonacci(5), Fibonacci(6), Fibonacci(7), Fibonacci(8), Fibonacci(9), Fibonacci(10), Fibonacci(11), Fibonacci(12), Fibonacci(13), @@ -89,121 +89,121 @@ static constexpr uint64_t min_length[] = { Fibonacci(38), Fibonacci(39), Fibonacci(40), Fibonacci(41), Fibonacci(42), Fibonacci(43), Fibonacci(44), Fibonacci(45), Fibonacci(46), Fibonacci(47), - 0xffffffffffffffffull, // Avoid overflow -}; - -static const int kMinLengthSize = ABSL_ARRAYSIZE(min_length); - + 0xffffffffffffffffull, // Avoid overflow +}; + +static const int kMinLengthSize = ABSL_ARRAYSIZE(min_length); + static inline bool btree_enabled() { return cord_internal::cord_btree_enabled.load( std::memory_order_relaxed); } - -static inline bool IsRootBalanced(CordRep* node) { + +static inline bool IsRootBalanced(CordRep* node) { if (!node->IsConcat()) { - return true; - } else if (node->concat()->depth() <= 15) { - return true; - } else if (node->concat()->depth() > kMinLengthSize) { - return false; - } else { - // Allow depth to become twice as large as implied by fibonacci rule to - // reduce rebalancing for larger strings. - return (node->length >= min_length[node->concat()->depth() / 2]); - } -} - -static CordRep* Rebalance(CordRep* node); + return true; + } else if (node->concat()->depth() <= 15) { + return true; + } else if (node->concat()->depth() > kMinLengthSize) { + return false; + } else { + // Allow depth to become twice as large as implied by fibonacci rule to + // reduce rebalancing for larger strings. + return (node->length >= min_length[node->concat()->depth() / 2]); + } +} + +static CordRep* Rebalance(CordRep* node); static void DumpNode(CordRep* rep, bool include_data, std::ostream* os, int indent = 0); -static bool VerifyNode(CordRep* root, CordRep* start_node, - bool full_validation); - -static inline CordRep* VerifyTree(CordRep* node) { - // Verification is expensive, so only do it in debug mode. - // Even in debug mode we normally do only light validation. - // If you are debugging Cord itself, you should define the - // macro EXTRA_CORD_VALIDATION, e.g. by adding - // --copt=-DEXTRA_CORD_VALIDATION to the blaze line. -#ifdef EXTRA_CORD_VALIDATION - assert(node == nullptr || VerifyNode(node, node, /*full_validation=*/true)); -#else // EXTRA_CORD_VALIDATION - assert(node == nullptr || VerifyNode(node, node, /*full_validation=*/false)); -#endif // EXTRA_CORD_VALIDATION - static_cast<void>(&VerifyNode); - - return node; -} - -// Return the depth of a node -static int Depth(const CordRep* rep) { +static bool VerifyNode(CordRep* root, CordRep* start_node, + bool full_validation); + +static inline CordRep* VerifyTree(CordRep* node) { + // Verification is expensive, so only do it in debug mode. + // Even in debug mode we normally do only light validation. + // If you are debugging Cord itself, you should define the + // macro EXTRA_CORD_VALIDATION, e.g. by adding + // --copt=-DEXTRA_CORD_VALIDATION to the blaze line. +#ifdef EXTRA_CORD_VALIDATION + assert(node == nullptr || VerifyNode(node, node, /*full_validation=*/true)); +#else // EXTRA_CORD_VALIDATION + assert(node == nullptr || VerifyNode(node, node, /*full_validation=*/false)); +#endif // EXTRA_CORD_VALIDATION + static_cast<void>(&VerifyNode); + + return node; +} + +// Return the depth of a node +static int Depth(const CordRep* rep) { if (rep->IsConcat()) { - return rep->concat()->depth(); - } else { - return 0; - } -} - -static void SetConcatChildren(CordRepConcat* concat, CordRep* left, - CordRep* right) { - concat->left = left; - concat->right = right; - - concat->length = left->length + right->length; - concat->set_depth(1 + std::max(Depth(left), Depth(right))); -} - -// Create a concatenation of the specified nodes. -// Does not change the refcounts of "left" and "right". -// The returned node has a refcount of 1. -static CordRep* RawConcat(CordRep* left, CordRep* right) { - // Avoid making degenerate concat nodes (one child is empty) + return rep->concat()->depth(); + } else { + return 0; + } +} + +static void SetConcatChildren(CordRepConcat* concat, CordRep* left, + CordRep* right) { + concat->left = left; + concat->right = right; + + concat->length = left->length + right->length; + concat->set_depth(1 + std::max(Depth(left), Depth(right))); +} + +// Create a concatenation of the specified nodes. +// Does not change the refcounts of "left" and "right". +// The returned node has a refcount of 1. +static CordRep* RawConcat(CordRep* left, CordRep* right) { + // Avoid making degenerate concat nodes (one child is empty) if (left == nullptr) return right; if (right == nullptr) return left; if (left->length == 0) { CordRep::Unref(left); - return right; - } + return right; + } if (right->length == 0) { CordRep::Unref(right); - return left; - } - - CordRepConcat* rep = new CordRepConcat(); + return left; + } + + CordRepConcat* rep = new CordRepConcat(); rep->tag = cord_internal::CONCAT; - SetConcatChildren(rep, left, right); - - return rep; -} - -static CordRep* Concat(CordRep* left, CordRep* right) { - CordRep* rep = RawConcat(left, right); - if (rep != nullptr && !IsRootBalanced(rep)) { - rep = Rebalance(rep); - } - return VerifyTree(rep); -} - -// Make a balanced tree out of an array of leaf nodes. -static CordRep* MakeBalancedTree(CordRep** reps, size_t n) { - // Make repeated passes over the array, merging adjacent pairs - // until we are left with just a single node. - while (n > 1) { - size_t dst = 0; - for (size_t src = 0; src < n; src += 2) { - if (src + 1 < n) { - reps[dst] = Concat(reps[src], reps[src + 1]); - } else { - reps[dst] = reps[src]; - } - dst++; - } - n = dst; - } - - return reps[0]; -} - + SetConcatChildren(rep, left, right); + + return rep; +} + +static CordRep* Concat(CordRep* left, CordRep* right) { + CordRep* rep = RawConcat(left, right); + if (rep != nullptr && !IsRootBalanced(rep)) { + rep = Rebalance(rep); + } + return VerifyTree(rep); +} + +// Make a balanced tree out of an array of leaf nodes. +static CordRep* MakeBalancedTree(CordRep** reps, size_t n) { + // Make repeated passes over the array, merging adjacent pairs + // until we are left with just a single node. + while (n > 1) { + size_t dst = 0; + for (size_t src = 0; src < n; src += 2) { + if (src + 1 < n) { + reps[dst] = Concat(reps[src], reps[src + 1]); + } else { + reps[dst] = reps[src]; + } + dst++; + } + n = dst; + } + + return reps[0]; +} + static CordRepFlat* CreateFlat(const char* data, size_t length, size_t alloc_hint) { CordRepFlat* flat = CordRepFlat::New(length + alloc_hint); @@ -217,63 +217,63 @@ static CordRepFlat* CreateFlat(const char* data, size_t length, static CordRep* NewBtree(const char* data, size_t length, size_t alloc_hint) { if (length <= kMaxFlatLength) { return CreateFlat(data, length, alloc_hint); - } + } CordRepFlat* flat = CreateFlat(data, kMaxFlatLength, 0); data += kMaxFlatLength; length -= kMaxFlatLength; auto* root = CordRepBtree::Create(flat); return CordRepBtree::Append(root, {data, length}, alloc_hint); -} - -// Create a new tree out of the specified array. -// The returned node has a refcount of 1. +} + +// Create a new tree out of the specified array. +// The returned node has a refcount of 1. static CordRep* NewTree(const char* data, size_t length, size_t alloc_hint) { - if (length == 0) return nullptr; + if (length == 0) return nullptr; if (btree_enabled()) { return NewBtree(data, length, alloc_hint); } - y_absl::FixedArray<CordRep*> reps((length - 1) / kMaxFlatLength + 1); - size_t n = 0; - do { - const size_t len = std::min(length, kMaxFlatLength); + y_absl::FixedArray<CordRep*> reps((length - 1) / kMaxFlatLength + 1); + size_t n = 0; + do { + const size_t len = std::min(length, kMaxFlatLength); CordRepFlat* rep = CordRepFlat::New(len + alloc_hint); - rep->length = len; + rep->length = len; memcpy(rep->Data(), data, len); - reps[n++] = VerifyTree(rep); - data += len; - length -= len; - } while (length != 0); - return MakeBalancedTree(reps.data(), n); -} - -namespace cord_internal { - + reps[n++] = VerifyTree(rep); + data += len; + length -= len; + } while (length != 0); + return MakeBalancedTree(reps.data(), n); +} + +namespace cord_internal { + void InitializeCordRepExternal(y_absl::string_view data, CordRepExternal* rep) { - assert(!data.empty()); - rep->length = data.size(); - rep->tag = EXTERNAL; - rep->base = data.data(); + assert(!data.empty()); + rep->length = data.size(); + rep->tag = EXTERNAL; + rep->base = data.data(); VerifyTree(rep); -} - -} // namespace cord_internal - -static CordRep* NewSubstring(CordRep* child, size_t offset, size_t length) { - // Never create empty substring nodes - if (length == 0) { +} + +} // namespace cord_internal + +static CordRep* NewSubstring(CordRep* child, size_t offset, size_t length) { + // Never create empty substring nodes + if (length == 0) { CordRep::Unref(child); - return nullptr; - } else { - CordRepSubstring* rep = new CordRepSubstring(); - assert((offset + length) <= child->length); - rep->length = length; + return nullptr; + } else { + CordRepSubstring* rep = new CordRepSubstring(); + assert((offset + length) <= child->length); + rep->length = length; rep->tag = cord_internal::SUBSTRING; - rep->start = offset; - rep->child = child; - return VerifyTree(rep); - } -} - + rep->start = offset; + rep->child = child; + return VerifyTree(rep); + } +} + // Creates a CordRep from the provided string. If the string is large enough, // and not wasteful, we move the string into an external cord rep, preserving // the already allocated string contents. @@ -303,41 +303,41 @@ static CordRep* CordRepFromString(TString&& src) { return rep; } -// -------------------------------------------------------------------- -// Cord::InlineRep functions - +// -------------------------------------------------------------------- +// Cord::InlineRep functions + constexpr unsigned char Cord::InlineRep::kMaxInline; - -inline void Cord::InlineRep::set_data(const char* data, size_t n, - bool nullify_tail) { - static_assert(kMaxInline == 15, "set_data is hard-coded for a length of 15"); - + +inline void Cord::InlineRep::set_data(const char* data, size_t n, + bool nullify_tail) { + static_assert(kMaxInline == 15, "set_data is hard-coded for a length of 15"); + cord_internal::SmallMemmove(data_.as_chars(), data, n, nullify_tail); set_inline_size(n); -} - -inline char* Cord::InlineRep::set_data(size_t n) { - assert(n <= kMaxInline); +} + +inline char* Cord::InlineRep::set_data(size_t n) { + assert(n <= kMaxInline); ResetToEmpty(); set_inline_size(n); return data_.as_chars(); -} - -inline void Cord::InlineRep::reduce_size(size_t n) { +} + +inline void Cord::InlineRep::reduce_size(size_t n) { size_t tag = inline_size(); - assert(tag <= kMaxInline); - assert(tag >= n); - tag -= n; + assert(tag <= kMaxInline); + assert(tag >= n); + tag -= n; memset(data_.as_chars() + tag, 0, n); set_inline_size(static_cast<char>(tag)); -} - -inline void Cord::InlineRep::remove_prefix(size_t n) { +} + +inline void Cord::InlineRep::remove_prefix(size_t n) { cord_internal::SmallMemmove(data_.as_chars(), data_.as_chars() + n, inline_size() - n); - reduce_size(n); -} - + reduce_size(n); +} + // Returns `rep` converted into a CordRepBtree. // Directly returns `rep` if `rep` is already a CordRepBtree. static CordRepBtree* ForceBtree(CordRep* rep) { @@ -370,14 +370,14 @@ void Cord::InlineRep::AppendTreeToTree(CordRep* tree, MethodIdentifier method) { } void Cord::InlineRep::AppendTree(CordRep* tree, MethodIdentifier method) { - if (tree == nullptr) return; + if (tree == nullptr) return; if (data_.is_tree()) { AppendTreeToTree(tree, method); - } else { + } else { AppendTreeToInlined(tree, method); - } -} - + } +} + void Cord::InlineRep::PrependTreeToInlined(CordRep* tree, MethodIdentifier method) { assert(!is_tree()); @@ -408,17 +408,17 @@ void Cord::InlineRep::PrependTree(CordRep* tree, MethodIdentifier method) { assert(tree != nullptr); if (data_.is_tree()) { PrependTreeToTree(tree, method); - } else { + } else { PrependTreeToInlined(tree, method); - } -} - -// Searches for a non-full flat node at the rightmost leaf of the tree. If a -// suitable leaf is found, the function will update the length field for all -// nodes to account for the size increase. The append region address will be -// written to region and the actual size increase will be written to size. -static inline bool PrepareAppendRegion(CordRep* root, char** region, - size_t* size, size_t max_length) { + } +} + +// Searches for a non-full flat node at the rightmost leaf of the tree. If a +// suitable leaf is found, the function will update the length field for all +// nodes to account for the size increase. The append region address will be +// written to region and the actual size increase will be written to size. +static inline bool PrepareAppendRegion(CordRep* root, char** region, + size_t* size, size_t max_length) { if (root->IsBtree() && root->refcount.IsMutable()) { Span<char> span = root->btree()->GetAppendBuffer(max_length); if (!span.empty()) { @@ -428,44 +428,44 @@ static inline bool PrepareAppendRegion(CordRep* root, char** region, } } - // Search down the right-hand path for a non-full FLAT node. - CordRep* dst = root; + // Search down the right-hand path for a non-full FLAT node. + CordRep* dst = root; while (dst->IsConcat() && dst->refcount.IsMutable()) { - dst = dst->concat()->right; - } - + dst = dst->concat()->right; + } + if (!dst->IsFlat() || !dst->refcount.IsMutable()) { - *region = nullptr; - *size = 0; - return false; - } - - const size_t in_use = dst->length; + *region = nullptr; + *size = 0; + return false; + } + + const size_t in_use = dst->length; const size_t capacity = dst->flat()->Capacity(); - if (in_use == capacity) { - *region = nullptr; - *size = 0; - return false; - } - - size_t size_increase = std::min(capacity - in_use, max_length); - - // We need to update the length fields for all nodes, including the leaf node. - for (CordRep* rep = root; rep != dst; rep = rep->concat()->right) { - rep->length += size_increase; - } - dst->length += size_increase; - + if (in_use == capacity) { + *region = nullptr; + *size = 0; + return false; + } + + size_t size_increase = std::min(capacity - in_use, max_length); + + // We need to update the length fields for all nodes, including the leaf node. + for (CordRep* rep = root; rep != dst; rep = rep->concat()->right) { + rep->length += size_increase; + } + dst->length += size_increase; + *region = dst->flat()->Data() + in_use; - *size = size_increase; - return true; -} - + *size = size_increase; + return true; +} + template <bool has_length> -void Cord::InlineRep::GetAppendRegion(char** region, size_t* size, +void Cord::InlineRep::GetAppendRegion(char** region, size_t* size, size_t length) { auto constexpr method = CordzUpdateTracker::kGetAppendRegion; - + CordRep* root = tree(); size_t sz = root ? root->length : inline_size(); if (root == nullptr) { @@ -476,21 +476,21 @@ void Cord::InlineRep::GetAppendRegion(char** region, size_t* size, set_inline_size(has_length ? sz + length : kMaxInline); return; } - } - + } + size_t extra = has_length ? length : (std::max)(sz, kMinFlatLength); CordRep* rep = root ? root : MakeFlatWithExtraCapacity(extra); CordzUpdateScope scope(root ? data_.cordz_info() : nullptr, method); if (PrepareAppendRegion(rep, region, size, length)) { CommitTree(root, rep, scope, method); - return; - } - - // Allocate new node. + return; + } + + // Allocate new node. CordRepFlat* new_node = CordRepFlat::New(extra); new_node->length = std::min(new_node->Capacity(), length); *region = new_node->Data(); - *size = new_node->length; + *size = new_node->length; if (btree_enabled()) { rep = CordRepBtree::Append(ForceBtree(rep), new_node); @@ -498,8 +498,8 @@ void Cord::InlineRep::GetAppendRegion(char** region, size_t* size, rep = Concat(rep, new_node); } CommitTree(root, rep, scope, method); -} - +} + // Computes the memory side of the provided edge which must be a valid data edge // for a btrtee, i.e., a FLAT, EXTERNAL or SUBSTRING of a FLAT or EXTERNAL node. static bool RepMemoryUsageDataEdge(const CordRep* rep, @@ -508,11 +508,11 @@ static bool RepMemoryUsageDataEdge(const CordRep* rep, if (ABSL_PREDICT_FALSE(rep->IsSubstring())) { maybe_sub_size = sizeof(cord_internal::CordRepSubstring); rep = rep->substring()->child; - } + } if (rep->IsFlat()) { *total_mem_usage += maybe_sub_size + rep->flat()->AllocatedSize(); return true; - } + } if (rep->IsExternal()) { // We don't know anything about the embedded / bound data, but we can safely // assume it is 'at least' a word / pointer to data. In the future we may @@ -524,15 +524,15 @@ static bool RepMemoryUsageDataEdge(const CordRep* rep, return true; } return false; -} - -// If the rep is a leaf, this will increment the value at total_mem_usage and -// will return true. -static bool RepMemoryUsageLeaf(const CordRep* rep, size_t* total_mem_usage) { +} + +// If the rep is a leaf, this will increment the value at total_mem_usage and +// will return true. +static bool RepMemoryUsageLeaf(const CordRep* rep, size_t* total_mem_usage) { if (rep->IsFlat()) { *total_mem_usage += rep->flat()->AllocatedSize(); - return true; - } + return true; + } if (rep->IsExternal()) { // We don't know anything about the embedded / bound data, but we can safely // assume it is 'at least' a word / pointer to data. In the future we may @@ -540,12 +540,12 @@ static bool RepMemoryUsageLeaf(const CordRep* rep, size_t* total_mem_usage) { // well-known externals, such as a TString instance. *total_mem_usage += sizeof(cord_internal::CordRepExternalImpl<intptr_t>) + rep->length; - return true; - } - return false; -} - -void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) { + return true; + } + return false; +} + +void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) { assert(&src != this); assert(is_tree() || src.is_tree()); auto constexpr method = CordzUpdateTracker::kAssignCord; @@ -553,7 +553,7 @@ void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) { EmplaceTree(CordRep::Ref(src.as_tree()), src.data_, method); return; } - + CordRep* tree = as_tree(); if (CordRep* src_tree = src.tree()) { // Leave any existing `cordz_info` in place, and let MaybeTrackCord() @@ -563,31 +563,31 @@ void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) { } else { CordzInfo::MaybeUntrackCord(data_.cordz_info()); data_ = src.data_; - } + } CordRep::Unref(tree); -} - +} + void Cord::InlineRep::UnrefTree() { - if (is_tree()) { + if (is_tree()) { CordzInfo::MaybeUntrackCord(data_.cordz_info()); CordRep::Unref(tree()); - } -} - -// -------------------------------------------------------------------- -// Constructors and destructors - + } +} + +// -------------------------------------------------------------------- +// Constructors and destructors + Cord::Cord(y_absl::string_view src, MethodIdentifier method) : contents_(InlineData::kDefaultInit) { - const size_t n = src.size(); - if (n <= InlineRep::kMaxInline) { + const size_t n = src.size(); + if (n <= InlineRep::kMaxInline) { contents_.set_data(src.data(), n, true); - } else { + } else { CordRep* rep = NewTree(src.data(), n, 0); contents_.EmplaceTree(rep, method); - } -} - + } +} + template <typename T, Cord::EnableIfString<T>> Cord::Cord(T&& src) : contents_(InlineData::kDefaultInit) { if (src.size() <= InlineRep::kMaxInline) { @@ -600,23 +600,23 @@ Cord::Cord(T&& src) : contents_(InlineData::kDefaultInit) { template Cord::Cord(TString&& src); -// The destruction code is separate so that the compiler can determine -// that it does not need to call the destructor on a moved-from Cord. -void Cord::DestroyCordSlow() { +// The destruction code is separate so that the compiler can determine +// that it does not need to call the destructor on a moved-from Cord. +void Cord::DestroyCordSlow() { assert(contents_.is_tree()); CordzInfo::MaybeUntrackCord(contents_.cordz_info()); CordRep::Unref(VerifyTree(contents_.as_tree())); -} - -// -------------------------------------------------------------------- -// Mutators - -void Cord::Clear() { +} + +// -------------------------------------------------------------------- +// Mutators + +void Cord::Clear() { if (CordRep* tree = contents_.clear()) { CordRep::Unref(tree); } -} - +} + Cord& Cord::AssignLargeString(TString&& src) { auto constexpr method = CordzUpdateTracker::kAssignString; assert(src.size() > kMaxBytesToCopy); @@ -631,21 +631,21 @@ Cord& Cord::AssignLargeString(TString&& src) { return *this; } -Cord& Cord::operator=(y_absl::string_view src) { +Cord& Cord::operator=(y_absl::string_view src) { auto constexpr method = CordzUpdateTracker::kAssignString; - const char* data = src.data(); - size_t length = src.size(); - CordRep* tree = contents_.tree(); - if (length <= InlineRep::kMaxInline) { + const char* data = src.data(); + size_t length = src.size(); + CordRep* tree = contents_.tree(); + if (length <= InlineRep::kMaxInline) { // Embed into this->contents_, which is somewhat subtle: // - MaybeUntrackCord must be called before Unref(tree). // - MaybeUntrackCord must be called before set_data() clobbers cordz_info. // - set_data() must be called before Unref(tree) as it may reference tree. if (tree != nullptr) CordzInfo::MaybeUntrackCord(contents_.cordz_info()); - contents_.set_data(data, length, true); + contents_.set_data(data, length, true); if (tree != nullptr) CordRep::Unref(tree); - return *this; - } + return *this; + } if (tree != nullptr) { CordzUpdateScope scope(contents_.cordz_info(), method); if (tree->IsFlat() && tree->flat()->Capacity() >= length && @@ -664,22 +664,22 @@ Cord& Cord::operator=(y_absl::string_view src) { return *this; } -// TODO(sanjay): Move to Cord::InlineRep section of file. For now, -// we keep it here to make diffs easier. +// TODO(sanjay): Move to Cord::InlineRep section of file. For now, +// we keep it here to make diffs easier. void Cord::InlineRep::AppendArray(y_absl::string_view src, MethodIdentifier method) { if (src.empty()) return; // memcpy(_, nullptr, 0) is undefined. - - size_t appended = 0; + + size_t appended = 0; CordRep* rep = tree(); const CordRep* const root = rep; CordzUpdateScope scope(root ? cordz_info() : nullptr, method); if (root != nullptr) { - char* region; + char* region; if (PrepareAppendRegion(rep, ®ion, &appended, src.size())) { memcpy(region, src.data(), appended); - } - } else { + } + } else { // Try to fit in the inline buffer if possible. size_t inline_length = inline_size(); if (src.size() <= kMaxInline - inline_length) { @@ -697,14 +697,14 @@ void Cord::InlineRep::AppendArray(y_absl::string_view src, memcpy(rep->flat()->Data(), data_.as_chars(), inline_length); memcpy(rep->flat()->Data() + inline_length, src.data(), appended); rep->length = inline_length + appended; - } - + } + src.remove_prefix(appended); if (src.empty()) { CommitTree(root, rep, scope, method); - return; - } - + return; + } + if (btree_enabled()) { // TODO(b/192061034): keep legacy 10% growth rate: consider other rates. rep = ForceBtree(rep); @@ -727,22 +727,22 @@ void Cord::InlineRep::AppendArray(y_absl::string_view src, rep = Concat(rep, NewTree(src.data(), src.size(), length - src.size())); } CommitTree(root, rep, scope, method); -} - -inline CordRep* Cord::TakeRep() const& { +} + +inline CordRep* Cord::TakeRep() const& { return CordRep::Ref(contents_.tree()); -} - -inline CordRep* Cord::TakeRep() && { - CordRep* rep = contents_.tree(); - contents_.clear(); - return rep; -} - -template <typename C> -inline void Cord::AppendImpl(C&& src) { +} + +inline CordRep* Cord::TakeRep() && { + CordRep* rep = contents_.tree(); + contents_.clear(); + return rep; +} + +template <typename C> +inline void Cord::AppendImpl(C&& src) { auto constexpr method = CordzUpdateTracker::kAppendCord; - if (empty()) { + if (empty()) { // Since destination is empty, we can avoid allocating a node, if (src.contents_.is_tree()) { // by taking the tree directly @@ -752,48 +752,48 @@ inline void Cord::AppendImpl(C&& src) { // or copying over inline data contents_.data_ = src.contents_.data_; } - return; - } - - // For short cords, it is faster to copy data if there is room in dst. - const size_t src_size = src.contents_.size(); - if (src_size <= kMaxBytesToCopy) { - CordRep* src_tree = src.contents_.tree(); - if (src_tree == nullptr) { - // src has embedded data. + return; + } + + // For short cords, it is faster to copy data if there is room in dst. + const size_t src_size = src.contents_.size(); + if (src_size <= kMaxBytesToCopy) { + CordRep* src_tree = src.contents_.tree(); + if (src_tree == nullptr) { + // src has embedded data. contents_.AppendArray({src.contents_.data(), src_size}, method); - return; - } + return; + } if (src_tree->IsFlat()) { - // src tree just has one flat node. + // src tree just has one flat node. contents_.AppendArray({src_tree->flat()->Data(), src_size}, method); - return; - } - if (&src == this) { - // ChunkIterator below assumes that src is not modified during traversal. - Append(Cord(src)); - return; - } - // TODO(mec): Should we only do this if "dst" has space? - for (y_absl::string_view chunk : src.Chunks()) { - Append(chunk); - } - return; - } - + return; + } + if (&src == this) { + // ChunkIterator below assumes that src is not modified during traversal. + Append(Cord(src)); + return; + } + // TODO(mec): Should we only do this if "dst" has space? + for (y_absl::string_view chunk : src.Chunks()) { + Append(chunk); + } + return; + } + // Guaranteed to be a tree (kMaxBytesToCopy > kInlinedSize) CordRep* rep = std::forward<C>(src).TakeRep(); contents_.AppendTree(rep, CordzUpdateTracker::kAppendCord); -} - +} + void Cord::Append(const Cord& src) { AppendImpl(src); } - + void Cord::Append(Cord&& src) { AppendImpl(std::move(src)); } - + template <typename T, Cord::EnableIfString<T>> void Cord::Append(T&& src) { if (src.size() <= kMaxBytesToCopy) { @@ -806,21 +806,21 @@ void Cord::Append(T&& src) { template void Cord::Append(TString&& src); -void Cord::Prepend(const Cord& src) { - CordRep* src_tree = src.contents_.tree(); - if (src_tree != nullptr) { +void Cord::Prepend(const Cord& src) { + CordRep* src_tree = src.contents_.tree(); + if (src_tree != nullptr) { CordRep::Ref(src_tree); contents_.PrependTree(src_tree, CordzUpdateTracker::kPrependCord); - return; - } - - // `src` cord is inlined. - y_absl::string_view src_contents(src.contents_.data(), src.contents_.size()); - return Prepend(src_contents); -} - + return; + } + + // `src` cord is inlined. + y_absl::string_view src_contents(src.contents_.data(), src.contents_.size()); + return Prepend(src_contents); +} + void Cord::PrependArray(y_absl::string_view src, MethodIdentifier method) { - if (src.empty()) return; // memcpy(_, nullptr, 0) is undefined. + if (src.empty()) return; // memcpy(_, nullptr, 0) is undefined. if (!contents_.is_tree()) { size_t cur_size = contents_.inline_size(); if (cur_size + src.size() <= InlineRep::kMaxInline) { @@ -841,107 +841,107 @@ template <typename T, Cord::EnableIfString<T>> inline void Cord::Prepend(T&& src) { if (src.size() <= kMaxBytesToCopy) { Prepend(y_absl::string_view(src)); - } else { + } else { CordRep* rep = CordRepFromString(std::forward<T>(src)); contents_.PrependTree(rep, CordzUpdateTracker::kPrependString); - } -} - + } +} + template void Cord::Prepend(TString&& src); -static CordRep* RemovePrefixFrom(CordRep* node, size_t n) { - if (n >= node->length) return nullptr; +static CordRep* RemovePrefixFrom(CordRep* node, size_t n) { + if (n >= node->length) return nullptr; if (n == 0) return CordRep::Ref(node); - y_absl::InlinedVector<CordRep*, kInlinedVectorSize> rhs_stack; - + y_absl::InlinedVector<CordRep*, kInlinedVectorSize> rhs_stack; + while (node->IsConcat()) { - assert(n <= node->length); - if (n < node->concat()->left->length) { - // Push right to stack, descend left. - rhs_stack.push_back(node->concat()->right); - node = node->concat()->left; - } else { - // Drop left, descend right. - n -= node->concat()->left->length; - node = node->concat()->right; - } - } - assert(n <= node->length); - - if (n == 0) { + assert(n <= node->length); + if (n < node->concat()->left->length) { + // Push right to stack, descend left. + rhs_stack.push_back(node->concat()->right); + node = node->concat()->left; + } else { + // Drop left, descend right. + n -= node->concat()->left->length; + node = node->concat()->right; + } + } + assert(n <= node->length); + + if (n == 0) { CordRep::Ref(node); - } else { - size_t start = n; - size_t len = node->length - n; + } else { + size_t start = n; + size_t len = node->length - n; if (node->IsSubstring()) { - // Consider in-place update of node, similar to in RemoveSuffixFrom(). - start += node->substring()->start; - node = node->substring()->child; - } + // Consider in-place update of node, similar to in RemoveSuffixFrom(). + start += node->substring()->start; + node = node->substring()->child; + } node = NewSubstring(CordRep::Ref(node), start, len); - } - while (!rhs_stack.empty()) { + } + while (!rhs_stack.empty()) { node = Concat(node, CordRep::Ref(rhs_stack.back())); - rhs_stack.pop_back(); - } - return node; -} - -// RemoveSuffixFrom() is very similar to RemovePrefixFrom(), with the -// exception that removing a suffix has an optimization where a node may be -// edited in place iff that node and all its ancestors have a refcount of 1. -static CordRep* RemoveSuffixFrom(CordRep* node, size_t n) { - if (n >= node->length) return nullptr; + rhs_stack.pop_back(); + } + return node; +} + +// RemoveSuffixFrom() is very similar to RemovePrefixFrom(), with the +// exception that removing a suffix has an optimization where a node may be +// edited in place iff that node and all its ancestors have a refcount of 1. +static CordRep* RemoveSuffixFrom(CordRep* node, size_t n) { + if (n >= node->length) return nullptr; if (n == 0) return CordRep::Ref(node); - y_absl::InlinedVector<CordRep*, kInlinedVectorSize> lhs_stack; + y_absl::InlinedVector<CordRep*, kInlinedVectorSize> lhs_stack; bool inplace_ok = node->refcount.IsMutable(); - + while (node->IsConcat()) { - assert(n <= node->length); - if (n < node->concat()->right->length) { - // Push left to stack, descend right. - lhs_stack.push_back(node->concat()->left); - node = node->concat()->right; - } else { - // Drop right, descend left. - n -= node->concat()->right->length; - node = node->concat()->left; - } + assert(n <= node->length); + if (n < node->concat()->right->length) { + // Push left to stack, descend right. + lhs_stack.push_back(node->concat()->left); + node = node->concat()->right; + } else { + // Drop right, descend left. + n -= node->concat()->right->length; + node = node->concat()->left; + } inplace_ok = inplace_ok && node->refcount.IsMutable(); - } - assert(n <= node->length); - - if (n == 0) { + } + assert(n <= node->length); + + if (n == 0) { CordRep::Ref(node); } else if (inplace_ok && !node->IsExternal()) { - // Consider making a new buffer if the current node capacity is much - // larger than the new length. + // Consider making a new buffer if the current node capacity is much + // larger than the new length. CordRep::Ref(node); - node->length -= n; - } else { - size_t start = 0; - size_t len = node->length - n; + node->length -= n; + } else { + size_t start = 0; + size_t len = node->length - n; if (node->IsSubstring()) { - start = node->substring()->start; - node = node->substring()->child; - } + start = node->substring()->start; + node = node->substring()->child; + } node = NewSubstring(CordRep::Ref(node), start, len); - } - while (!lhs_stack.empty()) { + } + while (!lhs_stack.empty()) { node = Concat(CordRep::Ref(lhs_stack.back()), node); - lhs_stack.pop_back(); - } - return node; -} - -void Cord::RemovePrefix(size_t n) { - ABSL_INTERNAL_CHECK(n <= size(), - y_absl::StrCat("Requested prefix size ", n, - " exceeds Cord's size ", size())); - CordRep* tree = contents_.tree(); - if (tree == nullptr) { - contents_.remove_prefix(n); - } else { + lhs_stack.pop_back(); + } + return node; +} + +void Cord::RemovePrefix(size_t n) { + ABSL_INTERNAL_CHECK(n <= size(), + y_absl::StrCat("Requested prefix size ", n, + " exceeds Cord's size ", size())); + CordRep* tree = contents_.tree(); + if (tree == nullptr) { + contents_.remove_prefix(n); + } else { auto constexpr method = CordzUpdateTracker::kRemovePrefix; CordzUpdateScope scope(contents_.cordz_info(), method); if (tree->IsBtree()) { @@ -954,17 +954,17 @@ void Cord::RemovePrefix(size_t n) { tree = VerifyTree(newrep); } contents_.SetTreeOrEmpty(tree, scope); - } -} - -void Cord::RemoveSuffix(size_t n) { - ABSL_INTERNAL_CHECK(n <= size(), - y_absl::StrCat("Requested suffix size ", n, - " exceeds Cord's size ", size())); - CordRep* tree = contents_.tree(); - if (tree == nullptr) { - contents_.reduce_size(n); - } else { + } +} + +void Cord::RemoveSuffix(size_t n) { + ABSL_INTERNAL_CHECK(n <= size(), + y_absl::StrCat("Requested suffix size ", n, + " exceeds Cord's size ", size())); + CordRep* tree = contents_.tree(); + if (tree == nullptr) { + contents_.reduce_size(n); + } else { auto constexpr method = CordzUpdateTracker::kRemoveSuffix; CordzUpdateScope scope(contents_.cordz_info(), method); if (tree->IsBtree()) { @@ -975,296 +975,296 @@ void Cord::RemoveSuffix(size_t n) { tree = VerifyTree(newrep); } contents_.SetTreeOrEmpty(tree, scope); - } -} - -// Work item for NewSubRange(). -struct SubRange { - SubRange(CordRep* a_node, size_t a_pos, size_t a_n) - : node(a_node), pos(a_pos), n(a_n) {} - CordRep* node; // nullptr means concat last 2 results. - size_t pos; - size_t n; -}; - -static CordRep* NewSubRange(CordRep* node, size_t pos, size_t n) { - y_absl::InlinedVector<CordRep*, kInlinedVectorSize> results; - y_absl::InlinedVector<SubRange, kInlinedVectorSize> todo; - todo.push_back(SubRange(node, pos, n)); - do { - const SubRange& sr = todo.back(); - node = sr.node; - pos = sr.pos; - n = sr.n; - todo.pop_back(); - - if (node == nullptr) { - assert(results.size() >= 2); - CordRep* right = results.back(); - results.pop_back(); - CordRep* left = results.back(); - results.pop_back(); - results.push_back(Concat(left, right)); - } else if (pos == 0 && n == node->length) { + } +} + +// Work item for NewSubRange(). +struct SubRange { + SubRange(CordRep* a_node, size_t a_pos, size_t a_n) + : node(a_node), pos(a_pos), n(a_n) {} + CordRep* node; // nullptr means concat last 2 results. + size_t pos; + size_t n; +}; + +static CordRep* NewSubRange(CordRep* node, size_t pos, size_t n) { + y_absl::InlinedVector<CordRep*, kInlinedVectorSize> results; + y_absl::InlinedVector<SubRange, kInlinedVectorSize> todo; + todo.push_back(SubRange(node, pos, n)); + do { + const SubRange& sr = todo.back(); + node = sr.node; + pos = sr.pos; + n = sr.n; + todo.pop_back(); + + if (node == nullptr) { + assert(results.size() >= 2); + CordRep* right = results.back(); + results.pop_back(); + CordRep* left = results.back(); + results.pop_back(); + results.push_back(Concat(left, right)); + } else if (pos == 0 && n == node->length) { results.push_back(CordRep::Ref(node)); } else if (!node->IsConcat()) { if (node->IsSubstring()) { - pos += node->substring()->start; - node = node->substring()->child; - } + pos += node->substring()->start; + node = node->substring()->child; + } results.push_back(NewSubstring(CordRep::Ref(node), pos, n)); - } else if (pos + n <= node->concat()->left->length) { - todo.push_back(SubRange(node->concat()->left, pos, n)); - } else if (pos >= node->concat()->left->length) { - pos -= node->concat()->left->length; - todo.push_back(SubRange(node->concat()->right, pos, n)); - } else { - size_t left_n = node->concat()->left->length - pos; - todo.push_back(SubRange(nullptr, 0, 0)); // Concat() - todo.push_back(SubRange(node->concat()->right, 0, n - left_n)); - todo.push_back(SubRange(node->concat()->left, pos, left_n)); - } - } while (!todo.empty()); - assert(results.size() == 1); - return results[0]; -} - -Cord Cord::Subcord(size_t pos, size_t new_size) const { - Cord sub_cord; - size_t length = size(); - if (pos > length) pos = length; - if (new_size > length - pos) new_size = length - pos; + } else if (pos + n <= node->concat()->left->length) { + todo.push_back(SubRange(node->concat()->left, pos, n)); + } else if (pos >= node->concat()->left->length) { + pos -= node->concat()->left->length; + todo.push_back(SubRange(node->concat()->right, pos, n)); + } else { + size_t left_n = node->concat()->left->length - pos; + todo.push_back(SubRange(nullptr, 0, 0)); // Concat() + todo.push_back(SubRange(node->concat()->right, 0, n - left_n)); + todo.push_back(SubRange(node->concat()->left, pos, left_n)); + } + } while (!todo.empty()); + assert(results.size() == 1); + return results[0]; +} + +Cord Cord::Subcord(size_t pos, size_t new_size) const { + Cord sub_cord; + size_t length = size(); + if (pos > length) pos = length; + if (new_size > length - pos) new_size = length - pos; if (new_size == 0) return sub_cord; - CordRep* tree = contents_.tree(); - if (tree == nullptr) { - // sub_cord is newly constructed, no need to re-zero-out the tail of - // contents_ memory. - sub_cord.contents_.set_data(contents_.data() + pos, new_size, false); + CordRep* tree = contents_.tree(); + if (tree == nullptr) { + // sub_cord is newly constructed, no need to re-zero-out the tail of + // contents_ memory. + sub_cord.contents_.set_data(contents_.data() + pos, new_size, false); return sub_cord; } if (new_size <= InlineRep::kMaxInline) { char* dest = sub_cord.contents_.data_.as_chars(); - Cord::ChunkIterator it = chunk_begin(); - it.AdvanceBytes(pos); - size_t remaining_size = new_size; - while (remaining_size > it->size()) { - cord_internal::SmallMemmove(dest, it->data(), it->size()); - remaining_size -= it->size(); - dest += it->size(); - ++it; - } - cord_internal::SmallMemmove(dest, it->data(), remaining_size); + Cord::ChunkIterator it = chunk_begin(); + it.AdvanceBytes(pos); + size_t remaining_size = new_size; + while (remaining_size > it->size()) { + cord_internal::SmallMemmove(dest, it->data(), it->size()); + remaining_size -= it->size(); + dest += it->size(); + ++it; + } + cord_internal::SmallMemmove(dest, it->data(), remaining_size); sub_cord.contents_.set_inline_size(new_size); return sub_cord; } if (tree->IsBtree()) { tree = tree->btree()->SubTree(pos, new_size); - } else { + } else { tree = NewSubRange(tree, pos, new_size); - } + } sub_cord.contents_.EmplaceTree(tree, contents_.data_, CordzUpdateTracker::kSubCord); - return sub_cord; -} - -// -------------------------------------------------------------------- -// Balancing - -class CordForest { - public: - explicit CordForest(size_t length) - : root_length_(length), trees_(kMinLengthSize, nullptr) {} - - void Build(CordRep* cord_root) { - std::vector<CordRep*> pending = {cord_root}; - - while (!pending.empty()) { - CordRep* node = pending.back(); - pending.pop_back(); - CheckNode(node); + return sub_cord; +} + +// -------------------------------------------------------------------- +// Balancing + +class CordForest { + public: + explicit CordForest(size_t length) + : root_length_(length), trees_(kMinLengthSize, nullptr) {} + + void Build(CordRep* cord_root) { + std::vector<CordRep*> pending = {cord_root}; + + while (!pending.empty()) { + CordRep* node = pending.back(); + pending.pop_back(); + CheckNode(node); if (ABSL_PREDICT_FALSE(!node->IsConcat())) { - AddNode(node); - continue; - } - - CordRepConcat* concat_node = node->concat(); - if (concat_node->depth() >= kMinLengthSize || - concat_node->length < min_length[concat_node->depth()]) { - pending.push_back(concat_node->right); - pending.push_back(concat_node->left); - - if (concat_node->refcount.IsOne()) { - concat_node->left = concat_freelist_; - concat_freelist_ = concat_node; - } else { + AddNode(node); + continue; + } + + CordRepConcat* concat_node = node->concat(); + if (concat_node->depth() >= kMinLengthSize || + concat_node->length < min_length[concat_node->depth()]) { + pending.push_back(concat_node->right); + pending.push_back(concat_node->left); + + if (concat_node->refcount.IsOne()) { + concat_node->left = concat_freelist_; + concat_freelist_ = concat_node; + } else { CordRep::Ref(concat_node->right); CordRep::Ref(concat_node->left); CordRep::Unref(concat_node); - } - } else { - AddNode(node); - } - } - } - - CordRep* ConcatNodes() { - CordRep* sum = nullptr; - for (auto* node : trees_) { - if (node == nullptr) continue; - - sum = PrependNode(node, sum); - root_length_ -= node->length; - if (root_length_ == 0) break; - } - ABSL_INTERNAL_CHECK(sum != nullptr, "Failed to locate sum node"); - return VerifyTree(sum); - } - - private: - CordRep* AppendNode(CordRep* node, CordRep* sum) { - return (sum == nullptr) ? node : MakeConcat(sum, node); - } - - CordRep* PrependNode(CordRep* node, CordRep* sum) { - return (sum == nullptr) ? node : MakeConcat(node, sum); - } - - void AddNode(CordRep* node) { - CordRep* sum = nullptr; - + } + } else { + AddNode(node); + } + } + } + + CordRep* ConcatNodes() { + CordRep* sum = nullptr; + for (auto* node : trees_) { + if (node == nullptr) continue; + + sum = PrependNode(node, sum); + root_length_ -= node->length; + if (root_length_ == 0) break; + } + ABSL_INTERNAL_CHECK(sum != nullptr, "Failed to locate sum node"); + return VerifyTree(sum); + } + + private: + CordRep* AppendNode(CordRep* node, CordRep* sum) { + return (sum == nullptr) ? node : MakeConcat(sum, node); + } + + CordRep* PrependNode(CordRep* node, CordRep* sum) { + return (sum == nullptr) ? node : MakeConcat(node, sum); + } + + void AddNode(CordRep* node) { + CordRep* sum = nullptr; + // Collect together everything with which we will merge with node - int i = 0; - for (; node->length > min_length[i + 1]; ++i) { - auto& tree_at_i = trees_[i]; - - if (tree_at_i == nullptr) continue; - sum = PrependNode(tree_at_i, sum); - tree_at_i = nullptr; - } - - sum = AppendNode(node, sum); - - // Insert sum into appropriate place in the forest - for (; sum->length >= min_length[i]; ++i) { - auto& tree_at_i = trees_[i]; - if (tree_at_i == nullptr) continue; - - sum = MakeConcat(tree_at_i, sum); - tree_at_i = nullptr; - } - - // min_length[0] == 1, which means sum->length >= min_length[0] - assert(i > 0); - trees_[i - 1] = sum; - } - - // Make concat node trying to resue existing CordRepConcat nodes we - // already collected in the concat_freelist_. - CordRep* MakeConcat(CordRep* left, CordRep* right) { - if (concat_freelist_ == nullptr) return RawConcat(left, right); - - CordRepConcat* rep = concat_freelist_; - if (concat_freelist_->left == nullptr) { - concat_freelist_ = nullptr; - } else { - concat_freelist_ = concat_freelist_->left->concat(); - } - SetConcatChildren(rep, left, right); - - return rep; - } - - static void CheckNode(CordRep* node) { - ABSL_INTERNAL_CHECK(node->length != 0u, ""); + int i = 0; + for (; node->length > min_length[i + 1]; ++i) { + auto& tree_at_i = trees_[i]; + + if (tree_at_i == nullptr) continue; + sum = PrependNode(tree_at_i, sum); + tree_at_i = nullptr; + } + + sum = AppendNode(node, sum); + + // Insert sum into appropriate place in the forest + for (; sum->length >= min_length[i]; ++i) { + auto& tree_at_i = trees_[i]; + if (tree_at_i == nullptr) continue; + + sum = MakeConcat(tree_at_i, sum); + tree_at_i = nullptr; + } + + // min_length[0] == 1, which means sum->length >= min_length[0] + assert(i > 0); + trees_[i - 1] = sum; + } + + // Make concat node trying to resue existing CordRepConcat nodes we + // already collected in the concat_freelist_. + CordRep* MakeConcat(CordRep* left, CordRep* right) { + if (concat_freelist_ == nullptr) return RawConcat(left, right); + + CordRepConcat* rep = concat_freelist_; + if (concat_freelist_->left == nullptr) { + concat_freelist_ = nullptr; + } else { + concat_freelist_ = concat_freelist_->left->concat(); + } + SetConcatChildren(rep, left, right); + + return rep; + } + + static void CheckNode(CordRep* node) { + ABSL_INTERNAL_CHECK(node->length != 0u, ""); if (node->IsConcat()) { - ABSL_INTERNAL_CHECK(node->concat()->left != nullptr, ""); - ABSL_INTERNAL_CHECK(node->concat()->right != nullptr, ""); - ABSL_INTERNAL_CHECK(node->length == (node->concat()->left->length + - node->concat()->right->length), - ""); - } - } - - size_t root_length_; - - // use an inlined vector instead of a flat array to get bounds checking - y_absl::InlinedVector<CordRep*, kInlinedVectorSize> trees_; - - // List of concat nodes we can re-use for Cord balancing. - CordRepConcat* concat_freelist_ = nullptr; -}; - -static CordRep* Rebalance(CordRep* node) { - VerifyTree(node); + ABSL_INTERNAL_CHECK(node->concat()->left != nullptr, ""); + ABSL_INTERNAL_CHECK(node->concat()->right != nullptr, ""); + ABSL_INTERNAL_CHECK(node->length == (node->concat()->left->length + + node->concat()->right->length), + ""); + } + } + + size_t root_length_; + + // use an inlined vector instead of a flat array to get bounds checking + y_absl::InlinedVector<CordRep*, kInlinedVectorSize> trees_; + + // List of concat nodes we can re-use for Cord balancing. + CordRepConcat* concat_freelist_ = nullptr; +}; + +static CordRep* Rebalance(CordRep* node) { + VerifyTree(node); assert(node->IsConcat()); - - if (node->length == 0) { - return nullptr; - } - - CordForest forest(node->length); - forest.Build(node); - return forest.ConcatNodes(); -} - -// -------------------------------------------------------------------- -// Comparators - -namespace { - -int ClampResult(int memcmp_res) { - return static_cast<int>(memcmp_res > 0) - static_cast<int>(memcmp_res < 0); -} - -int CompareChunks(y_absl::string_view* lhs, y_absl::string_view* rhs, - size_t* size_to_compare) { - size_t compared_size = std::min(lhs->size(), rhs->size()); - assert(*size_to_compare >= compared_size); - *size_to_compare -= compared_size; - - int memcmp_res = ::memcmp(lhs->data(), rhs->data(), compared_size); - if (memcmp_res != 0) return memcmp_res; - - lhs->remove_prefix(compared_size); - rhs->remove_prefix(compared_size); - - return 0; -} - -// This overload set computes comparison results from memcmp result. This -// interface is used inside GenericCompare below. Differet implementations -// are specialized for int and bool. For int we clamp result to {-1, 0, 1} -// set. For bool we just interested in "value == 0". -template <typename ResultType> -ResultType ComputeCompareResult(int memcmp_res) { - return ClampResult(memcmp_res); -} -template <> -bool ComputeCompareResult<bool>(int memcmp_res) { - return memcmp_res == 0; -} - -} // namespace - + + if (node->length == 0) { + return nullptr; + } + + CordForest forest(node->length); + forest.Build(node); + return forest.ConcatNodes(); +} + +// -------------------------------------------------------------------- +// Comparators + +namespace { + +int ClampResult(int memcmp_res) { + return static_cast<int>(memcmp_res > 0) - static_cast<int>(memcmp_res < 0); +} + +int CompareChunks(y_absl::string_view* lhs, y_absl::string_view* rhs, + size_t* size_to_compare) { + size_t compared_size = std::min(lhs->size(), rhs->size()); + assert(*size_to_compare >= compared_size); + *size_to_compare -= compared_size; + + int memcmp_res = ::memcmp(lhs->data(), rhs->data(), compared_size); + if (memcmp_res != 0) return memcmp_res; + + lhs->remove_prefix(compared_size); + rhs->remove_prefix(compared_size); + + return 0; +} + +// This overload set computes comparison results from memcmp result. This +// interface is used inside GenericCompare below. Differet implementations +// are specialized for int and bool. For int we clamp result to {-1, 0, 1} +// set. For bool we just interested in "value == 0". +template <typename ResultType> +ResultType ComputeCompareResult(int memcmp_res) { + return ClampResult(memcmp_res); +} +template <> +bool ComputeCompareResult<bool>(int memcmp_res) { + return memcmp_res == 0; +} + +} // namespace + // Helper routine. Locates the first flat or external chunk of the Cord without // initializing the iterator, and returns a string_view referencing the data. -inline y_absl::string_view Cord::InlineRep::FindFlatStartPiece() const { +inline y_absl::string_view Cord::InlineRep::FindFlatStartPiece() const { if (!is_tree()) { return y_absl::string_view(data_.as_chars(), data_.inline_size()); - } - - CordRep* node = tree(); + } + + CordRep* node = tree(); if (node->IsFlat()) { return y_absl::string_view(node->flat()->Data(), node->length); - } - + } + if (node->IsExternal()) { - return y_absl::string_view(node->external()->base, node->length); - } - + return y_absl::string_view(node->external()->base, node->length); + } + if (node->IsBtree()) { CordRepBtree* tree = node->btree(); int height = tree->height(); @@ -1274,264 +1274,264 @@ inline y_absl::string_view Cord::InlineRep::FindFlatStartPiece() const { return tree->Data(tree->begin()); } - // Walk down the left branches until we hit a non-CONCAT node. + // Walk down the left branches until we hit a non-CONCAT node. while (node->IsConcat()) { - node = node->concat()->left; - } - - // Get the child node if we encounter a SUBSTRING. - size_t offset = 0; - size_t length = node->length; - assert(length != 0); - + node = node->concat()->left; + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; + assert(length != 0); + if (node->IsSubstring()) { - offset = node->substring()->start; - node = node->substring()->child; - } - + offset = node->substring()->start; + node = node->substring()->child; + } + if (node->IsFlat()) { return y_absl::string_view(node->flat()->Data() + offset, length); - } - + } + assert(node->IsExternal() && "Expect FLAT or EXTERNAL node here"); - - return y_absl::string_view(node->external()->base + offset, length); -} - -inline int Cord::CompareSlowPath(y_absl::string_view rhs, size_t compared_size, - size_t size_to_compare) const { - auto advance = [](Cord::ChunkIterator* it, y_absl::string_view* chunk) { - if (!chunk->empty()) return true; - ++*it; - if (it->bytes_remaining_ == 0) return false; - *chunk = **it; - return true; - }; - - Cord::ChunkIterator lhs_it = chunk_begin(); - - // compared_size is inside first chunk. - y_absl::string_view lhs_chunk = - (lhs_it.bytes_remaining_ != 0) ? *lhs_it : y_absl::string_view(); - assert(compared_size <= lhs_chunk.size()); - assert(compared_size <= rhs.size()); - lhs_chunk.remove_prefix(compared_size); - rhs.remove_prefix(compared_size); - size_to_compare -= compared_size; // skip already compared size. - - while (advance(&lhs_it, &lhs_chunk) && !rhs.empty()) { - int comparison_result = CompareChunks(&lhs_chunk, &rhs, &size_to_compare); - if (comparison_result != 0) return comparison_result; - if (size_to_compare == 0) return 0; - } - - return static_cast<int>(rhs.empty()) - static_cast<int>(lhs_chunk.empty()); -} - -inline int Cord::CompareSlowPath(const Cord& rhs, size_t compared_size, - size_t size_to_compare) const { - auto advance = [](Cord::ChunkIterator* it, y_absl::string_view* chunk) { - if (!chunk->empty()) return true; - ++*it; - if (it->bytes_remaining_ == 0) return false; - *chunk = **it; - return true; - }; - - Cord::ChunkIterator lhs_it = chunk_begin(); - Cord::ChunkIterator rhs_it = rhs.chunk_begin(); - - // compared_size is inside both first chunks. - y_absl::string_view lhs_chunk = - (lhs_it.bytes_remaining_ != 0) ? *lhs_it : y_absl::string_view(); - y_absl::string_view rhs_chunk = - (rhs_it.bytes_remaining_ != 0) ? *rhs_it : y_absl::string_view(); - assert(compared_size <= lhs_chunk.size()); - assert(compared_size <= rhs_chunk.size()); - lhs_chunk.remove_prefix(compared_size); - rhs_chunk.remove_prefix(compared_size); - size_to_compare -= compared_size; // skip already compared size. - - while (advance(&lhs_it, &lhs_chunk) && advance(&rhs_it, &rhs_chunk)) { - int memcmp_res = CompareChunks(&lhs_chunk, &rhs_chunk, &size_to_compare); - if (memcmp_res != 0) return memcmp_res; - if (size_to_compare == 0) return 0; - } - - return static_cast<int>(rhs_chunk.empty()) - - static_cast<int>(lhs_chunk.empty()); -} - -inline y_absl::string_view Cord::GetFirstChunk(const Cord& c) { - return c.contents_.FindFlatStartPiece(); -} -inline y_absl::string_view Cord::GetFirstChunk(y_absl::string_view sv) { - return sv; -} - -// Compares up to 'size_to_compare' bytes of 'lhs' with 'rhs'. It is assumed -// that 'size_to_compare' is greater that size of smallest of first chunks. -template <typename ResultType, typename RHS> -ResultType GenericCompare(const Cord& lhs, const RHS& rhs, - size_t size_to_compare) { - y_absl::string_view lhs_chunk = Cord::GetFirstChunk(lhs); - y_absl::string_view rhs_chunk = Cord::GetFirstChunk(rhs); - - size_t compared_size = std::min(lhs_chunk.size(), rhs_chunk.size()); - assert(size_to_compare >= compared_size); - int memcmp_res = ::memcmp(lhs_chunk.data(), rhs_chunk.data(), compared_size); - if (compared_size == size_to_compare || memcmp_res != 0) { - return ComputeCompareResult<ResultType>(memcmp_res); - } - - return ComputeCompareResult<ResultType>( - lhs.CompareSlowPath(rhs, compared_size, size_to_compare)); -} - -bool Cord::EqualsImpl(y_absl::string_view rhs, size_t size_to_compare) const { - return GenericCompare<bool>(*this, rhs, size_to_compare); -} - -bool Cord::EqualsImpl(const Cord& rhs, size_t size_to_compare) const { - return GenericCompare<bool>(*this, rhs, size_to_compare); -} - -template <typename RHS> -inline int SharedCompareImpl(const Cord& lhs, const RHS& rhs) { - size_t lhs_size = lhs.size(); - size_t rhs_size = rhs.size(); - if (lhs_size == rhs_size) { - return GenericCompare<int>(lhs, rhs, lhs_size); - } - if (lhs_size < rhs_size) { - auto data_comp_res = GenericCompare<int>(lhs, rhs, lhs_size); - return data_comp_res == 0 ? -1 : data_comp_res; - } - - auto data_comp_res = GenericCompare<int>(lhs, rhs, rhs_size); - return data_comp_res == 0 ? +1 : data_comp_res; -} - -int Cord::Compare(y_absl::string_view rhs) const { - return SharedCompareImpl(*this, rhs); -} - -int Cord::CompareImpl(const Cord& rhs) const { - return SharedCompareImpl(*this, rhs); -} - -bool Cord::EndsWith(y_absl::string_view rhs) const { - size_t my_size = size(); - size_t rhs_size = rhs.size(); - - if (my_size < rhs_size) return false; - - Cord tmp(*this); - tmp.RemovePrefix(my_size - rhs_size); - return tmp.EqualsImpl(rhs, rhs_size); -} - -bool Cord::EndsWith(const Cord& rhs) const { - size_t my_size = size(); - size_t rhs_size = rhs.size(); - - if (my_size < rhs_size) return false; - - Cord tmp(*this); - tmp.RemovePrefix(my_size - rhs_size); - return tmp.EqualsImpl(rhs, rhs_size); -} - -// -------------------------------------------------------------------- -// Misc. - -Cord::operator TString() const { - TString s; - y_absl::CopyCordToString(*this, &s); - return s; -} - -void CopyCordToString(const Cord& src, TString* dst) { - if (!src.contents_.is_tree()) { - src.contents_.CopyTo(dst); - } else { - y_absl::strings_internal::STLStringResizeUninitialized(dst, src.size()); - src.CopyToArraySlowPath(&(*dst)[0]); - } -} - -void Cord::CopyToArraySlowPath(char* dst) const { - assert(contents_.is_tree()); - y_absl::string_view fragment; - if (GetFlatAux(contents_.tree(), &fragment)) { - memcpy(dst, fragment.data(), fragment.size()); - return; - } - for (y_absl::string_view chunk : Chunks()) { - memcpy(dst, chunk.data(), chunk.size()); - dst += chunk.size(); - } -} - + + return y_absl::string_view(node->external()->base + offset, length); +} + +inline int Cord::CompareSlowPath(y_absl::string_view rhs, size_t compared_size, + size_t size_to_compare) const { + auto advance = [](Cord::ChunkIterator* it, y_absl::string_view* chunk) { + if (!chunk->empty()) return true; + ++*it; + if (it->bytes_remaining_ == 0) return false; + *chunk = **it; + return true; + }; + + Cord::ChunkIterator lhs_it = chunk_begin(); + + // compared_size is inside first chunk. + y_absl::string_view lhs_chunk = + (lhs_it.bytes_remaining_ != 0) ? *lhs_it : y_absl::string_view(); + assert(compared_size <= lhs_chunk.size()); + assert(compared_size <= rhs.size()); + lhs_chunk.remove_prefix(compared_size); + rhs.remove_prefix(compared_size); + size_to_compare -= compared_size; // skip already compared size. + + while (advance(&lhs_it, &lhs_chunk) && !rhs.empty()) { + int comparison_result = CompareChunks(&lhs_chunk, &rhs, &size_to_compare); + if (comparison_result != 0) return comparison_result; + if (size_to_compare == 0) return 0; + } + + return static_cast<int>(rhs.empty()) - static_cast<int>(lhs_chunk.empty()); +} + +inline int Cord::CompareSlowPath(const Cord& rhs, size_t compared_size, + size_t size_to_compare) const { + auto advance = [](Cord::ChunkIterator* it, y_absl::string_view* chunk) { + if (!chunk->empty()) return true; + ++*it; + if (it->bytes_remaining_ == 0) return false; + *chunk = **it; + return true; + }; + + Cord::ChunkIterator lhs_it = chunk_begin(); + Cord::ChunkIterator rhs_it = rhs.chunk_begin(); + + // compared_size is inside both first chunks. + y_absl::string_view lhs_chunk = + (lhs_it.bytes_remaining_ != 0) ? *lhs_it : y_absl::string_view(); + y_absl::string_view rhs_chunk = + (rhs_it.bytes_remaining_ != 0) ? *rhs_it : y_absl::string_view(); + assert(compared_size <= lhs_chunk.size()); + assert(compared_size <= rhs_chunk.size()); + lhs_chunk.remove_prefix(compared_size); + rhs_chunk.remove_prefix(compared_size); + size_to_compare -= compared_size; // skip already compared size. + + while (advance(&lhs_it, &lhs_chunk) && advance(&rhs_it, &rhs_chunk)) { + int memcmp_res = CompareChunks(&lhs_chunk, &rhs_chunk, &size_to_compare); + if (memcmp_res != 0) return memcmp_res; + if (size_to_compare == 0) return 0; + } + + return static_cast<int>(rhs_chunk.empty()) - + static_cast<int>(lhs_chunk.empty()); +} + +inline y_absl::string_view Cord::GetFirstChunk(const Cord& c) { + return c.contents_.FindFlatStartPiece(); +} +inline y_absl::string_view Cord::GetFirstChunk(y_absl::string_view sv) { + return sv; +} + +// Compares up to 'size_to_compare' bytes of 'lhs' with 'rhs'. It is assumed +// that 'size_to_compare' is greater that size of smallest of first chunks. +template <typename ResultType, typename RHS> +ResultType GenericCompare(const Cord& lhs, const RHS& rhs, + size_t size_to_compare) { + y_absl::string_view lhs_chunk = Cord::GetFirstChunk(lhs); + y_absl::string_view rhs_chunk = Cord::GetFirstChunk(rhs); + + size_t compared_size = std::min(lhs_chunk.size(), rhs_chunk.size()); + assert(size_to_compare >= compared_size); + int memcmp_res = ::memcmp(lhs_chunk.data(), rhs_chunk.data(), compared_size); + if (compared_size == size_to_compare || memcmp_res != 0) { + return ComputeCompareResult<ResultType>(memcmp_res); + } + + return ComputeCompareResult<ResultType>( + lhs.CompareSlowPath(rhs, compared_size, size_to_compare)); +} + +bool Cord::EqualsImpl(y_absl::string_view rhs, size_t size_to_compare) const { + return GenericCompare<bool>(*this, rhs, size_to_compare); +} + +bool Cord::EqualsImpl(const Cord& rhs, size_t size_to_compare) const { + return GenericCompare<bool>(*this, rhs, size_to_compare); +} + +template <typename RHS> +inline int SharedCompareImpl(const Cord& lhs, const RHS& rhs) { + size_t lhs_size = lhs.size(); + size_t rhs_size = rhs.size(); + if (lhs_size == rhs_size) { + return GenericCompare<int>(lhs, rhs, lhs_size); + } + if (lhs_size < rhs_size) { + auto data_comp_res = GenericCompare<int>(lhs, rhs, lhs_size); + return data_comp_res == 0 ? -1 : data_comp_res; + } + + auto data_comp_res = GenericCompare<int>(lhs, rhs, rhs_size); + return data_comp_res == 0 ? +1 : data_comp_res; +} + +int Cord::Compare(y_absl::string_view rhs) const { + return SharedCompareImpl(*this, rhs); +} + +int Cord::CompareImpl(const Cord& rhs) const { + return SharedCompareImpl(*this, rhs); +} + +bool Cord::EndsWith(y_absl::string_view rhs) const { + size_t my_size = size(); + size_t rhs_size = rhs.size(); + + if (my_size < rhs_size) return false; + + Cord tmp(*this); + tmp.RemovePrefix(my_size - rhs_size); + return tmp.EqualsImpl(rhs, rhs_size); +} + +bool Cord::EndsWith(const Cord& rhs) const { + size_t my_size = size(); + size_t rhs_size = rhs.size(); + + if (my_size < rhs_size) return false; + + Cord tmp(*this); + tmp.RemovePrefix(my_size - rhs_size); + return tmp.EqualsImpl(rhs, rhs_size); +} + +// -------------------------------------------------------------------- +// Misc. + +Cord::operator TString() const { + TString s; + y_absl::CopyCordToString(*this, &s); + return s; +} + +void CopyCordToString(const Cord& src, TString* dst) { + if (!src.contents_.is_tree()) { + src.contents_.CopyTo(dst); + } else { + y_absl::strings_internal::STLStringResizeUninitialized(dst, src.size()); + src.CopyToArraySlowPath(&(*dst)[0]); + } +} + +void Cord::CopyToArraySlowPath(char* dst) const { + assert(contents_.is_tree()); + y_absl::string_view fragment; + if (GetFlatAux(contents_.tree(), &fragment)) { + memcpy(dst, fragment.data(), fragment.size()); + return; + } + for (y_absl::string_view chunk : Chunks()) { + memcpy(dst, chunk.data(), chunk.size()); + dst += chunk.size(); + } +} + Cord::ChunkIterator& Cord::ChunkIterator::AdvanceStack() { auto& stack_of_right_children = stack_of_right_children_; if (stack_of_right_children.empty()) { - assert(!current_chunk_.empty()); // Called on invalid iterator. - // We have reached the end of the Cord. - return *this; - } - - // Process the next node on the stack. + assert(!current_chunk_.empty()); // Called on invalid iterator. + // We have reached the end of the Cord. + return *this; + } + + // Process the next node on the stack. CordRep* node = stack_of_right_children.back(); stack_of_right_children.pop_back(); - - // Walk down the left branches until we hit a non-CONCAT node. Save the - // right children to the stack for subsequent traversal. + + // Walk down the left branches until we hit a non-CONCAT node. Save the + // right children to the stack for subsequent traversal. while (node->IsConcat()) { stack_of_right_children.push_back(node->concat()->right); - node = node->concat()->left; - } - - // Get the child node if we encounter a SUBSTRING. - size_t offset = 0; - size_t length = node->length; + node = node->concat()->left; + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; if (node->IsSubstring()) { - offset = node->substring()->start; - node = node->substring()->child; - } - + offset = node->substring()->start; + node = node->substring()->child; + } + assert(node->IsExternal() || node->IsFlat()); - assert(length != 0); - const char* data = + assert(length != 0); + const char* data = node->IsExternal() ? node->external()->base : node->flat()->Data(); - current_chunk_ = y_absl::string_view(data + offset, length); - current_leaf_ = node; - return *this; -} - -Cord Cord::ChunkIterator::AdvanceAndReadBytes(size_t n) { + current_chunk_ = y_absl::string_view(data + offset, length); + current_leaf_ = node; + return *this; +} + +Cord Cord::ChunkIterator::AdvanceAndReadBytes(size_t n) { ABSL_HARDENING_ASSERT(bytes_remaining_ >= n && "Attempted to iterate past `end()`"); - Cord subcord; + Cord subcord; auto constexpr method = CordzUpdateTracker::kCordReader; - - if (n <= InlineRep::kMaxInline) { - // Range to read fits in inline data. Flatten it. - char* data = subcord.contents_.set_data(n); - while (n > current_chunk_.size()) { - memcpy(data, current_chunk_.data(), current_chunk_.size()); - data += current_chunk_.size(); - n -= current_chunk_.size(); - ++*this; - } - memcpy(data, current_chunk_.data(), n); - if (n < current_chunk_.size()) { - RemoveChunkPrefix(n); - } else if (n > 0) { - ++*this; - } - return subcord; - } + + if (n <= InlineRep::kMaxInline) { + // Range to read fits in inline data. Flatten it. + char* data = subcord.contents_.set_data(n); + while (n > current_chunk_.size()) { + memcpy(data, current_chunk_.data(), current_chunk_.size()); + data += current_chunk_.size(); + n -= current_chunk_.size(); + ++*this; + } + memcpy(data, current_chunk_.data(), n); + if (n < current_chunk_.size()) { + RemoveChunkPrefix(n); + } else if (n > 0) { + ++*this; + } + return subcord; + } if (btree_reader_) { size_t chunk_size = current_chunk_.size(); @@ -1552,261 +1552,261 @@ Cord Cord::ChunkIterator::AdvanceAndReadBytes(size_t n) { } auto& stack_of_right_children = stack_of_right_children_; - if (n < current_chunk_.size()) { - // Range to read is a proper subrange of the current chunk. - assert(current_leaf_ != nullptr); + if (n < current_chunk_.size()) { + // Range to read is a proper subrange of the current chunk. + assert(current_leaf_ != nullptr); CordRep* subnode = CordRep::Ref(current_leaf_); const char* data = subnode->IsExternal() ? subnode->external()->base : subnode->flat()->Data(); - subnode = NewSubstring(subnode, current_chunk_.data() - data, n); + subnode = NewSubstring(subnode, current_chunk_.data() - data, n); subcord.contents_.EmplaceTree(VerifyTree(subnode), method); - RemoveChunkPrefix(n); - return subcord; - } - - // Range to read begins with a proper subrange of the current chunk. - assert(!current_chunk_.empty()); - assert(current_leaf_ != nullptr); + RemoveChunkPrefix(n); + return subcord; + } + + // Range to read begins with a proper subrange of the current chunk. + assert(!current_chunk_.empty()); + assert(current_leaf_ != nullptr); CordRep* subnode = CordRep::Ref(current_leaf_); - if (current_chunk_.size() < subnode->length) { + if (current_chunk_.size() < subnode->length) { const char* data = subnode->IsExternal() ? subnode->external()->base : subnode->flat()->Data(); - subnode = NewSubstring(subnode, current_chunk_.data() - data, - current_chunk_.size()); - } - n -= current_chunk_.size(); - bytes_remaining_ -= current_chunk_.size(); - - // Process the next node(s) on the stack, reading whole subtrees depending on - // their length and how many bytes we are advancing. - CordRep* node = nullptr; + subnode = NewSubstring(subnode, current_chunk_.data() - data, + current_chunk_.size()); + } + n -= current_chunk_.size(); + bytes_remaining_ -= current_chunk_.size(); + + // Process the next node(s) on the stack, reading whole subtrees depending on + // their length and how many bytes we are advancing. + CordRep* node = nullptr; while (!stack_of_right_children.empty()) { node = stack_of_right_children.back(); stack_of_right_children.pop_back(); - if (node->length > n) break; - // TODO(qrczak): This might unnecessarily recreate existing concat nodes. - // Avoiding that would need pretty complicated logic (instead of + if (node->length > n) break; + // TODO(qrczak): This might unnecessarily recreate existing concat nodes. + // Avoiding that would need pretty complicated logic (instead of // current_leaf, keep current_subtree_ which points to the highest node - // such that the current leaf can be found on the path of left children - // starting from current_subtree_; delay creating subnode while node is - // below current_subtree_; find the proper node along the path of left - // children starting from current_subtree_ if this loop exits while staying - // below current_subtree_; etc.; alternatively, push parents instead of - // right children on the stack). + // such that the current leaf can be found on the path of left children + // starting from current_subtree_; delay creating subnode while node is + // below current_subtree_; find the proper node along the path of left + // children starting from current_subtree_ if this loop exits while staying + // below current_subtree_; etc.; alternatively, push parents instead of + // right children on the stack). subnode = Concat(subnode, CordRep::Ref(node)); - n -= node->length; - bytes_remaining_ -= node->length; - node = nullptr; - } - - if (node == nullptr) { - // We have reached the end of the Cord. - assert(bytes_remaining_ == 0); + n -= node->length; + bytes_remaining_ -= node->length; + node = nullptr; + } + + if (node == nullptr) { + // We have reached the end of the Cord. + assert(bytes_remaining_ == 0); subcord.contents_.EmplaceTree(VerifyTree(subnode), method); - return subcord; - } - - // Walk down the appropriate branches until we hit a non-CONCAT node. Save the - // right children to the stack for subsequent traversal. + return subcord; + } + + // Walk down the appropriate branches until we hit a non-CONCAT node. Save the + // right children to the stack for subsequent traversal. while (node->IsConcat()) { - if (node->concat()->left->length > n) { - // Push right, descend left. + if (node->concat()->left->length > n) { + // Push right, descend left. stack_of_right_children.push_back(node->concat()->right); - node = node->concat()->left; - } else { - // Read left, descend right. + node = node->concat()->left; + } else { + // Read left, descend right. subnode = Concat(subnode, CordRep::Ref(node->concat()->left)); - n -= node->concat()->left->length; - bytes_remaining_ -= node->concat()->left->length; - node = node->concat()->right; - } - } - - // Get the child node if we encounter a SUBSTRING. - size_t offset = 0; - size_t length = node->length; + n -= node->concat()->left->length; + bytes_remaining_ -= node->concat()->left->length; + node = node->concat()->right; + } + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; if (node->IsSubstring()) { - offset = node->substring()->start; - node = node->substring()->child; - } - - // Range to read ends with a proper (possibly empty) subrange of the current - // chunk. + offset = node->substring()->start; + node = node->substring()->child; + } + + // Range to read ends with a proper (possibly empty) subrange of the current + // chunk. assert(node->IsExternal() || node->IsFlat()); - assert(length > n); + assert(length > n); if (n > 0) { subnode = Concat(subnode, NewSubstring(CordRep::Ref(node), offset, n)); } - const char* data = + const char* data = node->IsExternal() ? node->external()->base : node->flat()->Data(); - current_chunk_ = y_absl::string_view(data + offset + n, length - n); - current_leaf_ = node; - bytes_remaining_ -= n; + current_chunk_ = y_absl::string_view(data + offset + n, length - n); + current_leaf_ = node; + bytes_remaining_ -= n; subcord.contents_.EmplaceTree(VerifyTree(subnode), method); - return subcord; -} - -void Cord::ChunkIterator::AdvanceBytesSlowPath(size_t n) { - assert(bytes_remaining_ >= n && "Attempted to iterate past `end()`"); - assert(n >= current_chunk_.size()); // This should only be called when - // iterating to a new node. - - n -= current_chunk_.size(); - bytes_remaining_ -= current_chunk_.size(); - + return subcord; +} + +void Cord::ChunkIterator::AdvanceBytesSlowPath(size_t n) { + assert(bytes_remaining_ >= n && "Attempted to iterate past `end()`"); + assert(n >= current_chunk_.size()); // This should only be called when + // iterating to a new node. + + n -= current_chunk_.size(); + bytes_remaining_ -= current_chunk_.size(); + if (stack_of_right_children_.empty()) { // We have reached the end of the Cord. assert(bytes_remaining_ == 0); return; } - // Process the next node(s) on the stack, skipping whole subtrees depending on - // their length and how many bytes we are advancing. - CordRep* node = nullptr; + // Process the next node(s) on the stack, skipping whole subtrees depending on + // their length and how many bytes we are advancing. + CordRep* node = nullptr; auto& stack_of_right_children = stack_of_right_children_; while (!stack_of_right_children.empty()) { node = stack_of_right_children.back(); stack_of_right_children.pop_back(); - if (node->length > n) break; - n -= node->length; - bytes_remaining_ -= node->length; - node = nullptr; - } - - if (node == nullptr) { - // We have reached the end of the Cord. - assert(bytes_remaining_ == 0); - return; - } - - // Walk down the appropriate branches until we hit a non-CONCAT node. Save the - // right children to the stack for subsequent traversal. + if (node->length > n) break; + n -= node->length; + bytes_remaining_ -= node->length; + node = nullptr; + } + + if (node == nullptr) { + // We have reached the end of the Cord. + assert(bytes_remaining_ == 0); + return; + } + + // Walk down the appropriate branches until we hit a non-CONCAT node. Save the + // right children to the stack for subsequent traversal. while (node->IsConcat()) { - if (node->concat()->left->length > n) { - // Push right, descend left. + if (node->concat()->left->length > n) { + // Push right, descend left. stack_of_right_children.push_back(node->concat()->right); - node = node->concat()->left; - } else { - // Skip left, descend right. - n -= node->concat()->left->length; - bytes_remaining_ -= node->concat()->left->length; - node = node->concat()->right; - } - } - - // Get the child node if we encounter a SUBSTRING. - size_t offset = 0; - size_t length = node->length; + node = node->concat()->left; + } else { + // Skip left, descend right. + n -= node->concat()->left->length; + bytes_remaining_ -= node->concat()->left->length; + node = node->concat()->right; + } + } + + // Get the child node if we encounter a SUBSTRING. + size_t offset = 0; + size_t length = node->length; if (node->IsSubstring()) { - offset = node->substring()->start; - node = node->substring()->child; - } - + offset = node->substring()->start; + node = node->substring()->child; + } + assert(node->IsExternal() || node->IsFlat()); - assert(length > n); - const char* data = + assert(length > n); + const char* data = node->IsExternal() ? node->external()->base : node->flat()->Data(); - current_chunk_ = y_absl::string_view(data + offset + n, length - n); - current_leaf_ = node; - bytes_remaining_ -= n; -} - -char Cord::operator[](size_t i) const { + current_chunk_ = y_absl::string_view(data + offset + n, length - n); + current_leaf_ = node; + bytes_remaining_ -= n; +} + +char Cord::operator[](size_t i) const { ABSL_HARDENING_ASSERT(i < size()); - size_t offset = i; - const CordRep* rep = contents_.tree(); - if (rep == nullptr) { - return contents_.data()[i]; - } - while (true) { - assert(rep != nullptr); - assert(offset < rep->length); + size_t offset = i; + const CordRep* rep = contents_.tree(); + if (rep == nullptr) { + return contents_.data()[i]; + } + while (true) { + assert(rep != nullptr); + assert(offset < rep->length); if (rep->IsFlat()) { - // Get the "i"th character directly from the flat array. + // Get the "i"th character directly from the flat array. return rep->flat()->Data()[offset]; } else if (rep->IsBtree()) { return rep->btree()->GetCharacter(offset); } else if (rep->IsExternal()) { - // Get the "i"th character from the external array. - return rep->external()->base[offset]; + // Get the "i"th character from the external array. + return rep->external()->base[offset]; } else if (rep->IsConcat()) { - // Recursively branch to the side of the concatenation that the "i"th - // character is on. - size_t left_length = rep->concat()->left->length; - if (offset < left_length) { - rep = rep->concat()->left; - } else { - offset -= left_length; - rep = rep->concat()->right; - } - } else { - // This must be a substring a node, so bypass it to get to the child. + // Recursively branch to the side of the concatenation that the "i"th + // character is on. + size_t left_length = rep->concat()->left->length; + if (offset < left_length) { + rep = rep->concat()->left; + } else { + offset -= left_length; + rep = rep->concat()->right; + } + } else { + // This must be a substring a node, so bypass it to get to the child. assert(rep->IsSubstring()); - offset += rep->substring()->start; - rep = rep->substring()->child; - } - } -} - -y_absl::string_view Cord::FlattenSlowPath() { + offset += rep->substring()->start; + rep = rep->substring()->child; + } + } +} + +y_absl::string_view Cord::FlattenSlowPath() { assert(contents_.is_tree()); - size_t total_size = size(); - CordRep* new_rep; - char* new_buffer; - - // Try to put the contents into a new flat rep. If they won't fit in the - // biggest possible flat node, use an external rep instead. - if (total_size <= kMaxFlatLength) { + size_t total_size = size(); + CordRep* new_rep; + char* new_buffer; + + // Try to put the contents into a new flat rep. If they won't fit in the + // biggest possible flat node, use an external rep instead. + if (total_size <= kMaxFlatLength) { new_rep = CordRepFlat::New(total_size); - new_rep->length = total_size; + new_rep->length = total_size; new_buffer = new_rep->flat()->Data(); - CopyToArraySlowPath(new_buffer); - } else { - new_buffer = std::allocator<char>().allocate(total_size); - CopyToArraySlowPath(new_buffer); - new_rep = y_absl::cord_internal::NewExternalRep( - y_absl::string_view(new_buffer, total_size), [](y_absl::string_view s) { - std::allocator<char>().deallocate(const_cast<char*>(s.data()), - s.size()); - }); - } + CopyToArraySlowPath(new_buffer); + } else { + new_buffer = std::allocator<char>().allocate(total_size); + CopyToArraySlowPath(new_buffer); + new_rep = y_absl::cord_internal::NewExternalRep( + y_absl::string_view(new_buffer, total_size), [](y_absl::string_view s) { + std::allocator<char>().deallocate(const_cast<char*>(s.data()), + s.size()); + }); + } CordzUpdateScope scope(contents_.cordz_info(), CordzUpdateTracker::kFlatten); CordRep::Unref(contents_.as_tree()); contents_.SetTree(new_rep, scope); - return y_absl::string_view(new_buffer, total_size); -} - -/* static */ bool Cord::GetFlatAux(CordRep* rep, y_absl::string_view* fragment) { - assert(rep != nullptr); + return y_absl::string_view(new_buffer, total_size); +} + +/* static */ bool Cord::GetFlatAux(CordRep* rep, y_absl::string_view* fragment) { + assert(rep != nullptr); if (rep->IsFlat()) { *fragment = y_absl::string_view(rep->flat()->Data(), rep->length); - return true; + return true; } else if (rep->IsExternal()) { - *fragment = y_absl::string_view(rep->external()->base, rep->length); - return true; + *fragment = y_absl::string_view(rep->external()->base, rep->length); + return true; } else if (rep->IsBtree()) { return rep->btree()->IsFlat(fragment); } else if (rep->IsSubstring()) { - CordRep* child = rep->substring()->child; + CordRep* child = rep->substring()->child; if (child->IsFlat()) { *fragment = y_absl::string_view( child->flat()->Data() + rep->substring()->start, rep->length); - return true; + return true; } else if (child->IsExternal()) { - *fragment = y_absl::string_view( - child->external()->base + rep->substring()->start, rep->length); - return true; + *fragment = y_absl::string_view( + child->external()->base + rep->substring()->start, rep->length); + return true; } else if (child->IsBtree()) { return child->btree()->IsFlat(rep->substring()->start, rep->length, fragment); - } - } - return false; -} - -/* static */ void Cord::ForEachChunkAux( - y_absl::cord_internal::CordRep* rep, - y_absl::FunctionRef<void(y_absl::string_view)> callback) { + } + } + return false; +} + +/* static */ void Cord::ForEachChunkAux( + y_absl::cord_internal::CordRep* rep, + y_absl::FunctionRef<void(y_absl::string_view)> callback) { if (rep->IsBtree()) { ChunkIterator it(rep), end; while (it != end) { @@ -1816,175 +1816,175 @@ y_absl::string_view Cord::FlattenSlowPath() { return; } - assert(rep != nullptr); - int stack_pos = 0; - constexpr int stack_max = 128; - // Stack of right branches for tree traversal - y_absl::cord_internal::CordRep* stack[stack_max]; - y_absl::cord_internal::CordRep* current_node = rep; - while (true) { + assert(rep != nullptr); + int stack_pos = 0; + constexpr int stack_max = 128; + // Stack of right branches for tree traversal + y_absl::cord_internal::CordRep* stack[stack_max]; + y_absl::cord_internal::CordRep* current_node = rep; + while (true) { if (current_node->IsConcat()) { - if (stack_pos == stack_max) { - // There's no more room on our stack array to add another right branch, - // and the idea is to avoid allocations, so call this function - // recursively to navigate this subtree further. (This is not something - // we expect to happen in practice). - ForEachChunkAux(current_node, callback); - - // Pop the next right branch and iterate. - current_node = stack[--stack_pos]; - continue; - } else { - // Save the right branch for later traversal and continue down the left - // branch. - stack[stack_pos++] = current_node->concat()->right; - current_node = current_node->concat()->left; - continue; - } - } - // This is a leaf node, so invoke our callback. - y_absl::string_view chunk; - bool success = GetFlatAux(current_node, &chunk); - assert(success); - if (success) { - callback(chunk); - } - if (stack_pos == 0) { - // end of traversal - return; - } - current_node = stack[--stack_pos]; - } -} - + if (stack_pos == stack_max) { + // There's no more room on our stack array to add another right branch, + // and the idea is to avoid allocations, so call this function + // recursively to navigate this subtree further. (This is not something + // we expect to happen in practice). + ForEachChunkAux(current_node, callback); + + // Pop the next right branch and iterate. + current_node = stack[--stack_pos]; + continue; + } else { + // Save the right branch for later traversal and continue down the left + // branch. + stack[stack_pos++] = current_node->concat()->right; + current_node = current_node->concat()->left; + continue; + } + } + // This is a leaf node, so invoke our callback. + y_absl::string_view chunk; + bool success = GetFlatAux(current_node, &chunk); + assert(success); + if (success) { + callback(chunk); + } + if (stack_pos == 0) { + // end of traversal + return; + } + current_node = stack[--stack_pos]; + } +} + static void DumpNode(CordRep* rep, bool include_data, std::ostream* os, int indent) { - const int kIndentStep = 1; - y_absl::InlinedVector<CordRep*, kInlinedVectorSize> stack; - y_absl::InlinedVector<int, kInlinedVectorSize> indents; - for (;;) { - *os << std::setw(3) << rep->refcount.Get(); - *os << " " << std::setw(7) << rep->length; - *os << " ["; - if (include_data) *os << static_cast<void*>(rep); - *os << "]"; - *os << " " << (IsRootBalanced(rep) ? 'b' : 'u'); - *os << " " << std::setw(indent) << ""; + const int kIndentStep = 1; + y_absl::InlinedVector<CordRep*, kInlinedVectorSize> stack; + y_absl::InlinedVector<int, kInlinedVectorSize> indents; + for (;;) { + *os << std::setw(3) << rep->refcount.Get(); + *os << " " << std::setw(7) << rep->length; + *os << " ["; + if (include_data) *os << static_cast<void*>(rep); + *os << "]"; + *os << " " << (IsRootBalanced(rep) ? 'b' : 'u'); + *os << " " << std::setw(indent) << ""; if (rep->IsConcat()) { - *os << "CONCAT depth=" << Depth(rep) << "\n"; - indent += kIndentStep; - indents.push_back(indent); - stack.push_back(rep->concat()->right); - rep = rep->concat()->left; + *os << "CONCAT depth=" << Depth(rep) << "\n"; + indent += kIndentStep; + indents.push_back(indent); + stack.push_back(rep->concat()->right); + rep = rep->concat()->left; } else if (rep->IsSubstring()) { - *os << "SUBSTRING @ " << rep->substring()->start << "\n"; - indent += kIndentStep; - rep = rep->substring()->child; + *os << "SUBSTRING @ " << rep->substring()->start << "\n"; + indent += kIndentStep; + rep = rep->substring()->child; } else { // Leaf or ring if (rep->IsExternal()) { - *os << "EXTERNAL ["; - if (include_data) - *os << y_absl::CEscape(TString(rep->external()->base, rep->length)); - *os << "]\n"; + *os << "EXTERNAL ["; + if (include_data) + *os << y_absl::CEscape(TString(rep->external()->base, rep->length)); + *os << "]\n"; } else if (rep->IsFlat()) { *os << "FLAT cap=" << rep->flat()->Capacity() << " ["; - if (include_data) + if (include_data) *os << y_absl::CEscape(TString(rep->flat()->Data(), rep->length)); - *os << "]\n"; + *os << "]\n"; } else { CordRepBtree::Dump(rep, /*label=*/ "", include_data, *os); - } - if (stack.empty()) break; - rep = stack.back(); - stack.pop_back(); - indent = indents.back(); - indents.pop_back(); - } - } - ABSL_INTERNAL_CHECK(indents.empty(), ""); -} - -static TString ReportError(CordRep* root, CordRep* node) { - std::ostringstream buf; - buf << "Error at node " << node << " in:"; - DumpNode(root, true, &buf); - return TString(buf.str()); -} - -static bool VerifyNode(CordRep* root, CordRep* start_node, - bool full_validation) { - y_absl::InlinedVector<CordRep*, 2> worklist; - worklist.push_back(start_node); - do { - CordRep* node = worklist.back(); - worklist.pop_back(); - - ABSL_INTERNAL_CHECK(node != nullptr, ReportError(root, node)); - if (node != root) { - ABSL_INTERNAL_CHECK(node->length != 0, ReportError(root, node)); - } - + } + if (stack.empty()) break; + rep = stack.back(); + stack.pop_back(); + indent = indents.back(); + indents.pop_back(); + } + } + ABSL_INTERNAL_CHECK(indents.empty(), ""); +} + +static TString ReportError(CordRep* root, CordRep* node) { + std::ostringstream buf; + buf << "Error at node " << node << " in:"; + DumpNode(root, true, &buf); + return TString(buf.str()); +} + +static bool VerifyNode(CordRep* root, CordRep* start_node, + bool full_validation) { + y_absl::InlinedVector<CordRep*, 2> worklist; + worklist.push_back(start_node); + do { + CordRep* node = worklist.back(); + worklist.pop_back(); + + ABSL_INTERNAL_CHECK(node != nullptr, ReportError(root, node)); + if (node != root) { + ABSL_INTERNAL_CHECK(node->length != 0, ReportError(root, node)); + } + if (node->IsConcat()) { - ABSL_INTERNAL_CHECK(node->concat()->left != nullptr, - ReportError(root, node)); - ABSL_INTERNAL_CHECK(node->concat()->right != nullptr, - ReportError(root, node)); - ABSL_INTERNAL_CHECK((node->length == node->concat()->left->length + - node->concat()->right->length), - ReportError(root, node)); - if (full_validation) { - worklist.push_back(node->concat()->right); - worklist.push_back(node->concat()->left); - } + ABSL_INTERNAL_CHECK(node->concat()->left != nullptr, + ReportError(root, node)); + ABSL_INTERNAL_CHECK(node->concat()->right != nullptr, + ReportError(root, node)); + ABSL_INTERNAL_CHECK((node->length == node->concat()->left->length + + node->concat()->right->length), + ReportError(root, node)); + if (full_validation) { + worklist.push_back(node->concat()->right); + worklist.push_back(node->concat()->left); + } } else if (node->IsFlat()) { ABSL_INTERNAL_CHECK(node->length <= node->flat()->Capacity(), ReportError(root, node)); } else if (node->IsExternal()) { - ABSL_INTERNAL_CHECK(node->external()->base != nullptr, - ReportError(root, node)); + ABSL_INTERNAL_CHECK(node->external()->base != nullptr, + ReportError(root, node)); } else if (node->IsSubstring()) { - ABSL_INTERNAL_CHECK( - node->substring()->start < node->substring()->child->length, - ReportError(root, node)); - ABSL_INTERNAL_CHECK(node->substring()->start + node->length <= - node->substring()->child->length, - ReportError(root, node)); - } - } while (!worklist.empty()); - return true; -} - -// Traverses the tree and computes the total memory allocated. -/* static */ size_t Cord::MemoryUsageAux(const CordRep* rep) { - size_t total_mem_usage = 0; - - // Allow a quick exit for the common case that the root is a leaf. - if (RepMemoryUsageLeaf(rep, &total_mem_usage)) { - return total_mem_usage; - } - - // Iterate over the tree. cur_node is never a leaf node and leaf nodes will - // never be appended to tree_stack. This reduces overhead from manipulating - // tree_stack. - y_absl::InlinedVector<const CordRep*, kInlinedVectorSize> tree_stack; - const CordRep* cur_node = rep; - while (true) { - const CordRep* next_node = nullptr; - + ABSL_INTERNAL_CHECK( + node->substring()->start < node->substring()->child->length, + ReportError(root, node)); + ABSL_INTERNAL_CHECK(node->substring()->start + node->length <= + node->substring()->child->length, + ReportError(root, node)); + } + } while (!worklist.empty()); + return true; +} + +// Traverses the tree and computes the total memory allocated. +/* static */ size_t Cord::MemoryUsageAux(const CordRep* rep) { + size_t total_mem_usage = 0; + + // Allow a quick exit for the common case that the root is a leaf. + if (RepMemoryUsageLeaf(rep, &total_mem_usage)) { + return total_mem_usage; + } + + // Iterate over the tree. cur_node is never a leaf node and leaf nodes will + // never be appended to tree_stack. This reduces overhead from manipulating + // tree_stack. + y_absl::InlinedVector<const CordRep*, kInlinedVectorSize> tree_stack; + const CordRep* cur_node = rep; + while (true) { + const CordRep* next_node = nullptr; + if (cur_node->IsConcat()) { - total_mem_usage += sizeof(CordRepConcat); - const CordRep* left = cur_node->concat()->left; - if (!RepMemoryUsageLeaf(left, &total_mem_usage)) { - next_node = left; - } - - const CordRep* right = cur_node->concat()->right; - if (!RepMemoryUsageLeaf(right, &total_mem_usage)) { - if (next_node) { - tree_stack.push_back(next_node); - } - next_node = right; - } + total_mem_usage += sizeof(CordRepConcat); + const CordRep* left = cur_node->concat()->left; + if (!RepMemoryUsageLeaf(left, &total_mem_usage)) { + next_node = left; + } + + const CordRep* right = cur_node->concat()->right; + if (!RepMemoryUsageLeaf(right, &total_mem_usage)) { + if (next_node) { + tree_stack.push_back(next_node); + } + next_node = right; + } } else if (cur_node->IsBtree()) { total_mem_usage += sizeof(CordRepBtree); const CordRepBtree* node = cur_node->btree(); @@ -1997,51 +1997,51 @@ static bool VerifyNode(CordRep* root, CordRep* start_node, tree_stack.push_back(edge); } } - } else { - // Since cur_node is not a leaf or a concat node it must be a substring. + } else { + // Since cur_node is not a leaf or a concat node it must be a substring. assert(cur_node->IsSubstring()); - total_mem_usage += sizeof(CordRepSubstring); - next_node = cur_node->substring()->child; - if (RepMemoryUsageLeaf(next_node, &total_mem_usage)) { - next_node = nullptr; - } - } - - if (!next_node) { - if (tree_stack.empty()) { - return total_mem_usage; - } - next_node = tree_stack.back(); - tree_stack.pop_back(); - } - cur_node = next_node; - } -} - -std::ostream& operator<<(std::ostream& out, const Cord& cord) { - for (y_absl::string_view chunk : cord.Chunks()) { - out.write(chunk.data(), chunk.size()); - } - return out; -} - -namespace strings_internal { + total_mem_usage += sizeof(CordRepSubstring); + next_node = cur_node->substring()->child; + if (RepMemoryUsageLeaf(next_node, &total_mem_usage)) { + next_node = nullptr; + } + } + + if (!next_node) { + if (tree_stack.empty()) { + return total_mem_usage; + } + next_node = tree_stack.back(); + tree_stack.pop_back(); + } + cur_node = next_node; + } +} + +std::ostream& operator<<(std::ostream& out, const Cord& cord) { + for (y_absl::string_view chunk : cord.Chunks()) { + out.write(chunk.data(), chunk.size()); + } + return out; +} + +namespace strings_internal { size_t CordTestAccess::FlatOverhead() { return cord_internal::kFlatOverhead; } size_t CordTestAccess::MaxFlatLength() { return cord_internal::kMaxFlatLength; } -size_t CordTestAccess::FlatTagToLength(uint8_t tag) { +size_t CordTestAccess::FlatTagToLength(uint8_t tag) { return cord_internal::TagToLength(tag); -} -uint8_t CordTestAccess::LengthToTag(size_t s) { - ABSL_INTERNAL_CHECK(s <= kMaxFlatLength, y_absl::StrCat("Invalid length ", s)); +} +uint8_t CordTestAccess::LengthToTag(size_t s) { + ABSL_INTERNAL_CHECK(s <= kMaxFlatLength, y_absl::StrCat("Invalid length ", s)); return cord_internal::AllocatedSizeToTag(s + cord_internal::kFlatOverhead); -} -size_t CordTestAccess::SizeofCordRepConcat() { return sizeof(CordRepConcat); } -size_t CordTestAccess::SizeofCordRepExternal() { - return sizeof(CordRepExternal); -} -size_t CordTestAccess::SizeofCordRepSubstring() { - return sizeof(CordRepSubstring); -} -} // namespace strings_internal -ABSL_NAMESPACE_END -} // namespace y_absl +} +size_t CordTestAccess::SizeofCordRepConcat() { return sizeof(CordRepConcat); } +size_t CordTestAccess::SizeofCordRepExternal() { + return sizeof(CordRepExternal); +} +size_t CordTestAccess::SizeofCordRepSubstring() { + return sizeof(CordRepSubstring); +} +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.h index 62359e0cf8..1722ff1e67 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord.h @@ -1,17 +1,17 @@ -// Copyright 2020 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// // ----------------------------------------------------------------------------- // File: cord.h // ----------------------------------------------------------------------------- @@ -52,33 +52,33 @@ // // Thread Safety // -// Cord has the same thread-safety properties as many other types like -// TString, std::vector<>, int, etc -- it is thread-compatible. In +// Cord has the same thread-safety properties as many other types like +// TString, std::vector<>, int, etc -- it is thread-compatible. In // particular, if threads do not call non-const methods, then it is safe to call // const methods without synchronization. Copying a Cord produces a new instance // that can be used concurrently with the original in arbitrary ways. - -#ifndef ABSL_STRINGS_CORD_H_ -#define ABSL_STRINGS_CORD_H_ - -#include <algorithm> -#include <cstddef> -#include <cstdint> -#include <cstring> + +#ifndef ABSL_STRINGS_CORD_H_ +#define ABSL_STRINGS_CORD_H_ + +#include <algorithm> +#include <cstddef> +#include <cstdint> +#include <cstring> #include <iosfwd> -#include <iterator> -#include <util/generic/string.h> +#include <iterator> +#include <util/generic/string.h> #include <type_traits> - + #include "y_absl/base/config.h" -#include "y_absl/base/internal/endian.h" -#include "y_absl/base/internal/per_thread_tls.h" -#include "y_absl/base/macros.h" -#include "y_absl/base/port.h" -#include "y_absl/container/inlined_vector.h" -#include "y_absl/functional/function_ref.h" -#include "y_absl/meta/type_traits.h" -#include "y_absl/strings/internal/cord_internal.h" +#include "y_absl/base/internal/endian.h" +#include "y_absl/base/internal/per_thread_tls.h" +#include "y_absl/base/macros.h" +#include "y_absl/base/port.h" +#include "y_absl/container/inlined_vector.h" +#include "y_absl/functional/function_ref.h" +#include "y_absl/meta/type_traits.h" +#include "y_absl/strings/internal/cord_internal.h" #include "y_absl/strings/internal/cord_rep_btree.h" #include "y_absl/strings/internal/cord_rep_btree_reader.h" #include "y_absl/strings/internal/cord_rep_ring.h" @@ -87,19 +87,19 @@ #include "y_absl/strings/internal/cordz_statistics.h" #include "y_absl/strings/internal/cordz_update_scope.h" #include "y_absl/strings/internal/cordz_update_tracker.h" -#include "y_absl/strings/internal/resize_uninitialized.h" +#include "y_absl/strings/internal/resize_uninitialized.h" #include "y_absl/strings/internal/string_constant.h" -#include "y_absl/strings/string_view.h" +#include "y_absl/strings/string_view.h" #include "y_absl/types/optional.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -class Cord; -class CordTestPeer; -template <typename Releaser> -Cord MakeCordFromExternal(y_absl::string_view, Releaser&&); -void CopyCordToString(const Cord& src, TString* dst); - + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +class Cord; +class CordTestPeer; +template <typename Releaser> +Cord MakeCordFromExternal(y_absl::string_view, Releaser&&); +void CopyCordToString(const Cord& src, TString* dst); + // Cord // // A Cord is a sequence of characters, designed to be more efficient than a @@ -128,54 +128,54 @@ void CopyCordToString(const Cord& src, TString* dst); // Additionally, the API provides iterator utilities to iterate through Cord // data via chunks or character bytes. // -class Cord { - private: - template <typename T> - using EnableIfString = - y_absl::enable_if_t<std::is_same<T, TString>::value, int>; - - public: +class Cord { + private: + template <typename T> + using EnableIfString = + y_absl::enable_if_t<std::is_same<T, TString>::value, int>; + + public: // Cord::Cord() Constructors. - + // Creates an empty Cord. - constexpr Cord() noexcept; - + constexpr Cord() noexcept; + // Creates a Cord from an existing Cord. Cord is copyable and efficiently // movable. The moved-from state is valid but unspecified. - Cord(const Cord& src); - Cord(Cord&& src) noexcept; - Cord& operator=(const Cord& x); - Cord& operator=(Cord&& x) noexcept; - + Cord(const Cord& src); + Cord(Cord&& src) noexcept; + Cord& operator=(const Cord& x); + Cord& operator=(Cord&& x) noexcept; + // Creates a Cord from a `src` string. This constructor is marked explicit to // prevent implicit Cord constructions from arguments convertible to an // `y_absl::string_view`. - explicit Cord(y_absl::string_view src); - Cord& operator=(y_absl::string_view src); - + explicit Cord(y_absl::string_view src); + Cord& operator=(y_absl::string_view src); + // Creates a Cord from a `TString&&` rvalue. These constructors are // templated to avoid ambiguities for types that are convertible to both // `y_absl::string_view` and `TString`, such as `const char*`. - template <typename T, EnableIfString<T> = 0> + template <typename T, EnableIfString<T> = 0> explicit Cord(T&& src); - template <typename T, EnableIfString<T> = 0> - Cord& operator=(T&& src); - + template <typename T, EnableIfString<T> = 0> + Cord& operator=(T&& src); + // Cord::~Cord() // // Destructs the Cord. - ~Cord() { - if (contents_.is_tree()) DestroyCordSlow(); - } - + ~Cord() { + if (contents_.is_tree()) DestroyCordSlow(); + } + // MakeCordFromExternal() - // + // // Creates a Cord that takes ownership of external string memory. The // contents of `data` are not copied to the Cord; instead, the external // memory is added to the Cord and reference-counted. This data may not be // changed for the life of the Cord, though it may be prepended or appended // to. - // + // // `MakeCordFromExternal()` takes a callable "releaser" that is invoked when // the reference count for `data` reaches zero. As noted above, this data must // remain live until the releaser is invoked. The callable releaser also must: @@ -183,146 +183,146 @@ class Cord { // * be move constructible // * support `void operator()(y_absl::string_view) const` or `void operator()` // - // Example: - // - // Cord MakeCord(BlockPool* pool) { - // Block* block = pool->NewBlock(); - // FillBlock(block); - // return y_absl::MakeCordFromExternal( - // block->ToStringView(), + // Example: + // + // Cord MakeCord(BlockPool* pool) { + // Block* block = pool->NewBlock(); + // FillBlock(block); + // return y_absl::MakeCordFromExternal( + // block->ToStringView(), // [pool, block](y_absl::string_view v) { // pool->FreeBlock(block, v); - // }); - // } - // + // }); + // } + // // WARNING: Because a Cord can be reference-counted, it's likely a bug if your // releaser doesn't do anything. For example, consider the following: - // - // void Foo(const char* buffer, int len) { - // auto c = y_absl::MakeCordFromExternal(y_absl::string_view(buffer, len), - // [](y_absl::string_view) {}); - // - // // BUG: If Bar() copies its cord for any reason, including keeping a - // // substring of it, the lifetime of buffer might be extended beyond - // // when Foo() returns. - // Bar(c); - // } - template <typename Releaser> - friend Cord MakeCordFromExternal(y_absl::string_view data, Releaser&& releaser); - + // + // void Foo(const char* buffer, int len) { + // auto c = y_absl::MakeCordFromExternal(y_absl::string_view(buffer, len), + // [](y_absl::string_view) {}); + // + // // BUG: If Bar() copies its cord for any reason, including keeping a + // // substring of it, the lifetime of buffer might be extended beyond + // // when Foo() returns. + // Bar(c); + // } + template <typename Releaser> + friend Cord MakeCordFromExternal(y_absl::string_view data, Releaser&& releaser); + // Cord::Clear() // // Releases the Cord data. Any nodes that share data with other Cords, if // applicable, will have their reference counts reduced by 1. - void Clear(); - + void Clear(); + // Cord::Append() // // Appends data to the Cord, which may come from another Cord or other string // data. - void Append(const Cord& src); - void Append(Cord&& src); - void Append(y_absl::string_view src); - template <typename T, EnableIfString<T> = 0> - void Append(T&& src); - + void Append(const Cord& src); + void Append(Cord&& src); + void Append(y_absl::string_view src); + template <typename T, EnableIfString<T> = 0> + void Append(T&& src); + // Cord::Prepend() // // Prepends data to the Cord, which may come from another Cord or other string // data. - void Prepend(const Cord& src); - void Prepend(y_absl::string_view src); - template <typename T, EnableIfString<T> = 0> - void Prepend(T&& src); - + void Prepend(const Cord& src); + void Prepend(y_absl::string_view src); + template <typename T, EnableIfString<T> = 0> + void Prepend(T&& src); + // Cord::RemovePrefix() // // Removes the first `n` bytes of a Cord. - void RemovePrefix(size_t n); - void RemoveSuffix(size_t n); - + void RemovePrefix(size_t n); + void RemoveSuffix(size_t n); + // Cord::Subcord() // // Returns a new Cord representing the subrange [pos, pos + new_size) of - // *this. If pos >= size(), the result is empty(). If - // (pos + new_size) >= size(), the result is the subrange [pos, size()). - Cord Subcord(size_t pos, size_t new_size) const; - + // *this. If pos >= size(), the result is empty(). If + // (pos + new_size) >= size(), the result is the subrange [pos, size()). + Cord Subcord(size_t pos, size_t new_size) const; + // Cord::swap() // // Swaps the contents of the Cord with `other`. void swap(Cord& other) noexcept; - + // swap() // // Swaps the contents of two Cords. friend void swap(Cord& x, Cord& y) noexcept { x.swap(y); } - + // Cord::size() // // Returns the size of the Cord. - size_t size() const; + size_t size() const; // Cord::empty() // // Determines whether the given Cord is empty, returning `true` is so. - bool empty() const; - + bool empty() const; + // Cord::EstimatedMemoryUsage() // // Returns the *approximate* number of bytes held in full or in part by this // Cord (which may not remain the same between invocations). Note that Cords // that share memory could each be "charged" independently for the same shared // memory. - size_t EstimatedMemoryUsage() const; - + size_t EstimatedMemoryUsage() const; + // Cord::Compare() // // Compares 'this' Cord with rhs. This function and its relatives treat Cords // as sequences of unsigned bytes. The comparison is a straightforward // lexicographic comparison. `Cord::Compare()` returns values as follows: // - // -1 'this' Cord is smaller - // 0 two Cords are equal - // 1 'this' Cord is larger - int Compare(y_absl::string_view rhs) const; - int Compare(const Cord& rhs) const; - + // -1 'this' Cord is smaller + // 0 two Cords are equal + // 1 'this' Cord is larger + int Compare(y_absl::string_view rhs) const; + int Compare(const Cord& rhs) const; + // Cord::StartsWith() // // Determines whether the Cord starts with the passed string data `rhs`. - bool StartsWith(const Cord& rhs) const; - bool StartsWith(y_absl::string_view rhs) const; + bool StartsWith(const Cord& rhs) const; + bool StartsWith(y_absl::string_view rhs) const; // Cord::EndsWith() // // Determines whether the Cord ends with the passed string data `rhs`. - bool EndsWith(y_absl::string_view rhs) const; - bool EndsWith(const Cord& rhs) const; - + bool EndsWith(y_absl::string_view rhs) const; + bool EndsWith(const Cord& rhs) const; + // Cord::operator TString() // // Converts a Cord into a `TString()`. This operator is marked explicit to // prevent unintended Cord usage in functions that take a string. - explicit operator TString() const; - + explicit operator TString() const; + // CopyCordToString() - // + // // Copies the contents of a `src` Cord into a `*dst` string. // // This function optimizes the case of reusing the destination string since it - // can reuse previously allocated capacity. However, this function does not - // guarantee that pointers previously returned by `dst->data()` remain valid - // even if `*dst` had enough capacity to hold `src`. If `*dst` is a new - // object, prefer to simply use the conversion operator to `TString`. - friend void CopyCordToString(const Cord& src, TString* dst); - - class CharIterator; - + // can reuse previously allocated capacity. However, this function does not + // guarantee that pointers previously returned by `dst->data()` remain valid + // even if `*dst` had enough capacity to hold `src`. If `*dst` is a new + // object, prefer to simply use the conversion operator to `TString`. + friend void CopyCordToString(const Cord& src, TString* dst); + + class CharIterator; + //---------------------------------------------------------------------------- // Cord::ChunkIterator //---------------------------------------------------------------------------- - // + // // A `Cord::ChunkIterator` allows iteration over the constituent chunks of its // Cord. Such iteration allows you to perform non-const operatons on the data // of a Cord without modifying it. @@ -335,8 +335,8 @@ class Cord { // // * The iterator is invalidated after any non-const operation on the // Cord object over which it iterates. - // * The `string_view` returned by dereferencing a valid, non-`end()` - // iterator is guaranteed to be non-empty. + // * The `string_view` returned by dereferencing a valid, non-`end()` + // iterator is guaranteed to be non-empty. // * Two `ChunkIterator` objects can be compared equal if and only if they // remain valid and iterate over the same Cord. // * The iterator in this case is a proxy iterator; the `string_view` @@ -345,29 +345,29 @@ class Cord { // prevent lifetime issues, `ChunkIterator::reference` is not a true // reference type and is equivalent to `value_type`. // * The iterator keeps state that can grow for Cords that contain many - // nodes and are imbalanced due to sharing. Prefer to pass this type by - // const reference instead of by value. - class ChunkIterator { - public: - using iterator_category = std::input_iterator_tag; - using value_type = y_absl::string_view; - using difference_type = ptrdiff_t; - using pointer = const value_type*; - using reference = value_type; - - ChunkIterator() = default; - - ChunkIterator& operator++(); - ChunkIterator operator++(int); - bool operator==(const ChunkIterator& other) const; - bool operator!=(const ChunkIterator& other) const; - reference operator*() const; - pointer operator->() const; - - friend class Cord; - friend class CharIterator; - - private: + // nodes and are imbalanced due to sharing. Prefer to pass this type by + // const reference instead of by value. + class ChunkIterator { + public: + using iterator_category = std::input_iterator_tag; + using value_type = y_absl::string_view; + using difference_type = ptrdiff_t; + using pointer = const value_type*; + using reference = value_type; + + ChunkIterator() = default; + + ChunkIterator& operator++(); + ChunkIterator operator++(int); + bool operator==(const ChunkIterator& other) const; + bool operator!=(const ChunkIterator& other) const; + reference operator*() const; + pointer operator->() const; + + friend class Cord; + friend class CharIterator; + + private: using CordRep = y_absl::cord_internal::CordRep; using CordRepBtree = y_absl::cord_internal::CordRepBtree; using CordRepBtreeReader = y_absl::cord_internal::CordRepBtreeReader; @@ -381,17 +381,17 @@ class Cord { // Constructs a `begin()` iterator from `tree`. `tree` must not be null. explicit ChunkIterator(cord_internal::CordRep* tree); - // Constructs a `begin()` iterator from `cord`. - explicit ChunkIterator(const Cord* cord); - + // Constructs a `begin()` iterator from `cord`. + explicit ChunkIterator(const Cord* cord); + // Initializes this instance from a tree. Invoked by constructors. void InitTree(cord_internal::CordRep* tree); - // Removes `n` bytes from `current_chunk_`. Expects `n` to be smaller than - // `current_chunk_.size()`. - void RemoveChunkPrefix(size_t n); - Cord AdvanceAndReadBytes(size_t n); - void AdvanceBytes(size_t n); + // Removes `n` bytes from `current_chunk_`. Expects `n` to be smaller than + // `current_chunk_.size()`. + void RemoveChunkPrefix(size_t n); + Cord AdvanceAndReadBytes(size_t n); + void AdvanceBytes(size_t n); // Stack specific operator++ ChunkIterator& AdvanceStack(); @@ -400,56 +400,56 @@ class Cord { ChunkIterator& AdvanceBtree(); void AdvanceBytesBtree(size_t n); - // Iterates `n` bytes, where `n` is expected to be greater than or equal to - // `current_chunk_.size()`. - void AdvanceBytesSlowPath(size_t n); - - // A view into bytes of the current `CordRep`. It may only be a view to a - // suffix of bytes if this is being used by `CharIterator`. - y_absl::string_view current_chunk_; - // The current leaf, or `nullptr` if the iterator points to short data. - // If the current chunk is a substring node, current_leaf_ points to the - // underlying flat or external node. - y_absl::cord_internal::CordRep* current_leaf_ = nullptr; - // The number of bytes left in the `Cord` over which we are iterating. - size_t bytes_remaining_ = 0; + // Iterates `n` bytes, where `n` is expected to be greater than or equal to + // `current_chunk_.size()`. + void AdvanceBytesSlowPath(size_t n); + + // A view into bytes of the current `CordRep`. It may only be a view to a + // suffix of bytes if this is being used by `CharIterator`. + y_absl::string_view current_chunk_; + // The current leaf, or `nullptr` if the iterator points to short data. + // If the current chunk is a substring node, current_leaf_ points to the + // underlying flat or external node. + y_absl::cord_internal::CordRep* current_leaf_ = nullptr; + // The number of bytes left in the `Cord` over which we are iterating. + size_t bytes_remaining_ = 0; // Cord reader for cord btrees. Empty if not traversing a btree. CordRepBtreeReader btree_reader_; // See 'Stack' alias definition. Stack stack_of_right_children_; - }; - + }; + // Cord::ChunkIterator::chunk_begin() // - // Returns an iterator to the first chunk of the `Cord`. - // + // Returns an iterator to the first chunk of the `Cord`. + // // Generally, prefer using `Cord::Chunks()` within a range-based for loop for // iterating over the chunks of a Cord. This method may be useful for getting // a `ChunkIterator` where range-based for-loops are not useful. - // - // Example: - // - // y_absl::Cord::ChunkIterator FindAsChunk(const y_absl::Cord& c, - // y_absl::string_view s) { - // return std::find(c.chunk_begin(), c.chunk_end(), s); - // } - ChunkIterator chunk_begin() const; + // + // Example: + // + // y_absl::Cord::ChunkIterator FindAsChunk(const y_absl::Cord& c, + // y_absl::string_view s) { + // return std::find(c.chunk_begin(), c.chunk_end(), s); + // } + ChunkIterator chunk_begin() const; // Cord::ChunkItertator::chunk_end() // - // Returns an iterator one increment past the last chunk of the `Cord`. + // Returns an iterator one increment past the last chunk of the `Cord`. // // Generally, prefer using `Cord::Chunks()` within a range-based for loop for // iterating over the chunks of a Cord. This method may be useful for getting // a `ChunkIterator` where range-based for-loops may not be available. - ChunkIterator chunk_end() const; - + ChunkIterator chunk_end() const; + //---------------------------------------------------------------------------- // Cord::ChunkIterator::ChunkRange //---------------------------------------------------------------------------- - // + // // `ChunkRange` is a helper class for iterating over the chunks of the `Cord`, // producing an iterator which can be used within a range-based for loop. // Construction of a `ChunkRange` will return an iterator pointing to the @@ -458,8 +458,8 @@ class Cord { // // Implementation note: `ChunkRange` is simply a convenience wrapper over // `Cord::chunk_begin()` and `Cord::chunk_end()`. - class ChunkRange { - public: + class ChunkRange { + public: // Fulfill minimum c++ container requirements [container.requirements] // Theses (partial) container type definitions allow ChunkRange to be used // in various utilities expecting a subset of [container.requirements]. @@ -470,40 +470,40 @@ class Cord { using iterator = ChunkIterator; using const_iterator = ChunkIterator; - explicit ChunkRange(const Cord* cord) : cord_(cord) {} - - ChunkIterator begin() const; - ChunkIterator end() const; - - private: - const Cord* cord_; - }; - + explicit ChunkRange(const Cord* cord) : cord_(cord) {} + + ChunkIterator begin() const; + ChunkIterator end() const; + + private: + const Cord* cord_; + }; + // Cord::Chunks() - // + // // Returns a `Cord::ChunkIterator::ChunkRange` for iterating over the chunks // of a `Cord` with a range-based for-loop. For most iteration tasks on a // Cord, use `Cord::Chunks()` to retrieve this iterator. // - // Example: - // - // void ProcessChunks(const Cord& cord) { - // for (y_absl::string_view chunk : cord.Chunks()) { ... } - // } - // - // Note that the ordinary caveats of temporary lifetime extension apply: - // - // void Process() { - // for (y_absl::string_view chunk : CordFactory().Chunks()) { - // // The temporary Cord returned by CordFactory has been destroyed! - // } - // } - ChunkRange Chunks() const; - + // Example: + // + // void ProcessChunks(const Cord& cord) { + // for (y_absl::string_view chunk : cord.Chunks()) { ... } + // } + // + // Note that the ordinary caveats of temporary lifetime extension apply: + // + // void Process() { + // for (y_absl::string_view chunk : CordFactory().Chunks()) { + // // The temporary Cord returned by CordFactory has been destroyed! + // } + // } + ChunkRange Chunks() const; + //---------------------------------------------------------------------------- // Cord::CharIterator //---------------------------------------------------------------------------- - // + // // A `Cord::CharIterator` allows iteration over the constituent characters of // a `Cord`. // @@ -518,79 +518,79 @@ class Cord { // * Two `CharIterator` objects can be compared equal if and only if they // remain valid and iterate over the same Cord. // * The iterator keeps state that can grow for Cords that contain many - // nodes and are imbalanced due to sharing. Prefer to pass this type by - // const reference instead of by value. + // nodes and are imbalanced due to sharing. Prefer to pass this type by + // const reference instead of by value. // * This type cannot act as a forward iterator because a `Cord` can reuse // sections of memory. This fact violates the requirement for forward // iterators to compare equal if dereferencing them returns the same // object. - class CharIterator { - public: - using iterator_category = std::input_iterator_tag; - using value_type = char; - using difference_type = ptrdiff_t; - using pointer = const char*; - using reference = const char&; - - CharIterator() = default; - - CharIterator& operator++(); - CharIterator operator++(int); - bool operator==(const CharIterator& other) const; - bool operator!=(const CharIterator& other) const; - reference operator*() const; - pointer operator->() const; - - friend Cord; - - private: - explicit CharIterator(const Cord* cord) : chunk_iterator_(cord) {} - - ChunkIterator chunk_iterator_; - }; - + class CharIterator { + public: + using iterator_category = std::input_iterator_tag; + using value_type = char; + using difference_type = ptrdiff_t; + using pointer = const char*; + using reference = const char&; + + CharIterator() = default; + + CharIterator& operator++(); + CharIterator operator++(int); + bool operator==(const CharIterator& other) const; + bool operator!=(const CharIterator& other) const; + reference operator*() const; + pointer operator->() const; + + friend Cord; + + private: + explicit CharIterator(const Cord* cord) : chunk_iterator_(cord) {} + + ChunkIterator chunk_iterator_; + }; + // Cord::CharIterator::AdvanceAndRead() - // + // // Advances the `Cord::CharIterator` by `n_bytes` and returns the bytes // advanced as a separate `Cord`. `n_bytes` must be less than or equal to the // number of bytes within the Cord; otherwise, behavior is undefined. It is // valid to pass `char_end()` and `0`. - static Cord AdvanceAndRead(CharIterator* it, size_t n_bytes); - + static Cord AdvanceAndRead(CharIterator* it, size_t n_bytes); + // Cord::CharIterator::Advance() - // + // // Advances the `Cord::CharIterator` by `n_bytes`. `n_bytes` must be less than // or equal to the number of bytes remaining within the Cord; otherwise, // behavior is undefined. It is valid to pass `char_end()` and `0`. - static void Advance(CharIterator* it, size_t n_bytes); - + static void Advance(CharIterator* it, size_t n_bytes); + // Cord::CharIterator::ChunkRemaining() // - // Returns the longest contiguous view starting at the iterator's position. - // - // `it` must be dereferenceable. - static y_absl::string_view ChunkRemaining(const CharIterator& it); - + // Returns the longest contiguous view starting at the iterator's position. + // + // `it` must be dereferenceable. + static y_absl::string_view ChunkRemaining(const CharIterator& it); + // Cord::CharIterator::char_begin() // - // Returns an iterator to the first character of the `Cord`. + // Returns an iterator to the first character of the `Cord`. // // Generally, prefer using `Cord::Chars()` within a range-based for loop for // iterating over the chunks of a Cord. This method may be useful for getting // a `CharIterator` where range-based for-loops may not be available. - CharIterator char_begin() const; + CharIterator char_begin() const; // Cord::CharIterator::char_end() // - // Returns an iterator to one past the last character of the `Cord`. + // Returns an iterator to one past the last character of the `Cord`. // // Generally, prefer using `Cord::Chars()` within a range-based for loop for // iterating over the chunks of a Cord. This method may be useful for getting // a `CharIterator` where range-based for-loops are not useful. - CharIterator char_end() const; - + CharIterator char_end() const; + // Cord::CharIterator::CharRange - // + // // `CharRange` is a helper class for iterating over the characters of a // producing an iterator which can be used within a range-based for loop. // Construction of a `CharRange` will return an iterator pointing to the first @@ -599,8 +599,8 @@ class Cord { // // Implementation note: `CharRange` is simply a convenience wrapper over // `Cord::char_begin()` and `Cord::char_end()`. - class CharRange { - public: + class CharRange { + public: // Fulfill minimum c++ container requirements [container.requirements] // Theses (partial) container type definitions allow CharRange to be used // in various utilities expecting a subset of [container.requirements]. @@ -611,36 +611,36 @@ class Cord { using iterator = CharIterator; using const_iterator = CharIterator; - explicit CharRange(const Cord* cord) : cord_(cord) {} - - CharIterator begin() const; - CharIterator end() const; - - private: - const Cord* cord_; - }; - + explicit CharRange(const Cord* cord) : cord_(cord) {} + + CharIterator begin() const; + CharIterator end() const; + + private: + const Cord* cord_; + }; + // Cord::CharIterator::Chars() - // + // // Returns a `Cord::CharIterator` for iterating over the characters of a // `Cord` with a range-based for-loop. For most character-based iteration // tasks on a Cord, use `Cord::Chars()` to retrieve this iterator. // - // Example: - // - // void ProcessCord(const Cord& cord) { - // for (char c : cord.Chars()) { ... } - // } - // - // Note that the ordinary caveats of temporary lifetime extension apply: - // - // void Process() { - // for (char c : CordFactory().Chars()) { - // // The temporary Cord returned by CordFactory has been destroyed! - // } - // } - CharRange Chars() const; - + // Example: + // + // void ProcessCord(const Cord& cord) { + // for (char c : cord.Chars()) { ... } + // } + // + // Note that the ordinary caveats of temporary lifetime extension apply: + // + // void Process() { + // for (char c : CordFactory().Chars()) { + // // The temporary Cord returned by CordFactory has been destroyed! + // } + // } + CharRange Chars() const; + // Cord::operator[] // // Gets the "i"th character of the Cord and returns it, provided that @@ -648,11 +648,11 @@ class Cord { // // NOTE: This routine is reasonably efficient. It is roughly // logarithmic based on the number of chunks that make up the cord. Still, - // if you need to iterate over the contents of a cord, you should + // if you need to iterate over the contents of a cord, you should // use a CharIterator/ChunkIterator rather than call operator[] or Get() // repeatedly in a loop. - char operator[](size_t i) const; - + char operator[](size_t i) const; + // Cord::TryFlat() // // If this cord's representation is a single flat array, returns a @@ -661,11 +661,11 @@ class Cord { // Cord::Flatten() // - // Flattens the cord into a single array and returns a view of the data. - // - // If the cord was already flat, the contents are not modified. - y_absl::string_view Flatten(); - + // Flattens the cord into a single array and returns a view of the data. + // + // If the cord was already flat, the contents are not modified. + y_absl::string_view Flatten(); + // Supports y_absl::Cord as a sink object for y_absl::Format(). friend void AbslFormatFlush(y_absl::Cord* cord, y_absl::string_view part) { cord->Append(part); @@ -688,7 +688,7 @@ class Cord { template <typename T> explicit constexpr Cord(strings_internal::StringConstant<T>); - private: + private: using CordRep = y_absl::cord_internal::CordRep; using CordRepFlat = y_absl::cord_internal::CordRepFlat; using CordzInfo = cord_internal::CordzInfo; @@ -701,56 +701,56 @@ class Cord { // public API call causing the cord to be created. explicit Cord(y_absl::string_view src, MethodIdentifier method); - friend class CordTestPeer; - friend bool operator==(const Cord& lhs, const Cord& rhs); - friend bool operator==(const Cord& lhs, y_absl::string_view rhs); - + friend class CordTestPeer; + friend bool operator==(const Cord& lhs, const Cord& rhs); + friend bool operator==(const Cord& lhs, y_absl::string_view rhs); + friend const CordzInfo* GetCordzInfoForTesting(const Cord& cord); // Calls the provided function once for each cord chunk, in order. Unlike - // Chunks(), this API will not allocate memory. - void ForEachChunk(y_absl::FunctionRef<void(y_absl::string_view)>) const; - - // Allocates new contiguous storage for the contents of the cord. This is - // called by Flatten() when the cord was not already flat. - y_absl::string_view FlattenSlowPath(); - - // Actual cord contents are hidden inside the following simple - // class so that we can isolate the bulk of cord.cc from changes - // to the representation. - // + // Chunks(), this API will not allocate memory. + void ForEachChunk(y_absl::FunctionRef<void(y_absl::string_view)>) const; + + // Allocates new contiguous storage for the contents of the cord. This is + // called by Flatten() when the cord was not already flat. + y_absl::string_view FlattenSlowPath(); + + // Actual cord contents are hidden inside the following simple + // class so that we can isolate the bulk of cord.cc from changes + // to the representation. + // // InlineRep holds either a tree pointer, or an array of kMaxInline bytes. - class InlineRep { - public: + class InlineRep { + public: static constexpr unsigned char kMaxInline = cord_internal::kMaxInline; - static_assert(kMaxInline >= sizeof(y_absl::cord_internal::CordRep*), ""); - + static_assert(kMaxInline >= sizeof(y_absl::cord_internal::CordRep*), ""); + constexpr InlineRep() : data_() {} explicit InlineRep(InlineData::DefaultInitType init) : data_(init) {} - InlineRep(const InlineRep& src); - InlineRep(InlineRep&& src); - InlineRep& operator=(const InlineRep& src); - InlineRep& operator=(InlineRep&& src) noexcept; - + InlineRep(const InlineRep& src); + InlineRep(InlineRep&& src); + InlineRep& operator=(const InlineRep& src); + InlineRep& operator=(InlineRep&& src) noexcept; + explicit constexpr InlineRep(cord_internal::InlineData data); - void Swap(InlineRep* rhs); - bool empty() const; - size_t size() const; - const char* data() const; // Returns nullptr if holding pointer - void set_data(const char* data, size_t n, - bool nullify_tail); // Discards pointer, if any + void Swap(InlineRep* rhs); + bool empty() const; + size_t size() const; + const char* data() const; // Returns nullptr if holding pointer + void set_data(const char* data, size_t n, + bool nullify_tail); // Discards pointer, if any char* set_data(size_t n); // Write data to the result - // Returns nullptr if holding bytes - y_absl::cord_internal::CordRep* tree() const; + // Returns nullptr if holding bytes + y_absl::cord_internal::CordRep* tree() const; y_absl::cord_internal::CordRep* as_tree() const; - // Returns non-null iff was holding a pointer - y_absl::cord_internal::CordRep* clear(); + // Returns non-null iff was holding a pointer + y_absl::cord_internal::CordRep* clear(); // Converts to pointer if necessary. void reduce_size(size_t n); // REQUIRES: holding data - void remove_prefix(size_t n); // REQUIRES: holding data + void remove_prefix(size_t n); // REQUIRES: holding data void AppendArray(y_absl::string_view src, MethodIdentifier method); - y_absl::string_view FindFlatStartPiece() const; + y_absl::string_view FindFlatStartPiece() const; // Creates a CordRepFlat instance from the current inlined data with `extra' // bytes of desired additional capacity. @@ -794,40 +794,40 @@ class Cord { template <bool has_length> void GetAppendRegion(char** region, size_t* size, size_t length); - bool IsSame(const InlineRep& other) const { + bool IsSame(const InlineRep& other) const { return memcmp(&data_, &other.data_, sizeof(data_)) == 0; - } - int BitwiseCompare(const InlineRep& other) const { - uint64_t x, y; + } + int BitwiseCompare(const InlineRep& other) const { + uint64_t x, y; // Use memcpy to avoid aliasing issues. memcpy(&x, &data_, sizeof(x)); memcpy(&y, &other.data_, sizeof(y)); - if (x == y) { + if (x == y) { memcpy(&x, reinterpret_cast<const char*>(&data_) + 8, sizeof(x)); memcpy(&y, reinterpret_cast<const char*>(&other.data_) + 8, sizeof(y)); - if (x == y) return 0; - } - return y_absl::big_endian::FromHost64(x) < y_absl::big_endian::FromHost64(y) - ? -1 - : 1; - } - void CopyTo(TString* dst) const { - // memcpy is much faster when operating on a known size. On most supported + if (x == y) return 0; + } + return y_absl::big_endian::FromHost64(x) < y_absl::big_endian::FromHost64(y) + ? -1 + : 1; + } + void CopyTo(TString* dst) const { + // memcpy is much faster when operating on a known size. On most supported // platforms, the small string optimization is large enough that resizing - // to 15 bytes does not cause a memory allocation. - y_absl::strings_internal::STLStringResizeUninitialized(dst, - sizeof(data_) - 1); + // to 15 bytes does not cause a memory allocation. + y_absl::strings_internal::STLStringResizeUninitialized(dst, + sizeof(data_) - 1); memcpy(&(*dst)[0], &data_, sizeof(data_) - 1); - // erase is faster than resize because the logic for memory allocation is - // not needed. + // erase is faster than resize because the logic for memory allocation is + // not needed. dst->erase(inline_size()); - } - - // Copies the inline contents into `dst`. Assumes the cord is not empty. - void CopyToArray(char* dst) const; - + } + + // Copies the inline contents into `dst`. Assumes the cord is not empty. + void CopyToArray(char* dst) const; + bool is_tree() const { return data_.is_tree(); } - + // Returns true if the Cord is being profiled by cordz. bool is_profiled() const { return data_.is_tree() && data_.is_profiled(); } @@ -845,61 +845,61 @@ class Cord { // Resets the current cordz_info to null / empty. void clear_cordz_info() { data_.clear_cordz_info(); } - private: - friend class Cord; - - void AssignSlow(const InlineRep& src); + private: + friend class Cord; + + void AssignSlow(const InlineRep& src); // Unrefs the tree and stops profiling. void UnrefTree(); - + void ResetToEmpty() { data_ = {}; } void set_inline_size(size_t size) { data_.set_inline_size(size); } size_t inline_size() const { return data_.inline_size(); } cord_internal::InlineData data_; - }; - InlineRep contents_; - + }; + InlineRep contents_; + // Helper for MemoryUsage(). - static size_t MemoryUsageAux(const y_absl::cord_internal::CordRep* rep); - + static size_t MemoryUsageAux(const y_absl::cord_internal::CordRep* rep); + // Helper for GetFlat() and TryFlat(). - static bool GetFlatAux(y_absl::cord_internal::CordRep* rep, - y_absl::string_view* fragment); - + static bool GetFlatAux(y_absl::cord_internal::CordRep* rep, + y_absl::string_view* fragment); + // Helper for ForEachChunk(). - static void ForEachChunkAux( - y_absl::cord_internal::CordRep* rep, - y_absl::FunctionRef<void(y_absl::string_view)> callback); - - // The destructor for non-empty Cords. - void DestroyCordSlow(); - - // Out-of-line implementation of slower parts of logic. - void CopyToArraySlowPath(char* dst) const; - int CompareSlowPath(y_absl::string_view rhs, size_t compared_size, - size_t size_to_compare) const; - int CompareSlowPath(const Cord& rhs, size_t compared_size, - size_t size_to_compare) const; - bool EqualsImpl(y_absl::string_view rhs, size_t size_to_compare) const; - bool EqualsImpl(const Cord& rhs, size_t size_to_compare) const; - int CompareImpl(const Cord& rhs) const; - - template <typename ResultType, typename RHS> - friend ResultType GenericCompare(const Cord& lhs, const RHS& rhs, - size_t size_to_compare); - static y_absl::string_view GetFirstChunk(const Cord& c); - static y_absl::string_view GetFirstChunk(y_absl::string_view sv); - - // Returns a new reference to contents_.tree(), or steals an existing - // reference if called on an rvalue. - y_absl::cord_internal::CordRep* TakeRep() const&; - y_absl::cord_internal::CordRep* TakeRep() &&; - + static void ForEachChunkAux( + y_absl::cord_internal::CordRep* rep, + y_absl::FunctionRef<void(y_absl::string_view)> callback); + + // The destructor for non-empty Cords. + void DestroyCordSlow(); + + // Out-of-line implementation of slower parts of logic. + void CopyToArraySlowPath(char* dst) const; + int CompareSlowPath(y_absl::string_view rhs, size_t compared_size, + size_t size_to_compare) const; + int CompareSlowPath(const Cord& rhs, size_t compared_size, + size_t size_to_compare) const; + bool EqualsImpl(y_absl::string_view rhs, size_t size_to_compare) const; + bool EqualsImpl(const Cord& rhs, size_t size_to_compare) const; + int CompareImpl(const Cord& rhs) const; + + template <typename ResultType, typename RHS> + friend ResultType GenericCompare(const Cord& lhs, const RHS& rhs, + size_t size_to_compare); + static y_absl::string_view GetFirstChunk(const Cord& c); + static y_absl::string_view GetFirstChunk(y_absl::string_view sv); + + // Returns a new reference to contents_.tree(), or steals an existing + // reference if called on an rvalue. + y_absl::cord_internal::CordRep* TakeRep() const&; + y_absl::cord_internal::CordRep* TakeRep() &&; + // Helper for Append(). - template <typename C> - void AppendImpl(C&& src); + template <typename C> + void AppendImpl(C&& src); // Prepends the provided data to this instance. `method` contains the public // API method for this action which is tracked for Cordz sampling purposes. @@ -919,106 +919,106 @@ class Cord { }); return H::combine(combiner.finalize(std::move(hash_state)), size()); } -}; - -ABSL_NAMESPACE_END -} // namespace y_absl - -namespace y_absl { -ABSL_NAMESPACE_BEGIN - -// allow a Cord to be logged -extern std::ostream& operator<<(std::ostream& out, const Cord& cord); - -// ------------------------------------------------------------------ -// Internal details follow. Clients should ignore. - -namespace cord_internal { - -// Fast implementation of memmove for up to 15 bytes. This implementation is -// safe for overlapping regions. If nullify_tail is true, the destination is -// padded with '\0' up to 16 bytes. -inline void SmallMemmove(char* dst, const char* src, size_t n, - bool nullify_tail = false) { - if (n >= 8) { - assert(n <= 16); - uint64_t buf1; - uint64_t buf2; - memcpy(&buf1, src, 8); - memcpy(&buf2, src + n - 8, 8); - if (nullify_tail) { - memset(dst + 8, 0, 8); - } - memcpy(dst, &buf1, 8); - memcpy(dst + n - 8, &buf2, 8); - } else if (n >= 4) { - uint32_t buf1; - uint32_t buf2; - memcpy(&buf1, src, 4); - memcpy(&buf2, src + n - 4, 4); - if (nullify_tail) { - memset(dst + 4, 0, 4); - memset(dst + 8, 0, 8); - } - memcpy(dst, &buf1, 4); - memcpy(dst + n - 4, &buf2, 4); - } else { - if (n != 0) { - dst[0] = src[0]; - dst[n / 2] = src[n / 2]; - dst[n - 1] = src[n - 1]; - } - if (nullify_tail) { - memset(dst + 8, 0, 8); - memset(dst + n, 0, 8); - } - } -} - +}; + +ABSL_NAMESPACE_END +} // namespace y_absl + +namespace y_absl { +ABSL_NAMESPACE_BEGIN + +// allow a Cord to be logged +extern std::ostream& operator<<(std::ostream& out, const Cord& cord); + +// ------------------------------------------------------------------ +// Internal details follow. Clients should ignore. + +namespace cord_internal { + +// Fast implementation of memmove for up to 15 bytes. This implementation is +// safe for overlapping regions. If nullify_tail is true, the destination is +// padded with '\0' up to 16 bytes. +inline void SmallMemmove(char* dst, const char* src, size_t n, + bool nullify_tail = false) { + if (n >= 8) { + assert(n <= 16); + uint64_t buf1; + uint64_t buf2; + memcpy(&buf1, src, 8); + memcpy(&buf2, src + n - 8, 8); + if (nullify_tail) { + memset(dst + 8, 0, 8); + } + memcpy(dst, &buf1, 8); + memcpy(dst + n - 8, &buf2, 8); + } else if (n >= 4) { + uint32_t buf1; + uint32_t buf2; + memcpy(&buf1, src, 4); + memcpy(&buf2, src + n - 4, 4); + if (nullify_tail) { + memset(dst + 4, 0, 4); + memset(dst + 8, 0, 8); + } + memcpy(dst, &buf1, 4); + memcpy(dst + n - 4, &buf2, 4); + } else { + if (n != 0) { + dst[0] = src[0]; + dst[n / 2] = src[n / 2]; + dst[n - 1] = src[n - 1]; + } + if (nullify_tail) { + memset(dst + 8, 0, 8); + memset(dst + n, 0, 8); + } + } +} + // Does non-template-specific `CordRepExternal` initialization. -// Expects `data` to be non-empty. +// Expects `data` to be non-empty. void InitializeCordRepExternal(y_absl::string_view data, CordRepExternal* rep); - -// Creates a new `CordRep` that owns `data` and `releaser` and returns a pointer -// to it, or `nullptr` if `data` was empty. -template <typename Releaser> -// NOLINTNEXTLINE - suppress clang-tidy raw pointer return. -CordRep* NewExternalRep(y_absl::string_view data, Releaser&& releaser) { - using ReleaserType = y_absl::decay_t<Releaser>; - if (data.empty()) { - // Never create empty external nodes. + +// Creates a new `CordRep` that owns `data` and `releaser` and returns a pointer +// to it, or `nullptr` if `data` was empty. +template <typename Releaser> +// NOLINTNEXTLINE - suppress clang-tidy raw pointer return. +CordRep* NewExternalRep(y_absl::string_view data, Releaser&& releaser) { + using ReleaserType = y_absl::decay_t<Releaser>; + if (data.empty()) { + // Never create empty external nodes. InvokeReleaser(Rank0{}, ReleaserType(std::forward<Releaser>(releaser)), data); - return nullptr; - } - + return nullptr; + } + CordRepExternal* rep = new CordRepExternalImpl<ReleaserType>( std::forward<Releaser>(releaser), 0); InitializeCordRepExternal(data, rep); return rep; -} - -// Overload for function reference types that dispatches using a function -// pointer because there are no `alignof()` or `sizeof()` a function reference. -// NOLINTNEXTLINE - suppress clang-tidy raw pointer return. -inline CordRep* NewExternalRep(y_absl::string_view data, - void (&releaser)(y_absl::string_view)) { - return NewExternalRep(data, &releaser); -} - -} // namespace cord_internal - -template <typename Releaser> -Cord MakeCordFromExternal(y_absl::string_view data, Releaser&& releaser) { - Cord cord; +} + +// Overload for function reference types that dispatches using a function +// pointer because there are no `alignof()` or `sizeof()` a function reference. +// NOLINTNEXTLINE - suppress clang-tidy raw pointer return. +inline CordRep* NewExternalRep(y_absl::string_view data, + void (&releaser)(y_absl::string_view)) { + return NewExternalRep(data, &releaser); +} + +} // namespace cord_internal + +template <typename Releaser> +Cord MakeCordFromExternal(y_absl::string_view data, Releaser&& releaser) { + Cord cord; if (auto* rep = ::y_absl::cord_internal::NewExternalRep( data, std::forward<Releaser>(releaser))) { cord.contents_.EmplaceTree(rep, Cord::MethodIdentifier::kMakeCordFromExternal); } - return cord; -} - + return cord; +} + constexpr Cord::InlineRep::InlineRep(cord_internal::InlineData data) : data_(data) {} @@ -1030,64 +1030,64 @@ inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) } else { data_ = src.data_; } -} - +} + inline Cord::InlineRep::InlineRep(Cord::InlineRep&& src) : data_(src.data_) { src.ResetToEmpty(); -} - -inline Cord::InlineRep& Cord::InlineRep::operator=(const Cord::InlineRep& src) { - if (this == &src) { - return *this; - } - if (!is_tree() && !src.is_tree()) { +} + +inline Cord::InlineRep& Cord::InlineRep::operator=(const Cord::InlineRep& src) { + if (this == &src) { + return *this; + } + if (!is_tree() && !src.is_tree()) { data_ = src.data_; - return *this; - } - AssignSlow(src); - return *this; -} - -inline Cord::InlineRep& Cord::InlineRep::operator=( - Cord::InlineRep&& src) noexcept { - if (is_tree()) { + return *this; + } + AssignSlow(src); + return *this; +} + +inline Cord::InlineRep& Cord::InlineRep::operator=( + Cord::InlineRep&& src) noexcept { + if (is_tree()) { UnrefTree(); - } + } data_ = src.data_; src.ResetToEmpty(); - return *this; -} - -inline void Cord::InlineRep::Swap(Cord::InlineRep* rhs) { - if (rhs == this) { - return; - } + return *this; +} + +inline void Cord::InlineRep::Swap(Cord::InlineRep* rhs) { + if (rhs == this) { + return; + } std::swap(data_, rhs->data_); -} - -inline const char* Cord::InlineRep::data() const { +} + +inline const char* Cord::InlineRep::data() const { return is_tree() ? nullptr : data_.as_chars(); -} - +} + inline y_absl::cord_internal::CordRep* Cord::InlineRep::as_tree() const { assert(data_.is_tree()); return data_.as_tree(); } -inline y_absl::cord_internal::CordRep* Cord::InlineRep::tree() const { - if (is_tree()) { +inline y_absl::cord_internal::CordRep* Cord::InlineRep::tree() const { + if (is_tree()) { return as_tree(); - } else { - return nullptr; - } -} - + } else { + return nullptr; + } +} + inline bool Cord::InlineRep::empty() const { return data_.is_empty(); } - -inline size_t Cord::InlineRep::size() const { + +inline size_t Cord::InlineRep::size() const { return is_tree() ? as_tree()->length : inline_size(); -} - +} + inline cord_internal::CordRepFlat* Cord::InlineRep::MakeFlatWithExtraCapacity( size_t extra) { static_assert(cord_internal::kMinFlatLength >= sizeof(data_), ""); @@ -1124,12 +1124,12 @@ inline void Cord::InlineRep::SetTreeOrEmpty(CordRep* rep, assert(data_.is_tree()); if (rep) { data_.set_tree(rep); - } else { + } else { data_ = {}; - } + } scope.SetCordRep(rep); -} - +} + inline void Cord::InlineRep::CommitTree(const CordRep* old_rep, CordRep* rep, const CordzUpdateScope& scope, MethodIdentifier method) { @@ -1137,27 +1137,27 @@ inline void Cord::InlineRep::CommitTree(const CordRep* old_rep, CordRep* rep, SetTree(rep, scope); } else { EmplaceTree(rep, method); - } -} - -inline y_absl::cord_internal::CordRep* Cord::InlineRep::clear() { + } +} + +inline y_absl::cord_internal::CordRep* Cord::InlineRep::clear() { if (is_tree()) { CordzInfo::MaybeUntrackCord(cordz_info()); } y_absl::cord_internal::CordRep* result = tree(); ResetToEmpty(); - return result; -} - -inline void Cord::InlineRep::CopyToArray(char* dst) const { - assert(!is_tree()); + return result; +} + +inline void Cord::InlineRep::CopyToArray(char* dst) const { + assert(!is_tree()); size_t n = inline_size(); - assert(n != 0); + assert(n != 0); cord_internal::SmallMemmove(dst, data_.as_chars(), n); -} - -constexpr inline Cord::Cord() noexcept {} - +} + +constexpr inline Cord::Cord() noexcept {} + inline Cord::Cord(y_absl::string_view src) : Cord(src, CordzUpdateTracker::kConstructorString) {} @@ -1171,11 +1171,11 @@ constexpr Cord::Cord(strings_internal::StringConstant<T>) &cord_internal::ConstInitExternalStorage< strings_internal::StringConstant<T>>::value)) {} -inline Cord& Cord::operator=(const Cord& x) { - contents_ = x.contents_; - return *this; -} - +inline Cord& Cord::operator=(const Cord& x) { + contents_ = x.contents_; + return *this; +} + template <typename T, Cord::EnableIfString<T>> Cord& Cord::operator=(T&& src) { if (src.size() <= cord_internal::kMaxBytesToCopy) { @@ -1187,34 +1187,34 @@ Cord& Cord::operator=(T&& src) { inline Cord::Cord(const Cord& src) : contents_(src.contents_) {} -inline Cord::Cord(Cord&& src) noexcept : contents_(std::move(src.contents_)) {} - +inline Cord::Cord(Cord&& src) noexcept : contents_(std::move(src.contents_)) {} + inline void Cord::swap(Cord& other) noexcept { contents_.Swap(&other.contents_); } -inline Cord& Cord::operator=(Cord&& x) noexcept { - contents_ = std::move(x.contents_); - return *this; -} - +inline Cord& Cord::operator=(Cord&& x) noexcept { + contents_ = std::move(x.contents_); + return *this; +} + extern template Cord::Cord(TString&& src); - -inline size_t Cord::size() const { - // Length is 1st field in str.rep_ - return contents_.size(); -} - -inline bool Cord::empty() const { return contents_.empty(); } - -inline size_t Cord::EstimatedMemoryUsage() const { - size_t result = sizeof(Cord); - if (const y_absl::cord_internal::CordRep* rep = contents_.tree()) { - result += MemoryUsageAux(rep); - } - return result; -} - + +inline size_t Cord::size() const { + // Length is 1st field in str.rep_ + return contents_.size(); +} + +inline bool Cord::empty() const { return contents_.empty(); } + +inline size_t Cord::EstimatedMemoryUsage() const { + size_t result = sizeof(Cord); + if (const y_absl::cord_internal::CordRep* rep = contents_.tree()) { + result += MemoryUsageAux(rep); + } + return result; +} + inline y_absl::optional<y_absl::string_view> Cord::TryFlat() const { y_absl::cord_internal::CordRep* rep = contents_.tree(); if (rep == nullptr) { @@ -1227,52 +1227,52 @@ inline y_absl::optional<y_absl::string_view> Cord::TryFlat() const { return y_absl::nullopt; } -inline y_absl::string_view Cord::Flatten() { - y_absl::cord_internal::CordRep* rep = contents_.tree(); - if (rep == nullptr) { - return y_absl::string_view(contents_.data(), contents_.size()); - } else { - y_absl::string_view already_flat_contents; - if (GetFlatAux(rep, &already_flat_contents)) { - return already_flat_contents; - } - } - return FlattenSlowPath(); -} - -inline void Cord::Append(y_absl::string_view src) { +inline y_absl::string_view Cord::Flatten() { + y_absl::cord_internal::CordRep* rep = contents_.tree(); + if (rep == nullptr) { + return y_absl::string_view(contents_.data(), contents_.size()); + } else { + y_absl::string_view already_flat_contents; + if (GetFlatAux(rep, &already_flat_contents)) { + return already_flat_contents; + } + } + return FlattenSlowPath(); +} + +inline void Cord::Append(y_absl::string_view src) { contents_.AppendArray(src, CordzUpdateTracker::kAppendString); -} - +} + inline void Cord::Prepend(y_absl::string_view src) { PrependArray(src, CordzUpdateTracker::kPrependString); } extern template void Cord::Append(TString&& src); extern template void Cord::Prepend(TString&& src); - -inline int Cord::Compare(const Cord& rhs) const { - if (!contents_.is_tree() && !rhs.contents_.is_tree()) { - return contents_.BitwiseCompare(rhs.contents_); - } - - return CompareImpl(rhs); -} - -// Does 'this' cord start/end with rhs -inline bool Cord::StartsWith(const Cord& rhs) const { - if (contents_.IsSame(rhs.contents_)) return true; - size_t rhs_size = rhs.size(); - if (size() < rhs_size) return false; - return EqualsImpl(rhs, rhs_size); -} - -inline bool Cord::StartsWith(y_absl::string_view rhs) const { - size_t rhs_size = rhs.size(); - if (size() < rhs_size) return false; - return EqualsImpl(rhs, rhs_size); -} - + +inline int Cord::Compare(const Cord& rhs) const { + if (!contents_.is_tree() && !rhs.contents_.is_tree()) { + return contents_.BitwiseCompare(rhs.contents_); + } + + return CompareImpl(rhs); +} + +// Does 'this' cord start/end with rhs +inline bool Cord::StartsWith(const Cord& rhs) const { + if (contents_.IsSame(rhs.contents_)) return true; + size_t rhs_size = rhs.size(); + if (size() < rhs_size) return false; + return EqualsImpl(rhs, rhs_size); +} + +inline bool Cord::StartsWith(y_absl::string_view rhs) const { + size_t rhs_size = rhs.size(); + if (size() < rhs_size) return false; + return EqualsImpl(rhs, rhs_size); +} + inline void Cord::ChunkIterator::InitTree(cord_internal::CordRep* tree) { if (tree->tag == cord_internal::BTREE) { current_chunk_ = btree_reader_.Init(tree->btree()); @@ -1288,16 +1288,16 @@ inline Cord::ChunkIterator::ChunkIterator(cord_internal::CordRep* tree) InitTree(tree); } -inline Cord::ChunkIterator::ChunkIterator(const Cord* cord) - : bytes_remaining_(cord->size()) { - if (cord->contents_.is_tree()) { +inline Cord::ChunkIterator::ChunkIterator(const Cord* cord) + : bytes_remaining_(cord->size()) { + if (cord->contents_.is_tree()) { InitTree(cord->contents_.as_tree()); - } else { + } else { current_chunk_ = y_absl::string_view(cord->contents_.data(), bytes_remaining_); - } -} - + } +} + inline Cord::ChunkIterator& Cord::ChunkIterator::AdvanceBtree() { current_chunk_ = btree_reader_.Next(); return *this; @@ -1331,191 +1331,191 @@ inline Cord::ChunkIterator& Cord::ChunkIterator::operator++() { return *this; } -inline Cord::ChunkIterator Cord::ChunkIterator::operator++(int) { - ChunkIterator tmp(*this); - operator++(); - return tmp; -} - -inline bool Cord::ChunkIterator::operator==(const ChunkIterator& other) const { - return bytes_remaining_ == other.bytes_remaining_; -} - -inline bool Cord::ChunkIterator::operator!=(const ChunkIterator& other) const { - return !(*this == other); -} - -inline Cord::ChunkIterator::reference Cord::ChunkIterator::operator*() const { +inline Cord::ChunkIterator Cord::ChunkIterator::operator++(int) { + ChunkIterator tmp(*this); + operator++(); + return tmp; +} + +inline bool Cord::ChunkIterator::operator==(const ChunkIterator& other) const { + return bytes_remaining_ == other.bytes_remaining_; +} + +inline bool Cord::ChunkIterator::operator!=(const ChunkIterator& other) const { + return !(*this == other); +} + +inline Cord::ChunkIterator::reference Cord::ChunkIterator::operator*() const { ABSL_HARDENING_ASSERT(bytes_remaining_ != 0); - return current_chunk_; -} - -inline Cord::ChunkIterator::pointer Cord::ChunkIterator::operator->() const { + return current_chunk_; +} + +inline Cord::ChunkIterator::pointer Cord::ChunkIterator::operator->() const { ABSL_HARDENING_ASSERT(bytes_remaining_ != 0); - return ¤t_chunk_; -} - -inline void Cord::ChunkIterator::RemoveChunkPrefix(size_t n) { - assert(n < current_chunk_.size()); - current_chunk_.remove_prefix(n); - bytes_remaining_ -= n; -} - -inline void Cord::ChunkIterator::AdvanceBytes(size_t n) { + return ¤t_chunk_; +} + +inline void Cord::ChunkIterator::RemoveChunkPrefix(size_t n) { + assert(n < current_chunk_.size()); + current_chunk_.remove_prefix(n); + bytes_remaining_ -= n; +} + +inline void Cord::ChunkIterator::AdvanceBytes(size_t n) { assert(bytes_remaining_ >= n); - if (ABSL_PREDICT_TRUE(n < current_chunk_.size())) { - RemoveChunkPrefix(n); - } else if (n != 0) { + if (ABSL_PREDICT_TRUE(n < current_chunk_.size())) { + RemoveChunkPrefix(n); + } else if (n != 0) { btree_reader_ ? AdvanceBytesBtree(n) : AdvanceBytesSlowPath(n); - } -} - -inline Cord::ChunkIterator Cord::chunk_begin() const { - return ChunkIterator(this); -} - -inline Cord::ChunkIterator Cord::chunk_end() const { return ChunkIterator(); } - -inline Cord::ChunkIterator Cord::ChunkRange::begin() const { - return cord_->chunk_begin(); -} - -inline Cord::ChunkIterator Cord::ChunkRange::end() const { - return cord_->chunk_end(); -} - -inline Cord::ChunkRange Cord::Chunks() const { return ChunkRange(this); } - -inline Cord::CharIterator& Cord::CharIterator::operator++() { - if (ABSL_PREDICT_TRUE(chunk_iterator_->size() > 1)) { - chunk_iterator_.RemoveChunkPrefix(1); - } else { - ++chunk_iterator_; - } - return *this; -} - -inline Cord::CharIterator Cord::CharIterator::operator++(int) { - CharIterator tmp(*this); - operator++(); - return tmp; -} - -inline bool Cord::CharIterator::operator==(const CharIterator& other) const { - return chunk_iterator_ == other.chunk_iterator_; -} - -inline bool Cord::CharIterator::operator!=(const CharIterator& other) const { - return !(*this == other); -} - -inline Cord::CharIterator::reference Cord::CharIterator::operator*() const { - return *chunk_iterator_->data(); -} - -inline Cord::CharIterator::pointer Cord::CharIterator::operator->() const { - return chunk_iterator_->data(); -} - -inline Cord Cord::AdvanceAndRead(CharIterator* it, size_t n_bytes) { - assert(it != nullptr); - return it->chunk_iterator_.AdvanceAndReadBytes(n_bytes); -} - -inline void Cord::Advance(CharIterator* it, size_t n_bytes) { - assert(it != nullptr); - it->chunk_iterator_.AdvanceBytes(n_bytes); -} - -inline y_absl::string_view Cord::ChunkRemaining(const CharIterator& it) { - return *it.chunk_iterator_; -} - -inline Cord::CharIterator Cord::char_begin() const { - return CharIterator(this); -} - -inline Cord::CharIterator Cord::char_end() const { return CharIterator(); } - -inline Cord::CharIterator Cord::CharRange::begin() const { - return cord_->char_begin(); -} - -inline Cord::CharIterator Cord::CharRange::end() const { - return cord_->char_end(); -} - -inline Cord::CharRange Cord::Chars() const { return CharRange(this); } - -inline void Cord::ForEachChunk( - y_absl::FunctionRef<void(y_absl::string_view)> callback) const { - y_absl::cord_internal::CordRep* rep = contents_.tree(); - if (rep == nullptr) { - callback(y_absl::string_view(contents_.data(), contents_.size())); - } else { - return ForEachChunkAux(rep, callback); - } -} - -// Nonmember Cord-to-Cord relational operarators. -inline bool operator==(const Cord& lhs, const Cord& rhs) { - if (lhs.contents_.IsSame(rhs.contents_)) return true; - size_t rhs_size = rhs.size(); - if (lhs.size() != rhs_size) return false; - return lhs.EqualsImpl(rhs, rhs_size); -} - -inline bool operator!=(const Cord& x, const Cord& y) { return !(x == y); } + } +} + +inline Cord::ChunkIterator Cord::chunk_begin() const { + return ChunkIterator(this); +} + +inline Cord::ChunkIterator Cord::chunk_end() const { return ChunkIterator(); } + +inline Cord::ChunkIterator Cord::ChunkRange::begin() const { + return cord_->chunk_begin(); +} + +inline Cord::ChunkIterator Cord::ChunkRange::end() const { + return cord_->chunk_end(); +} + +inline Cord::ChunkRange Cord::Chunks() const { return ChunkRange(this); } + +inline Cord::CharIterator& Cord::CharIterator::operator++() { + if (ABSL_PREDICT_TRUE(chunk_iterator_->size() > 1)) { + chunk_iterator_.RemoveChunkPrefix(1); + } else { + ++chunk_iterator_; + } + return *this; +} + +inline Cord::CharIterator Cord::CharIterator::operator++(int) { + CharIterator tmp(*this); + operator++(); + return tmp; +} + +inline bool Cord::CharIterator::operator==(const CharIterator& other) const { + return chunk_iterator_ == other.chunk_iterator_; +} + +inline bool Cord::CharIterator::operator!=(const CharIterator& other) const { + return !(*this == other); +} + +inline Cord::CharIterator::reference Cord::CharIterator::operator*() const { + return *chunk_iterator_->data(); +} + +inline Cord::CharIterator::pointer Cord::CharIterator::operator->() const { + return chunk_iterator_->data(); +} + +inline Cord Cord::AdvanceAndRead(CharIterator* it, size_t n_bytes) { + assert(it != nullptr); + return it->chunk_iterator_.AdvanceAndReadBytes(n_bytes); +} + +inline void Cord::Advance(CharIterator* it, size_t n_bytes) { + assert(it != nullptr); + it->chunk_iterator_.AdvanceBytes(n_bytes); +} + +inline y_absl::string_view Cord::ChunkRemaining(const CharIterator& it) { + return *it.chunk_iterator_; +} + +inline Cord::CharIterator Cord::char_begin() const { + return CharIterator(this); +} + +inline Cord::CharIterator Cord::char_end() const { return CharIterator(); } + +inline Cord::CharIterator Cord::CharRange::begin() const { + return cord_->char_begin(); +} + +inline Cord::CharIterator Cord::CharRange::end() const { + return cord_->char_end(); +} + +inline Cord::CharRange Cord::Chars() const { return CharRange(this); } + +inline void Cord::ForEachChunk( + y_absl::FunctionRef<void(y_absl::string_view)> callback) const { + y_absl::cord_internal::CordRep* rep = contents_.tree(); + if (rep == nullptr) { + callback(y_absl::string_view(contents_.data(), contents_.size())); + } else { + return ForEachChunkAux(rep, callback); + } +} + +// Nonmember Cord-to-Cord relational operarators. +inline bool operator==(const Cord& lhs, const Cord& rhs) { + if (lhs.contents_.IsSame(rhs.contents_)) return true; + size_t rhs_size = rhs.size(); + if (lhs.size() != rhs_size) return false; + return lhs.EqualsImpl(rhs, rhs_size); +} + +inline bool operator!=(const Cord& x, const Cord& y) { return !(x == y); } inline bool operator<(const Cord& x, const Cord& y) { return x.Compare(y) < 0; } inline bool operator>(const Cord& x, const Cord& y) { return x.Compare(y) > 0; } -inline bool operator<=(const Cord& x, const Cord& y) { - return x.Compare(y) <= 0; -} -inline bool operator>=(const Cord& x, const Cord& y) { - return x.Compare(y) >= 0; -} - -// Nonmember Cord-to-y_absl::string_view relational operators. -// -// Due to implicit conversions, these also enable comparisons of Cord with -// with TString, ::string, and const char*. -inline bool operator==(const Cord& lhs, y_absl::string_view rhs) { - size_t lhs_size = lhs.size(); - size_t rhs_size = rhs.size(); - if (lhs_size != rhs_size) return false; - return lhs.EqualsImpl(rhs, rhs_size); -} - -inline bool operator==(y_absl::string_view x, const Cord& y) { return y == x; } -inline bool operator!=(const Cord& x, y_absl::string_view y) { return !(x == y); } -inline bool operator!=(y_absl::string_view x, const Cord& y) { return !(x == y); } -inline bool operator<(const Cord& x, y_absl::string_view y) { - return x.Compare(y) < 0; -} -inline bool operator<(y_absl::string_view x, const Cord& y) { - return y.Compare(x) > 0; -} -inline bool operator>(const Cord& x, y_absl::string_view y) { return y < x; } -inline bool operator>(y_absl::string_view x, const Cord& y) { return y < x; } -inline bool operator<=(const Cord& x, y_absl::string_view y) { return !(y < x); } -inline bool operator<=(y_absl::string_view x, const Cord& y) { return !(y < x); } -inline bool operator>=(const Cord& x, y_absl::string_view y) { return !(x < y); } -inline bool operator>=(y_absl::string_view x, const Cord& y) { return !(x < y); } - -// Some internals exposed to test code. -namespace strings_internal { -class CordTestAccess { - public: - static size_t FlatOverhead(); - static size_t MaxFlatLength(); - static size_t SizeofCordRepConcat(); - static size_t SizeofCordRepExternal(); - static size_t SizeofCordRepSubstring(); - static size_t FlatTagToLength(uint8_t tag); - static uint8_t LengthToTag(size_t s); -}; -} // namespace strings_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_STRINGS_CORD_H_ +inline bool operator<=(const Cord& x, const Cord& y) { + return x.Compare(y) <= 0; +} +inline bool operator>=(const Cord& x, const Cord& y) { + return x.Compare(y) >= 0; +} + +// Nonmember Cord-to-y_absl::string_view relational operators. +// +// Due to implicit conversions, these also enable comparisons of Cord with +// with TString, ::string, and const char*. +inline bool operator==(const Cord& lhs, y_absl::string_view rhs) { + size_t lhs_size = lhs.size(); + size_t rhs_size = rhs.size(); + if (lhs_size != rhs_size) return false; + return lhs.EqualsImpl(rhs, rhs_size); +} + +inline bool operator==(y_absl::string_view x, const Cord& y) { return y == x; } +inline bool operator!=(const Cord& x, y_absl::string_view y) { return !(x == y); } +inline bool operator!=(y_absl::string_view x, const Cord& y) { return !(x == y); } +inline bool operator<(const Cord& x, y_absl::string_view y) { + return x.Compare(y) < 0; +} +inline bool operator<(y_absl::string_view x, const Cord& y) { + return y.Compare(x) > 0; +} +inline bool operator>(const Cord& x, y_absl::string_view y) { return y < x; } +inline bool operator>(y_absl::string_view x, const Cord& y) { return y < x; } +inline bool operator<=(const Cord& x, y_absl::string_view y) { return !(y < x); } +inline bool operator<=(y_absl::string_view x, const Cord& y) { return !(y < x); } +inline bool operator>=(const Cord& x, y_absl::string_view y) { return !(x < y); } +inline bool operator>=(y_absl::string_view x, const Cord& y) { return !(x < y); } + +// Some internals exposed to test code. +namespace strings_internal { +class CordTestAccess { + public: + static size_t FlatOverhead(); + static size_t MaxFlatLength(); + static size_t SizeofCordRepConcat(); + static size_t SizeofCordRepExternal(); + static size_t SizeofCordRepSubstring(); + static size_t FlatTagToLength(uint8_t tag); + static uint8_t LengthToTag(size_t s); +}; +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_STRINGS_CORD_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord_test_helpers.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord_test_helpers.h index 8dd7c05751..14b46ab606 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord_test_helpers.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord_test_helpers.h @@ -1,34 +1,34 @@ -// -// Copyright 2018 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef ABSL_STRINGS_CORD_TEST_HELPERS_H_ -#define ABSL_STRINGS_CORD_TEST_HELPERS_H_ - +// +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef ABSL_STRINGS_CORD_TEST_HELPERS_H_ +#define ABSL_STRINGS_CORD_TEST_HELPERS_H_ + #include <cstdint> #include <iostream> #include <util/generic/string.h> #include "y_absl/base/config.h" -#include "y_absl/strings/cord.h" +#include "y_absl/strings/cord.h" #include "y_absl/strings/internal/cord_internal.h" #include "y_absl/strings/string_view.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN - + +namespace y_absl { +ABSL_NAMESPACE_BEGIN + // Cord sizes relevant for testing enum class TestCordSize { // An empty value @@ -84,39 +84,39 @@ inline std::ostream& operator<<(std::ostream& stream, TestCordSize size) { return stream << ToString(size); } -// Creates a multi-segment Cord from an iterable container of strings. The -// resulting Cord is guaranteed to have one segment for every string in the -// container. This allows code to be unit tested with multi-segment Cord -// inputs. -// -// Example: -// -// y_absl::Cord c = y_absl::MakeFragmentedCord({"A ", "fragmented ", "Cord"}); -// EXPECT_FALSE(c.GetFlat(&unused)); -// -// The mechanism by which this Cord is created is an implementation detail. Any -// implementation that produces a multi-segment Cord may produce a flat Cord in -// the future as new optimizations are added to the Cord class. -// MakeFragmentedCord will, however, always be updated to return a multi-segment -// Cord. -template <typename Container> -Cord MakeFragmentedCord(const Container& c) { - Cord result; - for (const auto& s : c) { - auto* external = new TString(s); - Cord tmp = y_absl::MakeCordFromExternal( - *external, [external](y_absl::string_view) { delete external; }); - tmp.Prepend(result); - result = tmp; - } - return result; -} - -inline Cord MakeFragmentedCord(std::initializer_list<y_absl::string_view> list) { - return MakeFragmentedCord<std::initializer_list<y_absl::string_view>>(list); -} - -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_STRINGS_CORD_TEST_HELPERS_H_ +// Creates a multi-segment Cord from an iterable container of strings. The +// resulting Cord is guaranteed to have one segment for every string in the +// container. This allows code to be unit tested with multi-segment Cord +// inputs. +// +// Example: +// +// y_absl::Cord c = y_absl::MakeFragmentedCord({"A ", "fragmented ", "Cord"}); +// EXPECT_FALSE(c.GetFlat(&unused)); +// +// The mechanism by which this Cord is created is an implementation detail. Any +// implementation that produces a multi-segment Cord may produce a flat Cord in +// the future as new optimizations are added to the Cord class. +// MakeFragmentedCord will, however, always be updated to return a multi-segment +// Cord. +template <typename Container> +Cord MakeFragmentedCord(const Container& c) { + Cord result; + for (const auto& s : c) { + auto* external = new TString(s); + Cord tmp = y_absl::MakeCordFromExternal( + *external, [external](y_absl::string_view) { delete external; }); + tmp.Prepend(result); + result = tmp; + } + return result; +} + +inline Cord MakeFragmentedCord(std::initializer_list<y_absl::string_view> list) { + return MakeFragmentedCord<std::initializer_list<y_absl::string_view>>(list); +} + +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_STRINGS_CORD_TEST_HELPERS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.cc index 8c82740608..a66434921c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.cc @@ -20,13 +20,13 @@ #include <cstring> #include <iterator> #include <limits> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/internal/endian.h" #include "y_absl/base/internal/raw_logging.h" #include "y_absl/base/internal/unaligned_access.h" #include "y_absl/strings/internal/char_map.h" -#include "y_absl/strings/internal/escaping.h" +#include "y_absl/strings/internal/escaping.h" #include "y_absl/strings/internal/resize_uninitialized.h" #include "y_absl/strings/internal/utf8.h" #include "y_absl/strings/str_cat.h" @@ -34,7 +34,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { // These are used for the leave_nulls_escaped argument to CUnescapeInternal(). @@ -796,7 +796,7 @@ bool Base64UnescapeInternal(const char* src, size_t slen, String* dest, } /* clang-format off */ -constexpr char kHexValueLenient[256] = { +constexpr char kHexValueLenient[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -812,9 +812,9 @@ constexpr char kHexValueLenient[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - + /* clang-format on */ // This is a templated function so that T can be either a char* @@ -823,8 +823,8 @@ constexpr char kHexValueLenient[256] = { template <typename T> void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) { for (int i = 0; i < num; i++) { - to[i] = (kHexValueLenient[from[i * 2] & 0xFF] << 4) + - (kHexValueLenient[from[i * 2 + 1] & 0xFF]); + to[i] = (kHexValueLenient[from[i * 2] & 0xFF] << 4) + + (kHexValueLenient[from[i * 2 + 1] & 0xFF]); } } @@ -902,30 +902,30 @@ bool WebSafeBase64Unescape(y_absl::string_view src, TString* dest) { } void Base64Escape(y_absl::string_view src, TString* dest) { - strings_internal::Base64EscapeInternal( - reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, - true, strings_internal::kBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, + true, strings_internal::kBase64Chars); } void WebSafeBase64Escape(y_absl::string_view src, TString* dest) { - strings_internal::Base64EscapeInternal( - reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, - false, kWebSafeBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, + false, kWebSafeBase64Chars); } TString Base64Escape(y_absl::string_view src) { TString dest; - strings_internal::Base64EscapeInternal( - reinterpret_cast<const unsigned char*>(src.data()), src.size(), &dest, - true, strings_internal::kBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), &dest, + true, strings_internal::kBase64Chars); return dest; } TString WebSafeBase64Escape(y_absl::string_view src) { TString dest; - strings_internal::Base64EscapeInternal( - reinterpret_cast<const unsigned char*>(src.data()), src.size(), &dest, - false, kWebSafeBase64Chars); + strings_internal::Base64EscapeInternal( + reinterpret_cast<const unsigned char*>(src.data()), src.size(), &dest, + false, kWebSafeBase64Chars); return dest; } @@ -945,5 +945,5 @@ TString BytesToHexString(y_absl::string_view from) { return result; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.h index 8868b87879..149d497f03 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/escaping.h @@ -24,7 +24,7 @@ #define ABSL_STRINGS_ESCAPING_H_ #include <cstddef> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> #include "y_absl/base/macros.h" @@ -33,7 +33,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // CUnescape() // @@ -158,7 +158,7 @@ TString HexStringToBytes(y_absl::string_view from); // `2*from.size()`. TString BytesToHexString(y_absl::string_view from); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_ESCAPING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal/ya.make index 4e57fc75f6..6b12ede171 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal/ya.make @@ -11,23 +11,23 @@ OWNER( LICENSE(Apache-2.0) -PEERDIR( +PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base - contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging + contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/raw_logging contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/spinlock_wait - contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity -) - -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) + contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity +) + +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() SRCDIR(contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal) SRCS( - escaping.cc + escaping.cc ostringstream.cc utf8.cc ) diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/char_map.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/char_map.h index 25428e304c..9d19d6b721 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/char_map.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/char_map.h @@ -28,7 +28,7 @@ #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { class Charmap { @@ -150,7 +150,7 @@ constexpr Charmap GraphCharmap() { return PrintCharmap() & ~SpaceCharmap(); } constexpr Charmap PunctCharmap() { return GraphCharmap() & ~AlnumCharmap(); } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_CHAR_MAP_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.cc index 72a4fa188b..c14e28c0c5 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.cc @@ -16,10 +16,10 @@ #include <algorithm> #include <cassert> -#include <util/generic/string.h> +#include <util/generic/string.h> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { namespace { @@ -158,12 +158,12 @@ const uint32_t* LargePowerOfFiveData(int i) { int LargePowerOfFiveSize(int i) { return 2 * i; } } // namespace -ABSL_DLL const uint32_t kFiveToNth[14] = { +ABSL_DLL const uint32_t kFiveToNth[14] = { 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, }; -ABSL_DLL const uint32_t kTenToNth[10] = { +ABSL_DLL const uint32_t kTenToNth[10] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, }; @@ -355,5 +355,5 @@ template class BigUnsigned<4>; template class BigUnsigned<84>; } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.h index a77aab14dd..11c5581bad 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_bigint.h @@ -18,15 +18,15 @@ #include <algorithm> #include <cstdint> #include <iostream> -#include <util/generic/string.h> +#include <util/generic/string.h> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/strings/ascii.h" #include "y_absl/strings/internal/charconv_parse.h" #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // The largest power that 5 that can be raised to, and still fit in a uint32_t. @@ -34,9 +34,9 @@ constexpr int kMaxSmallPowerOfFive = 13; // The largest power that 10 that can be raised to, and still fit in a uint32_t. constexpr int kMaxSmallPowerOfTen = 9; -ABSL_DLL extern const uint32_t - kFiveToNth[kMaxSmallPowerOfFive + 1]; -ABSL_DLL extern const uint32_t kTenToNth[kMaxSmallPowerOfTen + 1]; +ABSL_DLL extern const uint32_t + kFiveToNth[kMaxSmallPowerOfFive + 1]; +ABSL_DLL extern const uint32_t kTenToNth[kMaxSmallPowerOfTen + 1]; // Large, fixed-width unsigned integer. // @@ -417,7 +417,7 @@ extern template class BigUnsigned<4>; extern template class BigUnsigned<84>; } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_CHARCONV_BIGINT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.cc index f0f78eb68c..050f1cf0af 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.cc @@ -22,7 +22,7 @@ #include "y_absl/strings/internal/memutil.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { // ParseFloat<10> will read the first 19 significant digits of the mantissa. @@ -500,5 +500,5 @@ template ParsedFloat ParseFloat<16>(const char* begin, const char* end, chars_format format_flags); } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.h index 3f942cd4cb..83b74723af 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/charconv_parse.h @@ -17,11 +17,11 @@ #include <cstdint> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/strings/charconv.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // Enum indicating whether a parsed float is a number or special value. @@ -94,6 +94,6 @@ extern template ParsedFloat ParseFloat<16>(const char* begin, const char* end, y_absl::chars_format format_flags); } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_CHARCONV_PARSE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cord_internal.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cord_internal.h index 82f5ac7b81..f9986faf33 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cord_internal.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cord_internal.h @@ -1,38 +1,38 @@ // Copyright 2021 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ -#define ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ - -#include <atomic> -#include <cassert> -#include <cstddef> -#include <cstdint> -#include <type_traits> - +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ +#define ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ + +#include <atomic> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <type_traits> + #include "y_absl/base/config.h" #include "y_absl/base/internal/endian.h" #include "y_absl/base/internal/invoke.h" #include "y_absl/base/optimization.h" #include "y_absl/container/internal/compressed_tuple.h" -#include "y_absl/meta/type_traits.h" -#include "y_absl/strings/string_view.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace cord_internal { - +#include "y_absl/meta/type_traits.h" +#include "y_absl/strings/string_view.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace cord_internal { + class CordzInfo; // Default feature enable states for cord ring buffers @@ -83,48 +83,48 @@ enum Constants { // Compact class for tracking the reference count and state flags for CordRep // instances. Data is stored in an atomic int32_t for compactness and speed. class RefcountAndFlags { - public: + public: constexpr RefcountAndFlags() : count_{kRefIncrement} {} struct Immortal {}; explicit constexpr RefcountAndFlags(Immortal) : count_(kImmortalFlag) {} struct WithCrc {}; explicit constexpr RefcountAndFlags(WithCrc) : count_(kCrcFlag | kRefIncrement) {} - + // Increments the reference count. Imposes no memory ordering. inline void Increment() { count_.fetch_add(kRefIncrement, std::memory_order_relaxed); } - - // Asserts that the current refcount is greater than 0. If the refcount is + + // Asserts that the current refcount is greater than 0. If the refcount is // greater than 1, decrements the reference count. - // - // Returns false if there are no references outstanding; true otherwise. - // Inserts barriers to ensure that state written before this method returns - // false will be visible to a thread that just observed this method returning + // + // Returns false if there are no references outstanding; true otherwise. + // Inserts barriers to ensure that state written before this method returns + // false will be visible to a thread that just observed this method returning // false. Always returns false when the immortal bit is set. - inline bool Decrement() { + inline bool Decrement() { int32_t refcount = count_.load(std::memory_order_acquire) & kRefcountMask; assert(refcount > 0 || refcount & kImmortalFlag); return refcount != kRefIncrement && (count_.fetch_sub(kRefIncrement, std::memory_order_acq_rel) & kRefcountMask) != kRefIncrement; - } - - // Same as Decrement but expect that refcount is greater than 1. - inline bool DecrementExpectHighRefcount() { + } + + // Same as Decrement but expect that refcount is greater than 1. + inline bool DecrementExpectHighRefcount() { int32_t refcount = count_.fetch_sub(kRefIncrement, std::memory_order_acq_rel) & kRefcountMask; assert(refcount > 0 || refcount & kImmortalFlag); return refcount != kRefIncrement; - } - - // Returns the current reference count using acquire semantics. + } + + // Returns the current reference count using acquire semantics. inline int32_t Get() const { return count_.load(std::memory_order_acquire) >> kNumFlags; } - + // Returns true if the referenced object carries a CRC value. bool HasCrc() const { return (count_.load(std::memory_order_relaxed) & kCrcFlag) != 0; @@ -155,12 +155,12 @@ class RefcountAndFlags { return (count_.load(std::memory_order_acquire) & kRefcountMask) == kRefIncrement; } - + bool IsImmortal() const { return (count_.load(std::memory_order_relaxed) & kImmortalFlag) != 0; } - private: + private: // We reserve the bottom bits for flags. // kImmortalBit indicates that this entity should never be collected; it is // used for the StringConstant constructor to avoid collecting immutable @@ -180,21 +180,21 @@ class RefcountAndFlags { kRefcountMask = ~kCrcFlag, }; - std::atomic<int32_t> count_; -}; - -// The overhead of a vtable is too much for Cord, so we roll our own subclasses -// using only a single byte to differentiate classes from each other - the "tag" -// byte. Define the subclasses first so we can provide downcasting helper -// functions in the base class. - -struct CordRepConcat; + std::atomic<int32_t> count_; +}; + +// The overhead of a vtable is too much for Cord, so we roll our own subclasses +// using only a single byte to differentiate classes from each other - the "tag" +// byte. Define the subclasses first so we can provide downcasting helper +// functions in the base class. + +struct CordRepConcat; struct CordRepExternal; struct CordRepFlat; -struct CordRepSubstring; +struct CordRepSubstring; class CordRepRing; class CordRepBtree; - + // Various representations that we allow enum CordRepKind { CONCAT = 0, @@ -224,19 +224,19 @@ static_assert(RING == BTREE + 1, "BTREE and RING not consecutive"); static_assert(EXTERNAL == RING + 1, "BTREE and EXTERNAL not consecutive"); static_assert(FLAT == EXTERNAL + 1, "EXTERNAL and FLAT not consecutive"); -struct CordRep { +struct CordRep { CordRep() = default; constexpr CordRep(RefcountAndFlags::Immortal immortal, size_t l) : length(l), refcount(immortal), tag(EXTERNAL), storage{} {} - // The following three fields have to be less than 32 bytes since - // that is the smallest supported flat node size. + // The following three fields have to be less than 32 bytes since + // that is the smallest supported flat node size. size_t length; RefcountAndFlags refcount; - // If tag < FLAT, it represents CordRepKind and indicates the type of node. - // Otherwise, the node type is CordRepFlat and the tag is the encoded size. - uint8_t tag; - + // If tag < FLAT, it represents CordRepKind and indicates the type of node. + // Otherwise, the node type is CordRepFlat and the tag is the encoded size. + uint8_t tag; + // `storage` provides two main purposes: // - the starting point for FlatCordRep.Data() [flexible-array-member] // - 3 bytes of additional storage for use by derived classes. @@ -257,12 +257,12 @@ struct CordRep { inline CordRepRing* ring(); inline const CordRepRing* ring() const; - inline CordRepConcat* concat(); - inline const CordRepConcat* concat() const; - inline CordRepSubstring* substring(); - inline const CordRepSubstring* substring() const; - inline CordRepExternal* external(); - inline const CordRepExternal* external() const; + inline CordRepConcat* concat(); + inline const CordRepConcat* concat() const; + inline CordRepSubstring* substring(); + inline const CordRepSubstring* substring() const; + inline CordRepExternal* external(); + inline const CordRepExternal* external() const; inline CordRepFlat* flat(); inline const CordRepFlat* flat() const; inline CordRepBtree* btree(); @@ -281,28 +281,28 @@ struct CordRep { // Decrements the reference count of `rep`. Destroys rep if count reaches // zero. Requires `rep` to be a non-null pointer value. static inline void Unref(CordRep* rep); -}; - -struct CordRepConcat : public CordRep { - CordRep* left; - CordRep* right; - +}; + +struct CordRepConcat : public CordRep { + CordRep* left; + CordRep* right; + uint8_t depth() const { return storage[0]; } void set_depth(uint8_t depth) { storage[0] = depth; } -}; - -struct CordRepSubstring : public CordRep { - size_t start; // Starting offset of substring in child - CordRep* child; -}; - +}; + +struct CordRepSubstring : public CordRep { + size_t start; // Starting offset of substring in child + CordRep* child; +}; + // Type for function pointer that will invoke the releaser function and also // delete the `CordRepExternalImpl` corresponding to the passed in // `CordRepExternal`. using ExternalReleaserInvoker = void (*)(CordRepExternal*); - -// External CordReps are allocated together with a type erased releaser. The -// releaser is stored in the memory directly following the CordRepExternal. + +// External CordReps are allocated together with a type erased releaser. The +// releaser is stored in the memory directly following the CordRepExternal. struct CordRepExternal : public CordRep { CordRepExternal() = default; explicit constexpr CordRepExternal(y_absl::string_view str) @@ -310,18 +310,18 @@ struct CordRepExternal : public CordRep { base(str.data()), releaser_invoker(nullptr) {} - const char* base; - // Pointer to function that knows how to call and destroy the releaser. - ExternalReleaserInvoker releaser_invoker; + const char* base; + // Pointer to function that knows how to call and destroy the releaser. + ExternalReleaserInvoker releaser_invoker; // Deletes (releases) the external rep. // Requires rep != nullptr and rep->IsExternal() static void Delete(CordRep* rep); -}; - +}; + struct Rank1 {}; struct Rank0 : Rank1 {}; - + template <typename Releaser, typename = ::y_absl::base_internal::invoke_result_t< Releaser, y_absl::string_view>> void InvokeReleaser(Rank0, Releaser&& releaser, y_absl::string_view data) { @@ -613,8 +613,8 @@ inline void CordRep::Unref(CordRep* rep) { } } -} // namespace cord_internal +} // namespace cord_internal -ABSL_NAMESPACE_END -} // namespace y_absl -#endif // ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ +ABSL_NAMESPACE_END +} // namespace y_absl +#endif // ABSL_STRINGS_INTERNAL_CORD_INTERNAL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_functions/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_functions/ya.make index 06e99346da..613da918ff 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_functions/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/cordz_functions/ya.make @@ -17,9 +17,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/profiling/internal/exponential_biased ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.cc index 01b8974983..36218c2bbd 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.cc @@ -1,180 +1,180 @@ -// Copyright 2020 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "y_absl/strings/internal/escaping.h" - -#include "y_absl/base/internal/endian.h" -#include "y_absl/base/internal/raw_logging.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace strings_internal { - -const char kBase64Chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding) { - // Base64 encodes three bytes of input at a time. If the input is not - // divisible by three, we pad as appropriate. - // - // (from https://tools.ietf.org/html/rfc3548) - // Special processing is performed if fewer than 24 bits are available - // at the end of the data being encoded. A full encoding quantum is - // always completed at the end of a quantity. When fewer than 24 input - // bits are available in an input group, zero bits are added (on the - // right) to form an integral number of 6-bit groups. Padding at the - // end of the data is performed using the '=' character. Since all base - // 64 input is an integral number of octets, only the following cases - // can arise: - - // Base64 encodes each three bytes of input into four bytes of output. - size_t len = (input_len / 3) * 4; - - if (input_len % 3 == 0) { - // (from https://tools.ietf.org/html/rfc3548) - // (1) the final quantum of encoding input is an integral multiple of 24 - // bits; here, the final unit of encoded output will be an integral - // multiple of 4 characters with no "=" padding, - } else if (input_len % 3 == 1) { - // (from https://tools.ietf.org/html/rfc3548) - // (2) the final quantum of encoding input is exactly 8 bits; here, the - // final unit of encoded output will be two characters followed by two - // "=" padding characters, or - len += 2; - if (do_padding) { - len += 2; - } - } else { // (input_len % 3 == 2) - // (from https://tools.ietf.org/html/rfc3548) - // (3) the final quantum of encoding input is exactly 16 bits; here, the - // final unit of encoded output will be three characters followed by one - // "=" padding character. - len += 3; - if (do_padding) { - len += 1; - } - } - - assert(len >= input_len); // make sure we didn't overflow - return len; -} - -size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, - size_t szdest, const char* base64, - bool do_padding) { - static const char kPad64 = '='; - - if (szsrc * 4 > szdest * 3) return 0; - - char* cur_dest = dest; - const unsigned char* cur_src = src; - - char* const limit_dest = dest + szdest; - const unsigned char* const limit_src = src + szsrc; - - // Three bytes of data encodes to four characters of cyphertext. - // So we can pump through three-byte chunks atomically. - if (szsrc >= 3) { // "limit_src - 3" is UB if szsrc < 3. - while (cur_src < limit_src - 3) { // While we have >= 32 bits. - uint32_t in = y_absl::big_endian::Load32(cur_src) >> 8; - - cur_dest[0] = base64[in >> 18]; - in &= 0x3FFFF; - cur_dest[1] = base64[in >> 12]; - in &= 0xFFF; - cur_dest[2] = base64[in >> 6]; - in &= 0x3F; - cur_dest[3] = base64[in]; - - cur_dest += 4; - cur_src += 3; - } - } - // To save time, we didn't update szdest or szsrc in the loop. So do it now. - szdest = limit_dest - cur_dest; - szsrc = limit_src - cur_src; - - /* now deal with the tail (<=3 bytes) */ - switch (szsrc) { - case 0: - // Nothing left; nothing more to do. - break; - case 1: { - // One byte left: this encodes to two characters, and (optionally) - // two pad characters to round out the four-character cypherblock. - if (szdest < 2) return 0; - uint32_t in = cur_src[0]; - cur_dest[0] = base64[in >> 2]; - in &= 0x3; - cur_dest[1] = base64[in << 4]; - cur_dest += 2; - szdest -= 2; - if (do_padding) { - if (szdest < 2) return 0; - cur_dest[0] = kPad64; - cur_dest[1] = kPad64; - cur_dest += 2; - szdest -= 2; - } - break; - } - case 2: { - // Two bytes left: this encodes to three characters, and (optionally) - // one pad character to round out the four-character cypherblock. - if (szdest < 3) return 0; - uint32_t in = y_absl::big_endian::Load16(cur_src); - cur_dest[0] = base64[in >> 10]; - in &= 0x3FF; - cur_dest[1] = base64[in >> 4]; - in &= 0x00F; - cur_dest[2] = base64[in << 2]; - cur_dest += 3; - szdest -= 3; - if (do_padding) { - if (szdest < 1) return 0; - cur_dest[0] = kPad64; - cur_dest += 1; - szdest -= 1; - } - break; - } - case 3: { - // Three bytes left: same as in the big loop above. We can't do this in - // the loop because the loop above always reads 4 bytes, and the fourth - // byte is past the end of the input. - if (szdest < 4) return 0; - uint32_t in = (cur_src[0] << 16) + y_absl::big_endian::Load16(cur_src + 1); - cur_dest[0] = base64[in >> 18]; - in &= 0x3FFFF; - cur_dest[1] = base64[in >> 12]; - in &= 0xFFF; - cur_dest[2] = base64[in >> 6]; - in &= 0x3F; - cur_dest[3] = base64[in]; - cur_dest += 4; - szdest -= 4; - break; - } - default: - // Should not be reached: blocks of 4 bytes are handled - // in the while loop before this switch statement. - ABSL_RAW_LOG(FATAL, "Logic problem? szsrc = %zu", szsrc); - break; - } - return (cur_dest - dest); -} - -} // namespace strings_internal -ABSL_NAMESPACE_END -} // namespace y_absl +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "y_absl/strings/internal/escaping.h" + +#include "y_absl/base/internal/endian.h" +#include "y_absl/base/internal/raw_logging.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace strings_internal { + +const char kBase64Chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding) { + // Base64 encodes three bytes of input at a time. If the input is not + // divisible by three, we pad as appropriate. + // + // (from https://tools.ietf.org/html/rfc3548) + // Special processing is performed if fewer than 24 bits are available + // at the end of the data being encoded. A full encoding quantum is + // always completed at the end of a quantity. When fewer than 24 input + // bits are available in an input group, zero bits are added (on the + // right) to form an integral number of 6-bit groups. Padding at the + // end of the data is performed using the '=' character. Since all base + // 64 input is an integral number of octets, only the following cases + // can arise: + + // Base64 encodes each three bytes of input into four bytes of output. + size_t len = (input_len / 3) * 4; + + if (input_len % 3 == 0) { + // (from https://tools.ietf.org/html/rfc3548) + // (1) the final quantum of encoding input is an integral multiple of 24 + // bits; here, the final unit of encoded output will be an integral + // multiple of 4 characters with no "=" padding, + } else if (input_len % 3 == 1) { + // (from https://tools.ietf.org/html/rfc3548) + // (2) the final quantum of encoding input is exactly 8 bits; here, the + // final unit of encoded output will be two characters followed by two + // "=" padding characters, or + len += 2; + if (do_padding) { + len += 2; + } + } else { // (input_len % 3 == 2) + // (from https://tools.ietf.org/html/rfc3548) + // (3) the final quantum of encoding input is exactly 16 bits; here, the + // final unit of encoded output will be three characters followed by one + // "=" padding character. + len += 3; + if (do_padding) { + len += 1; + } + } + + assert(len >= input_len); // make sure we didn't overflow + return len; +} + +size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, + size_t szdest, const char* base64, + bool do_padding) { + static const char kPad64 = '='; + + if (szsrc * 4 > szdest * 3) return 0; + + char* cur_dest = dest; + const unsigned char* cur_src = src; + + char* const limit_dest = dest + szdest; + const unsigned char* const limit_src = src + szsrc; + + // Three bytes of data encodes to four characters of cyphertext. + // So we can pump through three-byte chunks atomically. + if (szsrc >= 3) { // "limit_src - 3" is UB if szsrc < 3. + while (cur_src < limit_src - 3) { // While we have >= 32 bits. + uint32_t in = y_absl::big_endian::Load32(cur_src) >> 8; + + cur_dest[0] = base64[in >> 18]; + in &= 0x3FFFF; + cur_dest[1] = base64[in >> 12]; + in &= 0xFFF; + cur_dest[2] = base64[in >> 6]; + in &= 0x3F; + cur_dest[3] = base64[in]; + + cur_dest += 4; + cur_src += 3; + } + } + // To save time, we didn't update szdest or szsrc in the loop. So do it now. + szdest = limit_dest - cur_dest; + szsrc = limit_src - cur_src; + + /* now deal with the tail (<=3 bytes) */ + switch (szsrc) { + case 0: + // Nothing left; nothing more to do. + break; + case 1: { + // One byte left: this encodes to two characters, and (optionally) + // two pad characters to round out the four-character cypherblock. + if (szdest < 2) return 0; + uint32_t in = cur_src[0]; + cur_dest[0] = base64[in >> 2]; + in &= 0x3; + cur_dest[1] = base64[in << 4]; + cur_dest += 2; + szdest -= 2; + if (do_padding) { + if (szdest < 2) return 0; + cur_dest[0] = kPad64; + cur_dest[1] = kPad64; + cur_dest += 2; + szdest -= 2; + } + break; + } + case 2: { + // Two bytes left: this encodes to three characters, and (optionally) + // one pad character to round out the four-character cypherblock. + if (szdest < 3) return 0; + uint32_t in = y_absl::big_endian::Load16(cur_src); + cur_dest[0] = base64[in >> 10]; + in &= 0x3FF; + cur_dest[1] = base64[in >> 4]; + in &= 0x00F; + cur_dest[2] = base64[in << 2]; + cur_dest += 3; + szdest -= 3; + if (do_padding) { + if (szdest < 1) return 0; + cur_dest[0] = kPad64; + cur_dest += 1; + szdest -= 1; + } + break; + } + case 3: { + // Three bytes left: same as in the big loop above. We can't do this in + // the loop because the loop above always reads 4 bytes, and the fourth + // byte is past the end of the input. + if (szdest < 4) return 0; + uint32_t in = (cur_src[0] << 16) + y_absl::big_endian::Load16(cur_src + 1); + cur_dest[0] = base64[in >> 18]; + in &= 0x3FFFF; + cur_dest[1] = base64[in >> 12]; + in &= 0xFFF; + cur_dest[2] = base64[in >> 6]; + in &= 0x3F; + cur_dest[3] = base64[in]; + cur_dest += 4; + szdest -= 4; + break; + } + default: + // Should not be reached: blocks of 4 bytes are handled + // in the while loop before this switch statement. + ABSL_RAW_LOG(FATAL, "Logic problem? szsrc = %zu", szsrc); + break; + } + return (cur_dest - dest); +} + +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.h index d62fc0fbcb..be8dc4460e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping.h @@ -1,58 +1,58 @@ -// Copyright 2020 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef ABSL_STRINGS_INTERNAL_ESCAPING_H_ -#define ABSL_STRINGS_INTERNAL_ESCAPING_H_ - -#include <cassert> - -#include "y_absl/strings/internal/resize_uninitialized.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace strings_internal { - -ABSL_CONST_INIT extern const char kBase64Chars[]; - -// Calculates how long a string will be when it is base64 encoded given its -// length and whether or not the result should be padded. -size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding); - -// Base64-encodes `src` using the alphabet provided in `base64` and writes the -// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars -// until its length is a multiple of 3. Returns the length of `dest`. -size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, - size_t szdest, const char* base64, bool do_padding); - -// Base64-encodes `src` using the alphabet provided in `base64` and writes the -// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars -// until its length is a multiple of 3. -template <typename String> -void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest, - bool do_padding, const char* base64_chars) { - const size_t calc_escaped_size = - CalculateBase64EscapedLenInternal(szsrc, do_padding); - STLStringResizeUninitialized(dest, calc_escaped_size); - - const size_t escaped_len = Base64EscapeInternal( - src, szsrc, &(*dest)[0], dest->size(), base64_chars, do_padding); - assert(calc_escaped_size == escaped_len); - dest->erase(escaped_len); -} - -} // namespace strings_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_STRINGS_INTERNAL_ESCAPING_H_ +// Copyright 2020 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ABSL_STRINGS_INTERNAL_ESCAPING_H_ +#define ABSL_STRINGS_INTERNAL_ESCAPING_H_ + +#include <cassert> + +#include "y_absl/strings/internal/resize_uninitialized.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace strings_internal { + +ABSL_CONST_INIT extern const char kBase64Chars[]; + +// Calculates how long a string will be when it is base64 encoded given its +// length and whether or not the result should be padded. +size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding); + +// Base64-encodes `src` using the alphabet provided in `base64` and writes the +// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars +// until its length is a multiple of 3. Returns the length of `dest`. +size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, + size_t szdest, const char* base64, bool do_padding); + +// Base64-encodes `src` using the alphabet provided in `base64` and writes the +// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars +// until its length is a multiple of 3. +template <typename String> +void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest, + bool do_padding, const char* base64_chars) { + const size_t calc_escaped_size = + CalculateBase64EscapedLenInternal(szsrc, do_padding); + STLStringResizeUninitialized(dest, calc_escaped_size); + + const size_t escaped_len = Base64EscapeInternal( + src, szsrc, &(*dest)[0], dest->size(), base64_chars, do_padding); + assert(calc_escaped_size == escaped_len); + dest->erase(escaped_len); +} + +} // namespace strings_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_STRINGS_INTERNAL_ESCAPING_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping_test_common.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping_test_common.h index f145127225..20f98e27b0 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping_test_common.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/escaping_test_common.h @@ -22,7 +22,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { struct base64_testcase { @@ -127,7 +127,7 @@ inline const std::array<base64_testcase, 5>& base64_strings() { } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_ESCAPING_TEST_COMMON_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.cc index 0ba6574fdb..fcd0fd6ace 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.cc @@ -17,7 +17,7 @@ #include <cstdlib> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { int memcasecmp(const char* s1, const char* s2, size_t len) { @@ -108,5 +108,5 @@ const char* memmatch(const char* phaystack, size_t haylen, const char* pneedle, } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.h index ee442fe25f..050af2c345 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/memutil.h @@ -69,7 +69,7 @@ #include "y_absl/strings/ascii.h" // for y_absl::ascii_tolower namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { inline char* memcat(char* dest, size_t destlen, const char* src, @@ -142,7 +142,7 @@ const char* memmatch(const char* phaystack, size_t haylen, const char* pneedle, size_t neelen); } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_MEMUTIL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/numbers_test_common.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/numbers_test_common.h index 12aec3ac11..496cc1889a 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/numbers_test_common.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/numbers_test_common.h @@ -21,12 +21,12 @@ #include <array> #include <cstdint> #include <limits> -#include <util/generic/string.h> - -#include "y_absl/base/config.h" +#include <util/generic/string.h> +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { template <typename IntType> @@ -178,7 +178,7 @@ inline const std::array<uint64_test_case, 34>& strtouint64_test_cases() { } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_NUMBERS_TEST_COMMON_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.cc index ba18857d83..4427d66e27 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.cc @@ -15,7 +15,7 @@ #include "y_absl/strings/internal/ostringstream.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { OStringStream::Buf::int_type OStringStream::overflow(int c) { @@ -32,5 +32,5 @@ std::streamsize OStringStream::xsputn(const char* s, std::streamsize n) { } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.h index d00cef9c23..9dbcf09f57 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/ostringstream.h @@ -18,12 +18,12 @@ #include <cassert> #include <ostream> #include <streambuf> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // The same as std::ostringstream but appends to a user-specified TString, @@ -83,7 +83,7 @@ class OStringStream : private std::basic_streambuf<char>, public std::ostream { }; } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_OSTRINGSTREAM_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/pow10_helper.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/pow10_helper.h index e4d41d7e4e..7b529e72a4 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/pow10_helper.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/pow10_helper.h @@ -22,10 +22,10 @@ #include <vector> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // Computes the precise value of 10^exp. (I.e. the nearest representable @@ -34,7 +34,7 @@ namespace strings_internal { double Pow10(int exp); } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_POW10_HELPER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h index 14860bb237..68063a1922 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h @@ -18,7 +18,7 @@ #define ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_ #include <algorithm> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include <utility> @@ -26,7 +26,7 @@ #include "y_absl/meta/type_traits.h" // for void_t namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // In this type trait, we look for a __resize_default_init member function, and @@ -113,7 +113,7 @@ void STLStringResizeUninitializedAmortized(string_type* s, size_t new_size) { } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/stl_type_traits.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/stl_type_traits.h index db8d4635d0..a8a79a0e7d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/stl_type_traits.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/stl_type_traits.h @@ -40,7 +40,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { template <typename C, template <typename...> class T> @@ -243,6 +243,6 @@ struct IsStrictlyBaseOfAndConvertibleToSTLContainer IsConvertibleToSTLContainer<C>> {}; } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STL_TYPE_TRAITS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.cc index 8d5c3b61ac..ebe05ae232 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.cc @@ -21,7 +21,7 @@ #include <cassert> #include <cerrno> #include <cstdlib> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include "y_absl/base/port.h" @@ -29,7 +29,7 @@ #include "y_absl/strings/numbers.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -334,7 +334,7 @@ template <typename T> bool ConvertFloatArg(T v, const FormatConversionSpecImpl conv, FormatSinkImpl *sink) { return FormatConversionCharIsFloat(conv.conversion_char()) && - ConvertFloatImpl(v, conv, sink); + ConvertFloatImpl(v, conv, sink); } inline bool ConvertStringArg(string_view v, const FormatConversionSpecImpl conv, @@ -374,7 +374,7 @@ FormatConvertImpl(const char *v, const FormatConversionSpecImpl conv, } else if (conv.precision() < 0) { len = std::strlen(v); } else { - // If precision is set, we look for the NUL-terminator on the valid range. + // If precision is set, we look for the NUL-terminator on the valid range. len = std::find(v, v + conv.precision(), '\0') - v; } return {ConvertStringArg(string_view(v, len), conv, sink)}; @@ -484,5 +484,5 @@ ABSL_INTERNAL_FORMAT_DISPATCH_OVERLOADS_EXPAND_(); } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.h index 59b7bcc727..1413fc721f 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/arg.h @@ -23,7 +23,7 @@ #include <limits> #include <memory> #include <sstream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/stream/str.h> #include <type_traits> @@ -34,9 +34,9 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN -class Cord; +class Cord; class FormatCountCapture; class FormatSink; @@ -157,17 +157,17 @@ StringConvertResult FormatConvertImpl(const AbslCord& value, if (space_remaining > 0 && !is_left) sink->Append(space_remaining, ' '); - for (string_view piece : value.Chunks()) { - if (piece.size() > to_write) { - piece.remove_suffix(piece.size() - to_write); - to_write = 0; - } else { - to_write -= piece.size(); - } + for (string_view piece : value.Chunks()) { + if (piece.size() > to_write) { + piece.remove_suffix(piece.size() - to_write); + to_write = 0; + } else { + to_write -= piece.size(); + } sink->Append(piece); - if (to_write == 0) { - break; - } + if (to_write == 0) { + break; + } } if (space_remaining > 0 && is_left) sink->Append(space_remaining, ' '); @@ -522,7 +522,7 @@ ABSL_INTERNAL_FORMAT_DISPATCH_OVERLOADS_EXPAND_(extern); } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_ARG_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.cc index 211ce25dea..aff5aad744 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.cc @@ -17,10 +17,10 @@ #include <cerrno> #include <limits> #include <sstream> -#include <util/generic/string.h> +#include <util/generic/string.h> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -80,21 +80,21 @@ inline bool ArgContext::Bind(const UnboundConversion* unbound, return false; } - FormatConversionSpecImplFriend::SetWidth(width, bound); - FormatConversionSpecImplFriend::SetPrecision(precision, bound); - - if (force_left) { + FormatConversionSpecImplFriend::SetWidth(width, bound); + FormatConversionSpecImplFriend::SetPrecision(precision, bound); + + if (force_left) { FormatConversionSpecImplFriend::SetFlags(unbound->flags | Flags::kLeft, bound); - } else { - FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound); - } + } else { + FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound); + } } else { - FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound); - FormatConversionSpecImplFriend::SetWidth(-1, bound); - FormatConversionSpecImplFriend::SetPrecision(-1, bound); + FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound); + FormatConversionSpecImplFriend::SetWidth(-1, bound); + FormatConversionSpecImplFriend::SetPrecision(-1, bound); } - FormatConversionSpecImplFriend::SetConversionChar(unbound->conv, bound); + FormatConversionSpecImplFriend::SetConversionChar(unbound->conv, bound); bound->set_arg(arg); return true; } @@ -156,8 +156,8 @@ class SummarizingConverter { UntypedFormatSpecImpl spec("%d"); std::ostringstream ss; - ss << "{" << Streamable(spec, {*bound.arg()}) << ":" - << FormatConversionSpecImplFriend::FlagsToString(bound); + ss << "{" << Streamable(spec, {*bound.arg()}) << ":" + << FormatConversionSpecImplFriend::FlagsToString(bound); if (bound.width() >= 0) ss << bound.width(); if (bound.precision() >= 0) ss << "." << bound.precision(); ss << bound.conversion_char() << "}"; @@ -254,5 +254,5 @@ int SnprintF(char* output, size_t size, const UntypedFormatSpecImpl format, } } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h index 3966610710..a2ab6ff6ff 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/bind.h @@ -18,7 +18,7 @@ #include <array> #include <cstdio> #include <sstream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/port.h" #include "y_absl/strings/internal/str_format/arg.h" @@ -27,7 +27,7 @@ #include "y_absl/types/span.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class UntypedFormatSpec; @@ -88,7 +88,7 @@ class FormatSpecTemplate using Base = typename MakeDependent<UntypedFormatSpec, Args...>::type; public: -#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER // Honeypot overload for when the string is not constexpr. // We use the 'unavailable' attribute to give a better compiler error than @@ -211,7 +211,7 @@ class StreamedWrapper { }; } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_BIND_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h index 7c530d2507..78a137029f 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/checker.h @@ -15,20 +15,20 @@ #ifndef ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_ #define ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_ -#include "y_absl/base/attributes.h" +#include "y_absl/base/attributes.h" #include "y_absl/strings/internal/str_format/arg.h" #include "y_absl/strings/internal/str_format/extension.h" // Compile time check support for entry points. #ifndef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER -#if ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) +#if ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) #define ABSL_INTERNAL_ENABLE_FORMAT_CHECKER 1 -#endif // ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) +#endif // ABSL_HAVE_ATTRIBUTE(enable_if) && !defined(__native_client__) #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { constexpr bool AllOf() { return true; } @@ -38,7 +38,7 @@ constexpr bool AllOf(bool b, T... t) { return b && AllOf(t...); } -#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER constexpr bool ContainsChar(const char* chars, char c) { return *chars == c || (*chars && ContainsChar(chars + 1, c)); @@ -327,7 +327,7 @@ constexpr bool ValidFormatImpl(string_view format) { #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_CHECKER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.cc index f2a4169ae7..2eafe4721d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.cc @@ -17,10 +17,10 @@ #include <errno.h> #include <algorithm> -#include <util/generic/string.h> +#include <util/generic/string.h> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { TString FlagsToString(Flags v) { @@ -71,5 +71,5 @@ bool FormatSinkImpl::PutPaddedString(string_view value, int width, } } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.h index e5de5cb6a1..b4cd3d61f3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/extension.h @@ -17,19 +17,19 @@ #define ABSL_STRINGS_INTERNAL_STR_FORMAT_EXTENSION_H_ #include <limits.h> - + #include <cstddef> #include <cstring> #include <ostream> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/base/port.h" #include "y_absl/meta/type_traits.h" #include "y_absl/strings/internal/str_format/output.h" #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN enum class FormatConversionChar : uint8_t; enum class FormatConversionCharSet : uint64_t; @@ -156,7 +156,7 @@ inline std::ostream& operator<<(std::ostream& os, Flags v) { } // clang-format off -#define ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(X_VAL, X_SEP) \ +#define ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(X_VAL, X_SEP) \ /* text */ \ X_VAL(c) X_SEP X_VAL(s) X_SEP \ /* ints */ \ @@ -200,21 +200,21 @@ struct FormatConversionCharInternal { #undef ABSL_INTERNAL_X_VAL static constexpr FormatConversionChar kNone = static_cast<FormatConversionChar>(Enum::kNone); -}; -// clang-format on +}; +// clang-format on -inline FormatConversionChar FormatConversionCharFromChar(char c) { - switch (c) { -#define ABSL_INTERNAL_X_VAL(id) \ - case #id[0]: \ +inline FormatConversionChar FormatConversionCharFromChar(char c) { + switch (c) { +#define ABSL_INTERNAL_X_VAL(id) \ + case #id[0]: \ return FormatConversionCharInternal::id; - ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_X_VAL, ) -#undef ABSL_INTERNAL_X_VAL + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_X_VAL, ) +#undef ABSL_INTERNAL_X_VAL } return FormatConversionCharInternal::kNone; -} +} -inline bool FormatConversionCharIsUpper(FormatConversionChar c) { +inline bool FormatConversionCharIsUpper(FormatConversionChar c) { if (c == FormatConversionCharInternal::X || c == FormatConversionCharInternal::F || c == FormatConversionCharInternal::E || @@ -224,9 +224,9 @@ inline bool FormatConversionCharIsUpper(FormatConversionChar c) { } else { return false; } -} +} -inline bool FormatConversionCharIsFloat(FormatConversionChar c) { +inline bool FormatConversionCharIsFloat(FormatConversionChar c) { if (c == FormatConversionCharInternal::a || c == FormatConversionCharInternal::e || c == FormatConversionCharInternal::f || @@ -239,38 +239,38 @@ inline bool FormatConversionCharIsFloat(FormatConversionChar c) { } else { return false; } -} +} -inline char FormatConversionCharToChar(FormatConversionChar c) { +inline char FormatConversionCharToChar(FormatConversionChar c) { if (c == FormatConversionCharInternal::kNone) { return '\0'; #define ABSL_INTERNAL_X_VAL(e) \ } else if (c == FormatConversionCharInternal::e) { \ - return #e[0]; -#define ABSL_INTERNAL_X_SEP + return #e[0]; +#define ABSL_INTERNAL_X_SEP ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_X_VAL, ABSL_INTERNAL_X_SEP) } else { return '\0'; } -#undef ABSL_INTERNAL_X_VAL -#undef ABSL_INTERNAL_X_SEP -} +#undef ABSL_INTERNAL_X_VAL +#undef ABSL_INTERNAL_X_SEP +} -// The associated char. -inline std::ostream& operator<<(std::ostream& os, FormatConversionChar v) { - char c = FormatConversionCharToChar(v); - if (!c) c = '?'; - return os << c; -} +// The associated char. +inline std::ostream& operator<<(std::ostream& os, FormatConversionChar v) { + char c = FormatConversionCharToChar(v); + if (!c) c = '?'; + return os << c; +} -struct FormatConversionSpecImplFriend; +struct FormatConversionSpecImplFriend; class FormatConversionSpecImpl { - public: - // Width and precison are not specified, no flags are set. + public: + // Width and precison are not specified, no flags are set. bool is_basic() const { return flags_ == Flags::kBasic; } bool has_left_flag() const { return FlagsContains(flags_, Flags::kLeft); } bool has_show_pos_flag() const { @@ -282,7 +282,7 @@ class FormatConversionSpecImpl { bool has_alt_flag() const { return FlagsContains(flags_, Flags::kAlt); } bool has_zero_flag() const { return FlagsContains(flags_, Flags::kZero); } - FormatConversionChar conversion_char() const { + FormatConversionChar conversion_char() const { // Keep this field first in the struct . It generates better code when // accessing it when ConversionSpec is passed by value in registers. static_assert(offsetof(FormatConversionSpecImpl, conv_) == 0, ""); @@ -302,32 +302,32 @@ class FormatConversionSpecImpl { } private: - friend struct str_format_internal::FormatConversionSpecImplFriend; + friend struct str_format_internal::FormatConversionSpecImplFriend; FormatConversionChar conv_ = FormatConversionCharInternal::kNone; Flags flags_; int width_; int precision_; }; -struct FormatConversionSpecImplFriend final { +struct FormatConversionSpecImplFriend final { static void SetFlags(Flags f, FormatConversionSpecImpl* conv) { - conv->flags_ = f; - } - static void SetConversionChar(FormatConversionChar c, + conv->flags_ = f; + } + static void SetConversionChar(FormatConversionChar c, FormatConversionSpecImpl* conv) { - conv->conv_ = c; - } + conv->conv_ = c; + } static void SetWidth(int w, FormatConversionSpecImpl* conv) { conv->width_ = w; } static void SetPrecision(int p, FormatConversionSpecImpl* conv) { - conv->precision_ = p; - } + conv->precision_ = p; + } static TString FlagsToString(const FormatConversionSpecImpl& spec) { return str_format_internal::FlagsToString(spec.flags_); - } -}; - + } +}; + // Type safe OR operator. // We need this for two reasons: // 1. operator| on enums makes them decay to integers and the result is an @@ -355,9 +355,9 @@ constexpr uint64_t FormatConversionCharToConvInt(char conv) { #define ABSL_INTERNAL_CHAR_SET_CASE(c) \ conv == #c[0] \ ? FormatConversionCharToConvInt(FormatConversionCharInternal::c) \ - : - ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, ) -#undef ABSL_INTERNAL_CHAR_SET_CASE + : + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, ) +#undef ABSL_INTERNAL_CHAR_SET_CASE conv == '*' ? 1 : 0; @@ -372,8 +372,8 @@ struct FormatConversionCharSetInternal { #define ABSL_INTERNAL_CHAR_SET_CASE(c) \ static constexpr FormatConversionCharSet c = \ FormatConversionCharToConvValue(#c[0]); - ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, ) -#undef ABSL_INTERNAL_CHAR_SET_CASE + ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, ) +#undef ABSL_INTERNAL_CHAR_SET_CASE // Used for width/precision '*' specification. static constexpr FormatConversionCharSet kStar = @@ -393,8 +393,8 @@ struct FormatConversionCharSetInternal { // 1. operator| on enums makes them decay to integers and the result is an // integer. We need the result to stay as an enum. // 2. We use "enum class" which would not work even if we accepted the decay. -constexpr FormatConversionCharSet operator|(FormatConversionCharSet a, - FormatConversionCharSet b) { +constexpr FormatConversionCharSet operator|(FormatConversionCharSet a, + FormatConversionCharSet b) { return FormatConversionCharSetUnion(a, b); } @@ -415,14 +415,14 @@ template <typename T> void ToFormatConversionCharSet(T) = delete; // Checks whether `c` exists in `set`. -constexpr bool Contains(FormatConversionCharSet set, char c) { +constexpr bool Contains(FormatConversionCharSet set, char c) { return (static_cast<uint64_t>(set) & static_cast<uint64_t>(FormatConversionCharToConvValue(c))) != 0; } // Checks whether all the characters in `c` are contained in `set` -constexpr bool Contains(FormatConversionCharSet set, - FormatConversionCharSet c) { +constexpr bool Contains(FormatConversionCharSet set, + FormatConversionCharSet c) { return (static_cast<uint64_t>(set) & static_cast<uint64_t>(c)) == static_cast<uint64_t>(c); } @@ -439,7 +439,7 @@ inline size_t Excess(size_t used, size_t capacity) { } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_EXTENSION_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.cc index c49062538d..7a5f1d23a2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.cc @@ -20,7 +20,7 @@ #include <cassert> #include <cmath> #include <limits> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/attributes.h" #include "y_absl/base/config.h" @@ -35,7 +35,7 @@ #include "y_absl/types/span.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -946,7 +946,7 @@ bool FallbackToSnprintf(const Float v, const FormatConversionSpecImpl &conv, { char *fp = fmt; *fp++ = '%'; - fp = CopyStringTo(FormatConversionSpecImplFriend::FlagsToString(conv), fp); + fp = CopyStringTo(FormatConversionSpecImplFriend::FlagsToString(conv), fp); fp = CopyStringTo("*.*", fp); if (std::is_same<long double, Float>()) { *fp++ = 'L'; @@ -1419,5 +1419,5 @@ bool ConvertFloatImpl(double v, const FormatConversionSpecImpl &conv, } } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.h index d93a415756..c586eb4e49 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/float_conversion.h @@ -18,7 +18,7 @@ #include "y_absl/strings/internal/str_format/extension.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { bool ConvertFloatImpl(float v, const FormatConversionSpecImpl &conv, @@ -31,7 +31,7 @@ bool ConvertFloatImpl(long double v, const FormatConversionSpecImpl &conv, FormatSinkImpl *sink); } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_FLOAT_CONVERSION_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.cc index ade3f67ef2..f80aeb1214 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.cc @@ -18,7 +18,7 @@ #include <cstring> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { namespace { @@ -68,5 +68,5 @@ void FILERawSink::Write(string_view v) { } } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.h index 8fc46fbafa..2a2fa34abb 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/output.h @@ -23,13 +23,13 @@ #include <cstdio> #include <ostream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/port.h" #include "y_absl/strings/string_view.h" -namespace y_absl { -ABSL_NAMESPACE_BEGIN +namespace y_absl { +ABSL_NAMESPACE_BEGIN namespace str_format_internal { // RawSink implementation that writes into a char* buffer. @@ -90,7 +90,7 @@ auto InvokeFlush(T* out, string_view s) -> decltype(AbslFormatFlush(out, s)) { } } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_OUTPUT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.cc index af07e32fe5..f8b7c04931 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.cc @@ -24,16 +24,16 @@ #include <initializer_list> #include <limits> #include <ostream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <unordered_set> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { using CC = FormatConversionCharInternal; -using LM = LengthMod; - +using LM = LengthMod; + // Abbreviations to fit in the table below. constexpr auto f_sign = Flags::kSignCol; constexpr auto f_alt = Flags::kAlt; @@ -209,11 +209,11 @@ const char *ConsumeConversion(const char *pos, const char *const end, using str_format_internal::LengthMod; LengthMod length_mod = tag.as_length(); ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR(); - if (c == 'h' && length_mod == LengthMod::h) { - conv->length_mod = LengthMod::hh; + if (c == 'h' && length_mod == LengthMod::h) { + conv->length_mod = LengthMod::hh; ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR(); - } else if (c == 'l' && length_mod == LengthMod::l) { - conv->length_mod = LengthMod::ll; + } else if (c == 'l' && length_mod == LengthMod::l) { + conv->length_mod = LengthMod::ll; ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR(); } else { conv->length_mod = length_mod; @@ -232,32 +232,32 @@ const char *ConsumeConversion(const char *pos, const char *const end, } // namespace -TString LengthModToString(LengthMod v) { - switch (v) { - case LengthMod::h: - return "h"; - case LengthMod::hh: - return "hh"; - case LengthMod::l: - return "l"; - case LengthMod::ll: - return "ll"; - case LengthMod::L: - return "L"; - case LengthMod::j: - return "j"; - case LengthMod::z: - return "z"; - case LengthMod::t: - return "t"; - case LengthMod::q: - return "q"; - case LengthMod::none: - return ""; - } - return ""; -} - +TString LengthModToString(LengthMod v) { + switch (v) { + case LengthMod::h: + return "h"; + case LengthMod::hh: + return "hh"; + case LengthMod::l: + return "l"; + case LengthMod::ll: + return "ll"; + case LengthMod::L: + return "L"; + case LengthMod::j: + return "j"; + case LengthMod::z: + return "z"; + case LengthMod::t: + return "t"; + case LengthMod::q: + return "q"; + case LengthMod::none: + return ""; + } + return ""; +} + const char *ConsumeUnboundConversion(const char *p, const char *end, UnboundConversion *conv, int *next_arg) { if (*next_arg < 0) return ConsumeConversion<true>(p, end, conv, next_arg); @@ -327,13 +327,13 @@ bool ParsedFormatBase::MatchesConversions( if (conv.width.is_from_arg() && !add_if_valid_conv(conv.width.get_from_arg(), '*')) return false; - if (!add_if_valid_conv(conv.arg_position, - FormatConversionCharToChar(conv.conv))) - return false; + if (!add_if_valid_conv(conv.arg_position, + FormatConversionCharToChar(conv.conv))) + return false; } return used.size() == convs.size() || allow_ignored; } } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.h index ba614bb8b4..64a4a7ce59 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/parser.h @@ -20,25 +20,25 @@ #include <stdlib.h> #include <cassert> -#include <cstdint> +#include <cstdint> #include <initializer_list> #include <iosfwd> #include <iterator> #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> #include "y_absl/strings/internal/str_format/checker.h" #include "y_absl/strings/internal/str_format/extension.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace str_format_internal { -enum class LengthMod : std::uint8_t { h, hh, l, ll, L, j, z, t, q, none }; - -TString LengthModToString(LengthMod v); - +enum class LengthMod : std::uint8_t { h, hh, l, ll, L, j, z, t, q, none }; + +TString LengthModToString(LengthMod v); + // The analyzed properties of a single specified conversion. struct UnboundConversion { UnboundConversion() {} @@ -77,7 +77,7 @@ struct UnboundConversion { InputValue precision; Flags flags = Flags::kBasic; - LengthMod length_mod = LengthMod::none; + LengthMod length_mod = LengthMod::none; FormatConversionChar conv = FormatConversionCharInternal::kNone; }; @@ -91,12 +91,12 @@ const char* ConsumeUnboundConversion(const char* p, const char* end, // Helper tag class for the table below. // It allows fast `char -> ConversionChar/LengthMod/Flags` checking and -// conversions. +// conversions. class ConvTag { public: constexpr ConvTag(FormatConversionChar conversion_char) // NOLINT : tag_(static_cast<uint8_t>(conversion_char)) {} - constexpr ConvTag(LengthMod length_mod) // NOLINT + constexpr ConvTag(LengthMod length_mod) // NOLINT : tag_(0x80 | static_cast<uint8_t>(length_mod)) {} constexpr ConvTag(Flags flags) // NOLINT : tag_(0xc0 | static_cast<uint8_t>(flags)) {} @@ -308,7 +308,7 @@ template <FormatConversionCharSet... C> class ExtendedParsedFormat : public str_format_internal::ParsedFormatBase { public: explicit ExtendedParsedFormat(string_view format) -#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER +#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER __attribute__(( enable_if(str_format_internal::EnsureConstexpr(format), "Format string is not constexpr."), @@ -351,7 +351,7 @@ class ExtendedParsedFormat : public str_format_internal::ParsedFormatBase { : ParsedFormatBase(s, allow_ignored, {C...}) {} }; } // namespace str_format_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_PARSER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/ya.make index ff8069cd0f..63aaefb0c3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_format/ya.make @@ -22,9 +22,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_join_internal.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_join_internal.h index 0a220fa33d..3e9bc53cf6 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_join_internal.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_join_internal.h @@ -34,7 +34,7 @@ #include <cstring> #include <iterator> #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include <utility> @@ -43,7 +43,7 @@ #include "y_absl/strings/str_cat.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // @@ -308,7 +308,7 @@ TString JoinRange(const Range& range, y_absl::string_view separator) { } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_JOIN_INTERNAL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_split_internal.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_split_internal.h index 237864c0ed..158c1ea8ab 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_split_internal.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/str_split_internal.h @@ -47,7 +47,7 @@ #endif // _GLIBCXX_DEBUG namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // This class is implicitly constructible from everything that y_absl::string_view @@ -424,7 +424,7 @@ class Splitter { }; } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_STR_SPLIT_INTERNAL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.cc index 06b1cae79d..f1c2c15528 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.cc @@ -17,7 +17,7 @@ #include "y_absl/strings/internal/utf8.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { size_t EncodeUTF8Char(char *buffer, char32_t utf8_char) { @@ -49,5 +49,5 @@ size_t EncodeUTF8Char(char *buffer, char32_t utf8_char) { } } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.h index 1b2d6abd51..53ef10c972 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/utf8.h @@ -20,10 +20,10 @@ #include <cstddef> #include <cstdint> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // For Unicode code points 0 through 0x10FFFF, EncodeUTF8Char writes @@ -44,7 +44,7 @@ enum { kMaxEncodedUTF8Size = 4 }; size_t EncodeUTF8Char(char *buffer, char32_t utf8_char); } // namespace strings_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_INTERNAL_UTF8_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.cc index 3197bdf432..f13a2f323d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.cc @@ -17,7 +17,7 @@ #include "y_absl/strings/internal/memutil.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN bool EqualsIgnoreCase(y_absl::string_view piece1, y_absl::string_view piece2) noexcept { @@ -39,5 +39,5 @@ bool EndsWithIgnoreCase(y_absl::string_view text, EqualsIgnoreCase(text.substr(text.size() - suffix.size()), suffix); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.h index 4709abc93f..379676bc2d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/match.h @@ -20,7 +20,7 @@ // This file contains simple utilities for performing string matching checks. // All of these function parameters are specified as `y_absl::string_view`, // meaning that these functions can accept `TString`, `y_absl::string_view` or -// NUL-terminated C-style strings. +// NUL-terminated C-style strings. // // Examples: // TString s = "foo"; @@ -38,7 +38,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // StrContains() // @@ -94,7 +94,7 @@ bool StartsWithIgnoreCase(y_absl::string_view text, bool EndsWithIgnoreCase(y_absl::string_view text, y_absl::string_view suffix) noexcept; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_MATCH_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.cc index 528d044fa6..b8896837e1 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.cc @@ -30,7 +30,7 @@ #include <memory> #include <utility> -#include "y_absl/base/attributes.h" +#include "y_absl/base/attributes.h" #include "y_absl/base/internal/raw_logging.h" #include "y_absl/numeric/bits.h" #include "y_absl/strings/ascii.h" @@ -41,7 +41,7 @@ #include "y_absl/strings/str_cat.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN bool SimpleAtof(y_absl::string_view str, float* out) { *out = 0.0; @@ -730,8 +730,8 @@ inline bool safe_parse_sign_and_base(y_absl::string_view* text /*inout*/, // commonly used bases. template <typename IntType> struct LookupTables { - ABSL_CONST_INIT static const IntType kVmaxOverBase[]; - ABSL_CONST_INIT static const IntType kVminOverBase[]; + ABSL_CONST_INIT static const IntType kVmaxOverBase[]; + ABSL_CONST_INIT static const IntType kVminOverBase[]; }; // An array initializer macro for X/base where base in [0, 36]. @@ -755,49 +755,49 @@ struct LookupTables { // } // See https://godbolt.org/z/aneYsb // -// uint128& operator/=(uint128) is not constexpr, so hardcode the resulting -// array to avoid a static initializer. +// uint128& operator/=(uint128) is not constexpr, so hardcode the resulting +// array to avoid a static initializer. template<> -const uint128 LookupTables<uint128>::kVmaxOverBase[] = { - 0, - 0, - MakeUint128(9223372036854775807u, 18446744073709551615u), - MakeUint128(6148914691236517205u, 6148914691236517205u), - MakeUint128(4611686018427387903u, 18446744073709551615u), - MakeUint128(3689348814741910323u, 3689348814741910323u), - MakeUint128(3074457345618258602u, 12297829382473034410u), - MakeUint128(2635249153387078802u, 5270498306774157604u), - MakeUint128(2305843009213693951u, 18446744073709551615u), - MakeUint128(2049638230412172401u, 14347467612885206812u), - MakeUint128(1844674407370955161u, 11068046444225730969u), - MakeUint128(1676976733973595601u, 8384883669867978007u), - MakeUint128(1537228672809129301u, 6148914691236517205u), - MakeUint128(1418980313362273201u, 4256940940086819603u), - MakeUint128(1317624576693539401u, 2635249153387078802u), - MakeUint128(1229782938247303441u, 1229782938247303441u), - MakeUint128(1152921504606846975u, 18446744073709551615u), - MakeUint128(1085102592571150095u, 1085102592571150095u), - MakeUint128(1024819115206086200u, 16397105843297379214u), - MakeUint128(970881267037344821u, 16504981539634861972u), - MakeUint128(922337203685477580u, 14757395258967641292u), - MakeUint128(878416384462359600u, 14054662151397753612u), - MakeUint128(838488366986797800u, 13415813871788764811u), - MakeUint128(802032351030850070u, 4812194106185100421u), - MakeUint128(768614336404564650u, 12297829382473034410u), - MakeUint128(737869762948382064u, 11805916207174113034u), - MakeUint128(709490156681136600u, 11351842506898185609u), - MakeUint128(683212743470724133u, 17080318586768103348u), - MakeUint128(658812288346769700u, 10540996613548315209u), - MakeUint128(636094623231363848u, 15266270957552732371u), - MakeUint128(614891469123651720u, 9838263505978427528u), - MakeUint128(595056260442243600u, 9520900167075897608u), - MakeUint128(576460752303423487u, 18446744073709551615u), - MakeUint128(558992244657865200u, 8943875914525843207u), - MakeUint128(542551296285575047u, 9765923333140350855u), - MakeUint128(527049830677415760u, 8432797290838652167u), - MakeUint128(512409557603043100u, 8198552921648689607u), -}; - +const uint128 LookupTables<uint128>::kVmaxOverBase[] = { + 0, + 0, + MakeUint128(9223372036854775807u, 18446744073709551615u), + MakeUint128(6148914691236517205u, 6148914691236517205u), + MakeUint128(4611686018427387903u, 18446744073709551615u), + MakeUint128(3689348814741910323u, 3689348814741910323u), + MakeUint128(3074457345618258602u, 12297829382473034410u), + MakeUint128(2635249153387078802u, 5270498306774157604u), + MakeUint128(2305843009213693951u, 18446744073709551615u), + MakeUint128(2049638230412172401u, 14347467612885206812u), + MakeUint128(1844674407370955161u, 11068046444225730969u), + MakeUint128(1676976733973595601u, 8384883669867978007u), + MakeUint128(1537228672809129301u, 6148914691236517205u), + MakeUint128(1418980313362273201u, 4256940940086819603u), + MakeUint128(1317624576693539401u, 2635249153387078802u), + MakeUint128(1229782938247303441u, 1229782938247303441u), + MakeUint128(1152921504606846975u, 18446744073709551615u), + MakeUint128(1085102592571150095u, 1085102592571150095u), + MakeUint128(1024819115206086200u, 16397105843297379214u), + MakeUint128(970881267037344821u, 16504981539634861972u), + MakeUint128(922337203685477580u, 14757395258967641292u), + MakeUint128(878416384462359600u, 14054662151397753612u), + MakeUint128(838488366986797800u, 13415813871788764811u), + MakeUint128(802032351030850070u, 4812194106185100421u), + MakeUint128(768614336404564650u, 12297829382473034410u), + MakeUint128(737869762948382064u, 11805916207174113034u), + MakeUint128(709490156681136600u, 11351842506898185609u), + MakeUint128(683212743470724133u, 17080318586768103348u), + MakeUint128(658812288346769700u, 10540996613548315209u), + MakeUint128(636094623231363848u, 15266270957552732371u), + MakeUint128(614891469123651720u, 9838263505978427528u), + MakeUint128(595056260442243600u, 9520900167075897608u), + MakeUint128(576460752303423487u, 18446744073709551615u), + MakeUint128(558992244657865200u, 8943875914525843207u), + MakeUint128(542551296285575047u, 9765923333140350855u), + MakeUint128(527049830677415760u, 8432797290838652167u), + MakeUint128(512409557603043100u, 8198552921648689607u), +}; + // This kVmaxOverBase generated with // for (int base = 2; base < 37; ++base) { // y_absl::int128 max = std::numeric_limits<y_absl::int128>::max(); @@ -922,8 +922,8 @@ inline bool safe_parse_positive_int(y_absl::string_view text, int base, assert(base >= 0); assert(vmax >= static_cast<IntType>(base)); const IntType vmax_over_base = LookupTables<IntType>::kVmaxOverBase[base]; - assert(base < 2 || - std::numeric_limits<IntType>::max() / base == vmax_over_base); + assert(base < 2 || + std::numeric_limits<IntType>::max() / base == vmax_over_base); const char* start = text.data(); const char* end = start + text.size(); // loop over digits @@ -957,8 +957,8 @@ inline bool safe_parse_negative_int(y_absl::string_view text, int base, assert(vmin < 0); assert(vmin <= 0 - base); IntType vmin_over_base = LookupTables<IntType>::kVminOverBase[base]; - assert(base < 2 || - std::numeric_limits<IntType>::min() / base == vmin_over_base); + assert(base < 2 || + std::numeric_limits<IntType>::min() / base == vmin_over_base); // 2003 c++ standard [expr.mul] // "... the sign of the remainder is implementation-defined." // Although (vmin/base)*base + vmin%base is always vmin. @@ -1024,10 +1024,10 @@ inline bool safe_uint_internal(y_absl::string_view text, IntType* value_p, namespace numbers_internal { // Digit conversion. -ABSL_CONST_INIT ABSL_DLL const char kHexChar[] = - "0123456789abcdef"; +ABSL_CONST_INIT ABSL_DLL const char kHexChar[] = + "0123456789abcdef"; -ABSL_CONST_INIT ABSL_DLL const char kHexTable[513] = +ABSL_CONST_INIT ABSL_DLL const char kHexTable[513] = "000102030405060708090a0b0c0d0e0f" "101112131415161718191a1b1c1d1e1f" "202122232425262728292a2b2c2d2e2f" @@ -1045,7 +1045,7 @@ ABSL_CONST_INIT ABSL_DLL const char kHexTable[513] = "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"; -ABSL_CONST_INIT ABSL_DLL const char two_ASCII_digits[100][2] = { +ABSL_CONST_INIT ABSL_DLL const char two_ASCII_digits[100][2] = { {'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, {'0', '5'}, {'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'}, {'1', '0'}, {'1', '1'}, {'1', '2'}, {'1', '3'}, {'1', '4'}, {'1', '5'}, {'1', '6'}, {'1', '7'}, @@ -1089,5 +1089,5 @@ bool safe_strtou128_base(y_absl::string_view text, uint128* value, int base) { } } // namespace numbers_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.h index ce181d8eb1..8f4776f75b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/numbers.h @@ -40,10 +40,10 @@ #include <cstring> #include <ctime> #include <limits> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #ifdef _Y__SSE4_2__ // TODO(jorg): Remove this when we figure out the right way // to swap bytes on SSE 4.2 that works with the compilers @@ -59,24 +59,24 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // SimpleAtoi() // -// Converts the given string (optionally followed or preceded by ASCII -// whitespace) into an integer value, returning `true` if successful. The string -// must reflect a base-10 integer whose value falls within the range of the -// integer type (optionally preceded by a `+` or `-`). If any errors are -// encountered, this function returns `false`, leaving `out` in an unspecified -// state. +// Converts the given string (optionally followed or preceded by ASCII +// whitespace) into an integer value, returning `true` if successful. The string +// must reflect a base-10 integer whose value falls within the range of the +// integer type (optionally preceded by a `+` or `-`). If any errors are +// encountered, this function returns `false`, leaving `out` in an unspecified +// state. template <typename int_type> ABSL_MUST_USE_RESULT bool SimpleAtoi(y_absl::string_view str, int_type* out); // SimpleAtof() // // Converts the given string (optionally followed or preceded by ASCII -// whitespace) into a float, which may be rounded on overflow or underflow, -// returning `true` if successful. +// whitespace) into a float, which may be rounded on overflow or underflow, +// returning `true` if successful. // See https://en.cppreference.com/w/c/string/byte/strtof for details about the // allowed formats for `str`, except SimpleAtof() is locale-independent and will // always use the "C" locale. If any errors are encountered, this function @@ -86,8 +86,8 @@ ABSL_MUST_USE_RESULT bool SimpleAtof(y_absl::string_view str, float* out); // SimpleAtod() // // Converts the given string (optionally followed or preceded by ASCII -// whitespace) into a double, which may be rounded on overflow or underflow, -// returning `true` if successful. +// whitespace) into a double, which may be rounded on overflow or underflow, +// returning `true` if successful. // See https://en.cppreference.com/w/c/string/byte/strtof for details about the // allowed formats for `str`, except SimpleAtod is locale-independent and will // always use the "C" locale. If any errors are encountered, this function @@ -123,21 +123,21 @@ ABSL_MUST_USE_RESULT inline bool SimpleHexAtoi(y_absl::string_view str, ABSL_MUST_USE_RESULT inline bool SimpleHexAtoi(y_absl::string_view str, y_absl::uint128* out); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // End of public API. Implementation details follow. namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace numbers_internal { // Digit conversion. -ABSL_DLL extern const char kHexChar[17]; // 0123456789abcdef -ABSL_DLL extern const char - kHexTable[513]; // 000102030405060708090a0b0c0d0e0f1011... -ABSL_DLL extern const char - two_ASCII_digits[100][2]; // 00, 01, 02, 03... +ABSL_DLL extern const char kHexChar[17]; // 0123456789abcdef +ABSL_DLL extern const char + kHexTable[513]; // 000102030405060708090a0b0c0d0e0f1011... +ABSL_DLL extern const char + two_ASCII_digits[100][2]; // 00, 01, 02, 03... // Writes a two-character representation of 'i' to 'buf'. 'i' must be in the // range 0 <= i < 100, and buf must have space for two characters. Example: @@ -302,7 +302,7 @@ ABSL_MUST_USE_RESULT inline bool SimpleHexAtoi(y_absl::string_view str, return numbers_internal::safe_strtou128_base(str, out, 16); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_NUMBERS_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.cc index 9e11702eae..ebaa952be3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.cc @@ -25,7 +25,7 @@ #include "y_absl/strings/numbers.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN AlphaNum::AlphaNum(Hex hex) { static_assert(numbers_internal::kFastToBufferSize >= 32, @@ -242,5 +242,5 @@ void StrAppend(TString* dest, const AlphaNum& a, const AlphaNum& b, assert(out == begin + dest->size()); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.h index a77c9ae906..3bcd9234b4 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_cat.h @@ -55,7 +55,7 @@ #include <array> #include <cstdint> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include <vector> @@ -64,7 +64,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { // AlphaNumBuffer allows a way to pass a string to StrCat without having to do @@ -405,7 +405,7 @@ SixDigits(double d) { return result; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STR_CAT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_format.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_format.h index 4079f38fb4..b5da2fa822 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_format.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_format.h @@ -71,7 +71,7 @@ #define ABSL_STRINGS_STR_FORMAT_H_ #include <cstdio> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/strings/internal/str_format/arg.h" // IWYU pragma: export #include "y_absl/strings/internal/str_format/bind.h" // IWYU pragma: export @@ -80,7 +80,7 @@ #include "y_absl/strings/internal/str_format/parser.h" // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // UntypedFormatSpec // @@ -427,7 +427,7 @@ int FPrintF(std::FILE* output, const FormatSpec<Args...>& format, // type-safe); prefer `y_absl::SNPrintF()` over `std::snprintf()`. // // In particular, a successful call to `y_absl::SNPrintF()` writes at most `size` -// bytes of the formatted output to `output`, including a NUL-terminator, and +// bytes of the formatted output to `output`, including a NUL-terminator, and // returns the number of bytes that would have been written if truncation did // not occur. In the event of an error, a negative value is returned and `errno` // is set. @@ -806,7 +806,7 @@ struct FormatConvertResult { bool value; }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STR_FORMAT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_join.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_join.h index 46a0323c6e..acb48b4540 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_join.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_join.h @@ -50,7 +50,7 @@ #include <cstring> #include <initializer_list> #include <iterator> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <tuple> #include <type_traits> #include <utility> @@ -60,7 +60,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // Concept: Formatter @@ -287,7 +287,7 @@ TString StrJoin(const std::tuple<T...>& value, return strings_internal::JoinAlgorithm(value, separator, AlphaNumFormatter()); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STR_JOIN_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.cc index 77b78c6c16..b5439a22a7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.cc @@ -17,7 +17,7 @@ #include "y_absl/strings/str_cat.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace strings_internal { using FixedMapping = @@ -78,5 +78,5 @@ int StrReplaceAll(strings_internal::FixedMapping replacements, return StrReplaceAll<strings_internal::FixedMapping>(replacements, target); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.h index 42c85616a0..6640fbea39 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_replace.h @@ -38,7 +38,7 @@ #ifndef ABSL_STRINGS_STR_REPLACE_H_ #define ABSL_STRINGS_STR_REPLACE_H_ -#include <util/generic/string.h> +#include <util/generic/string.h> #include <utility> #include <vector> @@ -46,7 +46,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // StrReplaceAll() // @@ -213,7 +213,7 @@ int StrReplaceAll(const StrToStrMapping& replacements, TString* target) { return substitutions; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STR_REPLACE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.cc index 5f9193e6ba..22a691811f 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.cc @@ -27,7 +27,7 @@ #include "y_absl/strings/ascii.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { @@ -135,5 +135,5 @@ y_absl::string_view ByLength::Find(y_absl::string_view text, return y_absl::string_view(substr.data() + length_, 0); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.h index d32d54813e..8d8c54d6ff 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/str_split.h @@ -39,7 +39,7 @@ #include <cstddef> #include <map> #include <set> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <utility> #include <vector> @@ -50,7 +50,7 @@ #include "y_absl/strings/strip.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN //------------------------------------------------------------------------------ // Delimiters @@ -542,7 +542,7 @@ StrSplit(StringType&& text, Delimiter d, Predicate p) { std::move(text), DelimiterType(d), std::move(p)); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STR_SPLIT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.cc index 9893c7ab99..149897e3e0 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/string_view.cc @@ -24,7 +24,7 @@ #include "y_absl/strings/internal/memutil.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { void WritePadding(std::ostream& o, size_t pad) { @@ -224,7 +224,7 @@ constexpr string_view::size_type string_view::npos; ABSL_STRING_VIEW_SELECTANY constexpr string_view::size_type string_view::kMaxSize; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_STRING_VIEW 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_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h index 3164ff1ebc..204acb75df 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/strip.h @@ -22,7 +22,7 @@ #define ABSL_STRINGS_STRIP_H_ #include <cstddef> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/macros.h" #include "y_absl/strings/ascii.h" @@ -30,7 +30,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ConsumePrefix() // @@ -85,7 +85,7 @@ ABSL_MUST_USE_RESULT inline y_absl::string_view StripSuffix( return str; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_STRIP_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.cc index 177fba8cbe..e02e1a263e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.cc @@ -23,7 +23,7 @@ #include "y_absl/strings/string_view.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace substitute_internal { void SubstituteAndAppendArray(TString* output, y_absl::string_view format, @@ -168,5 +168,5 @@ Arg::Arg(Dec dec) { } } // namespace substitute_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.h index c31191fbda..d5ab12648e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/substitute.h @@ -71,7 +71,7 @@ #define ABSL_STRINGS_SUBSTITUTE_H_ #include <cstring> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include <vector> @@ -86,7 +86,7 @@ #include "y_absl/strings/strip.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace substitute_internal { // Arg @@ -194,12 +194,12 @@ void SubstituteAndAppendArray(TString* output, y_absl::string_view format, #if defined(ABSL_BAD_CALL_IF) constexpr int CalculateOneBit(const char* format) { - // Returns: - // * 2^N for '$N' when N is in [0-9] - // * 0 for correct '$' escaping: '$$'. - // * -1 otherwise. - return (*format < '0' || *format > '9') ? (*format == '$' ? 0 : -1) - : (1 << (*format - '0')); + // Returns: + // * 2^N for '$N' when N is in [0-9] + // * 0 for correct '$' escaping: '$$'. + // * -1 otherwise. + return (*format < '0' || *format > '9') ? (*format == '$' ? 0 : -1) + : (1 << (*format - '0')); } constexpr const char* SkipNumber(const char* format) { @@ -717,7 +717,7 @@ TString Substitute( "contains an unescaped $ character (use $$ instead)"); #endif // ABSL_BAD_CALL_IF -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_STRINGS_SUBSTITUTE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make index 77c5a47dc9..e855cade20 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/ya.make @@ -21,9 +21,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/absl_strings_internal ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.cc index b03f0ff559..f2f78e308c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.cc @@ -18,7 +18,7 @@ #include "y_absl/synchronization/mutex.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Return whether int *arg is zero. static bool IsZero(void *arg) { @@ -48,5 +48,5 @@ bool Barrier::Block() { return this->num_to_exit_ == 0; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.h index 527bd42be0..bd5d92dc57 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/barrier.h @@ -23,7 +23,7 @@ #include "y_absl/synchronization/mutex.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Barrier // @@ -74,6 +74,6 @@ class Barrier { int num_to_exit_ ABSL_GUARDED_BY(lock_); }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_BARRIER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.cc index 056185e51e..2138b05aa9 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.cc @@ -19,7 +19,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { @@ -63,5 +63,5 @@ void BlockingCounter::Wait() { // after we return from this method. } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.h index a1644903e3..4070bcfaff 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/blocking_counter.h @@ -26,7 +26,7 @@ #include "y_absl/synchronization/mutex.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // BlockingCounter // @@ -95,7 +95,7 @@ class BlockingCounter { bool done_ ABSL_GUARDED_BY(lock_); }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_BLOCKING_COUNTER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.cc index 3c5764eeb9..fae494099a 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.cc @@ -27,7 +27,7 @@ #include "y_absl/synchronization/internal/per_thread_sem.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // ThreadIdentity storage is persistent, we maintain a free-list of previously @@ -134,7 +134,7 @@ base_internal::ThreadIdentity* CreateThreadIdentity() { } } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_LOW_LEVEL_ALLOC_MISSING diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.h index d93209f424..573a9e1b26 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/create_thread_identity.h @@ -29,7 +29,7 @@ #include "y_absl/base/port.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // Allocates and attaches a ThreadIdentity object for the calling thread. @@ -54,7 +54,7 @@ inline base_internal::ThreadIdentity* GetOrCreateCurrentThreadIdentity() { } } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_CREATE_THREAD_IDENTITY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.cc index d8987c1a98..1498560ad4 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.cc @@ -45,7 +45,7 @@ // Do not use STL. This module does not use standard memory allocation. namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { namespace { @@ -692,7 +692,7 @@ int GraphCycles::GetStackTrace(GraphId id, void*** ptr) { } } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_LOW_LEVEL_ALLOC_MISSING diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.h index eaf130bc29..a6ab7c2fb7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/graphcycles.h @@ -40,10 +40,10 @@ #include <cstdint> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // Opaque identifier for a graph node. @@ -135,7 +135,7 @@ class GraphCycles { }; } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/kernel_timeout.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/kernel_timeout.h index ee4078702d..27b4204e9e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/kernel_timeout.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/kernel_timeout.h @@ -35,7 +35,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { class Futex; @@ -150,7 +150,7 @@ inline struct timespec KernelTimeout::MakeAbsTimespec() { } } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_KERNEL_TIMEOUT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.cc index 3e40e812a9..45cad03ad7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.cc @@ -25,7 +25,7 @@ #include "y_absl/synchronization/internal/waiter.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { void PerThreadSem::SetThreadBlockedCounter(std::atomic<int> *counter) { @@ -63,7 +63,7 @@ void PerThreadSem::Tick(base_internal::ThreadIdentity *identity) { } } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl extern "C" { diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.h index 2fc39ca130..9d629cb99e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/per_thread_sem.h @@ -32,7 +32,7 @@ #include "y_absl/synchronization/internal/kernel_timeout.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class Mutex; @@ -86,7 +86,7 @@ class PerThreadSem { }; } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // In some build configurations we pass --detect-odr-violations to the diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/thread_pool.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/thread_pool.h index 8b8912d494..d21b87e337 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/thread_pool.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/thread_pool.h @@ -26,7 +26,7 @@ #include "y_absl/synchronization/mutex.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // A simple ThreadPool implementation for tests. @@ -87,7 +87,7 @@ class ThreadPool { }; } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_THREAD_POOL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.cc index 573ce9c6c5..e3161e7e51 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.cc @@ -50,7 +50,7 @@ namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { static void MaybeBecomeIdle() { @@ -82,7 +82,7 @@ bool Waiter::Wait(KernelTimeout t) { while (true) { int32_t x = futex_.load(std::memory_order_relaxed); - while (x != 0) { + while (x != 0) { if (!futex_.compare_exchange_weak(x, x - 1, std::memory_order_acquire, std::memory_order_relaxed)) { @@ -258,7 +258,7 @@ bool Waiter::Wait(KernelTimeout t) { bool first_pass = true; while (true) { int x = wakeups_.load(std::memory_order_relaxed); - while (x != 0) { + while (x != 0) { if (!wakeups_.compare_exchange_weak(x, x - 1, std::memory_order_acquire, std::memory_order_relaxed)) { @@ -312,29 +312,29 @@ class Waiter::WinHelper { return reinterpret_cast<CONDITION_VARIABLE *>(&w->cv_storage_); } - static_assert(sizeof(SRWLOCK) == sizeof(void *), - "`mu_storage_` does not have the same size as SRWLOCK"); - static_assert(alignof(SRWLOCK) == alignof(void *), - "`mu_storage_` does not have the same alignment as SRWLOCK"); - - static_assert(sizeof(CONDITION_VARIABLE) == sizeof(void *), - "`ABSL_CONDITION_VARIABLE_STORAGE` does not have the same size " - "as `CONDITION_VARIABLE`"); + static_assert(sizeof(SRWLOCK) == sizeof(void *), + "`mu_storage_` does not have the same size as SRWLOCK"); + static_assert(alignof(SRWLOCK) == alignof(void *), + "`mu_storage_` does not have the same alignment as SRWLOCK"); + + static_assert(sizeof(CONDITION_VARIABLE) == sizeof(void *), + "`ABSL_CONDITION_VARIABLE_STORAGE` does not have the same size " + "as `CONDITION_VARIABLE`"); static_assert( - alignof(CONDITION_VARIABLE) == alignof(void *), - "`cv_storage_` does not have the same alignment as `CONDITION_VARIABLE`"); + alignof(CONDITION_VARIABLE) == alignof(void *), + "`cv_storage_` does not have the same alignment as `CONDITION_VARIABLE`"); // The SRWLOCK and CONDITION_VARIABLE types must be trivially constructible // and destructible because we never call their constructors or destructors. static_assert(std::is_trivially_constructible<SRWLOCK>::value, - "The `SRWLOCK` type must be trivially constructible"); - static_assert( - std::is_trivially_constructible<CONDITION_VARIABLE>::value, - "The `CONDITION_VARIABLE` type must be trivially constructible"); + "The `SRWLOCK` type must be trivially constructible"); + static_assert( + std::is_trivially_constructible<CONDITION_VARIABLE>::value, + "The `CONDITION_VARIABLE` type must be trivially constructible"); static_assert(std::is_trivially_destructible<SRWLOCK>::value, - "The `SRWLOCK` type must be trivially destructible"); + "The `SRWLOCK` type must be trivially destructible"); static_assert(std::is_trivially_destructible<CONDITION_VARIABLE>::value, - "The `CONDITION_VARIABLE` type must be trivially destructible"); + "The `CONDITION_VARIABLE` type must be trivially destructible"); }; class LockHolder { @@ -424,5 +424,5 @@ void Waiter::InternalCondVarPoke() { #endif } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.h index e6fede411f..4e868f5ada 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/waiter.h @@ -58,7 +58,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace synchronization_internal { // Waiter is an OS-specific semaphore. @@ -136,10 +136,10 @@ class Waiter { // REQUIRES: WinHelper::GetLock(this) must be held. void InternalCondVarPoke(); - // We can't include Windows.h in our headers, so we use aligned charachter - // buffers to define the storage of SRWLOCK and CONDITION_VARIABLE. - alignas(void*) unsigned char mu_storage_[sizeof(void*)]; - alignas(void*) unsigned char cv_storage_[sizeof(void*)]; + // We can't include Windows.h in our headers, so we use aligned charachter + // buffers to define the storage of SRWLOCK and CONDITION_VARIABLE. + alignas(void*) unsigned char mu_storage_[sizeof(void*)]; + alignas(void*) unsigned char cv_storage_[sizeof(void*)]; int waiter_count_; int wakeup_count_; @@ -149,7 +149,7 @@ class Waiter { }; } // namespace synchronization_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_INTERNAL_WAITER_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/ya.make index 167e710a78..f429a42b59 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/internal/ya.make @@ -19,9 +19,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc index babe5c4ada..e6b749df72 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.cc @@ -76,7 +76,7 @@ ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalMutexYield)() { } // extern "C" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { @@ -90,16 +90,16 @@ ABSL_CONST_INIT std::atomic<OnDeadlockCycle> synch_deadlock_detection( kDeadlockDetectionDefault); ABSL_CONST_INIT std::atomic<bool> synch_check_invariants(false); -ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES y_absl::base_internal::AtomicHook<void (*)(int64_t wait_cycles)> submit_profile_data; -ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES y_absl::base_internal::AtomicHook<void (*)( - const char *msg, const void *obj, int64_t wait_cycles)> - mutex_tracer; -ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES - y_absl::base_internal::AtomicHook<void (*)(const char *msg, const void *cv)> - cond_var_tracer; -ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES y_absl::base_internal::AtomicHook< +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES y_absl::base_internal::AtomicHook<void (*)( + const char *msg, const void *obj, int64_t wait_cycles)> + mutex_tracer; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES + y_absl::base_internal::AtomicHook<void (*)(const char *msg, const void *cv)> + cond_var_tracer; +ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES y_absl::base_internal::AtomicHook< bool (*)(const void *pc, char *out, int out_size)> symbolizer(y_absl::Symbolize); @@ -2747,5 +2747,5 @@ bool Condition::GuaranteedEqual(const Condition *a, const Condition *b) { a->arg_ == b->arg_ && a->method_ == b->method_; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.h index 0762a852df..c4dfc1aa07 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/mutex.h @@ -60,7 +60,7 @@ #include <atomic> #include <cstdint> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/const_init.h" #include "y_absl/base/internal/identity.h" @@ -74,7 +74,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class Condition; struct SynchWaitParams; @@ -1027,7 +1027,7 @@ void RegisterCondVarTracer(void (*fn)(const char *msg, const void *cv)); // // 'pc' is the program counter being symbolized, 'out' is the buffer to write // into, and 'out_size' is the size of the buffer. This function can return -// false if symbolizing failed, or true if a NUL-terminated symbol was written +// false if symbolizing failed, or true if a NUL-terminated symbol was written // to 'out.' // // This has the same memory ordering concerns as RegisterMutexProfiler() above. @@ -1066,7 +1066,7 @@ enum class OnDeadlockCycle { // the manner chosen here. void SetMutexDeadlockDetectionMode(OnDeadlockCycle mode); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // In some build configurations we pass --detect-odr-violations to the diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.cc index 0b5c5a5e48..bc005459c0 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.cc @@ -22,7 +22,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN void Notification::Notify() { MutexLock l(&this->mutex_); @@ -74,5 +74,5 @@ bool Notification::WaitForNotificationWithDeadline(y_absl::Time deadline) const return notified; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.h b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.h index eea7090f18..ac3ca02bca 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/notification.h @@ -57,7 +57,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // Notification @@ -117,7 +117,7 @@ class Notification { std::atomic<bool> notified_yet_; // written under mutex_ }; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_SYNCHRONIZATION_NOTIFICATION_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make index 860fd01b0f..7f41f563fc 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/synchronization/ya.make @@ -31,9 +31,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.cc index f24bac91e8..0cb0198459 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.cc @@ -15,13 +15,13 @@ #include "y_absl/time/civil_time.h" #include <cstdlib> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/strings/str_cat.h" #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { @@ -169,5 +169,5 @@ std::ostream& operator<<(std::ostream& os, CivilSecond s) { } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.h index 64fb6da494..ce425b6f90 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time.h @@ -70,13 +70,13 @@ #ifndef ABSL_TIME_CIVIL_TIME_H_ #define ABSL_TIME_CIVIL_TIME_H_ -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/strings/string_view.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { struct second_tag : cctz::detail::second_tag {}; @@ -532,7 +532,7 @@ std::ostream& operator<<(std::ostream& os, CivilSecond s); } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_CIVIL_TIME_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time/ya.make index 919773f619..07dfa2b3b8 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/civil_time/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.cc index dcc12b5633..d5fee03909 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.cc @@ -35,7 +35,7 @@ #include "y_absl/base/thread_annotations.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN Time Now() { // TODO(bww): Get a timespec instead so we don't have to divide. int64_t n = y_absl::GetCurrentTimeNanos(); @@ -45,7 +45,7 @@ Time Now() { } return time_internal::FromUnixDuration(y_absl::Nanoseconds(n)); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // Decide if we should use the fast GetCurrentTimeNanos() algorithm @@ -74,9 +74,9 @@ ABSL_NAMESPACE_END #if !ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN int64_t GetCurrentTimeNanos() { return GET_CURRENT_TIME_NANOS_FROM_SYSTEM(); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // Use the cyclecounter-based implementation below. @@ -87,7 +87,7 @@ ABSL_NAMESPACE_END #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { // This is a friend wrapper around UnscaledCycleClock::Now() // (needed to access UnscaledCycleClock). @@ -535,12 +535,12 @@ static uint64_t UpdateLastSample(uint64_t now_cycles, uint64_t now_ns, return estimated_base_ns; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { // Returns the maximum duration that SleepOnce() can sleep for. @@ -568,7 +568,7 @@ void SleepOnce(y_absl::Duration to_sleep) { } } // namespace -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl extern "C" { diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.h index 178b96d828..1b32d0b12f 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/clock.h @@ -26,7 +26,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Now() // @@ -50,7 +50,7 @@ int64_t GetCurrentTimeNanos(); // * Returns immediately when passed a nonpositive duration. void SleepFor(y_absl::Duration duration); -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl // ----------------------------------------------------------------------------- diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/duration.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/duration.cc index d4914556e6..919fdc339e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/duration.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/duration.cc @@ -64,7 +64,7 @@ #include <ctime> #include <functional> #include <limits> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/base/casts.h" #include "y_absl/base/macros.h" @@ -74,7 +74,7 @@ #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { @@ -950,5 +950,5 @@ bool ParseFlag(const TString& text, Duration* dst, TString* ) { TString UnparseFlag(Duration d) { return FormatDuration(d); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/format.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/format.cc index c75e4ec21a..76ea892eb6 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/format.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/format.cc @@ -25,7 +25,7 @@ namespace cctz = y_absl::time_internal::cctz; namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN ABSL_DLL extern const char RFC3339_full[] = "%Y-%m-%d%ET%H:%M:%E*S%Ez"; ABSL_DLL extern const char RFC3339_sec[] = "%Y-%m-%d%ET%H:%M:%S%Ez"; @@ -156,5 +156,5 @@ TString UnparseFlag(y_absl::Time t) { return y_absl::FormatTime(RFC3339_full, t, y_absl::UTCTimeZone()); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time.h index be60a54dbe..21cbb8e9bf 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time.h @@ -15,11 +15,11 @@ #ifndef ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_H_ #define ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_H_ -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time_detail.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -326,7 +326,7 @@ using detail::get_yearday; } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time_detail.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time_detail.h index 0e71a7cd33..927417fbed 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time_detail.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/civil_time_detail.h @@ -20,8 +20,8 @@ #include <ostream> #include <type_traits> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + // Disable constexpr support unless we are in C++14 mode. #if __cpp_constexpr >= 201304 || (defined(_MSC_VER) && _MSC_VER >= 1910) #define CONSTEXPR_D constexpr // data @@ -34,7 +34,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -56,8 +56,8 @@ using second_t = std::int_fast8_t; // [0:59] // Normalized civil-time fields: Y-M-D HH:MM:SS. struct fields { - CONSTEXPR_M fields(year_t year, month_t month, day_t day, hour_t hour, - minute_t minute, second_t second) + CONSTEXPR_M fields(year_t year, month_t month, day_t day, hour_t hour, + minute_t minute, second_t second) : y(year), m(month), d(day), hh(hour), mm(minute), ss(second) {} std::int_least64_t y; std::int_least8_t m; @@ -104,8 +104,8 @@ CONSTEXPR_F int days_per_month(year_t y, month_t m) noexcept { return k_days_per_month[m] + (m == 2 && is_leap_year(y)); } -CONSTEXPR_F fields n_day(year_t y, month_t m, diff_t d, diff_t cd, hour_t hh, - minute_t mm, second_t ss) noexcept { +CONSTEXPR_F fields n_day(year_t y, month_t m, diff_t d, diff_t cd, hour_t hh, + minute_t mm, second_t ss) noexcept { year_t ey = y % 400; const year_t oey = ey; ey += (cd / 146097) * 400; @@ -165,8 +165,8 @@ CONSTEXPR_F fields n_day(year_t y, month_t m, diff_t d, diff_t cd, hour_t hh, } return fields(y + (ey - oey), m, static_cast<day_t>(d), hh, mm, ss); } -CONSTEXPR_F fields n_mon(year_t y, diff_t m, diff_t d, diff_t cd, hour_t hh, - minute_t mm, second_t ss) noexcept { +CONSTEXPR_F fields n_mon(year_t y, diff_t m, diff_t d, diff_t cd, hour_t hh, + minute_t mm, second_t ss) noexcept { if (m != 12) { y += m / 12; m %= 12; @@ -177,8 +177,8 @@ CONSTEXPR_F fields n_mon(year_t y, diff_t m, diff_t d, diff_t cd, hour_t hh, } return n_day(y, static_cast<month_t>(m), d, cd, hh, mm, ss); } -CONSTEXPR_F fields n_hour(year_t y, diff_t m, diff_t d, diff_t cd, diff_t hh, - minute_t mm, second_t ss) noexcept { +CONSTEXPR_F fields n_hour(year_t y, diff_t m, diff_t d, diff_t cd, diff_t hh, + minute_t mm, second_t ss) noexcept { cd += hh / 24; hh %= 24; if (hh < 0) { @@ -277,8 +277,8 @@ CONSTEXPR_F diff_t ymd_ord(year_t y, month_t m, day_t d) noexcept { // yet the difference between two such extreme values may actually be // small, so we take a little care to avoid overflow when possible by // exploiting the 146097-day cycle. -CONSTEXPR_F diff_t day_difference(year_t y1, month_t m1, day_t d1, year_t y2, - month_t m2, day_t d2) noexcept { +CONSTEXPR_F diff_t day_difference(year_t y1, month_t m1, day_t d1, year_t y2, + month_t m2, day_t d2) noexcept { const diff_t a_c4_off = y1 % 400; const diff_t b_c4_off = y2 % 400; diff_t c4_diff = (y1 - a_c4_off) - (y2 - b_c4_off); @@ -318,7 +318,7 @@ CONSTEXPR_F diff_t difference(second_tag, fields f1, fields f2) noexcept { //////////////////////////////////////////////////////////////////////// // Aligns the (normalized) fields struct to the indicated field. -CONSTEXPR_F fields align(second_tag, fields f) noexcept { return f; } +CONSTEXPR_F fields align(second_tag, fields f) noexcept { return f; } CONSTEXPR_F fields align(minute_tag, fields f) noexcept { return fields{f.y, f.m, f.d, f.hh, f.mm, 0}; } @@ -397,11 +397,11 @@ class civil_time { : civil_time(ct.f_) {} // Factories for the maximum/minimum representable civil_time. - static CONSTEXPR_F civil_time(max)() { + static CONSTEXPR_F civil_time(max)() { const auto max_year = (std::numeric_limits<std::int_least64_t>::max)(); return civil_time(max_year, 12, 31, 23, 59, 59); } - static CONSTEXPR_F civil_time(min)() { + static CONSTEXPR_F civil_time(min)() { const auto min_year = (std::numeric_limits<std::int_least64_t>::min)(); return civil_time(min_year, 1, 1, 0, 0, 0); } @@ -421,13 +421,13 @@ class civil_time { CONSTEXPR_M civil_time& operator-=(diff_t n) noexcept { return *this = *this - n; } - CONSTEXPR_M civil_time& operator++() noexcept { return *this += 1; } + CONSTEXPR_M civil_time& operator++() noexcept { return *this += 1; } CONSTEXPR_M civil_time operator++(int) noexcept { const civil_time a = *this; ++*this; return a; } - CONSTEXPR_M civil_time& operator--() noexcept { return *this -= 1; } + CONSTEXPR_M civil_time& operator--() noexcept { return *this -= 1; } CONSTEXPR_M civil_time operator--(int) noexcept { const civil_time a = *this; --*this; @@ -486,17 +486,17 @@ using civil_second = civil_time<second_tag>; template <typename T1, typename T2> CONSTEXPR_F bool operator<(const civil_time<T1>& lhs, const civil_time<T2>& rhs) noexcept { - return ( - lhs.year() < rhs.year() || - (lhs.year() == rhs.year() && - (lhs.month() < rhs.month() || - (lhs.month() == rhs.month() && - (lhs.day() < rhs.day() || (lhs.day() == rhs.day() && - (lhs.hour() < rhs.hour() || - (lhs.hour() == rhs.hour() && - (lhs.minute() < rhs.minute() || - (lhs.minute() == rhs.minute() && - (lhs.second() < rhs.second()))))))))))); + return ( + lhs.year() < rhs.year() || + (lhs.year() == rhs.year() && + (lhs.month() < rhs.month() || + (lhs.month() == rhs.month() && + (lhs.day() < rhs.day() || (lhs.day() == rhs.day() && + (lhs.hour() < rhs.hour() || + (lhs.hour() == rhs.hour() && + (lhs.minute() < rhs.minute() || + (lhs.minute() == rhs.minute() && + (lhs.second() < rhs.second()))))))))))); } template <typename T1, typename T2> CONSTEXPR_F bool operator<=(const civil_time<T1>& lhs, @@ -618,7 +618,7 @@ std::ostream& operator<<(std::ostream& os, weekday wd); } // namespace detail } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #undef CONSTEXPR_M diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/time_zone.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/time_zone.h index 524654df4b..824f1e15c1 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/time_zone.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/time_zone.h @@ -23,14 +23,14 @@ #include <chrono> #include <cstdint> #include <limits> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <utility> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -186,13 +186,13 @@ class time_zone { bool next_transition(const time_point<seconds>& tp, civil_transition* trans) const; template <typename D> - bool next_transition(const time_point<D>& tp, civil_transition* trans) const { + bool next_transition(const time_point<D>& tp, civil_transition* trans) const { return next_transition(detail::split_seconds(tp).first, trans); } bool prev_transition(const time_point<seconds>& tp, civil_transition* trans) const; template <typename D> - bool prev_transition(const time_point<D>& tp, civil_transition* trans) const { + bool prev_transition(const time_point<D>& tp, civil_transition* trans) const { return prev_transition(detail::split_seconds(tp).first, trans); } @@ -210,7 +210,7 @@ class time_zone { friend bool operator==(time_zone lhs, time_zone rhs) { return &lhs.effective_impl() == &rhs.effective_impl(); } - friend bool operator!=(time_zone lhs, time_zone rhs) { return !(lhs == rhs); } + friend bool operator!=(time_zone lhs, time_zone rhs) { return !(lhs == rhs); } template <typename H> friend H AbslHashValue(H h, time_zone tz) { @@ -453,7 +453,7 @@ inline bool join_seconds(const time_point<seconds>& sec, const femtoseconds&, } // namespace detail } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/zone_info_source.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/zone_info_source.h index fd6dc4bbb0..9aff49cc50 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/zone_info_source.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/include/cctz/zone_info_source.h @@ -20,10 +20,10 @@ #include <memory> #include <util/generic/string.h> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -33,7 +33,7 @@ class ZoneInfoSource { virtual ~ZoneInfoSource(); virtual std::size_t Read(void* ptr, std::size_t size) = 0; // like fread() - virtual int Skip(std::size_t offset) = 0; // like fseek() + virtual int Skip(std::size_t offset) = 0; // like fseek() // Until the zoneinfo data supports versioning information, we provide // a way for a ZoneInfoSource to indicate it out-of-band. The default @@ -43,11 +43,11 @@ class ZoneInfoSource { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz_extension { @@ -57,8 +57,8 @@ namespace cctz_extension { using ZoneInfoSourceFactory = std::unique_ptr<y_absl::time_internal::cctz::ZoneInfoSource> (*)( const TString&, - const std::function<std::unique_ptr< - y_absl::time_internal::cctz::ZoneInfoSource>(const TString&)>&); + const std::function<std::unique_ptr< + y_absl::time_internal::cctz::ZoneInfoSource>(const TString&)>&); // The user can control the mapping of zone names to zoneinfo data by // providing a definition for cctz_extension::zone_info_source_factory. @@ -96,7 +96,7 @@ extern ZoneInfoSourceFactory zone_info_source_factory; } // namespace cctz_extension } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_ZONE_INFO_SOURCE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/civil_time_detail.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/civil_time_detail.cc index 61dbfc96ab..d90871be12 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/civil_time_detail.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/civil_time_detail.cc @@ -18,10 +18,10 @@ #include <ostream> #include <sstream> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { namespace detail { @@ -90,5 +90,5 @@ std::ostream& operator<<(std::ostream& os, weekday wd) { } // namespace detail } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.cc index 3a22cbea1d..a41b9cbef3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.cc @@ -18,12 +18,12 @@ #include <cassert> #include <chrono> #include <cstring> -#include <util/generic/string.h> - -#include "y_absl/base/config.h" +#include <util/generic/string.h> +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -62,9 +62,9 @@ bool FixedOffsetFromName(const TString& name, seconds* offset) { const char* const ep = kFixedZonePrefix + prefix_len; if (name.size() != prefix_len + 9) // <prefix>+99:99:99 return false; - if (!std::equal(kFixedZonePrefix, ep, name.begin())) return false; + if (!std::equal(kFixedZonePrefix, ep, name.begin())) return false; const char* np = name.data() + prefix_len; - if (np[0] != '+' && np[0] != '-') return false; + if (np[0] != '+' && np[0] != '-') return false; if (np[3] != ':' || np[6] != ':') // see note below about large offsets return false; @@ -89,29 +89,29 @@ TString FixedOffsetToName(const seconds& offset) { // offsets and to (somewhat) limit the total number of zones. return "UTC"; } - int offset_seconds = static_cast<int>(offset.count()); - const char sign = (offset_seconds < 0 ? '-' : '+'); - int offset_minutes = offset_seconds / 60; - offset_seconds %= 60; + int offset_seconds = static_cast<int>(offset.count()); + const char sign = (offset_seconds < 0 ? '-' : '+'); + int offset_minutes = offset_seconds / 60; + offset_seconds %= 60; if (sign == '-') { - if (offset_seconds > 0) { - offset_seconds -= 60; - offset_minutes += 1; + if (offset_seconds > 0) { + offset_seconds -= 60; + offset_minutes += 1; } - offset_seconds = -offset_seconds; - offset_minutes = -offset_minutes; + offset_seconds = -offset_seconds; + offset_minutes = -offset_minutes; } - int offset_hours = offset_minutes / 60; - offset_minutes %= 60; + int offset_hours = offset_minutes / 60; + offset_minutes %= 60; const std::size_t prefix_len = sizeof(kFixedZonePrefix) - 1; char buf[prefix_len + sizeof("-24:00:00")]; char* ep = std::copy(kFixedZonePrefix, kFixedZonePrefix + prefix_len, buf); *ep++ = sign; - ep = Format02d(ep, offset_hours); + ep = Format02d(ep, offset_hours); *ep++ = ':'; - ep = Format02d(ep, offset_minutes); + ep = Format02d(ep, offset_minutes); *ep++ = ':'; - ep = Format02d(ep, offset_seconds); + ep = Format02d(ep, offset_seconds); *ep++ = '\0'; assert(ep == buf + sizeof(buf)); return buf; @@ -136,5 +136,5 @@ TString FixedOffsetToAbbr(const seconds& offset) { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.h index 39b24e5a32..8e6c862cc2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_fixed.h @@ -15,13 +15,13 @@ #ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_ #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_ -#include <util/generic/string.h> +#include <util/generic/string.h> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -46,7 +46,7 @@ TString FixedOffsetToAbbr(const seconds& offset); } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_format.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_format.cc index 2f9597018b..ee1309582a 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_format.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_format.cc @@ -13,18 +13,18 @@ // limitations under the License. #if !defined(HAS_STRPTIME) -#if !defined(_MSC_VER) && !defined(__MINGW32__) -#define HAS_STRPTIME 1 // assume everyone has strptime() except windows -#endif +#if !defined(_MSC_VER) && !defined(__MINGW32__) +#define HAS_STRPTIME 1 // assume everyone has strptime() except windows #endif +#endif #if defined(HAS_STRPTIME) && HAS_STRPTIME -#if !defined(_XOPEN_SOURCE) -#define _XOPEN_SOURCE // Definedness suffices for strptime. -#endif +#if !defined(_XOPEN_SOURCE) +#define _XOPEN_SOURCE // Definedness suffices for strptime. #endif +#endif -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" // Include time.h directly since, by C++ standards, ctime doesn't have to @@ -38,7 +38,7 @@ #include <cstring> #include <ctime> #include <limits> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> #if !HAS_STRPTIME #include <iomanip> @@ -49,7 +49,7 @@ #include "time_zone_if.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { namespace detail { @@ -555,9 +555,9 @@ TString format(const TString& format, const time_point<seconds>& tp, bp = ep; if (n > 0) { if (n > kDigits10_64) n = kDigits10_64; - bp = Format64(bp, n, - (n > 15) ? fs.count() * kExp10[n - 15] - : fs.count() / kExp10[15 - n]); + bp = Format64(bp, n, + (n > 15) ? fs.count() * kExp10[n - 15] + : fs.count() / kExp10[15 - n]); if (*np == 'S') *--bp = '.'; } if (*np == 'S') bp = Format02d(bp, al.cs.second()); @@ -813,9 +813,9 @@ bool parse(const TString& format, const TString& input, data = ParseZone(data, &zone); continue; case 's': - data = - ParseInt(data, 0, std::numeric_limits<std::int_fast64_t>::min(), - std::numeric_limits<std::int_fast64_t>::max(), &percent_s); + data = + ParseInt(data, 0, std::numeric_limits<std::int_fast64_t>::min(), + std::numeric_limits<std::int_fast64_t>::max(), &percent_s); if (data != nullptr) saw_percent_s = true; continue; case ':': @@ -1025,5 +1025,5 @@ bool parse(const TString& format, const TString& input, } // namespace detail } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.cc index 2fe6d23c71..63daba1d16 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.cc @@ -13,13 +13,13 @@ // limitations under the License. #include "time_zone_if.h" - -#include "y_absl/base/config.h" + +#include "y_absl/base/config.h" #include "time_zone_info.h" #include "time_zone_libc.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -41,5 +41,5 @@ TimeZoneIf::~TimeZoneIf() {} } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.h index 10312badc2..add9c2b78b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_if.h @@ -18,14 +18,14 @@ #include <chrono> #include <cstdint> #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -40,7 +40,7 @@ class TimeZoneIf { virtual time_zone::absolute_lookup BreakTime( const time_point<seconds>& tp) const = 0; - virtual time_zone::civil_lookup MakeTime(const civil_second& cs) const = 0; + virtual time_zone::civil_lookup MakeTime(const civil_second& cs) const = 0; virtual bool NextTransition(const time_point<seconds>& tp, time_zone::civil_transition* trans) const = 0; @@ -60,18 +60,18 @@ class TimeZoneIf { // (That is, that they share an epoch, which is required since C++20.) inline std::int_fast64_t ToUnixSeconds(const time_point<seconds>& tp) { return (tp - std::chrono::time_point_cast<seconds>( - std::chrono::system_clock::from_time_t(0))) - .count(); + std::chrono::system_clock::from_time_t(0))) + .count(); } inline time_point<seconds> FromUnixSeconds(std::int_fast64_t t) { return std::chrono::time_point_cast<seconds>( - std::chrono::system_clock::from_time_t(0)) + - seconds(t); + std::chrono::system_clock::from_time_t(0)) + + seconds(t); } } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.cc index 3810defe3c..5273934293 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.cc @@ -17,15 +17,15 @@ #include <deque> #include <memory> #include <mutex> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <unordered_map> #include <utility> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "time_zone_fixed.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -46,7 +46,7 @@ std::mutex& TimeZoneMutex() { } // namespace -time_zone time_zone::Impl::UTC() { return time_zone(UTCImpl()); } +time_zone time_zone::Impl::UTC() { return time_zone(UTCImpl()); } bool time_zone::Impl::LoadTimeZone(const TString& name, time_zone* tz) { const Impl* const utc_impl = UTCImpl(); @@ -109,5 +109,5 @@ const time_zone::Impl* time_zone::Impl::UTCImpl() { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.h index c014ab41df..8cb580766a 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_impl.h @@ -16,16 +16,16 @@ #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IMPL_H_ #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" #include "time_zone_if.h" #include "time_zone_info.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -87,7 +87,7 @@ class time_zone::Impl { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IMPL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.cc index 72f7bdc3ca..460186a5dc 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.cc @@ -43,16 +43,16 @@ #include <functional> #include <memory> #include <sstream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <utility> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" #include "time_zone_fixed.h" #include "time_zone_posix.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -68,8 +68,8 @@ const std::int_least32_t kDaysPerYear[2] = {365, 366}; // The day offsets of the beginning of each (1-based) month in non-leap and // leap years respectively (e.g., 335 days before December in a leap year). const std::int_least16_t kMonthOffsets[2][1 + 12 + 1] = { - {-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, - {-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}, + {-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}, }; // We reject leap-second encoded zoneinfo and so assume 60-second minutes. @@ -80,8 +80,8 @@ const std::int_least64_t kSecsPer400Years = 146097LL * kSecsPerDay; // Like kDaysPerYear[] but scaled up by a factor of kSecsPerDay. const std::int_least32_t kSecsPerYear[2] = { - 365 * kSecsPerDay, - 366 * kSecsPerDay, + 365 * kSecsPerDay, + 366 * kSecsPerDay, }; // Convert a cctz::weekday to a POSIX TZ weekday number (0==Sun, ..., 6=Sat). @@ -196,8 +196,8 @@ inline time_zone::civil_lookup MakeRepeated(const Transition& tr, } inline civil_second YearShift(const civil_second& cs, year_t shift) { - return civil_second(cs.year() + shift, cs.month(), cs.day(), cs.hour(), - cs.minute(), cs.second()); + return civil_second(cs.year() + shift, cs.month(), cs.day(), cs.hour(), + cs.minute(), cs.second()); } } // namespace @@ -392,24 +392,24 @@ bool TimeZoneInfo::ExtendTransitions() { bool TimeZoneInfo::Load(ZoneInfoSource* zip) { // Read and validate the header. tzhead tzh; - if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false; + if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false; if (strncmp(tzh.tzh_magic, TZ_MAGIC, sizeof(tzh.tzh_magic)) != 0) return false; Header hdr; - if (!hdr.Build(tzh)) return false; + if (!hdr.Build(tzh)) return false; std::size_t time_len = 4; if (tzh.tzh_version[0] != '\0') { // Skip the 4-byte data. - if (zip->Skip(hdr.DataLength(time_len)) != 0) return false; + if (zip->Skip(hdr.DataLength(time_len)) != 0) return false; // Read and validate the header for the 8-byte data. - if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false; + if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false; if (strncmp(tzh.tzh_magic, TZ_MAGIC, sizeof(tzh.tzh_magic)) != 0) return false; - if (tzh.tzh_version[0] == '\0') return false; - if (!hdr.Build(tzh)) return false; + if (tzh.tzh_version[0] == '\0') return false; + if (!hdr.Build(tzh)) return false; time_len = 8; } - if (hdr.typecnt == 0) return false; + if (hdr.typecnt == 0) return false; if (hdr.leapcnt != 0) { // This code assumes 60-second minutes so we do not want // the leap-second encoded zoneinfo. We could reverse the @@ -417,13 +417,13 @@ bool TimeZoneInfo::Load(ZoneInfoSource* zip) { // so currently we simply reject such data. return false; } - if (hdr.ttisstdcnt != 0 && hdr.ttisstdcnt != hdr.typecnt) return false; - if (hdr.ttisutcnt != 0 && hdr.ttisutcnt != hdr.typecnt) return false; + if (hdr.ttisstdcnt != 0 && hdr.ttisstdcnt != hdr.typecnt) return false; + if (hdr.ttisutcnt != 0 && hdr.ttisutcnt != hdr.typecnt) return false; // Read the data into a local buffer. std::size_t len = hdr.DataLength(time_len); std::vector<char> tbuf(len); - if (zip->Read(tbuf.data(), len) != len) return false; + if (zip->Read(tbuf.data(), len) != len) return false; const char* bp = tbuf.data(); // Decode and validate the transitions. @@ -441,8 +441,8 @@ bool TimeZoneInfo::Load(ZoneInfoSource* zip) { bool seen_type_0 = false; for (std::size_t i = 0; i != hdr.timecnt; ++i) { transitions_[i].type_index = Decode8(bp++); - if (transitions_[i].type_index >= hdr.typecnt) return false; - if (transitions_[i].type_index == 0) seen_type_0 = true; + if (transitions_[i].type_index >= hdr.typecnt) return false; + if (transitions_[i].type_index == 0) seen_type_0 = true; } // Decode and validate the transition types. @@ -457,7 +457,7 @@ bool TimeZoneInfo::Load(ZoneInfoSource* zip) { bp += 4; transition_types_[i].is_dst = (Decode8(bp++) != 0); transition_types_[i].abbr_index = Decode8(bp++); - if (transition_types_[i].abbr_index >= hdr.charcnt) return false; + if (transition_types_[i].abbr_index >= hdr.charcnt) return false; } // Determine the before-first-transition type. @@ -466,10 +466,10 @@ bool TimeZoneInfo::Load(ZoneInfoSource* zip) { std::uint_fast8_t index = 0; if (transition_types_[0].is_dst) { index = transitions_[0].type_index; - while (index != 0 && transition_types_[index].is_dst) --index; + while (index != 0 && transition_types_[index].is_dst) --index; } - while (index != hdr.typecnt && transition_types_[index].is_dst) ++index; - if (index != hdr.typecnt) default_transition_type_ = index; + while (index != hdr.typecnt && transition_types_[index].is_dst) ++index; + if (index != hdr.typecnt) default_transition_type_ = index; } // Copy all the abbreviations. @@ -494,9 +494,9 @@ bool TimeZoneInfo::Load(ZoneInfoSource* zip) { unsigned char ch; // all non-EOF results are positive return (azip->Read(&ch, 1) == 1) ? ch : EOF; }; - if (get_char(zip) != '\n') return false; + if (get_char(zip) != '\n') return false; for (int c = get_char(zip); c != '\n'; c = get_char(zip)) { - if (c == EOF) return false; + if (c == EOF) return false; future_spec_.push_back(static_cast<char>(c)); } } @@ -801,13 +801,13 @@ time_zone::absolute_lookup TimeZoneInfo::LocalTime( // A civil time in "+offset" looks like (time+offset) in UTC. // Note: We perform two additions in the civil_second domain to // sidestep the chance of overflow in (unix_time + tt.utc_offset). - return {(civil_second() + unix_time) + tt.utc_offset, tt.utc_offset, - tt.is_dst, &*abbreviations_.begin() + tt.abbr_index}; + return {(civil_second() + unix_time) + tt.utc_offset, tt.utc_offset, + tt.is_dst, &*abbreviations_.begin() + tt.abbr_index}; } // BreakTime() translation for a particular transition. -time_zone::absolute_lookup TimeZoneInfo::LocalTime(std::int_fast64_t unix_time, - const Transition& tr) const { +time_zone::absolute_lookup TimeZoneInfo::LocalTime(std::int_fast64_t unix_time, + const Transition& tr) const { const TransitionType& tt = transition_types_[tr.type_index]; // Note: (unix_time - tr.unix_time) will never overflow as we // have ensured that there is always a "nearby" transition. @@ -950,7 +950,7 @@ time_zone::civil_lookup TimeZoneInfo::MakeTime(const civil_second& cs) const { return MakeUnique(tr->unix_time + (cs - tr->civil_sec)); } -TString TimeZoneInfo::Version() const { return version_; } +TString TimeZoneInfo::Version() const { return version_; } TString TimeZoneInfo::Description() const { std::ostringstream oss; @@ -972,8 +972,8 @@ bool TimeZoneInfo::NextTransition(const time_point<seconds>& tp, } std::int_fast64_t unix_time = ToUnixSeconds(tp); const Transition target = {unix_time, 0, civil_second(), civil_second()}; - const Transition* tr = - std::upper_bound(begin, end, target, Transition::ByUnixTime()); + const Transition* tr = + std::upper_bound(begin, end, target, Transition::ByUnixTime()); for (; tr != end; ++tr) { // skip no-op transitions std::uint_fast8_t prev_type_index = (tr == begin) ? default_transition_type_ : tr[-1].type_index; @@ -1007,8 +1007,8 @@ bool TimeZoneInfo::PrevTransition(const time_point<seconds>& tp, unix_time += 1; // ceils } const Transition target = {unix_time, 0, civil_second(), civil_second()}; - const Transition* tr = - std::lower_bound(begin, end, target, Transition::ByUnixTime()); + const Transition* tr = + std::lower_bound(begin, end, target, Transition::ByUnixTime()); for (; tr != begin; --tr) { // skip no-op transitions std::uint_fast8_t prev_type_index = (tr - 1 == begin) ? default_transition_type_ : tr[-2].type_index; @@ -1023,5 +1023,5 @@ bool TimeZoneInfo::PrevTransition(const time_point<seconds>& tp, } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.h index e55fd51847..a8641a71b7 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_info.h @@ -18,10 +18,10 @@ #include <atomic> #include <cstddef> #include <cstdint> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" #include "y_absl/time/internal/cctz/include/cctz/zone_info_source.h" @@ -29,7 +29,7 @@ #include "tzfile.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -74,7 +74,7 @@ class TimeZoneInfo : public TimeZoneIf { // TimeZoneIf implementations. time_zone::absolute_lookup BreakTime( const time_point<seconds>& tp) const override; - time_zone::civil_lookup MakeTime(const civil_second& cs) const override; + time_zone::civil_lookup MakeTime(const civil_second& cs) const override; bool NextTransition(const time_point<seconds>& tp, time_zone::civil_transition* trans) const override; bool PrevTransition(const time_point<seconds>& tp, @@ -83,7 +83,7 @@ class TimeZoneInfo : public TimeZoneIf { TString Description() const override; private: - struct Header { // counts of: + struct Header { // counts of: std::size_t timecnt; // transition times std::size_t typecnt; // transition types std::size_t charcnt; // zone abbreviation characters @@ -114,7 +114,7 @@ class TimeZoneInfo : public TimeZoneIf { std::vector<Transition> transitions_; // ordered by unix_time and civil_sec std::vector<TransitionType> transition_types_; // distinct transition types - std::uint_fast8_t default_transition_type_; // for before first transition + std::uint_fast8_t default_transition_type_; // for before first transition TString abbreviations_; // all the NUL-terminated abbreviations TString version_; // the tzdata version if available @@ -131,7 +131,7 @@ class TimeZoneInfo : public TimeZoneIf { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_INFO_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.cc index a73832fc29..803a9113cb 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.cc @@ -23,7 +23,7 @@ #include <limits> #include <utility> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/civil_time.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" @@ -34,7 +34,7 @@ extern long altzone; #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -92,7 +92,7 @@ auto tm_gmtoff(const T& tm) -> decltype(tm.__tm_gmtoff) { } #endif // tm_gmtoff #if defined(tm_zone) -auto tm_zone(const std::tm& tm) -> decltype(tm.tm_zone) { return tm.tm_zone; } +auto tm_zone(const std::tm& tm) -> decltype(tm.tm_zone) { return tm.tm_zone; } #elif defined(__tm_zone) auto tm_zone(const std::tm& tm) -> decltype(tm.__tm_zone) { return tm.__tm_zone; @@ -109,19 +109,19 @@ auto tm_zone(const T& tm) -> decltype(tm.__tm_zone) { #endif // tm_zone #endif -inline std::tm* gm_time(const std::time_t* timep, std::tm* result) { +inline std::tm* gm_time(const std::time_t* timep, std::tm* result) { #if defined(_WIN32) || defined(_WIN64) - return gmtime_s(result, timep) ? nullptr : result; + return gmtime_s(result, timep) ? nullptr : result; #else - return gmtime_r(timep, result); + return gmtime_r(timep, result); #endif } -inline std::tm* local_time(const std::time_t* timep, std::tm* result) { +inline std::tm* local_time(const std::time_t* timep, std::tm* result) { #if defined(_WIN32) || defined(_WIN64) - return localtime_s(result, timep) ? nullptr : result; + return localtime_s(result, timep) ? nullptr : result; #else - return localtime_r(timep, result); + return localtime_r(timep, result); #endif } @@ -216,8 +216,8 @@ time_zone::absolute_lookup TimeZoneLibC::BreakTime( } const year_t year = tmp->tm_year + year_t{1900}; - al.cs = civil_second(year, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, - tmp->tm_min, tmp->tm_sec); + al.cs = civil_second(year, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, + tmp->tm_min, tmp->tm_sec); al.offset = static_cast<int>(tm_gmtoff(*tmp)); al.abbr = local_ ? tm_zone(*tmp) : "UTC"; // as expected by cctz al.is_dst = tmp->tm_isdst > 0; @@ -311,5 +311,5 @@ TString TimeZoneLibC::Description() const { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.h index fc926fecf7..3f70ccbafa 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_libc.h @@ -15,13 +15,13 @@ #ifndef ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_ #define ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_ -#include <util/generic/string.h> +#include <util/generic/string.h> -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "time_zone_if.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -35,7 +35,7 @@ class TimeZoneLibC : public TimeZoneIf { // TimeZoneIf implementations. time_zone::absolute_lookup BreakTime( const time_point<seconds>& tp) const override; - time_zone::civil_lookup MakeTime(const civil_second& cs) const override; + time_zone::civil_lookup MakeTime(const civil_second& cs) const override; bool NextTransition(const time_point<seconds>& tp, time_zone::civil_transition* trans) const override; bool PrevTransition(const time_point<seconds>& tp, @@ -49,7 +49,7 @@ class TimeZoneLibC : public TimeZoneIf { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_lookup.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_lookup.cc index 92c9208d6d..84d4782d13 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_lookup.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_lookup.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" #if defined(__ANDROID__) @@ -24,7 +24,7 @@ #if defined(__APPLE__) #include <CoreFoundation/CFTimeZone.h> - + #include <vector> #endif @@ -37,13 +37,13 @@ #include <cstdlib> #include <cstring> -#include <util/generic/string.h> +#include <util/generic/string.h> #include "time_zone_fixed.h" #include "time_zone_impl.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -76,7 +76,7 @@ int __system_property_get(const char* name, char* value) { } // namespace #endif -TString time_zone::name() const { return effective_impl().Name(); } +TString time_zone::name() const { return effective_impl().Name(); } time_zone::absolute_lookup time_zone::lookup( const time_point<seconds>& tp) const { @@ -97,7 +97,7 @@ bool time_zone::prev_transition(const time_point<seconds>& tp, return effective_impl().PrevTransition(tp, trans); } -TString time_zone::version() const { return effective_impl().Version(); } +TString time_zone::version() const { return effective_impl().Version(); } TString time_zone::description() const { return effective_impl().Description(); @@ -232,5 +232,5 @@ time_zone local_time_zone() { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.cc index 4096503915..f69615aa26 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.cc @@ -17,12 +17,12 @@ #include <cstddef> #include <cstring> #include <limits> -#include <util/generic/string.h> - -#include "y_absl/base/config.h" +#include <util/generic/string.h> +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -155,5 +155,5 @@ bool ParsePosixSpec(const TString& spec, PosixTimeZone* res) { } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.h index e9de2b77ad..bce77fc941 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/time_zone_posix.h @@ -55,10 +55,10 @@ #include <cstdint> #include <util/generic/string.h> -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -126,7 +126,7 @@ bool ParsePosixSpec(const TString& spec, PosixTimeZone* res); } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_POSIX_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/tzfile.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/tzfile.h index 31e8598257..8911beb970 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/tzfile.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/tzfile.h @@ -22,15 +22,15 @@ */ #ifndef TZDIR -#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ -#endif /* !defined TZDIR */ +#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ +#endif /* !defined TZDIR */ #ifndef TZDEFAULT -#define TZDEFAULT "/etc/localtime" +#define TZDEFAULT "/etc/localtime" #endif /* !defined TZDEFAULT */ #ifndef TZDEFRULES -#define TZDEFRULES "posixrules" +#define TZDEFRULES "posixrules" #endif /* !defined TZDEFRULES */ /* See Internet RFC 8536 for more details about the following format. */ @@ -39,18 +39,18 @@ ** Each file begins with. . . */ -#define TZ_MAGIC "TZif" +#define TZ_MAGIC "TZif" struct tzhead { - char tzh_magic[4]; /* TZ_MAGIC */ + char tzh_magic[4]; /* TZ_MAGIC */ char tzh_version[1]; /* '\0' or '2'-'4' as of 2021 */ - char tzh_reserved[15]; /* reserved; must be zero */ - char tzh_ttisutcnt[4]; /* coded number of trans. time flags */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ - char tzh_leapcnt[4]; /* coded number of leap seconds */ - char tzh_timecnt[4]; /* coded number of transition times */ - char tzh_typecnt[4]; /* coded number of local time types */ - char tzh_charcnt[4]; /* coded number of abbr. chars */ + char tzh_reserved[15]; /* reserved; must be zero */ + char tzh_ttisutcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ }; /* @@ -102,21 +102,21 @@ struct tzhead { */ #ifndef TZ_MAX_TIMES -#define TZ_MAX_TIMES 2000 +#define TZ_MAX_TIMES 2000 #endif /* !defined TZ_MAX_TIMES */ #ifndef TZ_MAX_TYPES /* This must be at least 17 for Europe/Samara and Europe/Vilnius. */ -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#endif /* !defined TZ_MAX_TYPES */ +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#endif /* !defined TZ_MAX_TYPES */ #ifndef TZ_MAX_CHARS -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ - /* (limited by what unsigned chars can hold) */ -#endif /* !defined TZ_MAX_CHARS */ +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + /* (limited by what unsigned chars can hold) */ +#endif /* !defined TZ_MAX_CHARS */ #ifndef TZ_MAX_LEAPS -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ -#endif /* !defined TZ_MAX_LEAPS */ +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ +#endif /* !defined TZ_MAX_LEAPS */ #endif /* !defined TZFILE_H */ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/zone_info_source.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/zone_info_source.cc index be58c20fb3..086055c3b8 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/zone_info_source.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/cctz/src/zone_info_source.cc @@ -14,10 +14,10 @@ #include "y_absl/time/internal/cctz/include/cctz/zone_info_source.h" -#include "y_absl/base/config.h" - +#include "y_absl/base/config.h" + namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz { @@ -27,11 +27,11 @@ TString ZoneInfoSource::Version() const { return TString(); } } // namespace cctz } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { namespace cctz_extension { @@ -41,9 +41,9 @@ namespace { // defers to the fallback factory. std::unique_ptr<y_absl::time_internal::cctz::ZoneInfoSource> DefaultFactory( const TString& name, - const std::function< - std::unique_ptr<y_absl::time_internal::cctz::ZoneInfoSource>( - const TString& name)>& fallback_factory) { + const std::function< + std::unique_ptr<y_absl::time_internal::cctz::ZoneInfoSource>( + const TString& name)>& fallback_factory) { return fallback_factory(name); } @@ -59,48 +59,48 @@ std::unique_ptr<y_absl::time_internal::cctz::ZoneInfoSource> DefaultFactory( // Windows linker cannot handle that. Nor does the MinGW compiler know how to // pass "#pragma comment(linker, ...)" to the Windows linker. #if (__has_attribute(weak) || defined(__GNUC__)) && !defined(__MINGW32__) -ZoneInfoSourceFactory zone_info_source_factory __attribute__((weak)) = - DefaultFactory; +ZoneInfoSourceFactory zone_info_source_factory __attribute__((weak)) = + DefaultFactory; #elif defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_LIBCPP_VERSION) extern ZoneInfoSourceFactory zone_info_source_factory; extern ZoneInfoSourceFactory default_factory; ZoneInfoSourceFactory default_factory = DefaultFactory; #if defined(_M_IX86) || defined(_M_ARM) -#pragma comment( \ - linker, \ - "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@@ZA=?default_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@@ZA") +#pragma comment( \ + linker, \ + "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZA=?default_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZA") #elif defined(_M_IA_64) || defined(_M_AMD64) || defined(_M_ARM64) -#pragma comment( \ - linker, \ - "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@@ZEA=?default_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ - "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ - "@@ZEA") +#pragma comment( \ + linker, \ + "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZEA=?default_factory@cctz_extension@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@U?$default_delete@VZoneInfoSource@cctz@time_internal@" ABSL_INTERNAL_MANGLED_NS \ + "@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@" ABSL_INTERNAL_MANGLED_BACKREFERENCE \ + "@@ZEA") #else #error Unsupported MSVC platform #endif // _M_<PLATFORM> @@ -111,5 +111,5 @@ ZoneInfoSourceFactory zone_info_source_factory = DefaultFactory; } // namespace cctz_extension } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_chrono.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_chrono.inc index ef28e97e5a..57f2d50517 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_chrono.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_chrono.inc @@ -16,7 +16,7 @@ #include <cstdint> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { static int64_t GetCurrentTimeNanosFromSystem() { @@ -27,5 +27,5 @@ static int64_t GetCurrentTimeNanosFromSystem() { } } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_posix.inc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_posix.inc index 1068fea026..f26fa92257 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_posix.inc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/get_current_time_posix.inc @@ -7,7 +7,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { static int64_t GetCurrentTimeNanosFromSystem() { @@ -20,5 +20,5 @@ static int64_t GetCurrentTimeNanosFromSystem() { } } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/test_util.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/test_util.h index 22b991b836..133e985aca 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/test_util.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/internal/test_util.h @@ -15,19 +15,19 @@ #ifndef ABSL_TIME_INTERNAL_TEST_UTIL_H_ #define ABSL_TIME_INTERNAL_TEST_UTIL_H_ -#include <util/generic/string.h> +#include <util/generic/string.h> #include "y_absl/time/time.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace time_internal { // Loads the named timezone, but dies on any failure. y_absl::TimeZone LoadTimeZone(const TString& name); } // namespace time_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_INTERNAL_TEST_UTIL_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.cc index 441638b256..82f9742755 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.cc @@ -47,7 +47,7 @@ namespace cctz = y_absl::time_internal::cctz; namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace { @@ -496,5 +496,5 @@ struct tm ToTM(y_absl::Time t, y_absl::TimeZone tz) { return tm; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.h b/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.h index 16150ad3b6..beb97488cf 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/time.h @@ -79,7 +79,7 @@ struct timeval; #include <cstdint> #include <ctime> #include <ostream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include <utility> @@ -89,7 +89,7 @@ struct timeval; #include "y_absl/time/internal/cctz/include/cctz/time_zone.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class Duration; // Defined below class Time; // Defined below @@ -1610,7 +1610,7 @@ constexpr Time FromTimeT(time_t t) { return time_internal::FromUnixDuration(Seconds(t)); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TIME_TIME_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone/ya.make index d7e1dc0c26..263156d95d 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone/ya.make @@ -11,9 +11,9 @@ OWNER( LICENSE(Apache-2.0) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) IF (OS_DARWIN) EXTRALIBS("-framework CoreFoundation") diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make index 37cc779265..2b844129af 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/time/ya.make @@ -27,9 +27,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/time/time_zone ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/any.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/any.h index f03d940ed9..d823bfa62e 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/any.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/any.h @@ -61,12 +61,12 @@ #include <any> // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using std::any; using std::any_cast; using std::bad_any_cast; using std::make_any; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_ANY @@ -94,7 +94,7 @@ ABSL_NAMESPACE_END #endif // !defined(__GNUC__) || defined(__GXX_RTTI) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN class any; @@ -518,7 +518,7 @@ T* any_cast(any* operand) noexcept { : nullptr; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #undef ABSL_ANY_DETAIL_HAS_RTTI diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.cc index 29916186da..4d78c5e56f 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.cc @@ -22,7 +22,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN bad_any_cast::~bad_any_cast() = default; @@ -40,7 +40,7 @@ void ThrowBadAnyCast() { } } // namespace any_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_ANY diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.h index 92c3bfe522..8068639195 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast.h @@ -30,15 +30,15 @@ #include <any> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using std::bad_any_cast; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_ANY namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_any_cast @@ -67,7 +67,7 @@ namespace any_internal { [[noreturn]] void ThrowBadAnyCast(); } // namespace any_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_ANY diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast/ya.make index a008127937..68a02e7311 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_any_cast/ya.make @@ -16,9 +16,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.cc index e583756cd5..4e6359c149 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.cc @@ -22,7 +22,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN bad_optional_access::~bad_optional_access() = default; @@ -42,7 +42,7 @@ void throw_bad_optional_access() { } } // namespace optional_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_OPTIONAL diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.h index 7420ade10f..508910e255 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access.h @@ -30,15 +30,15 @@ #include <optional> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using std::bad_optional_access; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_OPTIONAL namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_optional_access @@ -70,7 +70,7 @@ namespace optional_internal { [[noreturn]] ABSL_DLL void throw_bad_optional_access(); } // namespace optional_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_OPTIONAL diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access/ya.make index fca9a916ac..a23d5d8fb3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_optional_access/ya.make @@ -16,9 +16,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.cc index 77df7736a9..89abac25c3 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.cc @@ -23,7 +23,7 @@ #include "y_absl/base/internal/raw_logging.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN ////////////////////////// // [variant.bad.access] // @@ -58,7 +58,7 @@ void Rethrow() { } } // namespace variant_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_VARIANT diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.h index 6e41782e78..a39010cb62 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access.h @@ -30,15 +30,15 @@ #include <variant> namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using std::bad_variant_access; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_VARIANT namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // bad_variant_access @@ -74,7 +74,7 @@ namespace variant_internal { [[noreturn]] ABSL_DLL void Rethrow(); } // namespace variant_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_USES_STD_VARIANT diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access/ya.make b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access/ya.make index a80f8ed987..b59a278bad 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/bad_variant_access/ya.make @@ -16,9 +16,9 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/base/log_severity ) -ADDINCL( - GLOBAL contrib/restricted/abseil-cpp-tstring -) +ADDINCL( + GLOBAL contrib/restricted/abseil-cpp-tstring +) NO_COMPILER_WARNINGS() diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/compare.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/compare.h index 4c8cf2f59f..2e3ca7c9ff 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/compare.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/compare.h @@ -39,7 +39,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace compare_internal { using value_type = int8_t; @@ -178,14 +178,14 @@ class weak_equality weak_equality v) noexcept { return 0 != v.value_; } - friend constexpr bool operator==(weak_equality v1, - weak_equality v2) noexcept { - return v1.value_ == v2.value_; - } - friend constexpr bool operator!=(weak_equality v1, - weak_equality v2) noexcept { - return v1.value_ != v2.value_; - } + friend constexpr bool operator==(weak_equality v1, + weak_equality v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(weak_equality v1, + weak_equality v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; @@ -229,14 +229,14 @@ class strong_equality strong_equality v) noexcept { return 0 != v.value_; } - friend constexpr bool operator==(strong_equality v1, - strong_equality v2) noexcept { - return v1.value_ == v2.value_; - } - friend constexpr bool operator!=(strong_equality v1, - strong_equality v2) noexcept { - return v1.value_ != v2.value_; - } + friend constexpr bool operator==(strong_equality v1, + strong_equality v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(strong_equality v1, + strong_equality v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; @@ -324,14 +324,14 @@ class partial_ordering partial_ordering v) noexcept { return v.is_ordered() && 0 >= v.value_; } - friend constexpr bool operator==(partial_ordering v1, - partial_ordering v2) noexcept { - return v1.value_ == v2.value_; - } - friend constexpr bool operator!=(partial_ordering v1, - partial_ordering v2) noexcept { - return v1.value_ != v2.value_; - } + friend constexpr bool operator==(partial_ordering v1, + partial_ordering v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(partial_ordering v1, + partial_ordering v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; @@ -416,14 +416,14 @@ class weak_ordering weak_ordering v) noexcept { return 0 >= v.value_; } - friend constexpr bool operator==(weak_ordering v1, - weak_ordering v2) noexcept { - return v1.value_ == v2.value_; - } - friend constexpr bool operator!=(weak_ordering v1, - weak_ordering v2) noexcept { - return v1.value_ != v2.value_; - } + friend constexpr bool operator==(weak_ordering v1, + weak_ordering v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(weak_ordering v1, + weak_ordering v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; @@ -515,14 +515,14 @@ class strong_ordering strong_ordering v) noexcept { return 0 >= v.value_; } - friend constexpr bool operator==(strong_ordering v1, - strong_ordering v2) noexcept { - return v1.value_ == v2.value_; - } - friend constexpr bool operator!=(strong_ordering v1, - strong_ordering v2) noexcept { - return v1.value_ != v2.value_; - } + friend constexpr bool operator==(strong_ordering v1, + strong_ordering v2) noexcept { + return v1.value_ == v2.value_; + } + friend constexpr bool operator!=(strong_ordering v1, + strong_ordering v2) noexcept { + return v1.value_ != v2.value_; + } private: compare_internal::value_type value_; @@ -594,7 +594,7 @@ constexpr y_absl::weak_ordering do_three_way_comparison(const Compare &compare, } } // namespace compare_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TYPES_COMPARE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_aliases.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_aliases.h index ae9df53bf9..93c7392859 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_aliases.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_aliases.h @@ -1,447 +1,447 @@ -// Copyright 2018 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// regularity_aliases.h -// ----------------------------------------------------------------------------- -// -// This file contains type aliases of common ConformanceProfiles and Archetypes -// so that they can be directly used by name without creating them from scratch. - -#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ -#define ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ - -#include "y_absl/types/internal/conformance_archetype.h" -#include "y_absl/types/internal/conformance_profile.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace types_internal { - -// Creates both a Profile and a corresponding Archetype with root name "name". -#define ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS(name, ...) \ - struct name##Profile : __VA_ARGS__ {}; \ - \ - using name##Archetype = ::y_absl::types_internal::Archetype<name##Profile>; \ - \ - template <class AbslInternalProfileTag> \ - using name##Archetype##_ = ::y_absl::types_internal::Archetype< \ - ::y_absl::types_internal::StrongProfileTypedef<name##Profile, \ - AbslInternalProfileTag>> - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasTrivialDefaultConstructor, - ConformanceProfile<default_constructible::trivial>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowDefaultConstructor, - ConformanceProfile<default_constructible::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasDefaultConstructor, ConformanceProfile<default_constructible::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasTrivialMoveConstructor, ConformanceProfile<default_constructible::maybe, - move_constructible::trivial>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowMoveConstructor, ConformanceProfile<default_constructible::maybe, - move_constructible::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasMoveConstructor, - ConformanceProfile<default_constructible::maybe, move_constructible::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasTrivialCopyConstructor, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::trivial>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowCopyConstructor, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasCopyConstructor, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasTrivialMoveAssign, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::trivial>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowMoveAssign, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasMoveAssign, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasTrivialCopyAssign, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::trivial>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowCopyAssign, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasCopyAssign, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasTrivialDestructor, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::trivial>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowDestructor, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasDestructor, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowEquality, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasEquality, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowInequality, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::maybe, - inequality_comparable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasInequality, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::maybe, inequality_comparable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowLessThan, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::maybe, inequality_comparable::maybe, - less_than_comparable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasLessThan, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::maybe, inequality_comparable::maybe, - less_than_comparable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowLessEqual, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::maybe, inequality_comparable::maybe, - less_than_comparable::maybe, - less_equal_comparable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasLessEqual, - ConformanceProfile<default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, - equality_comparable::maybe, inequality_comparable::maybe, - less_than_comparable::maybe, - less_equal_comparable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowGreaterEqual, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasGreaterEqual, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowGreaterThan, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::maybe, - greater_than_comparable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasGreaterThan, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::maybe, - greater_than_comparable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasNothrowSwap, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::maybe, - greater_than_comparable::maybe, swappable::nothrow>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasSwap, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::maybe, - greater_than_comparable::maybe, swappable::yes>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HasStdHashSpecialization, - ConformanceProfile< - default_constructible::maybe, move_constructible::maybe, - copy_constructible::maybe, move_assignable::maybe, - copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, - inequality_comparable::maybe, less_than_comparable::maybe, - less_equal_comparable::maybe, greater_equal_comparable::maybe, - greater_than_comparable::maybe, swappable::maybe, hashable::yes>); - -//////////////////////////////////////////////////////////////////////////////// -//// The remaining aliases are combinations of the previous aliases. //// -//////////////////////////////////////////////////////////////////////////////// - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - Equatable, CombineProfiles<HasEqualityProfile, HasInequalityProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - Comparable, - CombineProfiles<EquatableProfile, HasLessThanProfile, HasLessEqualProfile, - HasGreaterEqualProfile, HasGreaterThanProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - NothrowEquatable, - CombineProfiles<HasNothrowEqualityProfile, HasNothrowInequalityProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - NothrowComparable, - CombineProfiles<NothrowEquatableProfile, HasNothrowLessThanProfile, - HasNothrowLessEqualProfile, HasNothrowGreaterEqualProfile, - HasNothrowGreaterThanProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - Value, - CombineProfiles<HasNothrowMoveConstructorProfile, HasCopyConstructorProfile, - HasNothrowMoveAssignProfile, HasCopyAssignProfile, - HasNothrowDestructorProfile, HasNothrowSwapProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - EquatableValue, CombineProfiles<EquatableProfile, ValueProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - ComparableValue, CombineProfiles<ComparableProfile, ValueProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - DefaultConstructibleValue, - CombineProfiles<HasDefaultConstructorProfile, ValueProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - NothrowMoveConstructible, CombineProfiles<HasNothrowMoveConstructorProfile, - HasNothrowDestructorProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - EquatableNothrowMoveConstructible, - CombineProfiles<EquatableProfile, NothrowMoveConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - ComparableNothrowMoveConstructible, - CombineProfiles<ComparableProfile, NothrowMoveConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - DefaultConstructibleNothrowMoveConstructible, - CombineProfiles<HasDefaultConstructorProfile, - NothrowMoveConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - CopyConstructible, - CombineProfiles<HasNothrowMoveConstructorProfile, HasCopyConstructorProfile, - HasNothrowDestructorProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - EquatableCopyConstructible, - CombineProfiles<EquatableProfile, CopyConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - ComparableCopyConstructible, - CombineProfiles<ComparableProfile, CopyConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - DefaultConstructibleCopyConstructible, - CombineProfiles<HasDefaultConstructorProfile, CopyConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - NothrowMovable, - CombineProfiles<HasNothrowMoveConstructorProfile, - HasNothrowMoveAssignProfile, HasNothrowDestructorProfile, - HasNothrowSwapProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - EquatableNothrowMovable, - CombineProfiles<EquatableProfile, NothrowMovableProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - ComparableNothrowMovable, - CombineProfiles<ComparableProfile, NothrowMovableProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - DefaultConstructibleNothrowMovable, - CombineProfiles<HasDefaultConstructorProfile, NothrowMovableProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - TrivialSpecialMemberFunctions, - CombineProfiles<HasTrivialDefaultConstructorProfile, - HasTrivialMoveConstructorProfile, - HasTrivialCopyConstructorProfile, - HasTrivialMoveAssignProfile, HasTrivialCopyAssignProfile, - HasTrivialDestructorProfile, HasNothrowSwapProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - TriviallyComplete, - CombineProfiles<TrivialSpecialMemberFunctionsProfile, ComparableProfile, - HasStdHashSpecializationProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HashableNothrowMoveConstructible, - CombineProfiles<HasStdHashSpecializationProfile, - NothrowMoveConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HashableCopyConstructible, - CombineProfiles<HasStdHashSpecializationProfile, CopyConstructibleProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HashableNothrowMovable, - CombineProfiles<HasStdHashSpecializationProfile, NothrowMovableProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - HashableValue, - CombineProfiles<HasStdHashSpecializationProfile, ValueProfile>); - -ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( - ComparableHashableValue, - CombineProfiles<HashableValueProfile, ComparableProfile>); - -// The "preferred" profiles that we support in Abseil. -template <template <class...> class Receiver> -using ExpandBasicProfiles = - Receiver<NothrowMoveConstructibleProfile, CopyConstructibleProfile, - NothrowMovableProfile, ValueProfile>; - -// The basic profiles except that they are also all Equatable. -template <template <class...> class Receiver> -using ExpandBasicEquatableProfiles = - Receiver<EquatableNothrowMoveConstructibleProfile, - EquatableCopyConstructibleProfile, EquatableNothrowMovableProfile, - EquatableValueProfile>; - -// The basic profiles except that they are also all Comparable. -template <template <class...> class Receiver> -using ExpandBasicComparableProfiles = - Receiver<ComparableNothrowMoveConstructibleProfile, - ComparableCopyConstructibleProfile, - ComparableNothrowMovableProfile, ComparableValueProfile>; - -// The basic profiles except that they are also all Hashable. -template <template <class...> class Receiver> -using ExpandBasicHashableProfiles = - Receiver<HashableNothrowMoveConstructibleProfile, - HashableCopyConstructibleProfile, HashableNothrowMovableProfile, - HashableValueProfile>; - -// The basic profiles except that they are also all DefaultConstructible. -template <template <class...> class Receiver> -using ExpandBasicDefaultConstructibleProfiles = - Receiver<DefaultConstructibleNothrowMoveConstructibleProfile, - DefaultConstructibleCopyConstructibleProfile, - DefaultConstructibleNothrowMovableProfile, - DefaultConstructibleValueProfile>; - -// The type profiles that we support in Abseil (all of the previous lists). -template <template <class...> class Receiver> -using ExpandSupportedProfiles = Receiver< - NothrowMoveConstructibleProfile, CopyConstructibleProfile, - NothrowMovableProfile, ValueProfile, - EquatableNothrowMoveConstructibleProfile, EquatableCopyConstructibleProfile, - EquatableNothrowMovableProfile, EquatableValueProfile, - ComparableNothrowMoveConstructibleProfile, - ComparableCopyConstructibleProfile, ComparableNothrowMovableProfile, - ComparableValueProfile, DefaultConstructibleNothrowMoveConstructibleProfile, - DefaultConstructibleCopyConstructibleProfile, - DefaultConstructibleNothrowMovableProfile, DefaultConstructibleValueProfile, - HashableNothrowMoveConstructibleProfile, HashableCopyConstructibleProfile, - HashableNothrowMovableProfile, HashableValueProfile>; - -// TODO(calabrese) Include types that have throwing move constructors, since in -// practice we still need to support them because of standard library types with -// (potentially) non-noexcept moves. - -} // namespace types_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#undef ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS - -#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ +// Copyright 2018 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// regularity_aliases.h +// ----------------------------------------------------------------------------- +// +// This file contains type aliases of common ConformanceProfiles and Archetypes +// so that they can be directly used by name without creating them from scratch. + +#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ +#define ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ + +#include "y_absl/types/internal/conformance_archetype.h" +#include "y_absl/types/internal/conformance_profile.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace types_internal { + +// Creates both a Profile and a corresponding Archetype with root name "name". +#define ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS(name, ...) \ + struct name##Profile : __VA_ARGS__ {}; \ + \ + using name##Archetype = ::y_absl::types_internal::Archetype<name##Profile>; \ + \ + template <class AbslInternalProfileTag> \ + using name##Archetype##_ = ::y_absl::types_internal::Archetype< \ + ::y_absl::types_internal::StrongProfileTypedef<name##Profile, \ + AbslInternalProfileTag>> + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialDefaultConstructor, + ConformanceProfile<default_constructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowDefaultConstructor, + ConformanceProfile<default_constructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasDefaultConstructor, ConformanceProfile<default_constructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialMoveConstructor, ConformanceProfile<default_constructible::maybe, + move_constructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowMoveConstructor, ConformanceProfile<default_constructible::maybe, + move_constructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasMoveConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialCopyConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowCopyConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasCopyConstructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialMoveAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowMoveAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasMoveAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialCopyAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowCopyAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasCopyAssign, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasTrivialDestructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::trivial>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowDestructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasDestructor, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowEquality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasEquality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowInequality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, + inequality_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasInequality, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowLessThan, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasLessThan, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowLessEqual, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::maybe, + less_equal_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasLessEqual, + ConformanceProfile<default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, + equality_comparable::maybe, inequality_comparable::maybe, + less_than_comparable::maybe, + less_equal_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowGreaterEqual, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasGreaterEqual, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowGreaterThan, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasGreaterThan, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasNothrowSwap, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::maybe, swappable::nothrow>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasSwap, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::maybe, swappable::yes>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HasStdHashSpecialization, + ConformanceProfile< + default_constructible::maybe, move_constructible::maybe, + copy_constructible::maybe, move_assignable::maybe, + copy_assignable::maybe, destructible::maybe, equality_comparable::maybe, + inequality_comparable::maybe, less_than_comparable::maybe, + less_equal_comparable::maybe, greater_equal_comparable::maybe, + greater_than_comparable::maybe, swappable::maybe, hashable::yes>); + +//////////////////////////////////////////////////////////////////////////////// +//// The remaining aliases are combinations of the previous aliases. //// +//////////////////////////////////////////////////////////////////////////////// + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + Equatable, CombineProfiles<HasEqualityProfile, HasInequalityProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + Comparable, + CombineProfiles<EquatableProfile, HasLessThanProfile, HasLessEqualProfile, + HasGreaterEqualProfile, HasGreaterThanProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowEquatable, + CombineProfiles<HasNothrowEqualityProfile, HasNothrowInequalityProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowComparable, + CombineProfiles<NothrowEquatableProfile, HasNothrowLessThanProfile, + HasNothrowLessEqualProfile, HasNothrowGreaterEqualProfile, + HasNothrowGreaterThanProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + Value, + CombineProfiles<HasNothrowMoveConstructorProfile, HasCopyConstructorProfile, + HasNothrowMoveAssignProfile, HasCopyAssignProfile, + HasNothrowDestructorProfile, HasNothrowSwapProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableValue, CombineProfiles<EquatableProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableValue, CombineProfiles<ComparableProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleValue, + CombineProfiles<HasDefaultConstructorProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowMoveConstructible, CombineProfiles<HasNothrowMoveConstructorProfile, + HasNothrowDestructorProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableNothrowMoveConstructible, + CombineProfiles<EquatableProfile, NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableNothrowMoveConstructible, + CombineProfiles<ComparableProfile, NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleNothrowMoveConstructible, + CombineProfiles<HasDefaultConstructorProfile, + NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + CopyConstructible, + CombineProfiles<HasNothrowMoveConstructorProfile, HasCopyConstructorProfile, + HasNothrowDestructorProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableCopyConstructible, + CombineProfiles<EquatableProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableCopyConstructible, + CombineProfiles<ComparableProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleCopyConstructible, + CombineProfiles<HasDefaultConstructorProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + NothrowMovable, + CombineProfiles<HasNothrowMoveConstructorProfile, + HasNothrowMoveAssignProfile, HasNothrowDestructorProfile, + HasNothrowSwapProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + EquatableNothrowMovable, + CombineProfiles<EquatableProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableNothrowMovable, + CombineProfiles<ComparableProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + DefaultConstructibleNothrowMovable, + CombineProfiles<HasDefaultConstructorProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + TrivialSpecialMemberFunctions, + CombineProfiles<HasTrivialDefaultConstructorProfile, + HasTrivialMoveConstructorProfile, + HasTrivialCopyConstructorProfile, + HasTrivialMoveAssignProfile, HasTrivialCopyAssignProfile, + HasTrivialDestructorProfile, HasNothrowSwapProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + TriviallyComplete, + CombineProfiles<TrivialSpecialMemberFunctionsProfile, ComparableProfile, + HasStdHashSpecializationProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableNothrowMoveConstructible, + CombineProfiles<HasStdHashSpecializationProfile, + NothrowMoveConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableCopyConstructible, + CombineProfiles<HasStdHashSpecializationProfile, CopyConstructibleProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableNothrowMovable, + CombineProfiles<HasStdHashSpecializationProfile, NothrowMovableProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + HashableValue, + CombineProfiles<HasStdHashSpecializationProfile, ValueProfile>); + +ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS( + ComparableHashableValue, + CombineProfiles<HashableValueProfile, ComparableProfile>); + +// The "preferred" profiles that we support in Abseil. +template <template <class...> class Receiver> +using ExpandBasicProfiles = + Receiver<NothrowMoveConstructibleProfile, CopyConstructibleProfile, + NothrowMovableProfile, ValueProfile>; + +// The basic profiles except that they are also all Equatable. +template <template <class...> class Receiver> +using ExpandBasicEquatableProfiles = + Receiver<EquatableNothrowMoveConstructibleProfile, + EquatableCopyConstructibleProfile, EquatableNothrowMovableProfile, + EquatableValueProfile>; + +// The basic profiles except that they are also all Comparable. +template <template <class...> class Receiver> +using ExpandBasicComparableProfiles = + Receiver<ComparableNothrowMoveConstructibleProfile, + ComparableCopyConstructibleProfile, + ComparableNothrowMovableProfile, ComparableValueProfile>; + +// The basic profiles except that they are also all Hashable. +template <template <class...> class Receiver> +using ExpandBasicHashableProfiles = + Receiver<HashableNothrowMoveConstructibleProfile, + HashableCopyConstructibleProfile, HashableNothrowMovableProfile, + HashableValueProfile>; + +// The basic profiles except that they are also all DefaultConstructible. +template <template <class...> class Receiver> +using ExpandBasicDefaultConstructibleProfiles = + Receiver<DefaultConstructibleNothrowMoveConstructibleProfile, + DefaultConstructibleCopyConstructibleProfile, + DefaultConstructibleNothrowMovableProfile, + DefaultConstructibleValueProfile>; + +// The type profiles that we support in Abseil (all of the previous lists). +template <template <class...> class Receiver> +using ExpandSupportedProfiles = Receiver< + NothrowMoveConstructibleProfile, CopyConstructibleProfile, + NothrowMovableProfile, ValueProfile, + EquatableNothrowMoveConstructibleProfile, EquatableCopyConstructibleProfile, + EquatableNothrowMovableProfile, EquatableValueProfile, + ComparableNothrowMoveConstructibleProfile, + ComparableCopyConstructibleProfile, ComparableNothrowMovableProfile, + ComparableValueProfile, DefaultConstructibleNothrowMoveConstructibleProfile, + DefaultConstructibleCopyConstructibleProfile, + DefaultConstructibleNothrowMovableProfile, DefaultConstructibleValueProfile, + HashableNothrowMoveConstructibleProfile, HashableCopyConstructibleProfile, + HashableNothrowMovableProfile, HashableValueProfile>; + +// TODO(calabrese) Include types that have throwing move constructors, since in +// practice we still need to support them because of standard library types with +// (potentially) non-noexcept moves. + +} // namespace types_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#undef ABSL_INTERNAL_PROFILE_AND_ARCHETYPE_ALIAS + +#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_ALIASES_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_archetype.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_archetype.h index dc27d05df3..5cdec760e2 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_archetype.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_archetype.h @@ -1,978 +1,978 @@ -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// conformance_archetype.h -// ----------------------------------------------------------------------------- -// -// This file contains a facility for generating "archetypes" of out of -// "Conformance Profiles" (see "conformance_profiles.h" for more information -// about Conformance Profiles). An archetype is a type that aims to support the -// bare minimum requirements of a given Conformance Profile. For instance, an -// archetype that corresponds to an ImmutableProfile has exactly a nothrow -// move-constructor, a potentially-throwing copy constructor, a nothrow -// destructor, with all other special-member-functions deleted. These archetypes -// are useful for testing to make sure that templates are able to work with the -// kinds of types that they claim to support (i.e. that they do not accidentally -// under-constrain), -// -// The main type template in this file is the Archetype template, which takes -// a Conformance Profile as a template argument and its instantiations are a -// minimum-conforming model of that profile. - -#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ -#define ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ - -#include <cstddef> -#include <functional> -#include <type_traits> -#include <utility> - -#include "y_absl/meta/type_traits.h" -#include "y_absl/types/internal/conformance_profile.h" - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace types_internal { - -// A minimum-conforming implementation of a type with properties specified in -// `Prof`, where `Prof` is a valid Conformance Profile. -template <class Prof, class /*Enabler*/ = void> -class Archetype; - -// Given an Archetype, obtain the properties of the profile associated with that -// archetype. -template <class Archetype> -struct PropertiesOfArchetype; - -template <class Prof> -struct PropertiesOfArchetype<Archetype<Prof>> { - using type = PropertiesOfT<Prof>; -}; - -template <class Archetype> -using PropertiesOfArchetypeT = typename PropertiesOfArchetype<Archetype>::type; - -// A metafunction to determine if a type is an `Archetype`. -template <class T> -struct IsArchetype : std::false_type {}; - -template <class Prof> -struct IsArchetype<Archetype<Prof>> : std::true_type {}; - -// A constructor tag type used when creating an Archetype with internal state. -struct MakeArchetypeState {}; - -// Data stored within an archetype that is copied/compared/hashed when the -// corresponding operations are used. -using ArchetypeState = std::size_t; - -//////////////////////////////////////////////////////////////////////////////// -// This section of the file defines a chain of base classes for Archetype, // -// where each base defines a specific special member function with the // -// appropriate properties (deleted, noexcept(false), noexcept, or trivial). // -//////////////////////////////////////////////////////////////////////////////// - -// The bottom-most base, which contains the state and the default constructor. -template <default_constructible DefaultConstructibleValue> -struct ArchetypeStateBase { - static_assert(DefaultConstructibleValue == default_constructible::yes || - DefaultConstructibleValue == default_constructible::nothrow, - ""); - - ArchetypeStateBase() noexcept( - DefaultConstructibleValue == - default_constructible:: - nothrow) /*Vacuous archetype_state initialization*/ {} - explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept - : archetype_state(state) {} - - ArchetypeState archetype_state; -}; - -template <> -struct ArchetypeStateBase<default_constructible::maybe> { - explicit ArchetypeStateBase() = delete; - explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept - : archetype_state(state) {} - - ArchetypeState archetype_state; -}; - -template <> -struct ArchetypeStateBase<default_constructible::trivial> { - ArchetypeStateBase() = default; - explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept - : archetype_state(state) {} - - ArchetypeState archetype_state; -}; - -// The move-constructor base -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue> -struct ArchetypeMoveConstructor - : ArchetypeStateBase<DefaultConstructibleValue> { - static_assert(MoveConstructibleValue == move_constructible::yes || - MoveConstructibleValue == move_constructible::nothrow, - ""); - - explicit ArchetypeMoveConstructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeMoveConstructor() = default; - ArchetypeMoveConstructor(ArchetypeMoveConstructor&& other) noexcept( - MoveConstructibleValue == move_constructible::nothrow) - : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), - other.archetype_state) {} - ArchetypeMoveConstructor(const ArchetypeMoveConstructor&) = default; - ArchetypeMoveConstructor& operator=(ArchetypeMoveConstructor&&) = default; - ArchetypeMoveConstructor& operator=(const ArchetypeMoveConstructor&) = - default; -}; - -template <default_constructible DefaultConstructibleValue> -struct ArchetypeMoveConstructor<DefaultConstructibleValue, - move_constructible::trivial> - : ArchetypeStateBase<DefaultConstructibleValue> { - explicit ArchetypeMoveConstructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeMoveConstructor() = default; -}; - -// The copy-constructor base -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue> -struct ArchetypeCopyConstructor - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue> { - static_assert(CopyConstructibleValue == copy_constructible::yes || - CopyConstructibleValue == copy_constructible::nothrow, - ""); - explicit ArchetypeCopyConstructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeCopyConstructor() = default; - ArchetypeCopyConstructor(ArchetypeCopyConstructor&&) = default; - ArchetypeCopyConstructor(const ArchetypeCopyConstructor& other) noexcept( - CopyConstructibleValue == copy_constructible::nothrow) - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue>( - MakeArchetypeState(), other.archetype_state) {} - ArchetypeCopyConstructor& operator=(ArchetypeCopyConstructor&&) = default; - ArchetypeCopyConstructor& operator=(const ArchetypeCopyConstructor&) = - default; -}; - -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue> -struct ArchetypeCopyConstructor<DefaultConstructibleValue, - MoveConstructibleValue, - copy_constructible::maybe> - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue> { - explicit ArchetypeCopyConstructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeCopyConstructor() = default; - ArchetypeCopyConstructor(ArchetypeCopyConstructor&&) = default; - ArchetypeCopyConstructor(const ArchetypeCopyConstructor&) = delete; - ArchetypeCopyConstructor& operator=(ArchetypeCopyConstructor&&) = default; - ArchetypeCopyConstructor& operator=(const ArchetypeCopyConstructor&) = - default; -}; - -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue> -struct ArchetypeCopyConstructor<DefaultConstructibleValue, - MoveConstructibleValue, - copy_constructible::trivial> - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue> { - explicit ArchetypeCopyConstructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeMoveConstructor<DefaultConstructibleValue, - MoveConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeCopyConstructor() = default; -}; - -// The move-assign base -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue> -struct ArchetypeMoveAssign - : ArchetypeCopyConstructor<DefaultConstructibleValue, - MoveConstructibleValue, CopyConstructibleValue> { - static_assert(MoveAssignableValue == move_assignable::yes || - MoveAssignableValue == move_assignable::nothrow, - ""); - explicit ArchetypeMoveAssign(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeCopyConstructor<DefaultConstructibleValue, - MoveConstructibleValue, - CopyConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeMoveAssign() = default; - ArchetypeMoveAssign(ArchetypeMoveAssign&&) = default; - ArchetypeMoveAssign(const ArchetypeMoveAssign&) = default; - ArchetypeMoveAssign& operator=(ArchetypeMoveAssign&& other) noexcept( - MoveAssignableValue == move_assignable::nothrow) { - this->archetype_state = other.archetype_state; - return *this; - } - - ArchetypeMoveAssign& operator=(const ArchetypeMoveAssign&) = default; -}; - -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue> -struct ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, move_assignable::trivial> - : ArchetypeCopyConstructor<DefaultConstructibleValue, - MoveConstructibleValue, CopyConstructibleValue> { - explicit ArchetypeMoveAssign(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeCopyConstructor<DefaultConstructibleValue, - MoveConstructibleValue, - CopyConstructibleValue>(MakeArchetypeState(), - state) {} - - ArchetypeMoveAssign() = default; -}; - -// The copy-assign base -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue, - copy_assignable CopyAssignableValue> -struct ArchetypeCopyAssign - : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue> { - static_assert(CopyAssignableValue == copy_assignable::yes || - CopyAssignableValue == copy_assignable::nothrow, - ""); - explicit ArchetypeCopyAssign(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue>( - MakeArchetypeState(), state) {} - - ArchetypeCopyAssign() = default; - ArchetypeCopyAssign(ArchetypeCopyAssign&&) = default; - ArchetypeCopyAssign(const ArchetypeCopyAssign&) = default; - ArchetypeCopyAssign& operator=(ArchetypeCopyAssign&&) = default; - - ArchetypeCopyAssign& operator=(const ArchetypeCopyAssign& other) noexcept( - CopyAssignableValue == copy_assignable::nothrow) { - this->archetype_state = other.archetype_state; - return *this; - } -}; - -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue> -struct ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - copy_assignable::maybe> - : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue> { - explicit ArchetypeCopyAssign(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue>( - MakeArchetypeState(), state) {} - - ArchetypeCopyAssign() = default; - ArchetypeCopyAssign(ArchetypeCopyAssign&&) = default; - ArchetypeCopyAssign(const ArchetypeCopyAssign&) = default; - ArchetypeCopyAssign& operator=(ArchetypeCopyAssign&&) = default; - ArchetypeCopyAssign& operator=(const ArchetypeCopyAssign&) = delete; -}; - -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue> -struct ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - copy_assignable::trivial> - : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue> { - explicit ArchetypeCopyAssign(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue>( - MakeArchetypeState(), state) {} - - ArchetypeCopyAssign() = default; -}; - -// The destructor base -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue, - copy_assignable CopyAssignableValue, destructible DestructibleValue> -struct ArchetypeDestructor - : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - CopyAssignableValue> { - static_assert(DestructibleValue == destructible::yes || - DestructibleValue == destructible::nothrow, - ""); - - explicit ArchetypeDestructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - CopyAssignableValue>(MakeArchetypeState(), state) {} - - ArchetypeDestructor() = default; - ArchetypeDestructor(ArchetypeDestructor&&) = default; - ArchetypeDestructor(const ArchetypeDestructor&) = default; - ArchetypeDestructor& operator=(ArchetypeDestructor&&) = default; - ArchetypeDestructor& operator=(const ArchetypeDestructor&) = default; - ~ArchetypeDestructor() noexcept(DestructibleValue == destructible::nothrow) {} -}; - -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue, - copy_assignable CopyAssignableValue> -struct ArchetypeDestructor<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - CopyAssignableValue, destructible::trivial> - : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - CopyAssignableValue> { - explicit ArchetypeDestructor(MakeArchetypeState, - ArchetypeState state) noexcept - : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, - CopyConstructibleValue, MoveAssignableValue, - CopyAssignableValue>(MakeArchetypeState(), state) {} - - ArchetypeDestructor() = default; -}; - -// An alias to the top of the chain of bases for special-member functions. -// NOTE: move_constructible::maybe, move_assignable::maybe, and -// destructible::maybe are handled in the top-level type by way of SFINAE. -// Because of this, we never instantiate the base classes with -// move_constructible::maybe, move_assignable::maybe, or destructible::maybe so -// that we minimize the number of different possible type-template -// instantiations. -template <default_constructible DefaultConstructibleValue, - move_constructible MoveConstructibleValue, - copy_constructible CopyConstructibleValue, - move_assignable MoveAssignableValue, - copy_assignable CopyAssignableValue, destructible DestructibleValue> -using ArchetypeSpecialMembersBase = ArchetypeDestructor< - DefaultConstructibleValue, - MoveConstructibleValue != move_constructible::maybe - ? MoveConstructibleValue - : move_constructible::nothrow, - CopyConstructibleValue, - MoveAssignableValue != move_assignable::maybe ? MoveAssignableValue - : move_assignable::nothrow, - CopyAssignableValue, - DestructibleValue != destructible::maybe ? DestructibleValue - : destructible::nothrow>; - -// A function that is used to create an archetype with some associated state. -template <class Arch> -Arch MakeArchetype(ArchetypeState state) noexcept { - static_assert(IsArchetype<Arch>::value, - "The explicit template argument to MakeArchetype is required " - "to be an Archetype."); - return Arch(MakeArchetypeState(), state); -} - -// This is used to conditionally delete "copy" and "move" constructors in a way -// that is consistent with what the ConformanceProfile requires and that also -// strictly enforces the arguments to the copy/move to not come from implicit -// conversions when dealing with the Archetype. -template <class Prof, class T> -constexpr bool ShouldDeleteConstructor() { - return !((PropertiesOfT<Prof>::move_constructible_support != - move_constructible::maybe && - std::is_same<T, Archetype<Prof>>::value) || - (PropertiesOfT<Prof>::copy_constructible_support != - copy_constructible::maybe && - (std::is_same<T, const Archetype<Prof>&>::value || - std::is_same<T, Archetype<Prof>&>::value || - std::is_same<T, const Archetype<Prof>>::value))); -} - -// This is used to conditionally delete "copy" and "move" assigns in a way -// that is consistent with what the ConformanceProfile requires and that also -// strictly enforces the arguments to the copy/move to not come from implicit -// conversions when dealing with the Archetype. -template <class Prof, class T> -constexpr bool ShouldDeleteAssign() { - return !( - (PropertiesOfT<Prof>::move_assignable_support != move_assignable::maybe && - std::is_same<T, Archetype<Prof>>::value) || - (PropertiesOfT<Prof>::copy_assignable_support != copy_assignable::maybe && - (std::is_same<T, const Archetype<Prof>&>::value || - std::is_same<T, Archetype<Prof>&>::value || - std::is_same<T, const Archetype<Prof>>::value))); -} - -// TODO(calabrese) Inherit from a chain of secondary bases to pull in the -// associated functions of other concepts. -template <class Prof, class Enabler> -class Archetype : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - static_assert(std::is_same<Enabler, void>::value, - "An explicit type must not be passed as the second template " - "argument to 'Archetype`."); - - // The cases mentioned in these static_asserts are expected to be handled in - // the partial template specializations of Archetype that follow this - // definition. - static_assert(PropertiesOfT<Prof>::destructible_support != - destructible::maybe, - ""); - static_assert(PropertiesOfT<Prof>::move_constructible_support != - move_constructible::maybe || - PropertiesOfT<Prof>::copy_constructible_support == - copy_constructible::maybe, - ""); - static_assert(PropertiesOfT<Prof>::move_assignable_support != - move_assignable::maybe || - PropertiesOfT<Prof>::copy_assignable_support == - copy_assignable::maybe, - ""); - - public: - Archetype() = default; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -template <class Prof> -class Archetype<Prof, typename std::enable_if< - PropertiesOfT<Prof>::move_constructible_support != - move_constructible::maybe && - PropertiesOfT<Prof>::move_assignable_support == - move_assignable::maybe && - PropertiesOfT<Prof>::destructible_support != - destructible::maybe>::type> - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - public: - Archetype() = default; - Archetype(Archetype&&) = default; - Archetype(const Archetype&) = default; - Archetype& operator=(Archetype&&) = delete; - Archetype& operator=(const Archetype&) = default; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -template <class Prof> -class Archetype<Prof, typename std::enable_if< - PropertiesOfT<Prof>::move_constructible_support == - move_constructible::maybe && - PropertiesOfT<Prof>::move_assignable_support == - move_assignable::maybe && - PropertiesOfT<Prof>::destructible_support != - destructible::maybe>::type> - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - public: - Archetype() = default; - Archetype(Archetype&&) = delete; - Archetype(const Archetype&) = default; - Archetype& operator=(Archetype&&) = delete; - Archetype& operator=(const Archetype&) = default; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -template <class Prof> -class Archetype<Prof, typename std::enable_if< - PropertiesOfT<Prof>::move_constructible_support == - move_constructible::maybe && - PropertiesOfT<Prof>::move_assignable_support != - move_assignable::maybe && - PropertiesOfT<Prof>::destructible_support != - destructible::maybe>::type> - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - public: - Archetype() = default; - Archetype(Archetype&&) = delete; - Archetype(const Archetype&) = default; - Archetype& operator=(Archetype&&) = default; - Archetype& operator=(const Archetype&) = default; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -template <class Prof> -class Archetype<Prof, typename std::enable_if< - PropertiesOfT<Prof>::move_constructible_support != - move_constructible::maybe && - PropertiesOfT<Prof>::move_assignable_support == - move_assignable::maybe && - PropertiesOfT<Prof>::destructible_support == - destructible::maybe>::type> - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - public: - Archetype() = default; - Archetype(Archetype&&) = default; - Archetype(const Archetype&) = default; - Archetype& operator=(Archetype&&) = delete; - Archetype& operator=(const Archetype&) = default; - ~Archetype() = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -template <class Prof> -class Archetype<Prof, typename std::enable_if< - PropertiesOfT<Prof>::move_constructible_support == - move_constructible::maybe && - PropertiesOfT<Prof>::move_assignable_support == - move_assignable::maybe && - PropertiesOfT<Prof>::destructible_support == - destructible::maybe>::type> - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - public: - Archetype() = default; - Archetype(Archetype&&) = delete; - Archetype(const Archetype&) = default; - Archetype& operator=(Archetype&&) = delete; - Archetype& operator=(const Archetype&) = default; - ~Archetype() = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -template <class Prof> -class Archetype<Prof, typename std::enable_if< - PropertiesOfT<Prof>::move_constructible_support == - move_constructible::maybe && - PropertiesOfT<Prof>::move_assignable_support != - move_assignable::maybe && - PropertiesOfT<Prof>::destructible_support == - destructible::maybe>::type> - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support> { - public: - Archetype() = default; - Archetype(Archetype&&) = delete; - Archetype(const Archetype&) = default; - Archetype& operator=(Archetype&&) = default; - Archetype& operator=(const Archetype&) = default; - ~Archetype() = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> - Archetype(T&&) = delete; - - // Disallow moves when requested, and disallow implicit conversions. - template <class T, typename std::enable_if< - ShouldDeleteAssign<Prof, T>()>::type* = nullptr> - Archetype& operator=(T&&) = delete; - - using ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>::archetype_state; - - private: - explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept - : ArchetypeSpecialMembersBase< - PropertiesOfT<Prof>::default_constructible_support, - PropertiesOfT<Prof>::move_constructible_support, - PropertiesOfT<Prof>::copy_constructible_support, - PropertiesOfT<Prof>::move_assignable_support, - PropertiesOfT<Prof>::copy_assignable_support, - PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), - state) {} - - friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; -}; - -// Explicitly deleted swap for Archetype if the profile does not require swap. -// It is important to delete it rather than simply leave it out so that the -// "using std::swap;" idiom will result in this deleted overload being picked. -template <class Prof, - y_absl::enable_if_t<!PropertiesOfT<Prof>::is_swappable, int> = 0> -void swap(Archetype<Prof>&, Archetype<Prof>&) = delete; // NOLINT - -// A conditionally-noexcept swap implementation for Archetype when the profile -// supports swap. -template <class Prof, - y_absl::enable_if_t<PropertiesOfT<Prof>::is_swappable, int> = 0> -void swap(Archetype<Prof>& lhs, Archetype<Prof>& rhs) // NOLINT - noexcept(PropertiesOfT<Prof>::swappable_support != swappable::yes) { - std::swap(lhs.archetype_state, rhs.archetype_state); -} - -// A convertible-to-bool type that is used as the return type of comparison -// operators since the standard doesn't always require exactly bool. -struct NothrowBool { - explicit NothrowBool() = delete; - ~NothrowBool() = default; - - // TODO(calabrese) Delete the copy constructor in C++17 mode since guaranteed - // elision makes it not required when returning from a function. - // NothrowBool(NothrowBool const&) = delete; - - NothrowBool& operator=(NothrowBool const&) = delete; - - explicit operator bool() const noexcept { return value; } - - static NothrowBool make(bool const value) noexcept { - return NothrowBool(value); - } - - private: - explicit NothrowBool(bool const value) noexcept : value(value) {} - - bool value; -}; - -// A convertible-to-bool type that is used as the return type of comparison -// operators since the standard doesn't always require exactly bool. -// Note: ExceptionalBool has a conversion operator that is not noexcept, so -// that even when a comparison operator is noexcept, that operation may still -// potentially throw when converted to bool. -struct ExceptionalBool { - explicit ExceptionalBool() = delete; - ~ExceptionalBool() = default; - - // TODO(calabrese) Delete the copy constructor in C++17 mode since guaranteed - // elision makes it not required when returning from a function. - // ExceptionalBool(ExceptionalBool const&) = delete; - - ExceptionalBool& operator=(ExceptionalBool const&) = delete; - - explicit operator bool() const { return value; } // NOLINT - - static ExceptionalBool make(bool const value) noexcept { - return ExceptionalBool(value); - } - - private: - explicit ExceptionalBool(bool const value) noexcept : value(value) {} - - bool value; -}; - -// The following macro is only used as a helper in this file to stamp out -// comparison operator definitions. It is undefined after usage. -// -// NOTE: Non-nothrow operators throw via their result's conversion to bool even -// though the operation itself is noexcept. -#define ABSL_TYPES_INTERNAL_OP(enum_name, op) \ - template <class Prof> \ - y_absl::enable_if_t<!PropertiesOfT<Prof>::is_##enum_name, bool> operator op( \ - const Archetype<Prof>&, const Archetype<Prof>&) = delete; \ - \ - template <class Prof> \ - typename y_absl::enable_if_t< \ - PropertiesOfT<Prof>::is_##enum_name, \ - std::conditional<PropertiesOfT<Prof>::enum_name##_support == \ - enum_name::nothrow, \ - NothrowBool, ExceptionalBool>>::type \ - operator op(const Archetype<Prof>& lhs, \ - const Archetype<Prof>& rhs) noexcept { \ - return y_absl::conditional_t< \ - PropertiesOfT<Prof>::enum_name##_support == enum_name::nothrow, \ - NothrowBool, ExceptionalBool>::make(lhs.archetype_state op \ - rhs.archetype_state); \ - } - -ABSL_TYPES_INTERNAL_OP(equality_comparable, ==); -ABSL_TYPES_INTERNAL_OP(inequality_comparable, !=); -ABSL_TYPES_INTERNAL_OP(less_than_comparable, <); -ABSL_TYPES_INTERNAL_OP(less_equal_comparable, <=); -ABSL_TYPES_INTERNAL_OP(greater_equal_comparable, >=); -ABSL_TYPES_INTERNAL_OP(greater_than_comparable, >); - -#undef ABSL_TYPES_INTERNAL_OP - -// Base class for std::hash specializations when an Archetype doesn't support -// hashing. -struct PoisonedHash { - PoisonedHash() = delete; - PoisonedHash(const PoisonedHash&) = delete; - PoisonedHash& operator=(const PoisonedHash&) = delete; -}; - -// Base class for std::hash specializations when an Archetype supports hashing. -template <class Prof> -struct EnabledHash { - using argument_type = Archetype<Prof>; - using result_type = std::size_t; - result_type operator()(const argument_type& arg) const { - return std::hash<ArchetypeState>()(arg.archetype_state); - } -}; - -} // namespace types_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -namespace std { - -template <class Prof> // NOLINT -struct hash<::y_absl::types_internal::Archetype<Prof>> - : conditional<::y_absl::types_internal::PropertiesOfT<Prof>::is_hashable, - ::y_absl::types_internal::EnabledHash<Prof>, - ::y_absl::types_internal::PoisonedHash>::type {}; - -} // namespace std - -#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// conformance_archetype.h +// ----------------------------------------------------------------------------- +// +// This file contains a facility for generating "archetypes" of out of +// "Conformance Profiles" (see "conformance_profiles.h" for more information +// about Conformance Profiles). An archetype is a type that aims to support the +// bare minimum requirements of a given Conformance Profile. For instance, an +// archetype that corresponds to an ImmutableProfile has exactly a nothrow +// move-constructor, a potentially-throwing copy constructor, a nothrow +// destructor, with all other special-member-functions deleted. These archetypes +// are useful for testing to make sure that templates are able to work with the +// kinds of types that they claim to support (i.e. that they do not accidentally +// under-constrain), +// +// The main type template in this file is the Archetype template, which takes +// a Conformance Profile as a template argument and its instantiations are a +// minimum-conforming model of that profile. + +#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ +#define ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ + +#include <cstddef> +#include <functional> +#include <type_traits> +#include <utility> + +#include "y_absl/meta/type_traits.h" +#include "y_absl/types/internal/conformance_profile.h" + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace types_internal { + +// A minimum-conforming implementation of a type with properties specified in +// `Prof`, where `Prof` is a valid Conformance Profile. +template <class Prof, class /*Enabler*/ = void> +class Archetype; + +// Given an Archetype, obtain the properties of the profile associated with that +// archetype. +template <class Archetype> +struct PropertiesOfArchetype; + +template <class Prof> +struct PropertiesOfArchetype<Archetype<Prof>> { + using type = PropertiesOfT<Prof>; +}; + +template <class Archetype> +using PropertiesOfArchetypeT = typename PropertiesOfArchetype<Archetype>::type; + +// A metafunction to determine if a type is an `Archetype`. +template <class T> +struct IsArchetype : std::false_type {}; + +template <class Prof> +struct IsArchetype<Archetype<Prof>> : std::true_type {}; + +// A constructor tag type used when creating an Archetype with internal state. +struct MakeArchetypeState {}; + +// Data stored within an archetype that is copied/compared/hashed when the +// corresponding operations are used. +using ArchetypeState = std::size_t; + +//////////////////////////////////////////////////////////////////////////////// +// This section of the file defines a chain of base classes for Archetype, // +// where each base defines a specific special member function with the // +// appropriate properties (deleted, noexcept(false), noexcept, or trivial). // +//////////////////////////////////////////////////////////////////////////////// + +// The bottom-most base, which contains the state and the default constructor. +template <default_constructible DefaultConstructibleValue> +struct ArchetypeStateBase { + static_assert(DefaultConstructibleValue == default_constructible::yes || + DefaultConstructibleValue == default_constructible::nothrow, + ""); + + ArchetypeStateBase() noexcept( + DefaultConstructibleValue == + default_constructible:: + nothrow) /*Vacuous archetype_state initialization*/ {} + explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept + : archetype_state(state) {} + + ArchetypeState archetype_state; +}; + +template <> +struct ArchetypeStateBase<default_constructible::maybe> { + explicit ArchetypeStateBase() = delete; + explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept + : archetype_state(state) {} + + ArchetypeState archetype_state; +}; + +template <> +struct ArchetypeStateBase<default_constructible::trivial> { + ArchetypeStateBase() = default; + explicit ArchetypeStateBase(MakeArchetypeState, ArchetypeState state) noexcept + : archetype_state(state) {} + + ArchetypeState archetype_state; +}; + +// The move-constructor base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue> +struct ArchetypeMoveConstructor + : ArchetypeStateBase<DefaultConstructibleValue> { + static_assert(MoveConstructibleValue == move_constructible::yes || + MoveConstructibleValue == move_constructible::nothrow, + ""); + + explicit ArchetypeMoveConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveConstructor() = default; + ArchetypeMoveConstructor(ArchetypeMoveConstructor&& other) noexcept( + MoveConstructibleValue == move_constructible::nothrow) + : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), + other.archetype_state) {} + ArchetypeMoveConstructor(const ArchetypeMoveConstructor&) = default; + ArchetypeMoveConstructor& operator=(ArchetypeMoveConstructor&&) = default; + ArchetypeMoveConstructor& operator=(const ArchetypeMoveConstructor&) = + default; +}; + +template <default_constructible DefaultConstructibleValue> +struct ArchetypeMoveConstructor<DefaultConstructibleValue, + move_constructible::trivial> + : ArchetypeStateBase<DefaultConstructibleValue> { + explicit ArchetypeMoveConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeStateBase<DefaultConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveConstructor() = default; +}; + +// The copy-constructor base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue> +struct ArchetypeCopyConstructor + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue> { + static_assert(CopyConstructibleValue == copy_constructible::yes || + CopyConstructibleValue == copy_constructible::nothrow, + ""); + explicit ArchetypeCopyConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeCopyConstructor() = default; + ArchetypeCopyConstructor(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor(const ArchetypeCopyConstructor& other) noexcept( + CopyConstructibleValue == copy_constructible::nothrow) + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>( + MakeArchetypeState(), other.archetype_state) {} + ArchetypeCopyConstructor& operator=(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor& operator=(const ArchetypeCopyConstructor&) = + default; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue> +struct ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + copy_constructible::maybe> + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue> { + explicit ArchetypeCopyConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeCopyConstructor() = default; + ArchetypeCopyConstructor(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor(const ArchetypeCopyConstructor&) = delete; + ArchetypeCopyConstructor& operator=(ArchetypeCopyConstructor&&) = default; + ArchetypeCopyConstructor& operator=(const ArchetypeCopyConstructor&) = + default; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue> +struct ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + copy_constructible::trivial> + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue> { + explicit ArchetypeCopyConstructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveConstructor<DefaultConstructibleValue, + MoveConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeCopyConstructor() = default; +}; + +// The move-assign base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue> +struct ArchetypeMoveAssign + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, CopyConstructibleValue> { + static_assert(MoveAssignableValue == move_assignable::yes || + MoveAssignableValue == move_assignable::nothrow, + ""); + explicit ArchetypeMoveAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + CopyConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveAssign() = default; + ArchetypeMoveAssign(ArchetypeMoveAssign&&) = default; + ArchetypeMoveAssign(const ArchetypeMoveAssign&) = default; + ArchetypeMoveAssign& operator=(ArchetypeMoveAssign&& other) noexcept( + MoveAssignableValue == move_assignable::nothrow) { + this->archetype_state = other.archetype_state; + return *this; + } + + ArchetypeMoveAssign& operator=(const ArchetypeMoveAssign&) = default; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue> +struct ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, move_assignable::trivial> + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, CopyConstructibleValue> { + explicit ArchetypeMoveAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyConstructor<DefaultConstructibleValue, + MoveConstructibleValue, + CopyConstructibleValue>(MakeArchetypeState(), + state) {} + + ArchetypeMoveAssign() = default; +}; + +// The copy-assign base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue> +struct ArchetypeCopyAssign + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue> { + static_assert(CopyAssignableValue == copy_assignable::yes || + CopyAssignableValue == copy_assignable::nothrow, + ""); + explicit ArchetypeCopyAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue>( + MakeArchetypeState(), state) {} + + ArchetypeCopyAssign() = default; + ArchetypeCopyAssign(ArchetypeCopyAssign&&) = default; + ArchetypeCopyAssign(const ArchetypeCopyAssign&) = default; + ArchetypeCopyAssign& operator=(ArchetypeCopyAssign&&) = default; + + ArchetypeCopyAssign& operator=(const ArchetypeCopyAssign& other) noexcept( + CopyAssignableValue == copy_assignable::nothrow) { + this->archetype_state = other.archetype_state; + return *this; + } +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue> +struct ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + copy_assignable::maybe> + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue> { + explicit ArchetypeCopyAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue>( + MakeArchetypeState(), state) {} + + ArchetypeCopyAssign() = default; + ArchetypeCopyAssign(ArchetypeCopyAssign&&) = default; + ArchetypeCopyAssign(const ArchetypeCopyAssign&) = default; + ArchetypeCopyAssign& operator=(ArchetypeCopyAssign&&) = default; + ArchetypeCopyAssign& operator=(const ArchetypeCopyAssign&) = delete; +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue> +struct ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + copy_assignable::trivial> + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue> { + explicit ArchetypeCopyAssign(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeMoveAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue>( + MakeArchetypeState(), state) {} + + ArchetypeCopyAssign() = default; +}; + +// The destructor base +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue, destructible DestructibleValue> +struct ArchetypeDestructor + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue> { + static_assert(DestructibleValue == destructible::yes || + DestructibleValue == destructible::nothrow, + ""); + + explicit ArchetypeDestructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue>(MakeArchetypeState(), state) {} + + ArchetypeDestructor() = default; + ArchetypeDestructor(ArchetypeDestructor&&) = default; + ArchetypeDestructor(const ArchetypeDestructor&) = default; + ArchetypeDestructor& operator=(ArchetypeDestructor&&) = default; + ArchetypeDestructor& operator=(const ArchetypeDestructor&) = default; + ~ArchetypeDestructor() noexcept(DestructibleValue == destructible::nothrow) {} +}; + +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue> +struct ArchetypeDestructor<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue, destructible::trivial> + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue> { + explicit ArchetypeDestructor(MakeArchetypeState, + ArchetypeState state) noexcept + : ArchetypeCopyAssign<DefaultConstructibleValue, MoveConstructibleValue, + CopyConstructibleValue, MoveAssignableValue, + CopyAssignableValue>(MakeArchetypeState(), state) {} + + ArchetypeDestructor() = default; +}; + +// An alias to the top of the chain of bases for special-member functions. +// NOTE: move_constructible::maybe, move_assignable::maybe, and +// destructible::maybe are handled in the top-level type by way of SFINAE. +// Because of this, we never instantiate the base classes with +// move_constructible::maybe, move_assignable::maybe, or destructible::maybe so +// that we minimize the number of different possible type-template +// instantiations. +template <default_constructible DefaultConstructibleValue, + move_constructible MoveConstructibleValue, + copy_constructible CopyConstructibleValue, + move_assignable MoveAssignableValue, + copy_assignable CopyAssignableValue, destructible DestructibleValue> +using ArchetypeSpecialMembersBase = ArchetypeDestructor< + DefaultConstructibleValue, + MoveConstructibleValue != move_constructible::maybe + ? MoveConstructibleValue + : move_constructible::nothrow, + CopyConstructibleValue, + MoveAssignableValue != move_assignable::maybe ? MoveAssignableValue + : move_assignable::nothrow, + CopyAssignableValue, + DestructibleValue != destructible::maybe ? DestructibleValue + : destructible::nothrow>; + +// A function that is used to create an archetype with some associated state. +template <class Arch> +Arch MakeArchetype(ArchetypeState state) noexcept { + static_assert(IsArchetype<Arch>::value, + "The explicit template argument to MakeArchetype is required " + "to be an Archetype."); + return Arch(MakeArchetypeState(), state); +} + +// This is used to conditionally delete "copy" and "move" constructors in a way +// that is consistent with what the ConformanceProfile requires and that also +// strictly enforces the arguments to the copy/move to not come from implicit +// conversions when dealing with the Archetype. +template <class Prof, class T> +constexpr bool ShouldDeleteConstructor() { + return !((PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe && + std::is_same<T, Archetype<Prof>>::value) || + (PropertiesOfT<Prof>::copy_constructible_support != + copy_constructible::maybe && + (std::is_same<T, const Archetype<Prof>&>::value || + std::is_same<T, Archetype<Prof>&>::value || + std::is_same<T, const Archetype<Prof>>::value))); +} + +// This is used to conditionally delete "copy" and "move" assigns in a way +// that is consistent with what the ConformanceProfile requires and that also +// strictly enforces the arguments to the copy/move to not come from implicit +// conversions when dealing with the Archetype. +template <class Prof, class T> +constexpr bool ShouldDeleteAssign() { + return !( + (PropertiesOfT<Prof>::move_assignable_support != move_assignable::maybe && + std::is_same<T, Archetype<Prof>>::value) || + (PropertiesOfT<Prof>::copy_assignable_support != copy_assignable::maybe && + (std::is_same<T, const Archetype<Prof>&>::value || + std::is_same<T, Archetype<Prof>&>::value || + std::is_same<T, const Archetype<Prof>>::value))); +} + +// TODO(calabrese) Inherit from a chain of secondary bases to pull in the +// associated functions of other concepts. +template <class Prof, class Enabler> +class Archetype : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + static_assert(std::is_same<Enabler, void>::value, + "An explicit type must not be passed as the second template " + "argument to 'Archetype`."); + + // The cases mentioned in these static_asserts are expected to be handled in + // the partial template specializations of Archetype that follow this + // definition. + static_assert(PropertiesOfT<Prof>::destructible_support != + destructible::maybe, + ""); + static_assert(PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe || + PropertiesOfT<Prof>::copy_constructible_support == + copy_constructible::maybe, + ""); + static_assert(PropertiesOfT<Prof>::move_assignable_support != + move_assignable::maybe || + PropertiesOfT<Prof>::copy_assignable_support == + copy_assignable::maybe, + ""); + + public: + Archetype() = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support != + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = default; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support != + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support != + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support != + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = default; + Archetype& operator=(const Archetype&) = default; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support != + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support == + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = default; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + ~Archetype() = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support == + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support == + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = delete; + Archetype& operator=(const Archetype&) = default; + ~Archetype() = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +template <class Prof> +class Archetype<Prof, typename std::enable_if< + PropertiesOfT<Prof>::move_constructible_support == + move_constructible::maybe && + PropertiesOfT<Prof>::move_assignable_support != + move_assignable::maybe && + PropertiesOfT<Prof>::destructible_support == + destructible::maybe>::type> + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support> { + public: + Archetype() = default; + Archetype(Archetype&&) = delete; + Archetype(const Archetype&) = default; + Archetype& operator=(Archetype&&) = default; + Archetype& operator=(const Archetype&) = default; + ~Archetype() = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteConstructor<Prof, T>()>::type* = nullptr> + Archetype(T&&) = delete; + + // Disallow moves when requested, and disallow implicit conversions. + template <class T, typename std::enable_if< + ShouldDeleteAssign<Prof, T>()>::type* = nullptr> + Archetype& operator=(T&&) = delete; + + using ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>::archetype_state; + + private: + explicit Archetype(MakeArchetypeState, ArchetypeState state) noexcept + : ArchetypeSpecialMembersBase< + PropertiesOfT<Prof>::default_constructible_support, + PropertiesOfT<Prof>::move_constructible_support, + PropertiesOfT<Prof>::copy_constructible_support, + PropertiesOfT<Prof>::move_assignable_support, + PropertiesOfT<Prof>::copy_assignable_support, + PropertiesOfT<Prof>::destructible_support>(MakeArchetypeState(), + state) {} + + friend Archetype MakeArchetype<Archetype>(ArchetypeState) noexcept; +}; + +// Explicitly deleted swap for Archetype if the profile does not require swap. +// It is important to delete it rather than simply leave it out so that the +// "using std::swap;" idiom will result in this deleted overload being picked. +template <class Prof, + y_absl::enable_if_t<!PropertiesOfT<Prof>::is_swappable, int> = 0> +void swap(Archetype<Prof>&, Archetype<Prof>&) = delete; // NOLINT + +// A conditionally-noexcept swap implementation for Archetype when the profile +// supports swap. +template <class Prof, + y_absl::enable_if_t<PropertiesOfT<Prof>::is_swappable, int> = 0> +void swap(Archetype<Prof>& lhs, Archetype<Prof>& rhs) // NOLINT + noexcept(PropertiesOfT<Prof>::swappable_support != swappable::yes) { + std::swap(lhs.archetype_state, rhs.archetype_state); +} + +// A convertible-to-bool type that is used as the return type of comparison +// operators since the standard doesn't always require exactly bool. +struct NothrowBool { + explicit NothrowBool() = delete; + ~NothrowBool() = default; + + // TODO(calabrese) Delete the copy constructor in C++17 mode since guaranteed + // elision makes it not required when returning from a function. + // NothrowBool(NothrowBool const&) = delete; + + NothrowBool& operator=(NothrowBool const&) = delete; + + explicit operator bool() const noexcept { return value; } + + static NothrowBool make(bool const value) noexcept { + return NothrowBool(value); + } + + private: + explicit NothrowBool(bool const value) noexcept : value(value) {} + + bool value; +}; + +// A convertible-to-bool type that is used as the return type of comparison +// operators since the standard doesn't always require exactly bool. +// Note: ExceptionalBool has a conversion operator that is not noexcept, so +// that even when a comparison operator is noexcept, that operation may still +// potentially throw when converted to bool. +struct ExceptionalBool { + explicit ExceptionalBool() = delete; + ~ExceptionalBool() = default; + + // TODO(calabrese) Delete the copy constructor in C++17 mode since guaranteed + // elision makes it not required when returning from a function. + // ExceptionalBool(ExceptionalBool const&) = delete; + + ExceptionalBool& operator=(ExceptionalBool const&) = delete; + + explicit operator bool() const { return value; } // NOLINT + + static ExceptionalBool make(bool const value) noexcept { + return ExceptionalBool(value); + } + + private: + explicit ExceptionalBool(bool const value) noexcept : value(value) {} + + bool value; +}; + +// The following macro is only used as a helper in this file to stamp out +// comparison operator definitions. It is undefined after usage. +// +// NOTE: Non-nothrow operators throw via their result's conversion to bool even +// though the operation itself is noexcept. +#define ABSL_TYPES_INTERNAL_OP(enum_name, op) \ + template <class Prof> \ + y_absl::enable_if_t<!PropertiesOfT<Prof>::is_##enum_name, bool> operator op( \ + const Archetype<Prof>&, const Archetype<Prof>&) = delete; \ + \ + template <class Prof> \ + typename y_absl::enable_if_t< \ + PropertiesOfT<Prof>::is_##enum_name, \ + std::conditional<PropertiesOfT<Prof>::enum_name##_support == \ + enum_name::nothrow, \ + NothrowBool, ExceptionalBool>>::type \ + operator op(const Archetype<Prof>& lhs, \ + const Archetype<Prof>& rhs) noexcept { \ + return y_absl::conditional_t< \ + PropertiesOfT<Prof>::enum_name##_support == enum_name::nothrow, \ + NothrowBool, ExceptionalBool>::make(lhs.archetype_state op \ + rhs.archetype_state); \ + } + +ABSL_TYPES_INTERNAL_OP(equality_comparable, ==); +ABSL_TYPES_INTERNAL_OP(inequality_comparable, !=); +ABSL_TYPES_INTERNAL_OP(less_than_comparable, <); +ABSL_TYPES_INTERNAL_OP(less_equal_comparable, <=); +ABSL_TYPES_INTERNAL_OP(greater_equal_comparable, >=); +ABSL_TYPES_INTERNAL_OP(greater_than_comparable, >); + +#undef ABSL_TYPES_INTERNAL_OP + +// Base class for std::hash specializations when an Archetype doesn't support +// hashing. +struct PoisonedHash { + PoisonedHash() = delete; + PoisonedHash(const PoisonedHash&) = delete; + PoisonedHash& operator=(const PoisonedHash&) = delete; +}; + +// Base class for std::hash specializations when an Archetype supports hashing. +template <class Prof> +struct EnabledHash { + using argument_type = Archetype<Prof>; + using result_type = std::size_t; + result_type operator()(const argument_type& arg) const { + return std::hash<ArchetypeState>()(arg.archetype_state); + } +}; + +} // namespace types_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +namespace std { + +template <class Prof> // NOLINT +struct hash<::y_absl::types_internal::Archetype<Prof>> + : conditional<::y_absl::types_internal::PropertiesOfT<Prof>::is_hashable, + ::y_absl::types_internal::EnabledHash<Prof>, + ::y_absl::types_internal::PoisonedHash>::type {}; + +} // namespace std + +#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_ARCHETYPE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_profile.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_profile.h index b19165a4b9..edc52df920 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_profile.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/conformance_profile.h @@ -1,61 +1,61 @@ -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// conformance_profiles.h -// ----------------------------------------------------------------------------- -// -// This file contains templates for representing "Regularity Profiles" and -// concisely-named versions of commonly used Regularity Profiles. -// -// A Regularity Profile is a compile-time description of the types of operations -// that a given type supports, along with properties of those operations when -// they do exist. For instance, a Regularity Profile may describe a type that -// has a move-constructor that is noexcept and a copy constructor that is not -// noexcept. This description can then be examined and passed around to other -// templates for the purposes of asserting expectations on user-defined types -// via a series trait checks, or for determining what kinds of run-time tests -// are able to be performed. -// -// Regularity Profiles are also used when creating "archetypes," which are -// minimum-conforming types that meet all of the requirements of a given -// Regularity Profile. For more information regarding archetypes, see -// "conformance_archetypes.h". - -#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ -#define ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ - +// Copyright 2019 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ----------------------------------------------------------------------------- +// conformance_profiles.h +// ----------------------------------------------------------------------------- +// +// This file contains templates for representing "Regularity Profiles" and +// concisely-named versions of commonly used Regularity Profiles. +// +// A Regularity Profile is a compile-time description of the types of operations +// that a given type supports, along with properties of those operations when +// they do exist. For instance, a Regularity Profile may describe a type that +// has a move-constructor that is noexcept and a copy constructor that is not +// noexcept. This description can then be examined and passed around to other +// templates for the purposes of asserting expectations on user-defined types +// via a series trait checks, or for determining what kinds of run-time tests +// are able to be performed. +// +// Regularity Profiles are also used when creating "archetypes," which are +// minimum-conforming types that meet all of the requirements of a given +// Regularity Profile. For more information regarding archetypes, see +// "conformance_archetypes.h". + +#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ +#define ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ + #include <set> -#include <type_traits> -#include <utility> +#include <type_traits> +#include <utility> #include <vector> - + #include "gtest/gtest.h" #include "y_absl/algorithm/container.h" -#include "y_absl/meta/type_traits.h" +#include "y_absl/meta/type_traits.h" #include "y_absl/strings/ascii.h" #include "y_absl/strings/str_cat.h" #include "y_absl/strings/string_view.h" #include "y_absl/types/internal/conformance_testing_helpers.h" #include "y_absl/utility/utility.h" - -// TODO(calabrese) Add support for extending profiles. - -namespace y_absl { -ABSL_NAMESPACE_BEGIN -namespace types_internal { - + +// TODO(calabrese) Add support for extending profiles. + +namespace y_absl { +ABSL_NAMESPACE_BEGIN +namespace types_internal { + // Converts an enum to its underlying integral value. template <typename Enum> constexpr y_absl::underlying_type_t<Enum> UnderlyingValue(Enum value) { @@ -237,32 +237,32 @@ class ConformanceErrors { bool has_error_ = false; }; -template <class T, class /*Enabler*/ = void> -struct PropertiesOfImpl {}; - -template <class T> -struct PropertiesOfImpl<T, y_absl::void_t<typename T::properties>> { - using type = typename T::properties; -}; - -template <class T> -struct PropertiesOfImpl<T, y_absl::void_t<typename T::profile_alias_of>> { - using type = typename PropertiesOfImpl<typename T::profile_alias_of>::type; -}; - -template <class T> -struct PropertiesOf : PropertiesOfImpl<T> {}; - -template <class T> -using PropertiesOfT = typename PropertiesOf<T>::type; - -// NOTE: These enums use this naming convention to be consistent with the -// standard trait names, which is useful since it allows us to match up each -// enum name with a corresponding trait name in macro definitions. - +template <class T, class /*Enabler*/ = void> +struct PropertiesOfImpl {}; + +template <class T> +struct PropertiesOfImpl<T, y_absl::void_t<typename T::properties>> { + using type = typename T::properties; +}; + +template <class T> +struct PropertiesOfImpl<T, y_absl::void_t<typename T::profile_alias_of>> { + using type = typename PropertiesOfImpl<typename T::profile_alias_of>::type; +}; + +template <class T> +struct PropertiesOf : PropertiesOfImpl<T> {}; + +template <class T> +using PropertiesOfT = typename PropertiesOf<T>::type; + +// NOTE: These enums use this naming convention to be consistent with the +// standard trait names, which is useful since it allows us to match up each +// enum name with a corresponding trait name in macro definitions. + // An enum that describes the various expectations on an operations existence. enum class function_support { maybe, yes, nothrow, trivial }; - + constexpr const char* PessimisticPropertyDescription(function_support v) { return v == function_support::maybe ? "no" @@ -271,7 +271,7 @@ constexpr const char* PessimisticPropertyDescription(function_support v) { : v == function_support::nothrow ? "yes, nothrow" : "yes, trivial"; } - + // Return a string that describes the kind of property support that was // expected. inline TString ExpectedFunctionKindList(function_support min, @@ -284,7 +284,7 @@ inline TString ExpectedFunctionKindList(function_support min, "\n"); return result; } - + TString result = "Expected one of:\n"; for (auto curr_support = UnderlyingValue(min); curr_support <= UnderlyingValue(max); ++curr_support) { @@ -337,14 +337,14 @@ ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for copy assignment", ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for destruction", destructible); -#undef ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM - +#undef ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM + #define ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(description, name) \ enum class name { maybe, yes, nothrow }; \ \ constexpr const char* PropertyName(name v) { return description; } \ static_assert(true, "") // Force a semicolon when using this macro. - + ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for ==", equality_comparable); ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for !=", inequality_comparable); ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for <", less_than_comparable); @@ -352,17 +352,17 @@ ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for <=", less_equal_comparable); ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for >=", greater_equal_comparable); ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for >", greater_than_comparable); - + ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for swap", swappable); - -#undef ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM - -enum class hashable { maybe, yes }; - -constexpr const char* PropertyName(hashable v) { - return "support for std::hash"; -} - + +#undef ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM + +enum class hashable { maybe, yes }; + +constexpr const char* PropertyName(hashable v) { + return "support for std::hash"; +} + template <class T> using AlwaysFalse = std::false_type; @@ -541,118 +541,118 @@ void ExpectModelOfHashable(ConformanceErrors* errors) { // //////////////////////////////////////////////////////////////////////////////// -template < - default_constructible DefaultConstructibleValue = - default_constructible::maybe, - move_constructible MoveConstructibleValue = move_constructible::maybe, - copy_constructible CopyConstructibleValue = copy_constructible::maybe, - move_assignable MoveAssignableValue = move_assignable::maybe, - copy_assignable CopyAssignableValue = copy_assignable::maybe, - destructible DestructibleValue = destructible::maybe, - equality_comparable EqualityComparableValue = equality_comparable::maybe, - inequality_comparable InequalityComparableValue = - inequality_comparable::maybe, - less_than_comparable LessThanComparableValue = less_than_comparable::maybe, - less_equal_comparable LessEqualComparableValue = - less_equal_comparable::maybe, - greater_equal_comparable GreaterEqualComparableValue = - greater_equal_comparable::maybe, - greater_than_comparable GreaterThanComparableValue = - greater_than_comparable::maybe, - swappable SwappableValue = swappable::maybe, - hashable HashableValue = hashable::maybe> -struct ConformanceProfile { - using properties = ConformanceProfile; - - static constexpr default_constructible - default_constructible_support = // NOLINT - DefaultConstructibleValue; - - static constexpr move_constructible move_constructible_support = // NOLINT - MoveConstructibleValue; - - static constexpr copy_constructible copy_constructible_support = // NOLINT - CopyConstructibleValue; - - static constexpr move_assignable move_assignable_support = // NOLINT - MoveAssignableValue; - - static constexpr copy_assignable copy_assignable_support = // NOLINT - CopyAssignableValue; - - static constexpr destructible destructible_support = // NOLINT - DestructibleValue; - - static constexpr equality_comparable equality_comparable_support = // NOLINT - EqualityComparableValue; - - static constexpr inequality_comparable - inequality_comparable_support = // NOLINT - InequalityComparableValue; - - static constexpr less_than_comparable - less_than_comparable_support = // NOLINT - LessThanComparableValue; - - static constexpr less_equal_comparable - less_equal_comparable_support = // NOLINT - LessEqualComparableValue; - - static constexpr greater_equal_comparable - greater_equal_comparable_support = // NOLINT - GreaterEqualComparableValue; - - static constexpr greater_than_comparable - greater_than_comparable_support = // NOLINT - GreaterThanComparableValue; - - static constexpr swappable swappable_support = SwappableValue; // NOLINT - - static constexpr hashable hashable_support = HashableValue; // NOLINT - - static constexpr bool is_default_constructible = // NOLINT - DefaultConstructibleValue != default_constructible::maybe; - - static constexpr bool is_move_constructible = // NOLINT - MoveConstructibleValue != move_constructible::maybe; - - static constexpr bool is_copy_constructible = // NOLINT - CopyConstructibleValue != copy_constructible::maybe; - - static constexpr bool is_move_assignable = // NOLINT - MoveAssignableValue != move_assignable::maybe; - - static constexpr bool is_copy_assignable = // NOLINT - CopyAssignableValue != copy_assignable::maybe; - - static constexpr bool is_destructible = // NOLINT - DestructibleValue != destructible::maybe; - - static constexpr bool is_equality_comparable = // NOLINT - EqualityComparableValue != equality_comparable::maybe; - - static constexpr bool is_inequality_comparable = // NOLINT - InequalityComparableValue != inequality_comparable::maybe; - - static constexpr bool is_less_than_comparable = // NOLINT - LessThanComparableValue != less_than_comparable::maybe; - - static constexpr bool is_less_equal_comparable = // NOLINT - LessEqualComparableValue != less_equal_comparable::maybe; - - static constexpr bool is_greater_equal_comparable = // NOLINT - GreaterEqualComparableValue != greater_equal_comparable::maybe; - - static constexpr bool is_greater_than_comparable = // NOLINT - GreaterThanComparableValue != greater_than_comparable::maybe; - - static constexpr bool is_swappable = // NOLINT - SwappableValue != swappable::maybe; - - static constexpr bool is_hashable = // NOLINT - HashableValue != hashable::maybe; -}; - +template < + default_constructible DefaultConstructibleValue = + default_constructible::maybe, + move_constructible MoveConstructibleValue = move_constructible::maybe, + copy_constructible CopyConstructibleValue = copy_constructible::maybe, + move_assignable MoveAssignableValue = move_assignable::maybe, + copy_assignable CopyAssignableValue = copy_assignable::maybe, + destructible DestructibleValue = destructible::maybe, + equality_comparable EqualityComparableValue = equality_comparable::maybe, + inequality_comparable InequalityComparableValue = + inequality_comparable::maybe, + less_than_comparable LessThanComparableValue = less_than_comparable::maybe, + less_equal_comparable LessEqualComparableValue = + less_equal_comparable::maybe, + greater_equal_comparable GreaterEqualComparableValue = + greater_equal_comparable::maybe, + greater_than_comparable GreaterThanComparableValue = + greater_than_comparable::maybe, + swappable SwappableValue = swappable::maybe, + hashable HashableValue = hashable::maybe> +struct ConformanceProfile { + using properties = ConformanceProfile; + + static constexpr default_constructible + default_constructible_support = // NOLINT + DefaultConstructibleValue; + + static constexpr move_constructible move_constructible_support = // NOLINT + MoveConstructibleValue; + + static constexpr copy_constructible copy_constructible_support = // NOLINT + CopyConstructibleValue; + + static constexpr move_assignable move_assignable_support = // NOLINT + MoveAssignableValue; + + static constexpr copy_assignable copy_assignable_support = // NOLINT + CopyAssignableValue; + + static constexpr destructible destructible_support = // NOLINT + DestructibleValue; + + static constexpr equality_comparable equality_comparable_support = // NOLINT + EqualityComparableValue; + + static constexpr inequality_comparable + inequality_comparable_support = // NOLINT + InequalityComparableValue; + + static constexpr less_than_comparable + less_than_comparable_support = // NOLINT + LessThanComparableValue; + + static constexpr less_equal_comparable + less_equal_comparable_support = // NOLINT + LessEqualComparableValue; + + static constexpr greater_equal_comparable + greater_equal_comparable_support = // NOLINT + GreaterEqualComparableValue; + + static constexpr greater_than_comparable + greater_than_comparable_support = // NOLINT + GreaterThanComparableValue; + + static constexpr swappable swappable_support = SwappableValue; // NOLINT + + static constexpr hashable hashable_support = HashableValue; // NOLINT + + static constexpr bool is_default_constructible = // NOLINT + DefaultConstructibleValue != default_constructible::maybe; + + static constexpr bool is_move_constructible = // NOLINT + MoveConstructibleValue != move_constructible::maybe; + + static constexpr bool is_copy_constructible = // NOLINT + CopyConstructibleValue != copy_constructible::maybe; + + static constexpr bool is_move_assignable = // NOLINT + MoveAssignableValue != move_assignable::maybe; + + static constexpr bool is_copy_assignable = // NOLINT + CopyAssignableValue != copy_assignable::maybe; + + static constexpr bool is_destructible = // NOLINT + DestructibleValue != destructible::maybe; + + static constexpr bool is_equality_comparable = // NOLINT + EqualityComparableValue != equality_comparable::maybe; + + static constexpr bool is_inequality_comparable = // NOLINT + InequalityComparableValue != inequality_comparable::maybe; + + static constexpr bool is_less_than_comparable = // NOLINT + LessThanComparableValue != less_than_comparable::maybe; + + static constexpr bool is_less_equal_comparable = // NOLINT + LessEqualComparableValue != less_equal_comparable::maybe; + + static constexpr bool is_greater_equal_comparable = // NOLINT + GreaterEqualComparableValue != greater_equal_comparable::maybe; + + static constexpr bool is_greater_than_comparable = // NOLINT + GreaterThanComparableValue != greater_than_comparable::maybe; + + static constexpr bool is_swappable = // NOLINT + SwappableValue != swappable::maybe; + + static constexpr bool is_hashable = // NOLINT + HashableValue != hashable::maybe; +}; + //////////////////////////////////////////////////////////////////////////////// // // Compliant SFINAE-friendliness is not always present on the standard library @@ -692,58 +692,58 @@ struct SyntacticConformanceProfileOf { conservative_hashable_support_of<T, ShouldCheckHashability>::Invoke()>; }; -#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, name) \ - template <default_constructible DefaultConstructibleValue, \ - move_constructible MoveConstructibleValue, \ - copy_constructible CopyConstructibleValue, \ - move_assignable MoveAssignableValue, \ - copy_assignable CopyAssignableValue, \ - destructible DestructibleValue, \ - equality_comparable EqualityComparableValue, \ - inequality_comparable InequalityComparableValue, \ - less_than_comparable LessThanComparableValue, \ - less_equal_comparable LessEqualComparableValue, \ - greater_equal_comparable GreaterEqualComparableValue, \ - greater_than_comparable GreaterThanComparableValue, \ - swappable SwappableValue, hashable HashableValue> \ - constexpr type ConformanceProfile< \ - DefaultConstructibleValue, MoveConstructibleValue, \ - CopyConstructibleValue, MoveAssignableValue, CopyAssignableValue, \ - DestructibleValue, EqualityComparableValue, InequalityComparableValue, \ - LessThanComparableValue, LessEqualComparableValue, \ - GreaterEqualComparableValue, GreaterThanComparableValue, SwappableValue, \ - HashableValue>::name - -#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(type) \ - ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, \ - type##_support); \ - ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(bool, is_##type) - -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(default_constructible); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(move_constructible); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(copy_constructible); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(move_assignable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(copy_assignable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(destructible); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(equality_comparable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(inequality_comparable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(less_than_comparable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(less_equal_comparable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(greater_equal_comparable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(greater_than_comparable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(swappable); -ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(hashable); - -#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF -#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL - +#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, name) \ + template <default_constructible DefaultConstructibleValue, \ + move_constructible MoveConstructibleValue, \ + copy_constructible CopyConstructibleValue, \ + move_assignable MoveAssignableValue, \ + copy_assignable CopyAssignableValue, \ + destructible DestructibleValue, \ + equality_comparable EqualityComparableValue, \ + inequality_comparable InequalityComparableValue, \ + less_than_comparable LessThanComparableValue, \ + less_equal_comparable LessEqualComparableValue, \ + greater_equal_comparable GreaterEqualComparableValue, \ + greater_than_comparable GreaterThanComparableValue, \ + swappable SwappableValue, hashable HashableValue> \ + constexpr type ConformanceProfile< \ + DefaultConstructibleValue, MoveConstructibleValue, \ + CopyConstructibleValue, MoveAssignableValue, CopyAssignableValue, \ + DestructibleValue, EqualityComparableValue, InequalityComparableValue, \ + LessThanComparableValue, LessEqualComparableValue, \ + GreaterEqualComparableValue, GreaterThanComparableValue, SwappableValue, \ + HashableValue>::name + +#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(type) \ + ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, \ + type##_support); \ + ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(bool, is_##type) + +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(default_constructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(move_constructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(copy_constructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(move_assignable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(copy_assignable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(destructible); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(equality_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(inequality_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(less_than_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(less_equal_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(greater_equal_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(greater_than_comparable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(swappable); +ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(hashable); + +#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF +#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL + // Retrieve the enum with the minimum underlying value. // Note: std::min is not constexpr in C++11, which is why this is necessary. template <class H> constexpr H MinEnum(H head) { return head; -} - +} + template <class H, class N, class... T> constexpr H MinEnum(H head, N next, T... tail) { return (UnderlyingValue)(head) < (UnderlyingValue)(next) @@ -811,108 +811,108 @@ struct MinimalProfiles { swappable_support, hashable_support>; }; -// Retrieve the enum with the greatest underlying value. -// Note: std::max is not constexpr in C++11, which is why this is necessary. -template <class H> -constexpr H MaxEnum(H head) { - return head; -} - -template <class H, class N, class... T> -constexpr H MaxEnum(H head, N next, T... tail) { - return (UnderlyingValue)(next) < (UnderlyingValue)(head) - ? (MaxEnum)(head, tail...) - : (MaxEnum)(next, tail...); -} - -template <class... Profs> -struct CombineProfilesImpl { - static constexpr default_constructible - default_constructible_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::default_constructible_support...); - - static constexpr move_constructible move_constructible_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::move_constructible_support...); - - static constexpr copy_constructible copy_constructible_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::copy_constructible_support...); - - static constexpr move_assignable move_assignable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::move_assignable_support...); - - static constexpr copy_assignable copy_assignable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::copy_assignable_support...); - - static constexpr destructible destructible_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::destructible_support...); - - static constexpr equality_comparable equality_comparable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::equality_comparable_support...); - - static constexpr inequality_comparable - inequality_comparable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::inequality_comparable_support...); - - static constexpr less_than_comparable - less_than_comparable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::less_than_comparable_support...); - - static constexpr less_equal_comparable - less_equal_comparable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::less_equal_comparable_support...); - - static constexpr greater_equal_comparable - greater_equal_comparable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::greater_equal_comparable_support...); - - static constexpr greater_than_comparable - greater_than_comparable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::greater_than_comparable_support...); - - static constexpr swappable swappable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::swappable_support...); - - static constexpr hashable hashable_support = // NOLINT - (MaxEnum)(PropertiesOfT<Profs>::hashable_support...); - - using properties = ConformanceProfile< - default_constructible_support, move_constructible_support, - copy_constructible_support, move_assignable_support, - copy_assignable_support, destructible_support, - equality_comparable_support, inequality_comparable_support, - less_than_comparable_support, less_equal_comparable_support, - greater_equal_comparable_support, greater_than_comparable_support, - swappable_support, hashable_support>; -}; - -// NOTE: We use this as opposed to a direct alias of CombineProfilesImpl so that -// when named aliases of CombineProfiles are created (such as in -// conformance_aliases.h), we only pay for the combination algorithm on the -// profiles that are actually used. -template <class... Profs> -struct CombineProfiles { - using profile_alias_of = CombineProfilesImpl<Profs...>; -}; - -template <> -struct CombineProfiles<> { - using properties = ConformanceProfile<>; -}; - -template <class Profile, class Tag> -struct StrongProfileTypedef { - using properties = PropertiesOfT<Profile>; -}; - -template <class T, class /*Enabler*/ = void> -struct IsProfileImpl : std::false_type {}; - -template <class T> -struct IsProfileImpl<T, y_absl::void_t<PropertiesOfT<T>>> : std::true_type {}; - -template <class T> -struct IsProfile : IsProfileImpl<T>::type {}; - +// Retrieve the enum with the greatest underlying value. +// Note: std::max is not constexpr in C++11, which is why this is necessary. +template <class H> +constexpr H MaxEnum(H head) { + return head; +} + +template <class H, class N, class... T> +constexpr H MaxEnum(H head, N next, T... tail) { + return (UnderlyingValue)(next) < (UnderlyingValue)(head) + ? (MaxEnum)(head, tail...) + : (MaxEnum)(next, tail...); +} + +template <class... Profs> +struct CombineProfilesImpl { + static constexpr default_constructible + default_constructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::default_constructible_support...); + + static constexpr move_constructible move_constructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::move_constructible_support...); + + static constexpr copy_constructible copy_constructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::copy_constructible_support...); + + static constexpr move_assignable move_assignable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::move_assignable_support...); + + static constexpr copy_assignable copy_assignable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::copy_assignable_support...); + + static constexpr destructible destructible_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::destructible_support...); + + static constexpr equality_comparable equality_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::equality_comparable_support...); + + static constexpr inequality_comparable + inequality_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::inequality_comparable_support...); + + static constexpr less_than_comparable + less_than_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::less_than_comparable_support...); + + static constexpr less_equal_comparable + less_equal_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::less_equal_comparable_support...); + + static constexpr greater_equal_comparable + greater_equal_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::greater_equal_comparable_support...); + + static constexpr greater_than_comparable + greater_than_comparable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::greater_than_comparable_support...); + + static constexpr swappable swappable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::swappable_support...); + + static constexpr hashable hashable_support = // NOLINT + (MaxEnum)(PropertiesOfT<Profs>::hashable_support...); + + using properties = ConformanceProfile< + default_constructible_support, move_constructible_support, + copy_constructible_support, move_assignable_support, + copy_assignable_support, destructible_support, + equality_comparable_support, inequality_comparable_support, + less_than_comparable_support, less_equal_comparable_support, + greater_equal_comparable_support, greater_than_comparable_support, + swappable_support, hashable_support>; +}; + +// NOTE: We use this as opposed to a direct alias of CombineProfilesImpl so that +// when named aliases of CombineProfiles are created (such as in +// conformance_aliases.h), we only pay for the combination algorithm on the +// profiles that are actually used. +template <class... Profs> +struct CombineProfiles { + using profile_alias_of = CombineProfilesImpl<Profs...>; +}; + +template <> +struct CombineProfiles<> { + using properties = ConformanceProfile<>; +}; + +template <class Profile, class Tag> +struct StrongProfileTypedef { + using properties = PropertiesOfT<Profile>; +}; + +template <class T, class /*Enabler*/ = void> +struct IsProfileImpl : std::false_type {}; + +template <class T> +struct IsProfileImpl<T, y_absl::void_t<PropertiesOfT<T>>> : std::true_type {}; + +template <class T> +struct IsProfile : IsProfileImpl<T>::type {}; + // A tag that describes which set of properties we will check when the user // requires a strict match in conformance (as opposed to a loose match which // allows more-refined support of any given operation). @@ -924,8 +924,8 @@ struct IsProfile : IsProfileImpl<T>::type {}; // be created. struct RegularityDomain {}; -} // namespace types_internal -ABSL_NAMESPACE_END -} // namespace y_absl - -#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ +} // namespace types_internal +ABSL_NAMESPACE_END +} // namespace y_absl + +#endif // ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/optional.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/optional.h index 1004a6a68a..afef0bd458 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/optional.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/optional.h @@ -54,7 +54,7 @@ #endif namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // Forward declaration template <typename T> @@ -388,7 +388,7 @@ struct optional_hash_base<T, decltype(std::hash<y_absl::remove_const_t<T> >()( }; } // namespace optional_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #undef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/span.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/span.h index 6b36c3b0d0..d33a432d52 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/span.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/span.h @@ -18,7 +18,7 @@ #include <algorithm> #include <cstddef> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <type_traits> #include "y_absl/algorithm/algorithm.h" @@ -26,7 +26,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace span_internal { // A constexpr min function @@ -122,7 +122,7 @@ template <typename From, typename To> using EnableIfConvertibleTo = typename std::enable_if<IsConvertible<From, To>::value>::type; } // namespace span_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TYPES_INTERNAL_SPAN_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/variant.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/variant.h index 4495fb4de6..0eff2f3fef 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/variant.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/internal/variant.h @@ -40,7 +40,7 @@ #if !defined(ABSL_USES_STD_VARIANT) namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN template <class... Types> class variant; @@ -1639,7 +1639,7 @@ struct VariantHashBase<Variant, }; } // namespace variant_internal -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // !defined(ABSL_USES_STD_VARIANT) diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/optional.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/optional.h index d4ef0bb57b..7ca9bb3846 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/optional.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/optional.h @@ -43,13 +43,13 @@ #include <optional> // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using std::bad_optional_access; using std::optional; using std::make_optional; using std::nullopt_t; using std::nullopt; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_OPTIONAL @@ -67,7 +67,7 @@ ABSL_NAMESPACE_END #include "y_absl/types/internal/optional.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // nullopt_t // @@ -757,7 +757,7 @@ constexpr auto operator>=(const U& v, const optional<T>& x) return static_cast<bool>(x) ? static_cast<bool>(v >= *x) : true; } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl namespace std { diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/span.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/span.h index 1490b2f1b2..83ece566ea 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/span.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/span.h @@ -68,7 +68,7 @@ #include "y_absl/types/internal/span.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN //------------------------------------------------------------------------------ // Span @@ -721,6 +721,6 @@ template <int&... ExplicitArgumentBarrier, typename T, size_t N> constexpr Span<const T> MakeConstSpan(const T (&array)[N]) noexcept { return Span<const T>(array, N); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TYPES_SPAN_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/types/variant.h b/contrib/restricted/abseil-cpp-tstring/y_absl/types/variant.h index b3d7235018..3419f92790 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/types/variant.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/types/variant.h @@ -50,7 +50,7 @@ #include <variant> // IWYU pragma: export namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN using std::bad_variant_access; using std::get; using std::get_if; @@ -63,7 +63,7 @@ using std::variant_npos; using std::variant_size; using std::variant_size_v; using std::visit; -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #else // ABSL_USES_STD_VARIANT @@ -79,7 +79,7 @@ ABSL_NAMESPACE_END #include "y_absl/types/internal/variant.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // ----------------------------------------------------------------------------- // y_absl::variant @@ -803,7 +803,7 @@ operator>=(const variant<Types...>& a, const variant<Types...>& b) { a.index()); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl namespace std { @@ -824,7 +824,7 @@ struct hash<y_absl::variant<T...>> #endif // ABSL_USES_STD_VARIANT namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN namespace variant_internal { // Helper visitor for converting a variant<Ts...>` into another type (mostly @@ -860,7 +860,7 @@ To ConvertVariantTo(Variant&& variant) { std::forward<Variant>(variant)); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_TYPES_VARIANT_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/utility/utility.h b/contrib/restricted/abseil-cpp-tstring/y_absl/utility/utility.h index c2e4d91d43..fdb7bdaac6 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/utility/utility.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/utility/utility.h @@ -51,7 +51,7 @@ #include "y_absl/meta/type_traits.h" namespace y_absl { -ABSL_NAMESPACE_BEGIN +ABSL_NAMESPACE_BEGIN // integer_sequence // @@ -344,7 +344,7 @@ constexpr T make_from_tuple(Tuple&& tup) { std::tuple_size<y_absl::decay_t<Tuple>>::value>{}); } -ABSL_NAMESPACE_END +ABSL_NAMESPACE_END } // namespace y_absl #endif // ABSL_UTILITY_UTILITY_H_ diff --git a/contrib/restricted/abseil-cpp-tstring/ya.make b/contrib/restricted/abseil-cpp-tstring/ya.make index 67363a6930..8ec447df34 100644 --- a/contrib/restricted/abseil-cpp-tstring/ya.make +++ b/contrib/restricted/abseil-cpp-tstring/ya.make @@ -66,7 +66,7 @@ PEERDIR( contrib/restricted/abseil-cpp-tstring/y_absl/random/internal/seed_material contrib/restricted/abseil-cpp-tstring/y_absl/random/seed_gen_exception contrib/restricted/abseil-cpp-tstring/y_absl/random/seed_sequences - contrib/restricted/abseil-cpp-tstring/y_absl/status + contrib/restricted/abseil-cpp-tstring/y_absl/status contrib/restricted/abseil-cpp-tstring/y_absl/status/statusor contrib/restricted/abseil-cpp-tstring/y_absl/strings contrib/restricted/abseil-cpp-tstring/y_absl/strings/cord @@ -91,7 +91,7 @@ PEERDIR( ) NO_RUNTIME() - + END() RECURSE( @@ -147,7 +147,7 @@ RECURSE( y_absl/random/internal/seed_material y_absl/random/seed_gen_exception y_absl/random/seed_sequences - y_absl/status + y_absl/status y_absl/status/statusor y_absl/strings y_absl/strings/cord |