Skip to content

Commit

Permalink
style: pre-commit.ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Aug 4, 2023
1 parent 44c8c8d commit 7a13563
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions examples/testEXE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,44 @@
#include <string>

namespace key {
enum class my_enum {
val1,
val2
};

std::optional<my_enum> deserialize(const std::string& value) {
if (value == "val1") {
return my_enum::val1;
}
else if (value == "val2") {
return my_enum::val2;
}
else {
return std::nullopt;
}
enum class my_enum { val1, val2 };

std::optional<my_enum> deserialize(const std::string &value) {
if(value == "val1") {
return my_enum::val1;
} else if(value == "val2") {
return my_enum::val2;
} else {
return std::nullopt;
}
}

// More deserialize overloads for a gazillion different types...

template<class T>
concept Deserializable = requires (const std::string & value) {
{ deserialize<T>(value) } -> std::same_as<bool>;
};
// More deserialize overloads for a gazillion different types...

template<class T>
bool lexical_cast(const std::string& src, T& dst) {
auto result = deserialize<T>(src);
if (result)
dst = *result;
return !!result;
}
template <class T>
concept Deserializable = requires(const std::string &value) {
{ deserialize<T>(value) } -> std::same_as<bool>;
};

template <class T> bool lexical_cast(const std::string &src, T &dst) {
auto result = deserialize<T>(src);
if(result)
dst = *result;
return !!result;
}
int main(int argc, const char *argv[]) {

} // namespace key
int main(int argc, const char *argv[]) {

CLI::App app;
CLI::App app;

key::my_enum test{ key::my_enum::val2 };
key::my_enum test{key::my_enum::val2};

app.add_option("--test", test);
app.add_option("--test", test);

// More code...
CLI11_PARSE(app,argc,argv);
// More code...
CLI11_PARSE(app, argc, argv);

std::cout<<static_cast<int>(test)<<"=="<<static_cast<int>(key::my_enum::val2)<<std::endl;
return 0;
std::cout << static_cast<int>(test) << "==" << static_cast<int>(key::my_enum::val2) << std::endl;
return 0;
}

0 comments on commit 7a13563

Please sign in to comment.