pw_result: Reimplement based on Abseli's StatusOr
This replaces pw::Result's implementation with one based on
absl::StatusOr. This significantly expands the capabilities of
pw::Result, enabling it to work a much broader range of types.
pw::Result now mirrors the held type's copy and move constructibility
and assignment and whether it is trivially destructible.
- Copy Abseil's absl::StatusOr into Pigweed as pw::Result. See
https://cs.opensource.google/abseil/abseil-cpp/+/master:absl/status/statusor.h
at commit 7f850b3167fb38e6b4a9ce1824e6fabd733b5d62.
- Update the implementation to use C++ Standard Library classes instead
of Abseil's implementations.
- Switch from absl::Status to pw::Status.
- Use PW_ASSERT to crash on illegal access.
- Remove exception handling code.
- Make pw::Result<T> constexpr and trivially destructible if T is.
Fixed: 363
Change-Id: I7f1ded4f5533a3dfc0340cb7f2391ccc0b8b9449
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/85524
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/pw_result/BUILD.gn b/pw_result/BUILD.gn
index aa09d75..1fac1ad 100644
--- a/pw_result/BUILD.gn
+++ b/pw_result/BUILD.gn
@@ -31,6 +31,7 @@
"$dir_pw_status",
]
public = [ "public/pw_result/result.h" ]
+ sources = [ "public/pw_result/internal/result_internal.h" ]
}
pw_test_group("tests") {
@@ -42,7 +43,10 @@
":pw_result",
dir_pw_status,
]
- sources = [ "result_test.cc" ]
+ sources = [
+ "result_test.cc",
+ "statusor_test.cc",
+ ]
}
pw_doc_group("docs") {