static int conf_stringify(const Option::value_t& v, string *out)
{
- if (boost::get<boost::blank>(&v)) {
+ if (v == Option::value_t{}) {
return -ENOENT;
}
*out = Option::to_str(v);
for (const auto &i : schema) {
const Option &opt = i.second;
if (opt.type == Option::TYPE_STR) {
- bool has_daemon_default = !boost::get<boost::blank>(&opt.daemon_value);
+ bool has_daemon_default = (opt.daemon_value != Option::value_t{});
Option::value_t default_val;
if (is_daemon && has_daemon_default) {
default_val = opt.daemon_value;
}
// We call pre_validate as a sanity check, but also to get any
// side effect (value modification) from the validator.
- std::string *def_str = boost::get<std::string>(&default_val);
+ auto* def_str = std::get_if<std::string>(&default_val);
std::string val = *def_str;
std::string err;
if (opt.pre_validate(&val, &err) != 0) {
std::ostream *err) const
{
if (key.empty()) {
- return Option::value_t(boost::blank());
+ return {};
}
// In key names, leading and trailing whitespace are not significant.
const Option *o = find_option(k);
if (!o) {
// not a valid config option
- return Option::value_t(boost::blank());
+ return {};
}
return _get_val(values, *o, stack, err);
const Option::value_t& md_config_t::_get_val_default(const Option& o) const
{
- bool has_daemon_default = !boost::get<boost::blank>(&o.daemon_value);
+ bool has_daemon_default = (o.daemon_value != Option::value_t{});
if (is_daemon && has_daemon_default) {
return o.daemon_value;
} else {
if (!stack) {
return in;
}
- const std::string *str = boost::get<const std::string>(&in);
+ const auto str = std::get_if<std::string>(&in);
if (!str) {
// strings only!
return in;
{
T *member = const_cast<T *>(&(conf->*(boost::get<const T Config::*>(ptr))));
- *member = boost::get<T>(val);
+ *member = std::get<T>(val);
}
void operator()(uint64_t Config::* ptr) const
{
using T = uint64_t;
auto member = const_cast<T*>(&(conf->*(boost::get<const T Config::*>(ptr))));
- *member = boost::apply_visitor(get_size_visitor<T>{}, val);
+ *member = std::visit(get_size_visitor<T>{}, val);
}
void operator()(int64_t Config::* ptr) const
{
using T = int64_t;
auto member = const_cast<T*>(&(conf->*(boost::get<const T Config::*>(ptr))));
- *member = boost::apply_visitor(get_size_visitor<T>{}, val);
+ *member = std::visit(get_size_visitor<T>{}, val);
}
};
} // anonymous namespace
static void dump(Formatter *f, int level, Option::value_t in)
{
- if (const bool *v = boost::get<const bool>(&in)) {
+ if (const auto v = std::get_if<bool>(&in)) {
f->dump_bool(ceph_conf_level_name(level), *v);
- } else if (const int64_t *v = boost::get<const int64_t>(&in)) {
+ } else if (const auto v = std::get_if<int64_t>(&in)) {
f->dump_int(ceph_conf_level_name(level), *v);
- } else if (const uint64_t *v = boost::get<const uint64_t>(&in)) {
+ } else if (const auto v = std::get_if<uint64_t>(&in)) {
f->dump_unsigned(ceph_conf_level_name(level), *v);
- } else if (const double *v = boost::get<const double>(&in)) {
+ } else if (const auto v = std::get_if<double>(&in)) {
f->dump_float(ceph_conf_level_name(level), *v);
} else {
f->dump_stream(ceph_conf_level_name(level)) << Option::to_str(in);
#include <map>
#include <boost/container/small_vector.hpp>
+#include <boost/variant.hpp>
#include "common/ConfUtils.h"
#include "common/code_environment.h"
#include "log/SubsystemMap.h"
Callback&& cb, Args&&... args) const ->
std::result_of_t<Callback(const T&, Args...)> {
return std::forward<Callback>(cb)(
- boost::get<T>(this->get_val_generic(values, key)),
+ std::get<T>(this->get_val_generic(values, key)),
std::forward<Args>(args)...);
}
template<typename T>
const T md_config_t::get_val(const ConfigValues& values,
const std::string_view key) const {
- return boost::get<T>(this->get_val_generic(values, key));
+ return std::get<T>(this->get_val_generic(values, key));
}
inline std::ostream& operator<<(std::ostream& o, const boost::blank& ) {
using ceph::parse_timespan;
namespace {
-class printer : public boost::static_visitor<> {
+class printer {
ostream& out;
public:
explicit printer(ostream& os)
void operator()(const T& v) const {
out << v;
}
- void operator()(boost::blank blank) const {
+ void operator()(std::monostate) const {
return;
}
void operator()(bool v) const {
ostream& operator<<(ostream& os, const Option::value_t& v) {
printer p{os};
- v.apply_visitor(p);
+ std::visit(p, v);
return os;
}
void Option::dump_value(const char *field_name,
const Option::value_t &v, Formatter *f) const
{
- if (boost::get<boost::blank>(&v)) {
+ if (v == value_t{}) {
// This should be nil but Formatter doesn't allow it.
f->dump_string(field_name, "");
return;
}
switch (type) {
case TYPE_INT:
- f->dump_int(field_name, boost::get<int64_t>(v)); break;
+ f->dump_int(field_name, std::get<int64_t>(v)); break;
case TYPE_UINT:
- f->dump_unsigned(field_name, boost::get<uint64_t>(v)); break;
+ f->dump_unsigned(field_name, std::get<uint64_t>(v)); break;
case TYPE_STR:
- f->dump_string(field_name, boost::get<std::string>(v)); break;
+ f->dump_string(field_name, std::get<std::string>(v)); break;
case TYPE_FLOAT:
- f->dump_float(field_name, boost::get<double>(v)); break;
+ f->dump_float(field_name, std::get<double>(v)); break;
case TYPE_BOOL:
- f->dump_bool(field_name, boost::get<bool>(v)); break;
+ f->dump_bool(field_name, std::get<bool>(v)); break;
default:
f->dump_stream(field_name) << v; break;
}
int Option::validate(const Option::value_t &new_value, std::string *err) const
{
// Generic validation: min
- if (!boost::get<boost::blank>(&(min))) {
+ if (min != value_t{}) {
if (new_value < min) {
std::ostringstream oss;
oss << "Value '" << new_value << "' is below minimum " << min;
}
// Generic validation: max
- if (!boost::get<boost::blank>(&(max))) {
+ if (max != value_t{}) {
if (new_value > max) {
std::ostringstream oss;
oss << "Value '" << new_value << "' exceeds maximum " << max;
// Generic validation: enum
if (!enum_allowed.empty() && type == Option::TYPE_STR) {
auto found = std::find(enum_allowed.begin(), enum_allowed.end(),
- boost::get<std::string>(new_value));
+ std::get<std::string>(new_value));
if (found == enum_allowed.end()) {
std::ostringstream oss;
oss << "'" << new_value << "' is not one of the permitted "
{
*out << name << " - " << desc << "\n";
*out << " (" << type_to_str(type) << ", " << level_to_str(level) << ")\n";
- if (!boost::get<boost::blank>(&daemon_value)) {
+ if (daemon_value != value_t{}) {
*out << " Default (non-daemon): " << stringify(value) << "\n";
*out << " Default (daemon): " << stringify(daemon_value) << "\n";
} else {
}
*out << "\n";
}
- if (!boost::get<boost::blank>(&min)) {
+ if (min != value_t{}) {
*out << " Minimum: " << stringify(min) << "\n"
<< " Maximum: " << stringify(max) << "\n";
}
#include <chrono>
#include <string>
+#include <variant>
#include <vector>
-#include <boost/variant.hpp>
#include "include/str_list.h"
#include "msg/msg_types.h"
#include "include/uuid.h"
}
};
- using value_t = boost::variant<
- boost::blank,
+ using value_t = std::variant<
+ std::monostate,
std::string,
uint64_t,
int64_t,
Option(std::string const &name, type_t t, level_t l)
: name(name), type(t), level(l)
{
- // While value_t is nullable (via boost::blank), we don't ever
+ // While value_t is nullable (via std::monostate), we don't ever
// want it set that way in an Option instance: within an instance,
// the type of ::value should always match the declared type.
switch (type) {
value = p->second;
} else {
if (!entity.is_client() &&
- !boost::get<boost::blank>(&opt->daemon_value)) {
+ opt->daemon_value != Option::value_t{}) {
value = Option::to_str(opt->daemon_value);
} else {
value = Option::to_str(opt->value);
goto reply;
}
if (!entity.is_client() &&
- !boost::get<boost::blank>(&opt->daemon_value)) {
+ opt->daemon_value != Option::value_t{}) {
odata.append(Option::to_str(opt->daemon_value));
} else {
odata.append(Option::to_str(opt->value));