Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed May 5, 2024
1 parent e919a72 commit 97e5861
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitpicker.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{
"user": "p-ranav",
"repo": "argparse",
"branch": "ac4c2c2d96c974c6a4e487f288bfc89e108b64b1",
"branch": "805e2356a9af85e5863cd076e070fb5e1664761f",
"root": "include/argparse",
"file": [
"argparse.hpp"
Expand Down
29 changes: 29 additions & 0 deletions argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SOFTWARE.
#include <algorithm>
#include <any>
#include <array>
#include <set>
#include <charconv>
#include <cstdlib>
#include <functional>
Expand Down Expand Up @@ -755,6 +756,34 @@ class Argument {
return *this;
}

auto &store_into(std::set<std::string> &var) {
if (m_default_value.has_value()) {
var = std::any_cast<std::set<std::string>>(m_default_value);
}
action([this, &var](const std::string &s) {
if (!m_is_used) {
var.clear();
}
m_is_used = true;
var.insert(s);
});
return *this;
}

auto &store_into(std::set<int> &var) {
if (m_default_value.has_value()) {
var = std::any_cast<std::set<int>>(m_default_value);
}
action([this, &var](const std::string &s) {
if (!m_is_used) {
var.clear();
}
m_is_used = true;
var.insert(details::parse_number<int, details::radix_10>()(s));
});
return *this;
}

auto &append() {
m_is_repeatable = true;
return *this;
Expand Down

0 comments on commit 97e5861

Please sign in to comment.