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/tools/nfdc/help.cpp b/tools/nfdc/help.cpp
index 3642a91..052d16c 100644
--- a/tools/nfdc/help.cpp
+++ b/tools/nfdc/help.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,
@@ -38,10 +38,10 @@
NDN_LOG_INIT(nfdc.Help);
-const int LIST_COMMAND_NAME_COLUMN_WIDTH = 16;
+constexpr int LIST_COMMAND_NAME_COLUMN_WIDTH = 16;
void
-helpList(std::ostream& os, const CommandParser& parser, ParseMode mode, const std::string& noun)
+helpList(std::ostream& os, const CommandParser& parser, ParseMode mode, std::string_view noun)
{
os << "nfdc [-h|--help] [-V|--version] [-f|--batch <batch-file>] [<command> [<args>]]\n\n";
if (noun.empty()) {
@@ -70,7 +70,7 @@
static void
helpCommand(const std::string& noun, const std::string& verb)
{
- std::string manpage = "nfdc-" + noun;
+ const std::string manpage = "nfdc-" + noun;
::execlp("man", "man", manpage.data(), nullptr);
NDN_LOG_FATAL("Error opening man page for " << manpage << ": " << std::strerror(errno));
@@ -79,7 +79,7 @@
int
help(std::ostream& os, const CommandParser& parser, std::vector<std::string> args)
{
- const auto helpOpts = {"help", "--help", "-h"};
+ const auto helpOpts = {"help"sv, "--help"sv, "-h"sv};
auto it = std::find_first_of(args.begin(), args.end(), helpOpts.begin(), helpOpts.end());
if (it == args.end())
return 2;