main: Use optional instead of unique_ptr
Change-Id: I3b9cbfd4483aeeea1e8adff8058a2737f2106de1
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/main.cpp b/main.cpp
index 74d8072..e84f144 100644
--- a/main.cpp
+++ b/main.cpp
@@ -26,7 +26,7 @@
#include <cstdint>
#include <exception>
#include <iostream>
-#include <memory>
+#include <optional>
#include <sdeventplus/event.hpp>
#include <sdeventplus/source/event.hpp>
#include <sdeventplus/source/io.hpp>
@@ -172,11 +172,11 @@
// Create sdevent and add IO source
try
{
- sdeventplus::Event event = sdeventplus::Event::get_default();
- std::unique_ptr<sdeventplus::source::IO> reporterSource;
+ auto event = sdeventplus::Event::get_default();
+ std::optional<sdeventplus::source::IO> reporterSource;
if (postFd > 0)
{
- reporterSource = std::make_unique<sdeventplus::source::IO>(
+ reporterSource.emplace(
event, postFd, EPOLLIN | EPOLLET,
std::bind(PostCodeEventHandler, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3,