Rename {absl => std}::optional in base + everywhere. [Final]
Automated patch. This is a no-op. Please avoid, as much as possible,
assigning unrelated bugs to this.
Context:
https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email
As of https://crrev.com/1204351, absl::optional is now a type alias
for std::optional. We should migrate toward it.
Script:
```
function replace {
echo "Replacing $1 by $2"
git grep -l "$1" \
| cut -f1 -d: \
| grep -v \
-e "components/cast_streaming/browser/public/receiver_config.*" \
-e "components/power_metrics/*" \
-e "components/zucchini/patch_reader.*" \
-e "third_party/abseil-cpp/*" \
-e "third_party/googletest/*" \
-e "third_party/leveldatabase/*" \
-e "third_party/libaddressinput/" \
-e "third_party/liburlpattern/*" \
-e "third_party/lzma_sdk/*" \
-e "third_party/maldoca/*" \
-e "third_party/mediapipe/*" \
-e "third_party/shell-encryption/*"\
-e "third_party/tflite_support/*" \
-e "third_party/webrtc_overrides/*" \
-e "third_party/zxcvbn-cpp/*" \
| grep \
-e "\.h" \
-e "\.cc" \
-e "\.mm" \
-e "\.pidl" \
| sort \
| uniq \
| xargs sed -i "s/$1/$2/g"
}
replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place," "std::in_place,"
replace "absl::in_place_t," "std::in_place_t,"
replace "absl::in_place)" "std::in_place)"
replace "absl::in_place_t)" "std::in_place_t)"
replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>"
git status
echo "Formatting"
echo "IncludeBlocks: Regroup" >> ".clang-format"
echo "IncludeIsMainRegex: \"(_(android|apple|chromeos|freebsd|fuchsia|fuzzer|ios|linux|mac|nacl|openbsd|posix|stubs?|win))?(_(unit|browser|perf)?tests?)?$\"" >> ".clang-format"
git cl format
git restore ".clang-format"
```
Bug: chromium:1500249
Change-Id: Ic2994b982bbc64d62f030d3d158979dc5d266121
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5296147
Reviewed-by: danakj <[email protected]>
Commit-Queue: danakj <[email protected]>
Owners-Override: danakj <[email protected]>
Auto-Submit: Arthur Sonzogni <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1263362}
diff --git a/base/token.h b/base/token.h
index aab6045..faa2dde 100644
--- a/base/token.h
+++ b/base/token.h
@@ -8,12 +8,12 @@
#include <stdint.h>
#include <compare>
+#include <optional>
#include <string>
#include "base/base_export.h"
#include "base/containers/span.h"
#include "base/strings/string_piece.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
@@ -59,9 +59,9 @@
// Generates a string representation of this Token useful for e.g. logging.
std::string ToString() const;
- // FromString is the opposite of ToString. It returns absl::nullopt if the
+ // FromString is the opposite of ToString. It returns std::nullopt if the
// |string_representation| is invalid.
- static absl::optional<Token> FromString(StringPiece string_representation);
+ static std::optional<Token> FromString(StringPiece string_representation);
private:
// Note: Two uint64_t are used instead of uint8_t[16] in order to have a
@@ -81,7 +81,7 @@
// For serializing and deserializing Token values.
BASE_EXPORT void WriteTokenToPickle(Pickle* pickle, const Token& token);
-BASE_EXPORT absl::optional<Token> ReadTokenFromPickle(
+BASE_EXPORT std::optional<Token> ReadTokenFromPickle(
PickleIterator* pickle_iterator);
} // namespace base