Updated example to use std::string instead of cstring for default value

This commit is contained in:
Pranav 2022-09-07 08:30:22 -05:00 committed by GitHub
parent b8160a86b5
commit af282c0f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -748,7 +748,7 @@ files = {"a.txt", "b.txt", "c.txt"}
argparse::ArgumentParser program("test");
program.add_argument("input")
.default_value("baz")
.default_value(std::string{"baz"})
.action([](const std::string& value) {
static const std::vector<std::string> choices = { "foo", "bar", "baz" };
if (std::find(choices.begin(), choices.end(), value) != choices.end()) {