Skip to content

Commit

Permalink
fix template default errors and other warnings (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhhughes committed Jan 13, 2024
1 parent 7439d8c commit 0a540ff
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions config_utilities/demos/demo_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void declare_config(SubConfig& config) {
class Base {
public:
virtual void print() const = 0;
virtual ~Base() = default;
};

class DerivedA : public Base {
Expand Down
2 changes: 1 addition & 1 deletion config_utilities/include/config_utilities/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct ConfigWrapperImpl : public ConfigWrapper {
explicit ConfigWrapperImpl(const std::string& _type) : ConfigWrapper(_type) {}
ConfigT config;
std::unique_ptr<ConfigWrapper> clone() const override { return std::make_unique<ConfigWrapperImpl<ConfigT>>(*this); };
void onDeclareConfig() { declare_config(config); }
void onDeclareConfig() override { declare_config(config); }
std::unique_ptr<ConfigWrapper> createDefault() const override {
return std::make_unique<ConfigWrapperImpl<ConfigT>>(type);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ MetaData Visitor::subVisit(ConfigT& config,
}

// Visit a non-config field.
template <typename T, typename std::enable_if<!isConfig<T>(), bool>::type = true>
template <typename T, typename std::enable_if<!isConfig<T>(), bool>::type>
void Visitor::visitField(T& field, const std::string& field_name, const std::string& unit) {
Visitor& visitor = Visitor::instance();
if (visitor.mode == Visitor::Mode::kSet) {
Expand All @@ -147,7 +147,7 @@ void Visitor::visitField(T& field, const std::string& field_name, const std::str
}

// Visits a non-config field with conversion.
template <typename Conversion, typename T, typename std::enable_if<!isConfig<T>(), bool>::type = true>
template <typename Conversion, typename T, typename std::enable_if<!isConfig<T>(), bool>::type>
void Visitor::visitField(T& field, const std::string& field_name, const std::string& unit) {
Visitor& visitor = Visitor::instance();
if (visitor.mode == Visitor::Mode::kSet) {
Expand Down Expand Up @@ -188,7 +188,7 @@ void Visitor::visitField(T& field, const std::string& field_name, const std::str
}

// Visits a single subconfig field.
template <typename ConfigT, typename std::enable_if<isConfig<ConfigT>(), bool>::type = true>
template <typename ConfigT, typename std::enable_if<isConfig<ConfigT>(), bool>::type>
void Visitor::visitField(ConfigT& config, const std::string& field_name, const std::string& name_space) {
Visitor& visitor = Visitor::instance();
if (visitor.mode == Visitor::Mode::kGetDefaults) {
Expand All @@ -208,7 +208,7 @@ void Visitor::visitField(ConfigT& config, const std::string& field_name, const s
}

// Visit a vector of subconfigs.
template <typename ConfigT, typename std::enable_if<isConfig<ConfigT>(), bool>::type = true>
template <typename ConfigT, typename std::enable_if<isConfig<ConfigT>(), bool>::type>
void Visitor::visitField(std::vector<ConfigT>& config, const std::string& field_name, const std::string& /* unit */) {
Visitor& visitor = Visitor::instance();
if (visitor.mode == Visitor::Mode::kGetDefaults) {
Expand Down Expand Up @@ -278,15 +278,15 @@ void Visitor::visitBase(ConfigT& config) {
}
}

template <typename ConfigT, typename std::enable_if<!is_virtual_config<ConfigT>::value, bool>::type = true>
template <typename ConfigT, typename std::enable_if<!is_virtual_config<ConfigT>::value, bool>::type>
MetaData Visitor::getDefaults(const ConfigT& config) {
Visitor visitor(Mode::kGetDefaults);
ConfigT default_config;
declare_config(default_config);
return visitor.data;
}

template <typename ConfigT, typename std::enable_if<is_virtual_config<ConfigT>::value, bool>::type = true>
template <typename ConfigT, typename std::enable_if<is_virtual_config<ConfigT>::value, bool>::type>
MetaData Visitor::getDefaults(const ConfigT& config) {
Visitor visitor(Mode::kGetDefaults);
if (config.isSet()) {
Expand Down
2 changes: 1 addition & 1 deletion config_utilities/include/config_utilities/parsing/yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool toYamlFile(const ConfigT& config, const std::string& file_name) {
// TODO(lschmid): Here should probably be some verification of the output and of the target file to be created, as
// well as extension handling. For now let ofstream handle it.
std::ofstream fout(file_name);
fout << std::string(out.c_str);
fout << std::string(out.c_str());
return true;
}

Expand Down
1 change: 1 addition & 0 deletions config_utilities/test/tests/config_arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void declare_config(ConfigWithArrays& config) {
class ProcessorBase {
public:
virtual void process(std::string& s) const = 0;
virtual ~ProcessorBase() = default;
};

class AddString : public ProcessorBase {
Expand Down
1 change: 1 addition & 0 deletions config_utilities/test/tests/virtual_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace config::test {
class Base2 {
public:
virtual std::string name() const = 0;
virtual ~Base2() = default;
};

class Derived2 : public Base2 {
Expand Down

0 comments on commit 0a540ff

Please sign in to comment.