Use more C++17 features
Mainly structured bindings, inline variables, and class template
argument deduction, plus many more smaller things.
Change-Id: I810d17e0adb470426e4e30c898e03b3140ad052f
diff --git a/daemon/common/config-file.cpp b/daemon/common/config-file.cpp
index 8d70349..a71bade 100644
--- a/daemon/common/config-file.cpp
+++ b/daemon/common/config-file.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,8 +32,8 @@
namespace nfd {
-ConfigFile::ConfigFile(UnknownConfigSectionHandler unknownSectionCallback)
- : m_unknownSectionCallback(unknownSectionCallback)
+ConfigFile::ConfigFile(UnknownConfigSectionHandler callback)
+ : m_unknownSectionCallback(std::move(callback))
{
}
@@ -77,7 +77,7 @@
ConfigFile::addSectionHandler(const std::string& sectionName,
ConfigSectionHandler subscriber)
{
- m_subscriptions[sectionName] = subscriber;
+ m_subscriptions[sectionName] = std::move(subscriber);
}
void
diff --git a/daemon/common/privilege-helper.hpp b/daemon/common/privilege-helper.hpp
index f0eb3bd..b26dce6 100644
--- a/daemon/common/privilege-helper.hpp
+++ b/daemon/common/privilege-helper.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -71,7 +71,7 @@
{
raise();
try {
- std::forward<F>(f)();
+ std::invoke(std::forward<F>(f));
}
catch (...) {
drop();