remove std::experimental usage
All of the std::experimental usages in this repository have a well
supported counterpart in std as of C++17. Switch to use them.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I4cdf5cd27053ce85c7f70c215ee9456f96f79f42
diff --git a/src/Makefile.am b/src/Makefile.am
index bac980e..3be2e32 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,8 +21,7 @@
$(SDEVENTPLUS_LIBS) \
$(PHOSPHOR_DBUS_INTERFACES_LIBS) \
$(PHOSPHOR_LOGGING_LIBS) \
- $(PHOSPHOR_SNMP_LIBS) \
- -lstdc++fs
+ $(PHOSPHOR_SNMP_LIBS)
phosphor_dbus_monitor_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
$(SDEVENTPLUS_CFLAGS) \
diff --git a/src/count.hpp b/src/count.hpp
index f231f26..35bf5ed 100644
--- a/src/count.hpp
+++ b/src/count.hpp
@@ -65,12 +65,12 @@
// and save the op result in storage[1].
const auto& storage = std::get<storageIndex>(item.second);
// Don't count properties that don't exist.
- if (std::get<valueIndex>(storage.get()).empty())
+ if (!std::get<valueIndex>(storage.get()).has_value())
{
return false;
}
const auto& value =
- any_ns::any_cast<T>(std::get<valueIndex>(storage.get()));
+ std::any_cast<T>(std::get<valueIndex>(storage.get()));
auto r = propertyOp(value);
std::get<resultIndex>(storage.get()) = r;
diff --git a/src/data_types.hpp b/src/data_types.hpp
index cffbd99..b266a29 100644
--- a/src/data_types.hpp
+++ b/src/data_types.hpp
@@ -2,7 +2,7 @@
#include "tupleref.hpp"
-#include <experimental/any>
+#include <any>
#include <sdbusplus/message.hpp>
#include <sdbusplus/utility/merge_variants.hpp>
#include <string>
@@ -10,8 +10,6 @@
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
#include <xyz/openbmc_project/Software/Version/server.hpp>
-namespace any_ns = std::experimental;
-
namespace phosphor
{
namespace dbus
@@ -89,7 +87,7 @@
// *INDENT-OFF*
using PropertyIndex =
TupleRefMap<TupleOfRefs<const std::string, const std::string,
- std::tuple<any_ns::any, any_ns::any>>,
+ std::tuple<std::any, std::any>>,
const std::string, const std::string, const std::string>;
// *INDENT-ON*
diff --git a/src/elog.hpp b/src/elog.hpp
index 6e46b77..24a4582 100644
--- a/src/elog.hpp
+++ b/src/elog.hpp
@@ -1,11 +1,11 @@
#pragma once
#include "callback.hpp"
-#include <experimental/tuple>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <sdbusplus/exception.hpp>
#include <string>
+#include <tuple>
namespace phosphor
{
@@ -107,8 +107,7 @@
/** @brief elog interface implementation. */
void log() const override
{
- std::experimental::apply(detail::CallElog<T, Args...>::op,
- std::tuple_cat(args));
+ std::apply(detail::CallElog<T, Args...>::op, std::tuple_cat(args));
}
std::tuple<Args...> args;
};
@@ -193,14 +192,13 @@
const auto& storage = std::get<storageIndex>(n.second).get();
const auto& result = std::get<resultIndex>(storage);
- if (!result.empty() && any_ns::any_cast<bool>(result))
+ if (result.has_value() && std::any_cast<bool>(result))
{
const auto& path = std::get<pathIndex>(n.first).get();
const auto& propertyName =
std::get<propertyIndex>(n.first).get();
- auto value =
- ToString<propertyType>::op(any_ns::any_cast<propertyType>(
- std::get<valueIndex>(storage)));
+ auto value = ToString<propertyType>::op(
+ std::any_cast<propertyType>(std::get<valueIndex>(storage)));
metadata += path + ":" + propertyName + '=' + value + '|';
}
diff --git a/src/event.hpp b/src/event.hpp
index 7ce764b..d8ab917 100644
--- a/src/event.hpp
+++ b/src/event.hpp
@@ -52,7 +52,7 @@
const auto& storage = std::get<storageIndex>(n.second);
const auto& value = std::get<valueIndex>(storage.get());
- if (!value.empty())
+ if (value.has_value())
{
createEvent(path, propertyMeta, value);
}
@@ -69,7 +69,7 @@
*/
virtual void createEvent(const std::string& path,
const std::string& property,
- const any_ns::any& value) const = 0;
+ const std::any& value) const = 0;
};
/** @class Event
@@ -109,10 +109,10 @@
* @param[in] value - Changed property value.
*/
void createEvent(const std::string& path, const std::string& property,
- const any_ns::any& value) const override
+ const std::any& value) const override
{
std::stringstream ss{};
- ss << any_ns::any_cast<T>(value);
+ ss << std::any_cast<T>(value);
phosphor::events::getManager().create(name, message, path, property,
ss.str());
}
diff --git a/src/event_manager.cpp b/src/event_manager.cpp
index 874c5a8..c52a96e 100644
--- a/src/event_manager.cpp
+++ b/src/event_manager.cpp
@@ -21,7 +21,7 @@
#include "event.hpp"
#include "event_serialize.hpp"
-#include <experimental/filesystem>
+#include <filesystem>
namespace phosphor
{
@@ -35,7 +35,7 @@
const std::string& propertyValue)
{
using namespace std::string_literals;
- namespace fs = std::experimental::filesystem;
+ namespace fs = std::filesystem;
auto msg = eventMessage;
std::vector<std::string> additionalData;
diff --git a/src/event_serialize.hpp b/src/event_serialize.hpp
index bb6f22f..b2f55e1 100644
--- a/src/event_serialize.hpp
+++ b/src/event_serialize.hpp
@@ -4,7 +4,7 @@
#include "event_entry.hpp"
-#include <experimental/filesystem>
+#include <filesystem>
#include <string>
namespace phosphor
@@ -12,7 +12,7 @@
namespace events
{
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
/** @brief Serialize and persist event d-bus object
* @param[in] event - const reference to event entry.
diff --git a/src/filters.hpp b/src/filters.hpp
index c7a5bcf..13b1533 100644
--- a/src/filters.hpp
+++ b/src/filters.hpp
@@ -28,7 +28,7 @@
virtual ~Filters() = default;
/** @brief Apply filter operations to a property value. */
- virtual bool operator()(const any_ns::any& value) = 0;
+ virtual bool operator()(const std::any& value) = 0;
};
/** @class OperandFilters
@@ -53,20 +53,20 @@
{
}
- bool operator()(const any_ns::any& value) override
+ bool operator()(const std::any& value) override
{
for (const auto& filterOps : ops)
{
try
{
// Apply filter operand to property value
- if (!filterOps(any_ns::any_cast<T>(value)))
+ if (!filterOps(std::any_cast<T>(value)))
{
// Property value should be filtered
return true;
}
}
- catch (const any_ns::bad_any_cast& bac)
+ catch (const std::bad_any_cast& bac)
{
// Unable to cast property value to filter value type
// to check filter, continue to next filter op
diff --git a/src/journal.cpp b/src/journal.cpp
index 41d51e4..09f98aa 100644
--- a/src/journal.cpp
+++ b/src/journal.cpp
@@ -32,7 +32,7 @@
const auto& storage = std::get<storageIndex>(n.second);
const auto& value = std::get<valueIndex>(storage.get());
- if (!value.empty())
+ if (value.has_value())
{
log(message, pathMeta, path, propertyMeta, value);
}
diff --git a/src/journal.hpp b/src/journal.hpp
index 29d01d1..ad792fb 100644
--- a/src/journal.hpp
+++ b/src/journal.hpp
@@ -41,7 +41,7 @@
/** @brief Delegate type specific calls to subclasses. */
virtual void log(const char* message, const std::string& pathMeta,
const std::string& path, const std::string& propertyMeta,
- const any_ns::any& value) const = 0;
+ const std::any& value) const = 0;
/** @brief The client provided message to be traced. */
const char* message;
@@ -96,7 +96,7 @@
/** @brief log interface implementation. */
void log(const char* message, const std::string& pathMeta,
const std::string& path, const std::string& propertyMeta,
- const any_ns::any& value) const override
+ const std::any& value) const override
{
phosphor::logging::log<Severity>(
message,
@@ -105,7 +105,7 @@
path.c_str()),
phosphor::logging::entry(
(propertyMeta + GetFormat<T>::format).c_str(),
- detail::Display<T>::op(any_ns::any_cast<T>(value))));
+ detail::Display<T>::op(std::any_cast<T>(value))));
}
};
diff --git a/src/median.hpp b/src/median.hpp
index a3ffe67..8498726 100644
--- a/src/median.hpp
+++ b/src/median.hpp
@@ -59,12 +59,12 @@
{
const auto& storage = std::get<storageIndex>(item.second);
// Don't count properties that don't exist.
- if (std::get<valueIndex>(storage.get()).empty())
+ if (!std::get<valueIndex>(storage.get()).has_value())
{
continue;
}
values.emplace_back(
- any_ns::any_cast<T>(std::get<valueIndex>(storage.get())));
+ std::any_cast<T>(std::get<valueIndex>(storage.get())));
}
if (!values.empty())
diff --git a/src/method.hpp b/src/method.hpp
index 8a561b6..92d6396 100644
--- a/src/method.hpp
+++ b/src/method.hpp
@@ -2,9 +2,9 @@
#include "callback.hpp"
-#include <experimental/tuple>
#include <phosphor-logging/log.hpp>
#include <string>
+#include <tuple>
namespace phosphor
{
@@ -109,11 +109,10 @@
/** @brief Callback interface implementation. */
void operator()(Context ctx) override
{
- std::experimental::apply(
- detail::CallDBusMethod<DBusInterface, MethodArgs...>::op,
- std::tuple_cat(std::make_tuple(bus), std::make_tuple(path),
- std::make_tuple(interface), std::make_tuple(method),
- args));
+ std::apply(detail::CallDBusMethod<DBusInterface, MethodArgs...>::op,
+ std::tuple_cat(std::make_tuple(bus), std::make_tuple(path),
+ std::make_tuple(interface),
+ std::make_tuple(method), args));
}
private:
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 271d9b2..0187bd1 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -167,13 +167,13 @@
auto value = std::get<T>(p.second);
if (filterOps)
{
- any_ns::any anyValue = value;
+ std::any anyValue = value;
if ((*filterOps)(anyValue))
{
// Property value filtered, clear it from storage so
// callback functions do not use it
isFiltered = true;
- std::get<valueIndex>(storage.get()).clear();
+ std::get<valueIndex>(storage.get()).reset();
}
}
if (!isFiltered)
diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp
index 9f9475a..2fc2f8c 100644
--- a/src/templates/generated.mako.hpp
+++ b/src/templates/generated.mako.hpp
@@ -111,7 +111,7 @@
struct ConfigPropertyStorage
{
- using Storage = std::array<std::tuple<any_ns::any, any_ns::any>, ${len(instances)}>;
+ using Storage = std::array<std::tuple<std::any, std::any>, ${len(instances)}>;
static auto& get()
{
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index 9314049..0faa765 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -197,8 +197,7 @@
$(builddir)/../elog.o \
$(builddir)/../resolve_errors.o \
$(builddir)/../event_manager.o \
- $(builddir)/../event_serialize.o \
- -lstdc++fs
+ $(builddir)/../event_serialize.o
check_PROGRAMS += interfaceaddtest
interfaceaddtest_SOURCES = \
diff --git a/src/test/propertywatchtest.cpp b/src/test/propertywatchtest.cpp
index 9a449b4..6ae36c9 100644
--- a/src/test/propertywatchtest.cpp
+++ b/src/test/propertywatchtest.cpp
@@ -27,7 +27,7 @@
const std::string meta;
-std::array<std::tuple<any_ns::any, any_ns::any>, 8> storage = {};
+std::array<std::tuple<std::any, std::any>, 8> storage = {};
const PropertyIndex watchIndex = {
{
@@ -115,10 +115,10 @@
};
template <typename T>
-void nonFilteredCheck(const any_ns::any& value, const size_t ndx)
+void nonFilteredCheck(const std::any& value, const size_t ndx)
{
- ASSERT_EQ(value.empty(), false);
- ASSERT_EQ(any_ns::any_cast<T>(value), Values<T>::get(ndx));
+ ASSERT_EQ(value.has_value(), true);
+ ASSERT_EQ(std::any_cast<T>(value), Values<T>::get(ndx));
}
template <typename T>
@@ -139,10 +139,10 @@
}
static auto& expected(size_t i)
{
- static const std::array<any_ns::any, 8> values = {
- {any_ns::any(uint8_t(0)), any_ns::any(uint8_t(1)),
- any_ns::any(uint8_t(2)), any_ns::any(uint8_t(3)), any_ns::any(),
- any_ns::any(), any_ns::any(), any_ns::any()}};
+ static const std::array<std::any, 8> values = {
+ {std::any(uint8_t(0)), std::any(uint8_t(1)), std::any(uint8_t(2)),
+ std::any(uint8_t(3)), std::any(), std::any(), std::any(),
+ std::any()}};
return values[i];
}
};
@@ -161,10 +161,10 @@
}
static auto& expected(size_t i)
{
- static const std::array<any_ns::any, 8> values = {
- {any_ns::any(), any_ns::any(uint16_t(77)),
- any_ns::any(uint16_t(66)), any_ns::any(uint16_t(55)),
- any_ns::any(), any_ns::any(), any_ns::any(), any_ns::any()}};
+ static const std::array<std::any, 8> values = {
+ {std::any(), std::any(uint16_t(77)), std::any(uint16_t(66)),
+ std::any(uint16_t(55)), std::any(), std::any(), std::any(),
+ std::any()}};
return values[i];
}
};
@@ -183,10 +183,10 @@
}
static auto& expected(size_t i)
{
- static const std::array<any_ns::any, 8> values = {
- {any_ns::any(), any_ns::any(uint32_t(1)), any_ns::any(uint32_t(3)),
- any_ns::any(), any_ns::any(uint32_t(5)), any_ns::any(uint32_t(7)),
- any_ns::any(uint32_t(9)), any_ns::any()}};
+ static const std::array<std::any, 8> values = {
+ {std::any(), std::any(uint32_t(1)), std::any(uint32_t(3)),
+ std::any(), std::any(uint32_t(5)), std::any(uint32_t(7)),
+ std::any(uint32_t(9)), std::any()}};
return values[i];
}
};
@@ -204,10 +204,9 @@
}
static auto& expected(size_t i)
{
- static const std::array<any_ns::any, 8> values = {
- {any_ns::any(), any_ns::any(), any_ns::any(uint64_t(7)),
- any_ns::any(), any_ns::any(), any_ns::any(), any_ns::any(),
- any_ns::any()}};
+ static const std::array<std::any, 8> values = {
+ {std::any(), std::any(), std::any(uint64_t(7)), std::any(),
+ std::any(), std::any(), std::any(), std::any()}};
return values[i];
}
};
@@ -226,29 +225,28 @@
}
static auto& expected(size_t i)
{
- static const std::array<any_ns::any, 8> values = {
- {any_ns::any(), any_ns::any("foo"s), any_ns::any("bar"s),
- any_ns::any("baz"s), any_ns::any("hello"s), any_ns::any(),
- any_ns::any("\x2\x3"s), any_ns::any("\\"s)}};
+ static const std::array<std::any, 8> values = {
+ {std::any(), std::any("foo"s), std::any("bar"s), std::any("baz"s),
+ std::any("hello"s), std::any(), std::any("\x2\x3"s),
+ std::any("\\"s)}};
return values[i];
}
};
template <typename T>
-void filteredCheck(const any_ns::any& value, const size_t ndx)
+void filteredCheck(const std::any& value, const size_t ndx)
{
- ASSERT_EQ(value.empty(), FilteredValues<T>::expected(ndx).empty());
- if (!value.empty())
+ ASSERT_EQ(value.has_value(), FilteredValues<T>::expected(ndx).has_value());
+ if (value.has_value())
{
- ASSERT_EQ(any_ns::any_cast<T>(value),
- any_ns::any_cast<T>(FilteredValues<T>::expected(ndx)));
+ ASSERT_EQ(std::any_cast<T>(value),
+ std::any_cast<T>(FilteredValues<T>::expected(ndx)));
}
}
template <typename T>
-void testStart(
- std::function<void(const any_ns::any&, const size_t)>&& checkState,
- OperandFilters<T>* opFilters = nullptr)
+void testStart(std::function<void(const std::any&, const size_t)>&& checkState,
+ OperandFilters<T>* opFilters = nullptr)
{
using ::testing::_;
using ::testing::Return;