ART: Minor cleanup in cmdline/.

Avoid `std::function<>` when dumping help.

Avoid `std::optional<>::value()` because it is specified as
throwing an exception and we do not use C++ exceptions in
ART. Use `std::optional<>::has_value()` instead of implicit
conversion to `bool`.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I7addd70b6a69dcaff7a03a829953ed476896bdc0
diff --git a/cmdline/cmdline_parser.h b/cmdline/cmdline_parser.h
index 5cdf446..8685da2 100644
--- a/cmdline/cmdline_parser.h
+++ b/cmdline/cmdline_parser.h
@@ -739,11 +739,11 @@
   std::unordered_map<std::string, std::vector<detail::CmdlineParseArgumentAny*>> args;
   for (const std::unique_ptr<detail::CmdlineParseArgumentAny>& it : completed_arguments_) {
     auto cat = it->GetCategory();
-    if (cat) {
-      if (args.find(cat.value()) == args.end()) {
-        args[cat.value()] = {};
+    if (cat.has_value()) {
+      if (args.find(*cat) == args.end()) {
+        args[*cat] = {};
       }
-      args.at(cat.value()).push_back(it.get());
+      args.at(*cat).push_back(it.get());
     } else {
       uncat.push_back(it.get());
     }
diff --git a/cmdline/detail/cmdline_parse_argument_detail.h b/cmdline/detail/cmdline_parse_argument_detail.h
index 0bde57b..de0a588 100644
--- a/cmdline/detail/cmdline_parse_argument_detail.h
+++ b/cmdline/detail/cmdline_parse_argument_detail.h
@@ -149,14 +149,13 @@
     vios.Stream() << std::endl;
     for (auto cname : names_) {
       std::string_view name = cname;
-      auto& os = vios.Stream();
-      // nblank gets captured by print_once, so needs to be declared here.
-      std::string_view nblank;
-      std::function<void()> print_once;
       if (using_blanks_) {
-        nblank = name.substr(0, name.find("_"));
-        print_once = [&]() {
-          os << nblank;
+        name = name.substr(0, name.find("_"));
+      }
+      auto& os = vios.Stream();
+      auto print_once = [&]() {
+        os << name;
+        if (using_blanks_) {
           if (has_value_map_) {
             bool first = true;
             for (auto [val, unused] : value_map_) {
@@ -164,17 +163,13 @@
               first = false;
             }
             os << "}";
-          } else if (metavar_) {
-            os << metavar_.value();
+          } else if (metavar_.has_value()) {
+            os << *metavar_;
           } else {
             os << "{" << CmdlineType<T>::DescribeType() << "}";
           }
-        };
-      } else {
-        print_once = [&]() {
-          os << name;
-        };
-      }
+        }
+      };
       print_once();
       if (appending_values_) {
         os << " [";
@@ -183,9 +178,9 @@
       }
       os << std::endl;
     }
-    if (help_) {
+    if (help_.has_value()) {
       ScopedIndentation si(&vios);
-      vios.Stream() << help_.value() << std::endl;
+      vios.Stream() << *help_ << std::endl;
     }
   }