Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run some tests and fixes for C++20 #663

Merged
merged 6 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ jobs:
gcc9:
containerImage: gcc:9
cli11.std: 17
gcc11:
containerImage: gcc:11
cli11.std: 20
gcc8:
containerImage: gcc:8
cli11.std: 17
Expand Down
7 changes: 4 additions & 3 deletions include/CLI/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,10 @@ class App {

/// Add option for flag with integer result - defaults to allowing multiple passings, but can be forced to one
/// if `multi_option_policy(CLI::MultiOptionPolicy::Throw)` is used.
template <typename T,
enable_if_t<std::is_constructible<T, std::int64_t>::value && !is_bool<T>::value, detail::enabler> =
detail::dummy>
template <
typename T,
enable_if_t<std::is_constructible<T, std::int64_t>::value && !std::is_const<T>::value && !is_bool<T>::value,
detail::enabler> = detail::dummy>
Option *add_flag(std::string flag_name,
T &flag_count, ///< A variable holding the count
std::string flag_description = "") {
Expand Down
8 changes: 8 additions & 0 deletions tests/AppTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2308,3 +2308,11 @@ TEST_CASE_METHOD(TApp, "logFormSingleDash", "[app]") {
CHECK(veryverbose);
CHECK(veryveryverbose);
}

TEST_CASE("C20_compile", "simple") {
CLI::App app{"test"};
auto flag = app.add_flag("--flag", "desc");

app.parse("--flag");
CHECK_FALSE(flag->empty());
}
9 changes: 6 additions & 3 deletions tests/OptionalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,19 @@ TEST_CASE_METHOD(TApp, "BoostOptionalEnumTest", "[optional]") {
auto dstring = optptr->get_default_str();
CHECK(dstring.empty());
run();
CHECK(!opt);
auto checkOpt = static_cast<bool>(opt);
CHECK_FALSE(checkOpt);

args = {"-v", "3"};
run();
CHECK(opt);
checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
CHECK(*opt == eval::val3);
opt = {};
args = {"--val", "1"};
run();
CHECK(opt);
checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
CHECK(*opt == eval::val1);
}

Expand Down