diff options
author | Abseil Team <absl-team@google.com> | 2020-09-22 14:23:22 -0700 |
---|---|---|
committer | vslashg <gfalcon@google.com> | 2020-09-23 13:36:05 -0400 |
commit | 9927a09898f1287e0ecd1276f42ec7a252667dad (patch) | |
tree | 29cb426aed67b58a8ffe80cb48e1a3b8a70e1387 /absl/status | |
parent | 7680a5f8efe32de4753baadbd63e74e59d95bac1 (diff) |
Export of internal Abseil changes
--
bddfb8bae4e569884bf8749f5368e536562f0682 by Samuel Benzaquen <sbenza@google.com>:
Forward the Status.
PiperOrigin-RevId: 333159251
--
461640476dab1726eba8d26a0c8012b5a35ba0b1 by Evan Brown <ezb@google.com>:
Avoid relying on mutable b-tree set iterators in merge(). Mutable set iterators is an API difference from std::set that we want to get rid of.
Also remove a superfluous `public` member specification in btree_container.
PiperOrigin-RevId: 333101335
--
96cf8ac6946840be17da445739c950fd237159f4 by Abseil Team <absl-team@google.com>:
Explicitly mention that FormatDuration deviates from Go for the zero duration
PiperOrigin-RevId: 333094962
--
83389040371436aab4e952211e98ffa98e24fd94 by Abseil Team <absl-team@google.com>:
Internal change.
PiperOrigin-RevId: 332862771
GitOrigin-RevId: bddfb8bae4e569884bf8749f5368e536562f0682
Change-Id: I4a47043ddbad6e700380614c75566c09d4943103
Diffstat (limited to 'absl/status')
-rw-r--r-- | absl/status/internal/statusor_internal.h | 2 | ||||
-rw-r--r-- | absl/status/statusor_test.cc | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/absl/status/internal/statusor_internal.h b/absl/status/internal/statusor_internal.h index 96e41da5..7cc76256 100644 --- a/absl/status/internal/statusor_internal.h +++ b/absl/status/internal/statusor_internal.h @@ -215,7 +215,7 @@ class StatusOrData { template <typename U, absl::enable_if_t<std::is_constructible<absl::Status, U&&>::value, int> = 0> - explicit StatusOrData(U&& v) : status_(v) { + explicit StatusOrData(U&& v) : status_(std::forward<U>(v)) { EnsureNotOk(); } diff --git a/absl/status/statusor_test.cc b/absl/status/statusor_test.cc index 5e4b2687..c2e8fb7e 100644 --- a/absl/status/statusor_test.cc +++ b/absl/status/statusor_test.cc @@ -292,6 +292,17 @@ TEST(StatusOr, TestDefaultCtor) { EXPECT_EQ(thing.status().code(), absl::StatusCode::kUnknown); } +TEST(StatusOr, StatusCtorForwards) { + absl::Status status(absl::StatusCode::kInternal, "Some error"); + + EXPECT_EQ(absl::StatusOr<int>(status).status().message(), "Some error"); + EXPECT_EQ(status.message(), "Some error"); + + EXPECT_EQ(absl::StatusOr<int>(std::move(status)).status().message(), + "Some error"); + EXPECT_NE(status.message(), "Some error"); +} + // Define `EXPECT_DEATH_OR_THROW` to test the behavior of `StatusOr::value`, // which either throws `BadStatusOrAccess` or `LOG(FATAL)` based on whether // exceptions are enabled. |