Upgrade to C++17
Change-Id: I0efd11f488ceee9b1a03ffaa1522cf0182ae1aca
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/configure.ac b/configure.ac
index b739d1e..a2ae7a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,7 +35,7 @@
PKG_INSTALLDIR
# Checks for typedefs, structures, and compiler characteristics.
-AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory])
+AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wpedantic], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wpedantic], [CXXFLAGS])
diff --git a/src/sdeventplus/event.hpp b/src/sdeventplus/event.hpp
index bcb89fe..ba7c77d 100644
--- a/src/sdeventplus/event.hpp
+++ b/src/sdeventplus/event.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <experimental/optional>
+#include <optional>
#include <sdeventplus/internal/sdevent.hpp>
#include <sdeventplus/internal/sdref.hpp>
#include <sdeventplus/internal/utils.hpp>
@@ -18,7 +18,7 @@
/** @brief Duration type used for specifying timeouts
*/
using Timeout = SdEventDuration;
- using MaybeTimeout = std::experimental::optional<Timeout>;
+ using MaybeTimeout = std::optional<Timeout>;
/** @brief Constructs a new event from sd_event
* Takes a reference on the passed in sd_event
diff --git a/test/event.cpp b/test/event.cpp
index a9b6439..1bf5976 100644
--- a/test/event.cpp
+++ b/test/event.cpp
@@ -1,6 +1,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
+#include <optional>
#include <sdeventplus/event.hpp>
#include <sdeventplus/exception.hpp>
#include <sdeventplus/test/sdevent.hpp>
@@ -128,14 +129,14 @@
const int events_ready = 10;
EXPECT_CALL(mock, sd_event_wait(expected_event, static_cast<uint64_t>(-1)))
.WillOnce(Return(events_ready));
- EXPECT_EQ(events_ready, event->wait(std::experimental::nullopt));
+ EXPECT_EQ(events_ready, event->wait(std::nullopt));
}
TEST_F(EventMethodTest, WaitInternalError)
{
EXPECT_CALL(mock, sd_event_wait(expected_event, static_cast<uint64_t>(-1)))
.WillOnce(Return(-EINVAL));
- EXPECT_THROW(event->wait(std::experimental::nullopt), SdEventError);
+ EXPECT_THROW(event->wait(std::nullopt), SdEventError);
}
TEST_F(EventMethodTest, DispatchInitial)
@@ -172,14 +173,14 @@
const int events_ready = 10;
EXPECT_CALL(mock, sd_event_run(expected_event, static_cast<uint64_t>(-1)))
.WillOnce(Return(events_ready));
- EXPECT_EQ(events_ready, event->run(std::experimental::nullopt));
+ EXPECT_EQ(events_ready, event->run(std::nullopt));
}
TEST_F(EventMethodTest, RunInternalError)
{
EXPECT_CALL(mock, sd_event_run(expected_event, static_cast<uint64_t>(-1)))
.WillOnce(Return(-EINVAL));
- EXPECT_THROW(event->run(std::experimental::nullopt), SdEventError);
+ EXPECT_THROW(event->run(std::nullopt), SdEventError);
}
TEST_F(EventMethodTest, LoopSuccess)