1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-02 21:53:51 +00:00

Fixes for warnings

This commit is contained in:
Henry Fredrick Schreiner 2017-11-20 16:24:22 -05:00 committed by Henry Schreiner
parent 6ae0960c1d
commit a133e9cc06
2 changed files with 8 additions and 8 deletions

View File

@ -285,7 +285,7 @@ class App {
options_.emplace_back();
Option_p &option = options_.back();
option.reset(new Option(name, description, callback, defaulted, this));
option->copy_from(option_defaults_);
option_defaults_.copy_to(option.get());
return option.get();
} else
throw OptionAlreadyAdded(myopt.get_name());
@ -895,7 +895,7 @@ class App {
std::set<std::string> subcmd_groups_seen;
for(const App_p &com : subcommands_) {
const std::string &group_key = detail::to_lower(com->get_group());
if(group_key == "" || subcmd_groups_seen.count(group_key) != 0)
if(group_key.empty() || subcmd_groups_seen.count(group_key) != 0)
continue;
subcmd_groups_seen.insert(group_key);

View File

@ -42,11 +42,11 @@ template <typename CRTP> class OptionBase {
/// Only take the last argument (requires `expected_ == 1`)
bool last_{false};
template <typename T> void copy_from(const T &other) {
group_ = other.get_group();
required_ = other.get_required();
ignore_case_ = other.get_ignore_case();
last_ = other.get_take_last();
template <typename T> void copy_to(T *other) const {
other->group(group_);
other->required(required_);
other->ignore_case(ignore_case_);
other->take_last(last_);
}
public:
@ -281,7 +281,7 @@ class Option : public OptionBase<Option> {
/// You are never expected to add an argument to the template here.
template <typename T = App> Option *ignore_case(bool value = true) {
ignore_case_ = value;
T *parent = dynamic_cast<T *>(parent_);
auto *parent = dynamic_cast<T *>(parent_);
if(parent == nullptr)
throw IncorrectConstruction("This should not happen, there is always a parent!");