Issue 72: Cleanups for ErrorOr
This patch removes ErrorOr's requirement that type shall be default
constructible, using absl::optional. This patch also ensures support for
and testing for primitive value types.
Note: I investigating providing an operator Value() to replace
MoveValue, however I believe that the resulting simplification is
dangerous and not useful enough. An example:
ErrorOr<UdpPacket> error_or_packet = foo();
UdpPacket packet = error_or_packet;
It is not obvious that error_or_packet is invalid now, and we have moved
its value into packet. Also, is the error still valid in
error_or_packet? Should it be?
Change-Id: I743c274fe4bcd466826d884b5d075ad2227d85c6
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1802369
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Reviewed-by: Ryan Keane <rwkeane@google.com>
Reviewed-by: Max Yakimakha <yakimakha@chromium.org>
diff --git a/platform/api/socket_integration_unittest.cc b/platform/api/socket_integration_unittest.cc
index a6c8157..fe15377 100644
--- a/platform/api/socket_integration_unittest.cc
+++ b/platform/api/socket_integration_unittest.cc
@@ -24,7 +24,7 @@
ErrorOr<UdpSocketUniquePtr> create_result = UdpSocket::Create(
&task_runner, &client, IPEndpoint{IPAddress(kIpV4AddrAny), 0});
ASSERT_TRUE(create_result) << create_result.error();
- const auto socket = create_result.MoveValue();
+ const auto socket = std::move(create_result.value());
EXPECT_CALL(client, OnError(_, _)).Times(0);
socket->Bind();
const IPEndpoint local_endpoint = socket->GetLocalEndpoint();
@@ -42,7 +42,7 @@
ErrorOr<UdpSocketUniquePtr> create_result = UdpSocket::Create(
&task_runner, &client, IPEndpoint{IPAddress(kIpV6AddrAny), 0});
ASSERT_TRUE(create_result) << create_result.error();
- const auto socket = create_result.MoveValue();
+ const auto socket = std::move(create_result.value());
EXPECT_CALL(client, OnError(_, _)).Times(0);
socket->Bind();
const IPEndpoint local_endpoint = socket->GetLocalEndpoint();