build: switch to C++17
Change-Id: Ie68020a04b7e20b74778b6d0370544ded55c5e26
diff --git a/tools/nfdc/canonizer.cpp b/tools/nfdc/canonizer.cpp
index 3e526cd..a44a2bf 100644
--- a/tools/nfdc/canonizer.cpp
+++ b/tools/nfdc/canonizer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, 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,
@@ -29,10 +29,10 @@
namespace tools {
namespace nfdc {
-std::pair<optional<FaceUri>, std::string>
+std::pair<std::optional<FaceUri>, std::string>
canonize(ExecuteContext& ctx, const FaceUri& uri)
{
- optional<FaceUri> result;
+ std::optional<FaceUri> result;
std::string error;
uri.canonize(
[&result] (const FaceUri& canonicalUri) { result = canonicalUri; },
diff --git a/tools/nfdc/canonizer.hpp b/tools/nfdc/canonizer.hpp
index b58372d..90b3afb 100644
--- a/tools/nfdc/canonizer.hpp
+++ b/tools/nfdc/canonizer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, 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,
@@ -39,7 +39,7 @@
/** \brief canonize FaceUri
* \return pair of canonical FaceUri (nullopt if failure) and error string
*/
-std::pair<optional<FaceUri>, std::string>
+std::pair<std::optional<FaceUri>, std::string>
canonize(ExecuteContext& ctx, const FaceUri& uri);
/** \brief helper to generate exit code and error message for face canonization failures
diff --git a/tools/nfdc/command-arguments.hpp b/tools/nfdc/command-arguments.hpp
index 1d0c9bd..6e096d6 100644
--- a/tools/nfdc/command-arguments.hpp
+++ b/tools/nfdc/command-arguments.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,
@@ -30,8 +30,8 @@
#include "status-report.hpp"
#include <ndn-cxx/encoding/nfd-constants.hpp>
-#include <ndn-cxx/util/any.hpp>
+#include <any>
#include <boost/logic/tribool.hpp>
namespace nfd {
@@ -43,17 +43,17 @@
/** \brief contains named command arguments
*/
-class CommandArguments : public std::map<std::string, ndn::any>
+class CommandArguments : public std::map<std::string, std::any>
{
public:
/** \return the argument value, or nullopt if the argument is omitted on command line
*/
template<typename T>
- optional<T>
+ std::optional<T>
getOptional(const std::string& key) const
{
auto i = find(key);
- return i == end() ? nullopt : ndn::make_optional(ndn::any_cast<T>(i->second));
+ return i == end() ? std::nullopt : std::make_optional(std::any_cast<T>(i->second));
}
/** \return the argument value, or a default value if the argument is omitted on command line
diff --git a/tools/nfdc/command-definition.cpp b/tools/nfdc/command-definition.cpp
index d421d11..3c450e1 100644
--- a/tools/nfdc/command-definition.cpp
+++ b/tools/nfdc/command-definition.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,
@@ -240,7 +240,7 @@
NDN_THROW(std::invalid_argument("unrecognized FacePersistency '" + s + "'"));
}
-ndn::any
+std::any
CommandDefinition::parseValue(ArgValueType valueType, const std::string& token) const
{
switch (valueType) {
diff --git a/tools/nfdc/command-definition.hpp b/tools/nfdc/command-definition.hpp
index c512948..dc5afed 100644
--- a/tools/nfdc/command-definition.hpp
+++ b/tools/nfdc/command-definition.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -191,7 +191,7 @@
parse(const std::vector<std::string>& tokens, size_t start = 0) const;
private:
- ndn::any
+ std::any
parseValue(ArgValueType valueType, const std::string& token) const;
private:
diff --git a/tools/nfdc/command-parser.cpp b/tools/nfdc/command-parser.cpp
index 9153890..0d59de2 100644
--- a/tools/nfdc/command-parser.cpp
+++ b/tools/nfdc/command-parser.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,
@@ -34,9 +34,9 @@
NDN_LOG_INIT(nfdc.CommandParser);
-static_assert(std::is_same<std::underlying_type<AvailableIn>::type,
- std::underlying_type<ParseMode>::type>::value,
- "AvailableIn and ParseMode must be declared with same underlying type");
+static_assert(std::is_same_v<std::underlying_type_t<AvailableIn>,
+ std::underlying_type_t<ParseMode>>,
+ "AvailableIn and ParseMode must be declared with the same underlying type");
std::ostream&
operator<<(std::ostream& os, AvailableIn modes)
@@ -72,7 +72,7 @@
CommandParser&
CommandParser::addCommand(const CommandDefinition& def, const ExecuteCommand& execute,
- std::underlying_type<AvailableIn>::type modes)
+ std::underlying_type_t<AvailableIn> modes)
{
BOOST_ASSERT(modes != AVAILABLE_IN_NONE);
@@ -98,7 +98,7 @@
{
std::vector<const CommandDefinition*> results;
for (auto i : m_commandOrder) {
- const Command& command = *i->second;
+ const auto& command = *i->second;
if ((command.modes & static_cast<AvailableIn>(mode)) != 0 &&
(noun.empty() || noun == command.def.getNoun())) {
results.push_back(&command.def);
diff --git a/tools/nfdc/command-parser.hpp b/tools/nfdc/command-parser.hpp
index a872fcd..e0e10b0 100644
--- a/tools/nfdc/command-parser.hpp
+++ b/tools/nfdc/command-parser.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -79,7 +79,7 @@
*/
CommandParser&
addCommand(const CommandDefinition& def, const ExecuteCommand& execute,
- std::underlying_type<AvailableIn>::type modes = AVAILABLE_IN_ALL);
+ std::underlying_type_t<AvailableIn> modes = AVAILABLE_IN_ALL);
/** \brief add an alias "noun verb2" to existing command "noun verb"
* \throw std::out_of_range "noun verb" does not exist
@@ -106,7 +106,7 @@
parse(const std::vector<std::string>& tokens, ParseMode mode) const;
private:
- typedef std::pair<std::string, std::string> CommandName;
+ using CommandName = std::pair<std::string, std::string>;
struct Command
{
@@ -117,7 +117,7 @@
/** \brief map from command name or alias to command definition
*/
- typedef std::map<CommandName, shared_ptr<Command>> CommandContainer;
+ using CommandContainer = std::map<CommandName, shared_ptr<Command>>;
CommandContainer m_commands;
/** \brief commands in insertion order
diff --git a/tools/nfdc/face-module.cpp b/tools/nfdc/face-module.cpp
index 18862aa..267187e 100644
--- a/tools/nfdc/face-module.cpp
+++ b/tools/nfdc/face-module.cpp
@@ -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,
@@ -164,7 +164,7 @@
auto mtuArg = ctx.args.getOptional<std::string>("mtu");
// MTU is nominally a uint64_t, but can be the string value 'auto' to unset an override MTU
- optional<uint64_t> mtu;
+ std::optional<uint64_t> mtu;
if (mtuArg == "auto") {
mtu = std::numeric_limits<uint64_t>::max();
}
@@ -180,8 +180,8 @@
mtu = static_cast<uint64_t>(v);
}
- optional<FaceUri> canonicalRemote;
- optional<FaceUri> canonicalLocal;
+ std::optional<FaceUri> canonicalRemote;
+ std::optional<FaceUri> canonicalLocal;
auto updateFace = [&] (ControlParameters respParams, ControlParameters resp) {
// faces/update response does not have FaceUris, copy from faces/create response
diff --git a/tools/nfdc/find-face.cpp b/tools/nfdc/find-face.cpp
index de0fd8e..05e7eec 100644
--- a/tools/nfdc/find-face.cpp
+++ b/tools/nfdc/find-face.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, 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,
@@ -57,14 +57,14 @@
}
FindFace::Code
-FindFace::execute(const ndn::any& faceIdOrUri, bool allowMulti)
+FindFace::execute(const std::any& faceIdOrUri, bool allowMulti)
{
- const uint64_t* faceId = ndn::any_cast<uint64_t>(&faceIdOrUri);
+ const uint64_t* faceId = std::any_cast<uint64_t>(&faceIdOrUri);
if (faceId != nullptr) {
return this->execute(*faceId);
}
else {
- return this->execute(ndn::any_cast<FaceUri>(faceIdOrUri), allowMulti);
+ return this->execute(std::any_cast<FaceUri>(faceIdOrUri), allowMulti);
}
}
@@ -105,7 +105,7 @@
return m_res;
}
-optional<FaceUri>
+std::optional<FaceUri>
FindFace::canonize(const std::string& fieldName, const FaceUri& uri)
{
// We use a wrapper because we want to accept FaceUris that cannot be canonized
@@ -114,7 +114,7 @@
return uri;
}
- optional<FaceUri> result;
+ std::optional<FaceUri> result;
std::string error;
std::tie(result, error) = nfdc::canonize(m_ctx, uri);
@@ -125,7 +125,7 @@
else {
// Canonization failed
std::tie(m_res, m_errorReason) = canonizeErrorHelper(uri, error);
- return nullopt;
+ return std::nullopt;
}
}
diff --git a/tools/nfdc/find-face.hpp b/tools/nfdc/find-face.hpp
index 3a6bba5..ee1c521 100644
--- a/tools/nfdc/find-face.hpp
+++ b/tools/nfdc/find-face.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, 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,12 +71,12 @@
execute(uint64_t faceId);
/** \brief find face by FaceId or FaceUri
- * \param faceIdOrUri a ndn::any that contains uint64_t or FaceUri
+ * \param faceIdOrUri either a FaceId (uint64_t) or a FaceUri
* \param allowMulti effective only if \p faceIdOrUri contains a FaceUri
* \throw ndn::bad_any_cast faceIdOrUri is neither uint64_t nor FaceUri
*/
Code
- execute(const ndn::any& faceIdOrUri, bool allowMulti = false);
+ execute(const std::any& faceIdOrUri, bool allowMulti = false);
/** \brief find face by FaceQueryFilter
* \pre execute has not been invoked
@@ -121,7 +121,7 @@
printDisambiguation(std::ostream& os, DisambiguationStyle style) const;
private:
- optional<FaceUri>
+ std::optional<FaceUri>
canonize(const std::string& fieldName, const FaceUri& uri);
/** \brief retrieve FaceStatus from filter
diff --git a/tools/nfdc/rib-module.cpp b/tools/nfdc/rib-module.cpp
index 544da6e..df980c4 100644
--- a/tools/nfdc/rib-module.cpp
+++ b/tools/nfdc/rib-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, 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,
@@ -189,7 +189,7 @@
};
auto handleFaceNotFound = [&] {
- const FaceUri* faceUri = ndn::any_cast<FaceUri>(&nexthop);
+ const FaceUri* faceUri = std::any_cast<FaceUri>(&nexthop);
if (faceUri == nullptr) {
ctx.err << "Face not found\n";
return;
@@ -203,7 +203,7 @@
return;
}
- optional<FaceUri> canonized;
+ std::optional<FaceUri> canonized;
std::string error;
std::tie(canonized, error) = canonize(ctx, *faceUri);
if (!canonized) {