Using an output paramter instead of returning is confusing but
common in pre-C++11 code. Let's modernize `cmd_getval()`.
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
#include <vector>
#include <stdexcept>
+#include <optional>
#include <ostream>
#include <boost/variant.hpp>
#include "include/ceph_assert.h" // boost clobbers this
}
}
+template <typename T>
+std::optional<T> cmd_getval(const cmdmap_t& cmdmap,
+ std::string_view k)
+{
+ T ret;
+ if (const bool found = cmd_getval(cmdmap, k, ret); found) {
+ return std::make_optional(std::move(ret));
+ } else {
+ return std::nullopt;
+ }
+}
+
// with default
template <typename T, typename V>